├── .atom-dbg.cson ├── .dockerignore ├── .gitignore ├── .gitmodules ├── CITATION.cff ├── LICENSE ├── Newbies.md ├── README.md ├── ReadmeGraveyard.md ├── WebDevReference.md ├── apps ├── calculator │ ├── README.md │ ├── build │ │ └── Makefile │ ├── client │ │ └── html │ │ │ └── index.html │ └── fpga │ │ └── src │ │ └── calculator_kernel.tlv ├── mandelbrot-react │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── components │ │ │ ├── Backup.js │ │ │ ├── Colors.js │ │ │ ├── FractalImage.js │ │ │ ├── OptionCard.js │ │ │ ├── Options.js │ │ │ ├── Renderer.js │ │ │ ├── Texture.js │ │ │ ├── Theme.js │ │ │ ├── ThreeD.js │ │ │ └── fractalMeet.js │ │ ├── index.js │ │ ├── store │ │ │ └── index.js │ │ ├── styles │ │ │ └── App.scss │ │ └── util │ │ │ └── index.js │ └── yarn.lock ├── mandelbrot │ ├── README.md │ ├── bin │ │ └── regress │ ├── build │ │ └── Makefile │ ├── client │ │ ├── css │ │ │ ├── about.css │ │ │ └── demo.css │ │ ├── html │ │ │ ├── about.html │ │ │ ├── client.html │ │ │ ├── favicon.ico │ │ │ └── index.html │ │ └── js │ │ │ ├── FullImageMandelbrotViewer.js │ │ │ ├── MandelbrotView.js │ │ │ └── demo.js │ ├── fpga │ │ ├── debug │ │ │ └── debug.wcfg │ │ └── src │ │ │ └── mandelbrot_kernel.tlv │ ├── host │ │ ├── lodepng.c │ │ ├── lodepng.h │ │ ├── mandelbrot.c │ │ ├── mandelbrot.h │ │ └── mandelbrot_main.cpp │ ├── prebuilt │ │ └── hw │ │ │ └── xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4.0 │ │ │ ├── host │ │ │ └── mandelbrot.awsxclbin │ └── webserver │ │ ├── flythrough │ │ ├── flythrough.py │ │ └── mandelbrot_server.py ├── manycore │ ├── README.md │ ├── build │ │ └── Makefile │ ├── client │ │ ├── css │ │ │ └── manycore.css │ │ ├── html │ │ │ └── index.html │ │ └── js │ │ │ └── manycore.js │ ├── doc │ │ └── notes.md │ └── fpga │ │ └── src │ │ └── manycore_kernel.tlv ├── matrix_mult │ ├── README.md │ ├── build │ │ └── Makefile │ ├── client │ │ └── html │ │ │ └── index.html │ └── fpga │ │ └── src │ │ ├── matrix_mult_kernel.tlv │ │ └── matrix_mult_makerchip.tlvlib ├── vadd │ ├── README.md │ ├── build │ │ └── Makefile │ ├── client │ │ └── html │ │ │ └── index.html │ ├── fpga │ │ └── src │ │ │ ├── tlv_varients │ │ │ ├── vadd_flow_kernel.tlv.disabled │ │ │ └── vadd_kernel.tlv.disabled │ │ │ ├── vadd_kernel.sv │ │ │ └── work_in_progress │ │ │ └── vadd_kernel.sv │ └── host │ │ └── need_to_be_reenabled │ │ ├── vadd.c │ │ └── vadd.h └── warpv │ ├── README.md │ ├── build │ └── Makefile │ ├── client │ ├── css │ │ └── warpv.css │ ├── html │ │ └── index.html │ └── js │ │ └── warpv.js │ ├── doc │ └── notes.md │ └── fpga │ └── src │ └── warpv_kernel.tlv ├── bin ├── copy_app ├── install_verilator ├── regress └── vnc_ec2 ├── doc ├── DevelopersGuide.md ├── F1Guide.md ├── GettingStarted.md ├── GettingStartedF1.md ├── Story.md ├── TLV_Tutorials.md ├── TmpORConfScreenCapture.md ├── VMsetup.md └── img │ ├── 1stCLaaS.png │ ├── 1stCLaaS_big.png │ ├── RDC.png │ ├── RDC_color.png │ ├── SteveProfilePic.jpg │ ├── framework.png │ ├── header.png │ ├── header_big.png │ ├── simple.png │ ├── simplify.png │ ├── vitis_1.png │ ├── vitis_2.png │ ├── vmware.png │ ├── vmware_2.png │ ├── vmware_3.png │ ├── vmware_4.png │ ├── vmware_5.png │ └── vmware_6.png ├── docker ├── Dockerfile └── docker-image-init.sh ├── framework ├── aws │ ├── ec2_time_bomb │ └── ec2_time_bomb_server.py ├── bin │ ├── patch_gtkwave │ └── regress ├── build │ ├── Makefile │ ├── launch │ └── template.remmina ├── client │ ├── css │ │ └── testbench.css │ ├── html │ │ └── testbench.html │ └── js │ │ ├── ec2_instance_status.js │ │ ├── fpgaServer.js │ │ └── testbench.js ├── fpga │ ├── default_shell_config.json │ ├── scripts │ │ ├── hack_vadd_example.pl │ │ ├── produce_tcl_file.py │ │ └── tcl │ │ │ ├── rtl_kernel_wiz.tcl │ │ │ └── sdaccel.ini │ └── src │ │ ├── clk_gate.sv │ │ ├── kernel_module.tlvlib │ │ ├── sandpiper.vh │ │ ├── sandpiper_gen.vh │ │ └── sp_default.vh ├── host │ ├── default_main.c │ ├── hw_kernel.c │ ├── hw_kernel.h │ ├── kernel.h │ ├── protocol.h │ ├── server_main.c │ ├── server_main.h │ ├── sim_kernel.c │ └── sim_kernel.h ├── terraform │ ├── config_instance_dev.sh │ ├── config_instance_dummy.sh │ ├── config_static_f1_instance.sh │ ├── ec2_instance.tf │ └── static_f1_reboot.sh └── webserver │ ├── default_server.py │ ├── server.py │ └── server_api.py ├── index.js ├── init ├── package.json ├── vitis_setup └── yarn.lock /.atom-dbg.cson: -------------------------------------------------------------------------------- 1 | "apps/mandelbrot/out/sw/host_debug": 2 | path: "apps/mandelbrot/out/sw/host_debug" 3 | cwd: "apps/mandelbrot/build" 4 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/compose* 19 | **/Dockerfile* 20 | **/node_modules 21 | **/npm-debug.log 22 | **/obj 23 | **/secrets.dev.yaml 24 | **/values.dev.yaml 25 | README.md 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | **/webserver/*.pyc 3 | **/webserver/ec2_time_bombs/ 4 | **/apps/*/live/ 5 | **/apps/*/build/log/ 6 | apps/mandelbrot/build/video 7 | apps/mandelbrot/build/cast 8 | **.tfstate 9 | **.tfstate.backup 10 | **.terraform 11 | **.terraform* 12 | **.pem 13 | /framework/terraform/development/centos_pwd.txt 14 | /local 15 | /terraform 16 | /tmp 17 | **/log/ 18 | **/out/ 19 | node_modules 20 | 21 | __pycache__ 22 | 23 | # Used by scripts to remember the active F1 instance IP address. 24 | .ec2_ip 25 | 26 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "framework/host/json"] 2 | path = framework/host/json 3 | url = https://github.com/nlohmann/json.git 4 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use 1st-CLaaS in your work, please cite it using the following metadata." 3 | title: "1st-CLaaS: Open-Source cloud FPGA-based Custom Logic as a Service" 4 | authors: 5 | - family-names: "Hoover" 6 | given-names: "Steven" 7 | orcid: "0000-0001-5844-2889" 8 | affiliation: "Redwood EDA, LLC" 9 | contributors: 10 | - family-names: "Alessandro" 11 | given-names: "Comodi" 12 | - family-names: "Hadnagy" 13 | given-names: "Akos" 14 | date-released: "2018-08-14" 15 | repository-code: "https://github.com/os-fpga/1st-CLaaS" 16 | url: "https://github.com/os-fpga/1st-CLaaS" 17 | abstract: > 18 | 1st-CLaaS (First Custom Logic as a Service) is an open-source framework for building, debugging, 19 | and deploying cloud-FPGA-based accelerators for web and cloud applications. 20 | keywords: 21 | - FPGA 22 | - Hardware Acceleration 23 | - Open-source 24 | - Cloud Computing 25 | - Custom Compute 26 | license: "BSD-3-Clause" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Alessandro Comodi 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /Newbies.md: -------------------------------------------------------------------------------- 1 | # A Bit of Background for Newbies 2 | 3 | ## What is an FPGA? 4 | 5 | FPGAs (Field-Programmable Gate Arrays), are chips with programmable circuitry. Rather than spending millions of dollars to fabricate a custom chip (or ASIC--Application-Specific Integrated Circuit), you can program your custom logic onto an FPGA almost instantly. While ASICs can be more deeply optimized, FPGAs are far more accessible, and are even available in the cloud. 6 | 7 | See Wikipedia Wikipedia 8 | 9 | ## What is Verilog/RTL/HDL? 10 | 11 | Verilog is the most popular RTL (Register Transfer Level) language for modeling digital circuits (err, well, analog too) so they can be turned into physical hardware or programmed onto an FPGA by some really sophisticated software and tooling. Other Hardware Description Languages (HDLs) aim to address the limitations of Verilog and enable design at a higher level. 12 | 13 | See Wikipedia Wikipedia 14 | 15 | -------------------------------------------------------------------------------- /ReadmeGraveyard.md: -------------------------------------------------------------------------------- 1 | # What's This? 2 | 3 | This file contains documentation that is obsolete. Feel free to delete old content as you see fit. We're just keeping stuff here for a while for while the replacement instructions are tested. 4 | 5 | ## Remote Desktop 6 | 7 | For remote desktop access to the EC2 machines, I have used X11, RDP, and VNC from a Linux client. X11 is easiest, but it is far too slow to be practical. RDP and VNC required several days for me to get working initially. I suggest using RDP, but I am also including instructions for VNC as a fall-back option. 8 | 9 | 10 | ### X11 Forwarding 11 | 12 | This is easy and stable, so even though it is not a solution for running Xilinx tools long-term, start with X11. 13 | 14 | ```sh 15 | ssh -X -i centos@ # (.pem created in "Prerequisit" instructions) 16 | sudo yum install xeyes -y # Just a GUI application to test X11. 17 | xeyes # You'll probably see "Error: Can't open display", so fix this with: 18 | sudo yum install xorg-x11-xauth -y 19 | exit 20 | ssh -X -i centos@ 21 | xeyes # Hopefully, you see some eyes now. 22 | 23 | ``` 24 | 25 | From this ssh shell, you can launch X applications that will (slowly) display on your local machine. In contrast, RDP and/or VNC provide you with a desktop environment. 26 | 27 | ### RDP 28 | 29 | #### Running RDP with Remmina Remote Desktop Client 30 | 31 | ```sh 32 | sudo apt-get install remmina 33 | remmina 34 | ``` 35 | 36 | 1. Click "New", and fill in the following: 37 | 1. Name: (as you like) 38 | 1. In the "Basic" tab 39 | 1. Server: [IPv4 Public IP] 40 | 1. User name: centos 41 | 1. Password: [leave blank] 42 | 1. Color depth: True color (24 bpp) 43 | 1. In the "Advanced" tab 44 | 1. Security: RDP 45 | 1. Connect 46 | 47 | Note that between Stopping and Starting Amazon instances the IPv4 Public IP of the instance changes and will need to be reassigned in Remmina. 48 | 49 | The password is in the centos_pwd.txt file after running the startup script. Take a note of this password, and delete the file afterwards for security reasons. 50 | 51 | ### VNC from Linux Client 52 | 53 | RDP is preferred over VNC, but, in case you have trouble with RDP... 54 | 55 | After much struggling, I was able to get VNC working with the Xfce desktop environment. 56 | 57 | On the EC2 Instance: 58 | 59 | ```sh 60 | sudo yum install tigervnc-server 61 | vncpasswd # Provide password for VNC desktop (and, optionally, a different password for view-only access) 62 | ``` 63 | 64 | ```sh 65 | sudo yum install -y epel-release # (should already be installed) 66 | sudo yum groupinstall -y "Xfce" 67 | ``` 68 | (I do not think a reboot is necessary.) 69 | 70 | Edit ~/.vnc/xstartup to contain: 71 | 72 | ```sh 73 | #!/bin/sh 74 | unset SESSION_MANAGER 75 | unset DBUS_SESSION_BUS_ADDRESS 76 | /etc/X11/xinit/xinitrc 77 | [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup 78 | [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources 79 | vncconfig -iconic & 80 | #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & 81 | startxfce4 & 82 | ``` 83 | 84 | And make it executable: 85 | 86 | ```sh 87 | chmod +x ~/.vnc/xstartup 88 | ``` 89 | 90 | The VNC Server can be started with: 91 | 92 | ```sh 93 | vncserver # Optionally -geometry XXXXxYYYY. 94 | ``` 95 | 96 | The output of this command indicates a log file. You should take a look. I got a number of warnings and a DBus permission error, but they did not appear to be fatal. 97 | 98 | From the client: 99 | 100 | ```sh 101 | vncpasswd # Enter the password used on the server. 102 | vncviewer :1 passwd=/.vnc/passwd 103 | ``` 104 | 105 | And, on the remote instance, kill the VNC server with: 106 | ```sh 107 | vncserver -kill :1 108 | ``` 109 | 110 | Any number of clients can be connected to this VNC server while it is running. Closing the client connection does not terminate the server. 111 | 112 | After you see that these commands are working, the script `vnc_ec2` (at the top level of the repo) can be used locally to launch a server on the remote instance and connect to it. Note the prerequisite "Assumptions" in the header comments of this file. 113 | 114 | ```sh 115 | vnc_ec2 -gXXXXxYYYY # where -g is the VNC --geometry argument specifying desktop size. 116 | ``` 117 | 118 | This running VNC server can be killed using: 119 | 120 | ```sh 121 | vnc_ec2 -k # can be omitted to use the IP of the last server launched w/ vnc_ec2. 122 | ``` 123 | 124 | ### SSH from Linux client 125 | 126 | A TLS keypair is generated every time you run the Terraform startup script. You can use this keypair to log into the VM. 127 | 128 | ```sh 129 | ssh -i puclic_key.pem centos@ 22 130 | ``` 131 | 132 | ## SSH keys 133 | 134 | If you happen to be using private git repositories or need passwordless authentication from your instance for any other reason, you may need to generate ssh access keys for your instance. 135 | 136 | ```sh 137 | ssh-keygen -o -t rsa -b 4096 -C "" 138 | sudo yum install xclip -y 139 | xclip -sel clip < ~/.ssh/id_rsa.pub 140 | ``` 141 | 142 | And paste this SSH key into the settings of your other account (e.g. gitlab). 143 | 144 | 145 | ## Clone Necessary Repos 146 | 147 | ```sh 148 | cd ~/workdisk 149 | git clone https://github.com/aws/aws-fpga.git $AWS_FPGA_REPO_DIR 150 | git clone https://github.com/stevehoover/1st-CLaaS 151 | cd 1st-CLaaS 152 | source ./init 153 | ``` 154 | 155 | 156 | -------------------------------------------------------------------------------- /WebDevReference.md: -------------------------------------------------------------------------------- 1 | # OBSOLETE. TODO: DELETE ME. -------------------------------------------------------------------------------- /apps/calculator/README.md: -------------------------------------------------------------------------------- 1 | In this case we decided to implement a simple calculator whose primary function was to return the computed value for new operands and operators computing upon the previous result of the calculator. 2 | To begin editing your customized kernel, it is essential to understand the data flow of inputs and output throughout the kernel. The data from the web front end is transferred to the kernel by means of the |in/trans$data variable which consists of 512 bits. In our example we pass the first 32 bits with the value for the next operand to be operated with the previous result and the next 4 bits are reserved for the operator variable which decides which operation is to be conducted between the 2 given operands. The rest is 0 padded and the variables are extracted as follows in the |in as follows:- 3 | $val2 = |in/trans$data[31:0]; 4 | $op = |in/trans$data[34:32]; 5 | 6 | Finally, the output data is transferred out through the |out/trans$data variable in a similar manner to which the input is accepted by the kernel. The final computed output stored in the variable $output, is then transferred to $data in |out/trans as follows:- 7 | |out/trans$data[31:0] = $output; 8 | 9 | 10 | This completes the transfer of data from the input and output side of the kernel respectively. To run the application locally, one must shift to the directory /apps/calculator/build and run the command - make launch. 11 | Once this is done, it opens a Web Server that can be accessed by entering http://localhost:8888 on your local browser. To stop the application from running, a simple ^C is enough. 12 | 13 | Ideally the web front end for this calculator will be designed in a way such that the user will be able to provide 2 primary inputs, one being the new operand value that the present result with operate with, and the operator, which will accordingly provide the new result using the previous result and the new operand value. A guide will be put up to indicate the different operators that this code can handle, and how to go about using them. Upon running, the output box will produce the necessary output back to the user, and this will be further used in successive iterations of the calculator and so forth. 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /apps/calculator/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info. 3 | 4 | ########## 5 | # TODO: lodepng.[c/h] is used in framework. Use should be moved to mandelbrot, so none of these are required. 6 | EXTRA_C_SRC=$(FRAMEWORK_HOST_DIR)/default_main.c ../../mandelbrot/host/lodepng.c 7 | EXTRA_C_HDRS=../../mandelbrot/host/lodepng.h 8 | PROJ_SW_CFLAGS=-I../../mandelbrot/host 9 | ########## 10 | 11 | 12 | include ../../../framework/build/Makefile 13 | -------------------------------------------------------------------------------- /apps/calculator/client/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 15 | 16 | 17 | 18 | Test Bench 19 | 20 | 21 | 22 | 23 |

Test Bench for FPGA Kernel

24 |

Send

25 |

Enter data to send to the server as a list of JS objects, where each object represents a 512-bit value, partitioned as 32-bit integer values. 26 | Each object can contain the following fields:

27 |
28 | default_int: {int},  // Default value for all 64 integers, used if not defined otherwise.
29 | high_int: {int},  // Lost-significant integer value.
30 | low_int: {int},  // Least-significent integer value.
31 | 
32 | 33 | 34 | 35 |
36 | 

Number of chunks expected:

37 | 38 |
39 |

Receive

40 |

Response data as hex strings, 512 bits per line, space-delimeted at 32-bit boundaries.

41 |
42 | 
43 | 
44 |

45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /apps/calculator/fpga/src/calculator_kernel.tlv: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d: tl-x.org 2 | \SV 3 | m4+definitions([' 4 | m4_include_url(['https://raw.githubusercontent.com/stevehoover/makerchip_examples/ceebf870862e222ebc6eaf92d5a7fb85a525d069/1st-claas_template_with_macros.tlv']) 5 | ']) 6 | m4_makerchip_module_with_random_kernel_tb(my, ['assign passed = cyc_cnt > 20;']) 7 | m4+definitions(['']) // A hack to reset line alignment to address the fact that the above macro is multi-line. 8 | \TLV 9 | // A default direct hookup from |in to |out. 10 | m4+tlv_wrapper(|in, @0, |out, @0, /trans) 11 | |in 12 | @0 13 | $data[31:0] = >>1$output; 14 | @1 15 | // Calculator logic 16 | 17 | 18 | // Extract input fields from input data 19 | $val1[31:0] = >>1$output; 20 | $val2[31:0] = /trans$data[31:0]; 21 | $op[2:0] = /trans$data[34:32]; 22 | 23 | //counter 24 | $counter = $reset?0:(>>1$counter+1); 25 | $valid = $reset || $counter; 26 | 27 | ?$valid 28 | @1 29 | $sum[31:0] = $val1[31:0] + $val2[31:0]; 30 | $diff[31:0] = $val1[31:0] - $val2[31:0]; 31 | $mult[31:0] = $val1[31:0] * $val2[31:0]; 32 | $quot[31:0] = $val1[31:0] / $val2[31:0]; 33 | //@2 34 | $mem[31:0] = 35 | $reset ? 0: 36 | ($op[2:0]==3'b101) 37 | ? >>1$mem[31:0] : >>1$output; 38 | 39 | 40 | $output[31:0] = 41 | $reset ? 0: 42 | ($op[2:0]==3'b000) 43 | ? $sum[31:0] : 44 | ($op[2:0]==3'b001) 45 | ? $diff[31:0] : 46 | ($op[2:0]==3'b010) 47 | ? $mult[31:0] : 48 | ($op[2:0]==3'b011) 49 | ? $quot[31:0] : 50 | ($op[2:0]==3'b100) 51 | ? >>1$mem[31:0] : $val1[31:0]; 52 | 53 | 54 | |out 55 | @0 56 | // Hook up inputs to outputs to implement a no-op kernel. 57 | // Delete this to add your kernel. 58 | $ANY = /top|in<>0$ANY; 59 | 60 | $ready = *out_ready; 61 | *out_avail = $avail; 62 | *out_data = $data; 63 | //`BOGUS_USE($op $rand $ready) 64 | `BOGUS_USE($ready) 65 | 66 | // Extract output data to the output field 67 | /trans@0$data = |in@1$output; 68 | 69 | m4+rename_flow(/top, |in, @0, |out, @0, /trans) 70 | \SV 71 | endmodule 72 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an intended replacement for `/mandelbrot`, but it remains incomplete. See the `readme.md` in `/mandelbrot`. 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.
15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.
25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.
28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 63 | 64 | ### Deployment 65 | 66 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 67 | 68 | ### `yarn build` fails to minify 69 | 70 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 71 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mandelbrot-react", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.11.0", 7 | "@testing-library/jest-dom": "^4.2.4", 8 | "@testing-library/react": "^9.3.2", 9 | "@testing-library/user-event": "^7.1.2", 10 | "node-sass": "^4.14.1", 11 | "react": "^16.13.1", 12 | "react-dom": "^16.13.1", 13 | "react-reflex": "^3.1.0", 14 | "react-resizable": "^1.11.0", 15 | "react-scripts": "3.4.3", 16 | "react-use-gesture": "^7.0.16", 17 | "zustand": "^3.1.2" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": "react-app" 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot-react/public/favicon.ico -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 28 | 32 | React App 33 | 34 | 35 | 36 |
37 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot-react/public/logo192.png -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot-react/public/logo512.png -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | font-family: 'Raleway'; 3 | } 4 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ReflexContainer, ReflexSplitter, ReflexElement } from 'react-reflex' 3 | 4 | import FractalImage from './components/FractalImage' 5 | import Options from './components/Options' 6 | 7 | const App = () => { 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | ) 27 | } 28 | 29 | export default App 30 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/Colors.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import OptionCard from './OptionCard' 3 | import store from '../store' 4 | 5 | const colors_array = [ 6 | { 7 | value: 0, 8 | label: 'Gradual Gradient', 9 | }, 10 | { 11 | value: 1, 12 | label: 'Random', 13 | }, 14 | { 15 | value: 2, 16 | label: 'Medium Gradient', 17 | }, 18 | { 19 | value: 3, 20 | label: 'Rainbow', 21 | }, 22 | ] 23 | 24 | const Colors = () => { 25 | const { colors, setColors } = store() 26 | 27 | return ( 28 | 29 |
Colors
30 | 31 |
32 | {colors_array.map(({ label, value }, idx) => ( 33 |
34 | 44 |
45 | ))} 46 |
47 |
48 | ) 49 | } 50 | 51 | export default Colors 52 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/FractalImage.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react' 2 | import { useGesture } from 'react-use-gesture' 3 | // import FractalMeet from './fractalMeet' 4 | 5 | import store from '../store' 6 | 7 | const FractalImage = ({ dimensions }) => { 8 | const { width: flexWidth, height: flexHeight } = dimensions 9 | const { 10 | height, 11 | width, 12 | renderer, 13 | three_d, 14 | theme, 15 | colors, 16 | darken, 17 | texture, 18 | x, 19 | y, 20 | brighten, 21 | edge, 22 | eye_adjust, 23 | eye_sep, 24 | max_depth, 25 | modes, 26 | offset_h, 27 | offset_w, 28 | pix_x, 29 | pix_y, 30 | test_flags, 31 | test_vars, 32 | var1, 33 | var2, 34 | setSize, 35 | setXY, 36 | setPix, 37 | } = store() 38 | 39 | const bind = useGesture({ 40 | onDrag: ({ offset: [x, y] }) => setXY(-x / 200, -y / 200), 41 | onPinch: ({ offset: [d, _] }) => setPix(-d / 200), 42 | onWheel: ({ offset: [_, d] }) => setPix(d / 1000000), 43 | }) 44 | 45 | useEffect(() => setSize(flexWidth, flexHeight), [flexWidth, flexHeight]) 46 | 47 | return ( 48 |
49 | 55 |
56 | ) 57 | } 58 | 59 | export default FractalImage 60 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/OptionCard.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Paper from '@material-ui/core/Paper' 3 | 4 | const OptionCard = ({ children, title }) => { 5 | return ( 6 |
7 | 8 |
{children}
9 |
10 |
11 | ) 12 | } 13 | 14 | export default OptionCard 15 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/Options.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import store from '../store' 3 | 4 | import Renderer from './Renderer' 5 | import ThreeD from './ThreeD' 6 | import Theme from './Theme' 7 | import Colors from './Colors' 8 | import Texture from './Texture' 9 | 10 | const Options = () => { 11 | const { tiled, renderer } = store() 12 | 13 | return ( 14 |
15 | 16 | {!tiled && } 17 | {renderer === 'cpp' && } 18 | {renderer !== 'python' && } 19 | 20 |
21 | ) 22 | } 23 | 24 | export default Options 25 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/Renderer.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import OptionCard from './OptionCard' 3 | import store from '../store' 4 | 5 | const renderers = [ 6 | { 7 | value: 'python', 8 | label: 'Python', 9 | }, 10 | { 11 | value: 'cpp', 12 | label: 'C++', 13 | }, 14 | { 15 | value: 'fpgq', 16 | label: 'FPGA/opt', 17 | }, 18 | ] 19 | 20 | const Renderer = () => { 21 | const { renderer, setRenderer, tiled, toggleTiled } = store() 22 | 23 | return ( 24 | 25 |
Renderer
26 | 27 | 30 | 31 |
32 | {renderers.map(({ label, value }, idx) => ( 33 |
34 | 44 |
45 | ))} 46 |
47 |
48 | ) 49 | } 50 | 51 | export default Renderer 52 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/Texture.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import store from '../store' 3 | import OptionCard from './OptionCard' 4 | 5 | const textures = [ 6 | { label: 'Smooth', value: 0, checked: 0 }, 7 | { label: 'String lights', value: 1 }, 8 | { label: 'Fanciful', value: 2 }, 9 | { label: 'Shadow', value: 4 }, 10 | { label: 'Rounded edges', value: 8 }, 11 | ] 12 | 13 | const Texture = () => { 14 | const { renderer, texture, darken, toggleDarken, setTexture } = store() 15 | 16 | const handleClick = e => { 17 | if (e.target.checked) { 18 | setTexture(texture + parseInt(e.target.value)) 19 | } else { 20 | setTexture(texture - parseInt(e.target.value)) 21 | } 22 | } 23 | 24 | return ( 25 | 26 |
Renderer
27 | 28 | 32 | 33 | {renderer === 'cpp' && ( 34 |
35 | {textures.map(({ label, value }, idx) => ( 36 |
37 | 47 |
48 | ))} 49 |
50 | )} 51 |
52 | ) 53 | } 54 | 55 | export default Texture 56 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/Theme.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import OptionCard from './OptionCard' 3 | import store from '../store' 4 | 5 | const themes = [ 6 | { 7 | value: 0, 8 | label: 'Customize', 9 | }, 10 | { 11 | value: 1, 12 | label: 'Christmas', 13 | }, 14 | ] 15 | 16 | const Theme = () => { 17 | const { theme, setTheme } = store() 18 | 19 | return ( 20 | 21 |
Theme
22 | 23 |
24 | {themes.map(({ label, value }, idx) => ( 25 |
26 | 36 |
37 | ))} 38 |
39 |
40 | ) 41 | } 42 | 43 | export default Theme 44 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/components/ThreeD.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import OptionCard from './OptionCard' 3 | import store from '../store' 4 | 5 | export const threeDs = [ 6 | { 7 | value: false, 8 | label: '2-D', 9 | }, 10 | { 11 | value: true, 12 | label: '3-D', 13 | }, 14 | // { 15 | // value: true, 16 | // label: 'Stereo 3-D', 17 | // }, 18 | ] 19 | 20 | const ThreeD = () => { 21 | const { three_d, setThreeD } = store() 22 | 23 | return ( 24 | 25 |
3-D
26 | 27 |
28 | {threeDs.map(({ label, value }, idx) => ( 29 |
30 | 40 |
41 | ))} 42 |
43 |
44 | ) 45 | } 46 | 47 | export default ThreeD 48 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import 'react-reflex/styles.css' 4 | import App from './App' 5 | 6 | ReactDOM.render(, document.getElementById('root')) 7 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/store/index.js: -------------------------------------------------------------------------------- 1 | import create from 'zustand' 2 | 3 | const useStore = create(set => ({ 4 | brighten: 0, 5 | colors: 2, 6 | darken: false, 7 | edge: 0, 8 | eye_adjust: 0, 9 | eye_sep: 0, 10 | height: 256, 11 | max_depth: 1225, 12 | modes: 66, 13 | offset_h: 0, 14 | offset_w: 0, 15 | pix_x: 0.015625, 16 | pix_y: 0.015625, 17 | renderer: 'cpp', 18 | test_flags: 0, 19 | test_vars: (16)[(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)], 20 | texture: 0, 21 | theme: 0, 22 | three_d: false, 23 | var1: 0, 24 | var2: 0, 25 | width: 256, 26 | x: 0, 27 | y: 0, 28 | 29 | // setter functions 30 | setRenderer: e => 31 | set(store => ({ 32 | renderer: e.target.value, 33 | theme: e.target.value === 'cpp' ? store.theme : 0, 34 | })), // set Renderer 35 | 36 | toggleTiled: () => 37 | set(store => ({ ...store, tiled: !store.tiled, three_d: false })), // toggle Tiled 38 | 39 | setThreeD: e => set({ three_d: e.target.value === 'true' }), // set 3-D options 40 | 41 | setTheme: e => set({ theme: parseInt(e.target.value) }), // set Theme 42 | 43 | setColors: e => set({ colors: parseInt(e.target.value) }), 44 | 45 | toggleDarken: () => set(store => ({ ...store, darken: !store.darken })), 46 | 47 | setTexture: texture => set({ texture }), 48 | 49 | setSize: (width, height) => set({ width, height }), 50 | 51 | setXY: (x, y) => set({ x, y }), 52 | 53 | setPix: pix => 54 | set(state => ({ pix_x: state.pix_x + pix, pix_y: state.pix_x + pix })), 55 | })) 56 | 57 | export default useStore 58 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/styles/App.scss: -------------------------------------------------------------------------------- 1 | .option-card { 2 | font-weight: 400; 3 | margin: 5px; 4 | 5 | .card { 6 | background: #faf9f9; 7 | min-height: 250px; 8 | padding: 10px; 9 | } 10 | } 11 | 12 | .title { 13 | text-align: left; 14 | margin-bottom: 10px; 15 | font-size: 26px; 16 | } 17 | 18 | .slider { 19 | width: 85% !important; 20 | display: inline-block !important; 21 | margin-bottom: 5px; 22 | } 23 | 24 | .box { 25 | background: #888888; 26 | } 27 | 28 | .react-resizable { 29 | position: relative; 30 | } 31 | .react-resizable-handle { 32 | position: absolute; 33 | width: 20px; 34 | height: 20px; 35 | background-repeat: no-repeat; 36 | background-origin: content-box; 37 | box-sizing: border-box; 38 | background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+'); 39 | background-position: bottom right; 40 | padding: 0 3px 3px 0; 41 | } 42 | .react-resizable-handle-sw { 43 | bottom: 0; 44 | left: 0; 45 | cursor: sw-resize; 46 | transform: rotate(90deg); 47 | } 48 | .react-resizable-handle-se { 49 | bottom: 0; 50 | right: 0; 51 | cursor: se-resize; 52 | } 53 | .react-resizable-handle-nw { 54 | top: 0; 55 | left: 0; 56 | cursor: nw-resize; 57 | transform: rotate(180deg); 58 | } 59 | .react-resizable-handle-ne { 60 | top: 0; 61 | right: 0; 62 | cursor: ne-resize; 63 | transform: rotate(270deg); 64 | } 65 | .react-resizable-handle-w, 66 | .react-resizable-handle-e { 67 | top: 50%; 68 | margin-top: -10px; 69 | cursor: ew-resize; 70 | } 71 | .react-resizable-handle-w { 72 | left: 0; 73 | transform: rotate(135deg); 74 | } 75 | .react-resizable-handle-e { 76 | right: 0; 77 | transform: rotate(315deg); 78 | } 79 | .react-resizable-handle-n, 80 | .react-resizable-handle-s { 81 | left: 50%; 82 | margin-left: -10px; 83 | cursor: ns-resize; 84 | } 85 | .react-resizable-handle-n { 86 | top: 0; 87 | transform: rotate(225deg); 88 | } 89 | .react-resizable-handle-s { 90 | bottom: 0; 91 | transform: rotate(45deg); 92 | } 93 | -------------------------------------------------------------------------------- /apps/mandelbrot-react/src/util/index.js: -------------------------------------------------------------------------------- 1 | export const rendererAr = [ 2 | { 3 | label: 'Python', 4 | }, 5 | { 6 | label: 'C++', 7 | }, 8 | { 9 | label: 'FPGA/opt', 10 | }, 11 | ] 12 | 13 | export const threeDAr = [ 14 | { 15 | label: '2-D', 16 | }, 17 | { 18 | label: '3-D', 19 | }, 20 | { 21 | label: 'Stereo 3-D', 22 | }, 23 | ] 24 | 25 | export const themeAr = [{ label: 'Customize' }, { label: 'Christmas' }] 26 | 27 | export const colorsAr = [ 28 | { label: 'Medium Gradient' }, 29 | { label: 'Random' }, 30 | { label: 'Gradual Gradient' }, 31 | { label: 'Rainbow' }, 32 | ] 33 | 34 | export const textureAr = [ 35 | { label: 'Darken', checked: false, all: true }, 36 | { label: 'Smooth', checked: false }, 37 | { label: 'String_lights', checked: false }, 38 | { label: 'Fanciful', checked: false }, 39 | { label: 'Shadow', checked: false }, 40 | { label: 'Rounded_edges', checked: false }, 41 | ] 42 | 43 | export const edgeAr = [ 44 | { label: 'Curved' }, 45 | { label: 'Bumpy' }, 46 | { label: 'Villi' }, 47 | ] 48 | 49 | export const motionAr = [{ label: 'Position' }, { label: 'Velocity' }] 50 | -------------------------------------------------------------------------------- /apps/mandelbrot/README.md: -------------------------------------------------------------------------------- 1 | # Mandelbrot Explorer 2 | 3 | ## Demo 4 | 5 | The Mandelbrot example is hosted [here](http://fractalvalley.net), by [Steve Hoover](mailto:steve.hoover@redwoodeda.com), without hardware acceleration. 6 | It includes an About page with general project information. 7 | 8 | ## Development 9 | 10 | ## Active Development 11 | 12 | FractalValley has gotten a lot of attention from students, especially for Google Summer of Code. Several students began work to develop better sites and then found paying gigs: 13 | - [Dharak Savalia's Mandelbrot front-end](https://github.com/dharaksavalia/Mandelbrot) 14 | - [Meet's Fractal component](https://github.com/meetcric/mandelbrot-fractal-custom) 15 | - [Meet's FrontEnd](https://github.com/meetcric/mandelbrot-fractals) 16 | - [Sanjeet's Front End](https://github.com/sanjeetiitr/fpga-webserver-fractalvalley) 17 | - [Faizan](/commits/master/apps/mandelbrot-react) (within this repo) 18 | 19 | ### Integration 20 | 21 | There is no continuous integration testing. Just open it locally and test manually before making a pull request. 22 | 23 | ### Deployment 24 | 25 | #### fractalvalley.net 26 | 27 | Steve holds the button to redeploy your changes at http://fractalvalley.net. If he forgets, please [let him know](mailto:steve.hoover@redwoodeda.com). 28 | 29 | #### Your own site 30 | 31 | To deploy at your own site on port 80 with F1 acceleration enabled: 32 | 33 | Create an AWS account w/ F1 privileges. Remember: THIS SOFTWARE IS PROVIDED AS IS. WE ARE NOT RESPONSIBLE FOR AWS CHARGES YOU INCUR BY USING THIS SOFTWARE, INCLUDING CHARGES RESULTING FROM SOFTWARE BUGS. 34 | 35 | Create a static F1 instance (based on the latest code in master): 36 | 37 | You must first have completed instructions in [**Getting Started**](../../doc/GettingStarted.md) and [**Getting Started with F1**](../../doc/GettingStartedF1.md). Then: 38 | 39 | ``` 40 | cd /apps/mandelbrot/build 41 | make static_accelerated_instance PREBUILT=true 42 | ``` 43 | 44 | Launch the main web server: 45 | 46 | ``` 47 | make ssh 48 | cd 1st-CLaaS/apps/mandelbrot 49 | make config # Enter AWS keys, region, etc. 50 | make PASSWORD=XXX INSTANCE=i-XXX live 51 | ``` 52 | 53 | ### Debug in GDB 54 | 55 | To debug using GDB inside Atom. 56 | - Use [dbg-gdb Atom plugin](https://atom.io/packages/dbg-gdb) 57 | - in `mandelbrot/build` 58 | - `make host_debug` 59 | - `F5` in Atom (to run `out/sw/host_debug`), and set breakpoints. 60 | - `launch -h none sw` 61 | - In browser, `localhost:8888` 62 | 63 | ### TO DO 64 | 65 | General TO DO items are kept here, where as the issue tracker is used for more specific items. Contact [Steve](mailto:steve.hoover@redwoodeda.com) for more details if you are interested in working on any of these items. 66 | 67 | #### Web Design 68 | 69 | The web page is quick-n-dirty. It could use a designer's touch. 70 | 71 | #### Web Dev 72 | 73 | There are currently two views, map (using Open Layers) and full-image. Open Layers is great, but it assumes a static image. 74 | It doesn't work for 3-D. And it doesn't refresh when parameters are changed. There is plenty of opportunity to build the 75 | best of both. 76 | 77 | #### Building Momentum 78 | 79 | Get the word out there and build interest. Put together some flashy demos, fly-through videos. 80 | 81 | #### 3-D 82 | 83 | Play w/ 3-D controls. Create videos. Get this working in VR displays (like Dodo Case). 84 | 85 | #### Algorithms 86 | 87 | The current algorithms are brute-force ones. There are ways to optimize. [Some ideas](https://docs.google.com/document/d/1K0gPk9uK7av3IdA827IM3OaHT1pDNHdVi7VGKfMQwHc/edit?usp=sharing). 88 | 89 | #### FPGA Optimizations 90 | 91 | The current FPGA implementation is not optimized and utilizes a fraction of the available FPGA resources. It could be sped up substantially with a little effort. [Some ideas](https://docs.google.com/document/d/1K0gPk9uK7av3IdA827IM3OaHT1pDNHdVi7VGKfMQwHc/edit?usp=sharing). 92 | 93 | -------------------------------------------------------------------------------- /apps/mandelbrot/bin/regress: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2019, Steven F. Hoover 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | # For usage, see /bin/regress 35 | 36 | set -e # Fail on any failure. 37 | 38 | 39 | # Args: 40 | AWS_REGRESS="$1" 41 | export CONFIG_FILE="$2" 42 | 43 | 44 | cd "$( dirname "${BASH_SOURCE[0]}")/../build" 45 | mkdir -p ../out/regress ../log 46 | 47 | echo "Running mandelbrot regression." 48 | 49 | 50 | # Run locally. 51 | 52 | # Go live 53 | make live TARGET=sw PORT=8887 # && sleep 2 54 | # Access image 55 | wget -O ../out/regress/img.jpg 'http://localhost:8887/img?json={"x":0,"y":0,"pix_x":0.2,"pix_y":0.2,"width":10,"height":10,"max_depth":25,"renderer":"cpp"}' 56 | # Go dead 57 | make dead TARGET=sw 58 | 59 | 60 | 61 | if [[ "$AWS_REGRESS" ]] 62 | then 63 | 64 | echo "Running AWS tests for Mandelbrot." 65 | 66 | # Create and destroy static F1 instance. 67 | make static_accelerated_instance AUTO_APPROVE=true INSTANCE_NAME=1st-CLaaS_static_accelerated_regress 68 | make destroy SETUP=1st-CLaaS_static_accelerated_regress AUTO_APPROVE=true 69 | 70 | fi 71 | -------------------------------------------------------------------------------- /apps/mandelbrot/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info, with the following additions: 3 | 4 | include ../../../framework/build/Makefile 5 | -------------------------------------------------------------------------------- /apps/mandelbrot/client/css/about.css: -------------------------------------------------------------------------------- 1 | #content { 2 | background-image: url("/img?json={%22x%22:-1.0221004461908865,%22y%22:0.37353728027791605,%22pix_x%22:0.000002985021213376194,%22pix_y%22:0.000002985021213376194,%22width%22:1670,%22height%22:1490,%22max_depth%22:2500,%22darken%22:true,%22renderer%22:%22fpga%22,%22colors%22:3604480,%22modes%22:194}"); 3 | background-attachment: fixed; 4 | } 5 | #mask { 6 | background: #000A; 7 | padding: 20px; 8 | } 9 | #content #header { 10 | background: #137E; 11 | color: #fff; 12 | } 13 | #content .section { 14 | background: #DDDD; 15 | color: #000; 16 | margin-bottom: 30px; 17 | padding: 10px; 18 | } -------------------------------------------------------------------------------- /apps/mandelbrot/client/css/demo.css: -------------------------------------------------------------------------------- 1 | .debug-only { 2 | display: none; /* block/none */ 3 | } 4 | 5 | .playback-only { 6 | display: none; 7 | } 8 | 9 | .contained-fieldset { 10 | height: 100%; 11 | } 12 | 13 | .imagesContainer { 14 | box-sizing: content-box; 15 | resize: both; 16 | min-width: 20px; 17 | min-height: 20px; 18 | overflow: hidden; 19 | border: 2px solid; 20 | padding: 6px; 21 | background-color: grey; 22 | height: 256px; 23 | width: 256px; 24 | position: relative; 25 | } 26 | .viewerContainer { 27 | box-sizing: content-box; 28 | width: 100%; 29 | height: 100%; 30 | display: none; 31 | } 32 | #eventRecipient { 33 | box-sizing: content-box; 34 | z-index: 100; 35 | width: 100%; 36 | height: 100%; 37 | position: absolute; 38 | } 39 | .mandelbrotImage { 40 | pointer-events: none; 41 | box-sizing: border-box; 42 | position: absolute; 43 | width: 256px; 44 | height: 256px; 45 | } 46 | .imgContainer { 47 | pointer-events: none; 48 | box-sizing: content-box; 49 | width: 100%; 50 | height: 100%; 51 | overflow: hidden; 52 | } 53 | .imgContainer img { 54 | position: relative; 55 | } 56 | .motionInstructions { 57 | display: none; 58 | } 59 | #positionMotionInstructions { 60 | display: block; 61 | } 62 | 63 | #parameters { 64 | align-items: normal; 65 | } 66 | #parameters div { 67 | text-align: left; 68 | } 69 | #renderer label, #modes label, #theme label, #edge-style label, #texture label, #motion label, #color-params label, #test-vars label, #test-flags label { 70 | display: inline; 71 | } 72 | #good-place { 73 | color: blue; 74 | } 75 | #good-place:hover { 76 | color: purple; 77 | text-decoration: underline; 78 | } 79 | .three-d-only, .stereo-only, div[forTheme] { 80 | display: none; 81 | } 82 | 83 | .btn[state="on"] { 84 | background-color: red; 85 | } 86 | 87 | .unselectable { 88 | -webkit-touch-callout: none; 89 | -webkit-user-select: none; 90 | -khtml-user-select: none; 91 | -moz-user-select: none; 92 | -ms-user-select: none; 93 | user-select: none; 94 | } 95 | -------------------------------------------------------------------------------- /apps/mandelbrot/client/html/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 16 | 18 | 19 | 21 | 22 | 23 | Mandelbrot 24 | 25 | 26 | 27 | 32 |
33 | 39 |
40 |

What is it?

41 |

42 | This Mandelbrot fractal explorer is a demonstration and development vehicle for emerging technologies, including: 43 |

    44 |
  • Cloud FPGAs
  • 45 |
  • Hardware-accelerated web applications
  • 46 |
  • Advanced hardware modeling in Transaction-Level Verilog
  • 47 |
48 |

49 |
50 |
51 |

Enable Hardware Acceleration

52 |

53 | The true showcase is enabled by special hardware 54 | acceleration technology, called cloud FPGAs. We use these to accelerate the Mandelbrot calculations 55 | by ~20x! This specialized hardware isn’t cheap, though, so we do not provide it here, but we enable you to provide 56 | your own. It is not for the faint of heart, but we’re doing our best to make it easier. You can find 57 | more information from the open-source repository. 58 |

59 |
60 |
61 |

Cool Technologies

62 |

Cloud FPGAs:

63 |

64 | Field Programmable Gate Arrays (FPGAs) are chips containing millions or billions of logic gates that 65 | can be configured to perform any logic function. In contrast, Application-Specific Integrated 66 | Circuilts (ASICs) are designed and manufactured for a specific purpose. ASICs are optimized; FPGAs 67 | are flexible. And FPGAs are now available in the cloud, which is a huge enabler for open-source 68 | hardware! 69 |

70 |

Hardware Accelerated Web Applications:

71 |

72 | Could FPGAs have great potential to accelerate compute infrastructure. But they are in their infancy. 73 | The barriers to entry are significant. This project is the development vehicle for an open-source 74 | framework for accelerating web applications (or services) using cloud FPGAs. The aim is to provide the 75 | communication layer by which a web application can communicate through standard web protocols, 76 | directly with hardware kernels running on cloud FPGAs. You are witnessing the first implementation 77 | of this infrastructure, or at least you would be if a cloud FPGA was attached. 78 |

79 |

Transaction-Level Verilog:

80 |

81 | One of the biggest hurdles to ubiquitous hardware acceleration is the mere fact that hardware is not 82 | as easy to program as software. But new technologies are making it easier. This project utilizes 83 | advanced modern modeling techniques available in Transaction-Level Verilog (TL-Verilog). You can 84 | learn about these techniques and try them for yourself at 85 | makerchip.com. 86 |

87 |
88 |
89 |

Contribute!

90 |

91 | This is a group effort. It’s tons of fun, it’s charting new territory, and it’s got something to 92 | offer everyone. You could: 93 |

    94 |
  • Improve the website.
  • 95 |
  • Enhance the algorithms.
  • 96 |
  • Optimize the hardware kernel.
  • 97 |
98 |

99 |

100 | If you are a student, Google 101 | Summer of Code might be a great opportunity to get involved. 102 |

103 |

104 | Feel free to contact the authors, or browse the 105 | project on github. 106 |

107 |
108 | 116 |
117 |

Share

118 |

119 | Help us spread the word on social media. 120 |

121 |
122 |
123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /apps/mandelbrot/client/html/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot/client/html/favicon.ico -------------------------------------------------------------------------------- /apps/mandelbrot/host/mandelbrot_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | 34 | #include "mandelbrot.h" 35 | 36 | int main(int argc, char const *argv[]) 37 | { 38 | (new HostMandelbrotApp())->server_main(argc, argv, "mandelbrot"); 39 | } 40 | -------------------------------------------------------------------------------- /apps/mandelbrot/prebuilt/hw/xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4.0/host: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot/prebuilt/hw/xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4.0/host -------------------------------------------------------------------------------- /apps/mandelbrot/prebuilt/hw/xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4.0/mandelbrot.awsxclbin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/apps/mandelbrot/prebuilt/hw/xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4.0/mandelbrot.awsxclbin -------------------------------------------------------------------------------- /apps/mandelbrot/webserver/flythrough: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script starts the host application build for sw or hw. 4 | 5 | # Usage: 6 | # flythrough hw 7 | # flythrough sw 8 | 9 | if [[ "$1" = "" ]]; 10 | then 11 | echo "Usage: flythrough [sw/hw]" 12 | exit 1 13 | fi 14 | 15 | 16 | ../host_app/$1/host & 17 | HOST_PID=$! 18 | python3 flythrough.py & 19 | SERVER_PID=$! 20 | 21 | function finish { 22 | # Kill child processes 23 | kill $HOST_PID 24 | kill $SERVER_PID 25 | echo "Killed host app and flythrough app" 26 | } 27 | 28 | trap finish EXIT 29 | 30 | wait 31 | 32 | -------------------------------------------------------------------------------- /apps/mandelbrot/webserver/flythrough.py: -------------------------------------------------------------------------------- 1 | """ 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | """ 32 | 33 | 34 | # Main application for the web server. 35 | 36 | from server import * 37 | 38 | """ 39 | Generate a zooming video. 40 | """ 41 | def flythrough(x_center, y_center, x_radius, y_radius, img_width, img_height, max_depth, zoom_factor, num_frames): 42 | renderer = "FPGA" # (most agressive available) 43 | for img_num in range(num_frames): 44 | img_data = get_img([x_center - x_radius, 45 | y_center - y_radius, 46 | (x_radius * 2.0) / img_width, 47 | (y_radius * 2.0) / img_height, 48 | img_width, 49 | img_height, 50 | max_depth], 51 | renderer) 52 | file = open('video/tmp_frame' + str(img_num) + '.png', "w") 53 | file.write(img_data) 54 | file.close() 55 | # Zoom by zoom_factor. 56 | x_radius *= zoom_factor 57 | y_radius *= zoom_factor 58 | 59 | 60 | def flythroughMain(): 61 | initSocket() 62 | 63 | # Delete images. 64 | if (subprocess.call("rm video/tmp_frame*.png", shell=True)): 65 | sys.stderr.write("Failed to remove temporary image files.") 66 | 67 | flythrough(0.29609899100000003, 0.577698899030599, 1.4, 1.4, 1023, 1023, 1000, 0.94 ** 1, 400) 68 | 69 | # Delete existing video. 70 | subprocess.call("rm video/video.mp4", shell=True) 71 | # Create video from images. 72 | if (subprocess.call("ffmpeg -framerate 12 -i video/tmp_frame%d.png video/video.mp4", shell=True)): 73 | sys.stderr.write("ffmpeg command failed.") 74 | 75 | # Stay open until killed, to conform to web server use model. 76 | print('All done. You can Ctrl-C now.') 77 | while (True): 78 | time.sleep(10) 79 | 80 | if __name__ == "__main__": 81 | flythroughMain() 82 | -------------------------------------------------------------------------------- /apps/manycore/README.md: -------------------------------------------------------------------------------- 1 | # WARP-V manycore Example 2 | 3 | The kernel in this example contains the manycore version of WARP-V, a TL-Verilog RISC-V CPU. 4 | 5 | The web front-end accepts a simple form of assembly code. It sends the assembled binary data to the kernel to load in instruction memory. A reset command (TODO: not implemented) will start execution and receive data from the CPU. 6 | 7 | # Implementation 8 | 9 | refer to WARP-V example. 10 | 11 | - At present, core-0 is attached with the I/O of stream interface, and all cores access instructions though Global Imem. 12 | 13 | # Notes 14 | - The manycore_kernal.tlv file in fpga/src can also be used in Makerchip for development after removing `--compiler verilator` flag`. Although the stimulus provided is random but can be changed as per ones need. 15 | - The number of cores can manually be changed by modifing `NUM_CORES`. 16 | 17 | 18 | # TODO: 19 | - Port these feature to be complied as their 1st-ClaaS version from warp-v configurator. 20 | - Change m4_include pointer after PR. 21 | - add VIZ 22 | -------------------------------------------------------------------------------- /apps/manycore/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info. 3 | 4 | ########## 5 | # TODO: lodepng.[c/h] is used in framework. Use should be moved to mandelbrot, so none of these are required. 6 | EXTRA_C_SRC=$(FRAMEWORK_HOST_DIR)/default_main.c ../../mandelbrot/host/lodepng.c 7 | EXTRA_C_HDRS=../../mandelbrot/host/lodepng.h 8 | PROJ_SW_CFLAGS=-I../../mandelbrot/host 9 | ########## 10 | 11 | 12 | include ../../../framework/build/Makefile 13 | -------------------------------------------------------------------------------- /apps/manycore/client/css/manycore.css: -------------------------------------------------------------------------------- 1 | #warpv-url { 2 | resize: horizontal; 3 | } 4 | #assembly-code { 5 | resize: both; 6 | font-family: "Lucida Console", Monaco, monospace; 7 | } 8 | #assembled-code > p, #imem > p { 9 | margin: 0px; 10 | } 11 | .error { 12 | color: red; 13 | } -------------------------------------------------------------------------------- /apps/manycore/client/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 15 | 16 | 17 | 1st CLaaS WARP-V Example 18 | 19 | 20 | 21 | 22 |

1st CLaaS WARP-V Example

23 |

Assemble based on this WARP-V code

24 |

25 | 26 |

27 |

Assembly Code

28 |

29 | 30 |

31 |

32 | (assemble, reset CPU, upload, and run) 33 | 34 |

35 |

36 | 37 |

38 |

Assembled Code

39 |
40 |

IMem Write Response

41 |

42 | 

WARP-V Response

43 |

-

44 |

Instruction Memory

(as last read)

45 |
46 |

47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /apps/manycore/doc/notes.md: -------------------------------------------------------------------------------- 1 | ## Many-Core planning 2 | 3 | TBD. 4 | -------------------------------------------------------------------------------- /apps/matrix_mult/README.md: -------------------------------------------------------------------------------- 1 | # VADD Example 2 | 3 | This example is a minimalistic example of how to construct a hardware-accelerated web application utilizing this repository. It can be used a starting template by copying the entire directory into a new parallel one and searching and replacing 'vadd' with the desired kernel name. TODO: A script could be provided to do this. 4 | 5 | The hardware kernel performs an identical function to the Xilinx example kernel created from their RTL Kernel Wizard. It simply adds one to vectors of integer values. 6 | -------------------------------------------------------------------------------- /apps/matrix_mult/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info. 3 | 4 | KERNEL=matrix_mult 5 | 6 | ########## 7 | # TODO: Eliminate lodepng here. 8 | EXTRA_C_SRC=$(FRAMEWORK_HOST_DIR)/default_main.c ../../mandelbrot/host/lodepng.c 9 | EXTRA_C_HDRS=../../mandelbrot/host/lodepng.h 10 | PROJ_SW_CFLAGS=-I../../mandelbrot/host 11 | ########## 12 | 13 | HW_SHELL_CONFIG_JSON=../../../framework/fpga/default_shell_config.json 14 | 15 | 16 | include ../../../framework/build/Makefile 17 | -------------------------------------------------------------------------------- /apps/matrix_mult/client/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /apps/matrix_mult/fpga/src/matrix_mult_kernel.tlv: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d --fmtFlatSignals --bestsv --noline: tl-x.org 2 | 3 | \SV 4 | m4_include_lib(['./matrix_mult_makerchip.tlvlib']) 5 | `define NUM_SIZE 3 6 | `define NUM_BUFFERS 2 7 | `define REG_FILE_SIZE 16 8 | `define REG_WIDTH 32 9 | `define NUM_ROWS 3 10 | `define NUM_COLS 3 11 | 12 | module matrix_mult_kernel #( 13 | parameter integer C_DATA_WIDTH = 512 // Data width of both input and output data 14 | ) 15 | ( 16 | input wire clk, 17 | input wire reset, 18 | 19 | output wire in_ready, 20 | input wire in_avail, 21 | input wire [C_DATA_WIDTH-1:0] in_data, 22 | 23 | input wire out_ready, 24 | output wire out_avail, 25 | output wire [C_DATA_WIDTH-1:0] out_data 26 | ); 27 | 28 | 29 | \TLV 30 | |mult 31 | @0 32 | // Input connections 33 | $in_avail = *in_avail; 34 | $in_data[511:0] = *in_data; 35 | // UNUSED $out_ready = *out_ready; 36 | 37 | 38 | // Matrix mult definition in matrix_mult_makerchip.tlv 39 | m4+matrix_mult(); 40 | 41 | |mult 42 | @3 43 | // Output connections 44 | *in_ready = $in_ready; 45 | *out_avail = $out_avail; 46 | *out_data = $out_data; 47 | 48 | \SV 49 | endmodule 50 | -------------------------------------------------------------------------------- /apps/matrix_mult/fpga/src/matrix_mult_makerchip.tlvlib: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d: tl-x.org 2 | 3 | \SV 4 | m4_include_url(['https://raw.githubusercontent.com/stevehoover/tlv_flow_lib/master/fundamentals_lib.tlv']) 5 | `define NUM_SIZE 3 6 | `define NUM_BUFFERS 2 7 | `define REG_FILE_SIZE 16 8 | `define REG_WIDTH 32 9 | `define NUM_ROWS 3 10 | `define NUM_COLS 3 11 | 12 | \TLV mac($_in_aa1, $_in_aa2, $_in_aa3, $_in_bb1, $_in_bb2, $_in_bb3, $_out_mac) 13 | $prod_aa1bb1[(2 * `NUM_SIZE)-1 : 0] = $_in_aa1 * $_in_bb1; 14 | $prod_aa2bb2[(2 * `NUM_SIZE)-1 : 0] = $_in_aa2 * $_in_bb2; 15 | $prod_aa3bb3[(2 * `NUM_SIZE)-1 : 0] = $_in_aa3 * $_in_bb3; 16 | 17 | $_out_mac[(2 * `NUM_SIZE) : 0] = $prod_aa1bb1 + $prod_aa2bb2 + $prod_aa3bb3; 18 | 19 | \TLV matrix_mult() 20 | |mult 21 | @0 22 | $reset = *reset; 23 | $cyc_cntr[31:0] = $reset ? 0 : >>1$cyc_cntr + 1; 24 | // One matrix's info per packet 25 | // So everytime in_avail goes up, we increase the matrix_id 26 | $matrix_id[1:0] = $reset ? 0 : 27 | ($in_avail) ? (>>1$matrix_id + 1) : 28 | $RETAIN; 29 | 30 | $in_ready = (>>1$in_avail || >>1$matrix_id == 2) ? 0 : 1; 31 | 32 | /buffers[`NUM_BUFFERS - 1 : 0] 33 | /reg_file[`REG_FILE_SIZE - 1:0] 34 | @0 35 | $reg[`REG_WIDTH - 1:0] = (|mult$in_avail && (#buffers == (|mult$matrix_id - 1))) ? |mult$in_data[((#reg_file * `REG_WIDTH) + (`REG_WIDTH - 1)) : (#reg_file * `REG_WIDTH)] : $RETAIN; 36 | 37 | /mat_r[`NUM_ROWS - 1 : 0] 38 | /mat_c[`NUM_COLS - 1 : 0] 39 | @0 40 | $index[3:0] = (#mat_r * `NUM_ROWS) + #mat_c; 41 | @1 42 | $aa[`NUM_SIZE - 1 : 0] = (|mult$in_avail && |mult$matrix_id == 1) ? |mult/buffers[0]/reg_file[$index]$reg[`NUM_SIZE-1:0] : $RETAIN; 43 | // |mult$reset ? $rand_val_aa[`NUM_SIZE - 1:0] : $RETAIN; 44 | 45 | $bb[`NUM_SIZE - 1 : 0] = (|mult$in_avail && |mult$matrix_id == 2) ? |mult/buffers[1]/reg_file[$index]$reg[`NUM_SIZE-1:0] : $RETAIN; 46 | //|mult$reset ? $rand_val_bb[`NUM_SIZE - 1:0] : $RETAIN; 47 | 48 | @3 49 | // The size for $cc should come from a `define or something -- but making it 8bits here for ease of use 50 | $cc[7 : 0] = |mult$reset ? 0 : (|mult$load_done && #mat_r == |mult$row_ctr && #mat_c == |mult$col_ctr) ? |mult$mac_out : $RETAIN; 51 | 52 | @1 53 | $load_done = $reset ? 0 : 54 | ($matrix_id == 2) ? 1 : 55 | $RETAIN; 56 | 57 | $row_ctr[1:0] = $reset ? 0 : 58 | (>>1$col_ctr == `NUM_COLS - 1 && >>1$load_done) ? >>1$row_ctr + 1 : 59 | $RETAIN; 60 | $col_ctr[1:0] = $reset ? 0 : 61 | (>>1$col_ctr == `NUM_COLS - 1 && >>1$load_done) ? 0 : 62 | (>>1$load_done) ? >>1$col_ctr + 1 : 63 | $RETAIN; 64 | 65 | $mult_done = $reset ? 0 : 66 | (>>1$row_ctr == `NUM_ROWS) ? 1 : 67 | $RETAIN; 68 | @2 69 | ?$load_done 70 | m4+mac(/mat_r[$row_ctr]/mat_c[0]$aa, /mat_r[$row_ctr]/mat_c[1]$aa, /mat_r[$row_ctr]/mat_c[2]$aa, 71 | /mat_r[0]/mat_c[$col_ctr]$bb, /mat_r[1]/mat_c[$col_ctr]$bb, /mat_r[2]/mat_c[$col_ctr]$bb, 72 | $mac_out); 73 | 74 | @3 75 | $out_avail = $mult_done; 76 | 77 | $out_data[511:0] = $mult_done ? 78 | {/mat_r[2]/mat_c[2]$cc, /mat_r[2]/mat_c[1]$cc, /mat_r[2]/mat_c[0]$cc, 79 | /mat_r[1]/mat_c[2]$cc, /mat_r[1]/mat_c[1]$cc, /mat_r[1]/mat_c[0]$cc, 80 | /mat_r[0]/mat_c[2]$cc, /mat_r[0]/mat_c[1]$cc, /mat_r[0]/mat_c[0]$cc } : 0; 81 | 82 | 83 | 84 | 85 | 86 | \SV 87 | 88 | 89 | 90 | // Default Makerchip TL-Verilog Code Template 91 | 92 | // Macro providing required top-level module definition, random 93 | // stimulus support, and Verilator config. 94 | m4_makerchip_module // (Expanded in Nav-TLV pane.) 95 | 96 | \TLV 97 | |mult 98 | @0 99 | $in_avail = $reset ? 0 : ($cyc_cntr % 20 == 0) ? 1 : 0; 100 | $in_data[511:0] = ($in_avail && $matrix_id == 1) ? {32'h7, 32'h3, 32'h1, 32'h1, 32'h0, 32'h6, 32'h5, 32'h5, 32'h3} : 101 | ($in_avail && $matrix_id == 2) ? {32'h7, 32'h5, 32'h1, 32'h4, 32'h7, 32'h5, 32'h7, 32'h7, 32'h1} : 102 | 0; 103 | 104 | m4+matrix_mult(); 105 | 106 | 107 | // Assert these to end simulation (before Makerchip cycle limit). 108 | *passed = *cyc_cnt > 60; //(|mult>>2$row_ctr == 3) ? 1 : 0; //*cyc_cnt > 40; 109 | *failed = 1'b0; 110 | \SV 111 | endmodule 112 | -------------------------------------------------------------------------------- /apps/vadd/README.md: -------------------------------------------------------------------------------- 1 | # VADD Example 2 | 3 | This example is a minimalistic example of how to construct a hardware-accelerated web application utilizing this repository. It can be used a starting template using `make copy_app APP_NAME=`. 4 | 5 | The hardware kernel performs an identical function to the Xilinx example kernel created from their RTL Kernel Wizard. It simply adds one to vectors of integer values. 6 | 7 | The web front-end is simply the default front-end test bench from the framework. 8 | -------------------------------------------------------------------------------- /apps/vadd/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info. 3 | 4 | ########## 5 | # TODO: lodepng.[c/h] is used in framework. Use should be moved to mandelbrot, so none of these are required. 6 | EXTRA_C_SRC=$(FRAMEWORK_HOST_DIR)/default_main.c ../../mandelbrot/host/lodepng.c 7 | EXTRA_C_HDRS=../../mandelbrot/host/lodepng.h 8 | PROJ_SW_CFLAGS=-I../../mandelbrot/host 9 | ########## 10 | 11 | 12 | include ../../../framework/build/Makefile 13 | -------------------------------------------------------------------------------- /apps/vadd/client/html/index.html: -------------------------------------------------------------------------------- 1 | ../../../../framework/client/html/testbench.html -------------------------------------------------------------------------------- /apps/vadd/fpga/src/tlv_varients/vadd_flow_kernel.tlv.disabled: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d --fmtFlatSignals --bestsv --noline: tl-x.org 2 | \SV 3 | m4_include_lib(['http://TODO/kernel_module.tlvlib']) 4 | // Vector add kernel example, using TL-Verilog. 5 | m4+kernel_flow_module(vadd_kernel, |kernel, @1, |kernel, @1, /trans) 6 | \TLV 7 | |kernel 8 | @1 9 | /trans 10 | /value[C_DATA_WIDTH/32-1:0] 11 | $value[#value * 32 +: 32] = $in_data[#value * 32 +: 32] + 1; 12 | $out_data[C_DATA_WIDTH-1:0] = /value[*]$value; 13 | \SV 14 | endmodule 15 | -------------------------------------------------------------------------------- /apps/vadd/fpga/src/tlv_varients/vadd_kernel.tlv.disabled: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d --fmtFlatSignals --bestsv --noline: tl-x.org 2 | \SV 3 | 4 | // TODO: Structure this for Makerchip editing, (like Mandelbrot). 5 | 6 | module vadd_kernel #( 7 | parameter integer C_DATA_WIDTH = 512 // Data width of both input and output data 8 | ) 9 | ( 10 | input wire clk, 11 | input wire reset, 12 | 13 | output wire in_ready, 14 | input wire in_avail, 15 | input wire [C_DATA_WIDTH-1:0] in_data, 16 | 17 | input wire out_ready, 18 | output wire out_avail, 19 | output wire [C_DATA_WIDTH-1:0] out_data 20 | ); 21 | 22 | /TLV 23 | // Combinational only. Connect output backpressure directly to inputs. 24 | *in_ready = *out_ready; 25 | *out_avail = *in_avail; 26 | 27 | /value[C_DATA_WIDTH/32-1:0] 28 | *out_data[#value * 32 +: 32] = *in_data[#value * 32 +: 32] + 1; 29 | 30 | /SV 31 | endmodule -------------------------------------------------------------------------------- /apps/vadd/fpga/src/vadd_kernel.sv: -------------------------------------------------------------------------------- 1 | 2 | module vadd_kernel #( 3 | parameter integer C_DATA_WIDTH = 512 // Data width of both input and output data 4 | ) 5 | ( 6 | input wire clk, 7 | input wire reset, 8 | 9 | output wire in_ready, 10 | input wire in_avail, 11 | input wire [C_DATA_WIDTH-1:0] in_data, 12 | 13 | input wire out_ready, 14 | output wire out_avail, 15 | output wire [C_DATA_WIDTH-1:0] out_data 16 | ); 17 | 18 | // Combinational only. Connect output backpressure directly to inputs. 19 | assign in_ready = out_ready; 20 | assign out_avail = in_avail; 21 | 22 | genvar i; 23 | generate 24 | for (i = 0; i < C_DATA_WIDTH / 32; i++) begin 25 | assign out_data[i*32 +: 32] = in_data[i*32 +: 32] + 1; 26 | end 27 | endgenerate 28 | 29 | endmodule -------------------------------------------------------------------------------- /apps/vadd/fpga/src/work_in_progress/vadd_kernel.sv: -------------------------------------------------------------------------------- 1 | 2 | /* verilator lint_off WIDTH */ 3 | module vadd_kernel #( 4 | parameter integer C_DATA_WIDTH = 512 // Data width of both input and output data 5 | ) 6 | ( 7 | input wire clk, 8 | input wire reset, 9 | 10 | output wire in_ready, 11 | input wire in_avail, 12 | input wire [C_DATA_WIDTH-1:0] in_data, 13 | 14 | input wire out_ready, 15 | output wire out_avail, 16 | output wire [C_DATA_WIDTH-1:0] out_data 17 | ); 18 | 19 | logic [7:0] debug_sigs; 20 | 21 | // The low byte specifies how many chunks to generate from the input, where each chunk is decremented from the last. 22 | logic [C_DATA_WIDTH-1:0] data, good_in_data, prev_out_data; 23 | logic [15:0] data_cnt; 24 | 25 | assign good_in_data = (in_ready && in_avail) ? in_data : {4{8'h01}}; 26 | assign in_ready = out_ready && (prev_out_data[7:0] == 8'h00); 27 | assign out_avail = data[7:0] != 8'h00; 28 | 29 | logic mismatch, sticky_mismatch; 30 | assign mismatch = good_in_data != {good_in_data[511:8], 8'h01}; 31 | always_ff @(posedge clk) begin 32 | if (reset) sticky_mismatch <= 0; 33 | else if (mismatch) sticky_mismatch <= 1; 34 | end 35 | always_ff @(posedge clk) begin 36 | if (reset) data_cnt <= '0; 37 | else if (in_ready && in_avail) data_cnt <= data_cnt + 1; 38 | end 39 | 40 | 41 | assign data = (in_ready && in_avail) ? good_in_data : prev_out_data; 42 | //assign data = (in_ready && in_avail) ? {good_in_data[511:8], 8'h01} : prev_out_data; 43 | 44 | genvar i; 45 | generate 46 | for (i = 0; i < C_DATA_WIDTH / 32; i++) begin 47 | assign out_data[i*32 +: 32] = 48 | !(out_ready && out_avail) ? {4{8'h0F}} : // Dont-care output - use a specific recognizable pattern. 49 | (i == 2) ? {mismatch || sticky_mismatch, data_cnt[14:0], {2{debug_sigs}}} : // Info for debug. 50 | //(i == 3) ? ctrl_xfer_size_in_bytes : 51 | //(i == 4) ? resp_xfer_size_in_bytes : 52 | data[i*32 +: 32] - 1; // Valid output. 53 | end 54 | endgenerate 55 | 56 | 57 | always_ff @(posedge clk) begin 58 | if (reset) begin 59 | prev_out_data <= '0; 60 | end else if (out_ready && out_avail) begin 61 | // out_data accepted at output. 62 | prev_out_data <= out_data; 63 | end 64 | end 65 | 66 | 67 | 68 | // 2nd copy of logic. 69 | 70 | 71 | // The low byte specifies how many chunks to generate from the input, where each chunk is decremented from the last. 72 | logic [C_DATA_WIDTH-1:0] data2, prev_out_data2, out_data2; 73 | 74 | assign data2 = (in_ready && in_avail) ? good_in_data : prev_out_data2; 75 | 76 | generate 77 | for (i = 0; i < C_DATA_WIDTH / 32; i++) begin 78 | assign out_data2[i*32 +: 32] = data2[i*32 +: 32] - 1; 79 | end 80 | endgenerate 81 | 82 | 83 | always_ff @(posedge clk) begin 84 | if (reset) begin 85 | prev_out_data2 <= '0; 86 | end else if (out_ready && out_avail) begin 87 | // out_data accepted at output. 88 | prev_out_data2 <= out_data2; 89 | end 90 | end 91 | 92 | 93 | // Capture signals for debug. 94 | always_ff @(posedge clk) begin 95 | if (reset) begin 96 | debug_sigs[3:0] <= {in_ready, in_avail, out_ready, out_avail}; 97 | end 98 | debug_sigs[7:4] <= {in_ready, in_avail, out_ready, out_avail}; 99 | end 100 | 101 | endmodule 102 | -------------------------------------------------------------------------------- /apps/vadd/host/need_to_be_reenabled/vadd.c: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, Steven F. Hoover 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** The main application that is needed to communicate with the hardware and the 36 | ** python server. 37 | ** 38 | ** It accepts socket communications to transmit data and commands. 39 | ** The access to the hardware resources is possible through the use of a library 40 | ** "kernel.c" which contains all the functions that are needed to utilize the FPGA device. 41 | ** 42 | ** There is a set of functions that handle the communication through the socket. 43 | ** 44 | ** Author: Alessandro Comodi, Politecnico di Milano 45 | ** 46 | */ 47 | 48 | 49 | #include 50 | 51 | 52 | void HostApp::fakeKernel(size_t bytes_in, void * in_buffer, size_t bytes_out, void * out_buffer) { 53 | if (bytes_out != bytes_in) { 54 | cerr_line() << "VAdd fakeServer expects bytes_out (" << bytes_out << ") == bytes_in (" << bytes_in << "). Exiting." << endl; 55 | exit(1); 56 | } 57 | if (bytes_in & 0x3) { 58 | cerr_line() << "VAdd fakeKernel expects uint32's, but received " << bytes_in << " bytes." << endl; 59 | } 60 | 61 | for (int i = 0, uint32 * in = (uint32 *)in_buffer, uint32 * out = (uint32 *)out_buffer; i < bytes_in >> 2; i++, in++, out++) { 62 | *out = *in + 1; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /apps/vadd/host/need_to_be_reenabled/vadd.h: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, Steven F. Hoover 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** The main application that is needed to communicate with the hardware and the 36 | ** python server. 37 | ** 38 | ** It accepts socket communications to transmit data and commands. 39 | ** The access to the hardware resources is possible through the use of a library 40 | ** "kernel.c" which contains all the functions that are needed to utilize the FPGA device. 41 | ** 42 | ** There is a set of functions that handle the communication through the socket. 43 | ** 44 | ** Author: Alessandro Comodi, Politecnico di Milano 45 | ** 46 | ** TODO: There's still a lot of image-specific content here. Partition cleanly. 47 | */ 48 | 49 | // THIS CODE NOT YET ENABLED 50 | ERROR 51 | 52 | #ifndef VADD_H 53 | #define VADD_H 54 | 55 | #include 56 | #include 57 | 58 | #include "server_main.h" 59 | 60 | using namespace std; 61 | 62 | 63 | 64 | // --------------------------------------------------------------------------------------------------------- 65 | class HostVAddApp : public HostApp { 66 | 67 | public: 68 | // Without OpenCL, define fake vadd kernel behavior for testing the client. 69 | // Othersize, default passthrough behavior is fine. 70 | void fakeKernel(size_t bytes_in, void * in_buffer, size_t bytes_out, void * out_buffer); 71 | }; 72 | 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /apps/warpv/README.md: -------------------------------------------------------------------------------- 1 | # WARP-V Example 2 | 3 | The kernel in this example contains a WARP-V TL-Verilog RISC-V CPU (TODO: not yet and eventually many-core). 4 | 5 | The web front-end accepts a simple form of assembly code. It sends the assembled binary data to the kernel to load in instruction memory. A reset command (TODO: not implemented) will start execution and receive data from the CPU. 6 | 7 | # Implementation 8 | 9 | WARP-V uses M4 macro pre-processing to define the instruction set. This definition is used to generate CPU decode logic and also to provide a simple assembler, so the assembler remains in sync w/ the hardware from a single definition of the instruction set. This simplifies the job of customizing the ISA (though, admittedly, the M4 code is rather ugly). 10 | 11 | We wish to preserve this single-source property in our example, so, we must use the same WARP-V code base that provides the kernel to assemble the instructions. This WARP-V TLV file must be accessible via a URL, and there is a slight burden on the user currently to use the same WARP-V for kernel build and assembly. 12 | 13 | The assembly code is processed as follows: 14 | 15 | - Lines in the source code starting with a parenthetical list of args are interpreted as instructions. 16 | - Each parenthetical expression is extracted as arguments for a TL-Verilog `m4_asm` macro instantiation. 17 | - A TL-Verilog file (well, string) is formed containing the `m4_asm`s. This TL-Verilog "file" includes the given WARP-V source code URL (via `m4_include_lib`). This WARP-V code presumably defines the `m4_asm` macro. 18 | - The TL-Verilog "file" is sent to SandPiper SaaS Edition to evaluate the `m4_asm` statements into Verilog constant expressions for the instructions' binary values. 19 | - The Verilog constant expressions from the resulting Verilog file are parsed into integer values. 20 | - These integer values are bundled into chunks and sent to the kernel to program the WARP-V in the kernel. 21 | 22 | # TODO: 23 | 24 | - Keep WARP-V version in sync between assembly and kernel. Either 25 | - Use NPM to install WARP-V and serve WARP-V TLV. JS will provide this file to SandPiper SaaS, and kernel compile will use it as a local include. 26 | - Create a file containing the WARP-V TLV URL. Serve this file for JS to use and use M4 to access this file for URL inclusion. 27 | - Instructions are assumed to be 32 bits, so this is not currently customizable. 28 | -------------------------------------------------------------------------------- /apps/warpv/build/Makefile: -------------------------------------------------------------------------------- 1 | # Extends framework Makefile with mandelbrot-specific stuff. 2 | # See framework/build/Makefile for usage info. 3 | 4 | ########## 5 | # TODO: lodepng.[c/h] is used in framework. Use should be moved to mandelbrot, so none of these are required. 6 | EXTRA_C_SRC=$(FRAMEWORK_HOST_DIR)/default_main.c ../../mandelbrot/host/lodepng.c 7 | EXTRA_C_HDRS=../../mandelbrot/host/lodepng.h 8 | PROJ_SW_CFLAGS=-I../../mandelbrot/host 9 | ########## 10 | 11 | 12 | include ../../../framework/build/Makefile 13 | -------------------------------------------------------------------------------- /apps/warpv/client/css/warpv.css: -------------------------------------------------------------------------------- 1 | #warpv-url { 2 | resize: horizontal; 3 | } 4 | #assembly-code { 5 | resize: both; 6 | font-family: "Lucida Console", Monaco, monospace; 7 | } 8 | #assembled-code > p, #imem > p { 9 | margin: 0px; 10 | } 11 | .error { 12 | color: red; 13 | } -------------------------------------------------------------------------------- /apps/warpv/client/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 15 | 16 | 17 | 1st CLaaS WARP-V Example 18 | 19 | 20 | 21 | 22 |

1st CLaaS WARP-V Example

23 |

Assemble based on this WARP-V code

24 |

25 | 26 |

27 |

Assembly Code

28 |

29 | 30 |

31 |

32 | (assemble, reset CPU, upload, and run) 33 | 34 |

35 |

36 | 37 |

38 |

Assembled Code

39 |
40 |

IMem Write Response

41 |

42 | 

WARP-V Response

43 |

-

44 |

Instruction Memory

(as last read)

45 |
46 |

47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /apps/warpv/doc/notes.md: -------------------------------------------------------------------------------- 1 | # 1st CLaaS WARP-V Planning 2 | 3 | ## Many-Core 4 | 5 | ### Virtex UltraScale+ vu9p Resources 6 | 7 | Ultra RAMs: 960 (288 Kb ea. 2rw; e.g. 8k x 36b) 8 | Block RAMs: 2060 (2rw 1k x 36b or 1r1w 512 x 72b) 9 | DSP Slices: 6840 (27x18 add/mul) 10 | LUTs: 1182k 11 | 12 | ### Targets 13 | 14 | These are limit calculations for what can fit on f1.2xlarge instance w/ 1 FPGA. We will not reach these. These do not account for shell logic. 15 | 16 | #### WARP-V RISC-V 17 | 18 | ``` 19 | 1920 cores, so per core: 20 | Ultra RAMs: 0.5 (+0%) [18KB DMem 1rw] 21 | Block RAMs: 1 (+7%) [1k instr IMem (share and grow)] 22 | DSP Slices: 3 (+18%) [2 for EXE, 1 for branch target?, 0 for address calc?] 23 | LUTs: 378 (at 60% util. of 630) 24 | ``` 25 | 26 | DSPs: 27 | 28 | #### WARP-V DSP CPU 29 | 30 | ``` 31 | 6840 cores, so per core: 32 | Ultra RAMs: 0.125 (12%) [36KB shared IMem] 33 | Block RAMs: 0.25 (20%) [1KB / core, 2rw / 4 cores] 34 | DSP Slices: 1 (.0) 35 | LUTs: 106 (at 60% util. of 177) <= experiment w/ feasibility (include interconnect) 36 | ``` 37 | 38 | 18-bit instr, 16b data (DSPs are 18b, but distributed RAM for RF is 16b). 39 | IStream is in UltraRAM, shared by 8 cores. 4 cores share 1 port. Each reads blocks of 4 instrs every 4 cycles. ICache can be an enhancement. 40 | Block RAM 2 ports shared by 4 cores, with each port shared by 2 cores. 41 | -------------------------------------------------------------------------------- /bin/copy_app: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd $(dirname ${BASH_SOURCE})/../apps 5 | 6 | template_app_name="$1" 7 | app_name="$2" 8 | 9 | usage() { 10 | echo '$0 ' 11 | } 12 | 13 | if [[ ! -e "../apps/$template_app_name" ]] 14 | then 15 | echo "No such app: $template_app_name" 16 | exit 1 17 | fi 18 | if [[ ! $app_name =~ ^[[:alnum:]_-]+$ ]] 19 | then 20 | echo 'Illegal application name' 21 | exit 1 22 | fi 23 | 24 | cp -rP "$template_app_name" "$app_name" 25 | cd "$app_name" 26 | 27 | # Change file names. 28 | for file in $(find . -name "*$template_app_name*") 29 | do 30 | mv "$file" $(echo "$file" | sed "s/$template_app_name/$app_name/") 31 | done 32 | 33 | # Replace app name within files. 34 | for file in $(find . -name '*') 35 | do 36 | if [[ -f "$file" ]] 37 | then 38 | sed -i "s/$template_app_name/$app_name/" "$file" || true 39 | fi 40 | done 41 | -------------------------------------------------------------------------------- /bin/install_verilator: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install Verilator in /local/verilator (if missing), or "install_verilator global" to also 4 | # install globally on the system. 5 | 6 | set -e 7 | cd $(dirname ${BASH_SOURCE})/.. 8 | 9 | arg1="$1" 10 | if [[ -n "$arg1" && "$arg1" != "global" ]] 11 | then 12 | echo "Usage: $0 [global]" 13 | exit 1 14 | fi 15 | 16 | 17 | mkdir -p local 18 | cd local 19 | 20 | if [[ -n "$(which apt-get 2> /dev/null)" ]] 21 | then 22 | # Ubuntu 23 | sudo apt-get install make autoconf g++ flex bison 24 | else [[ -n "$(which yum 2> /dev/null)" ]] 25 | # Ubuntu 26 | sudo yum install make autoconf flex bison which -y 27 | sudo yum groupinstall 'Development Tools' -y 28 | fi 29 | 30 | if [[ -e ./verilator ]] 31 | then 32 | echo "$(pwd)/verilator exists." 33 | echo "To reinstall, first 'rm -rf $(pwd)/verilator'." 34 | else 35 | curl https://www.veripool.org/ftp/verilator-4.108.tgz | tar -zx 36 | mv verilator* verilator # So path is not version-dependent. 37 | cd verilator 38 | autoconf 39 | ./configure 40 | make -j$(nproc) 41 | fi 42 | 43 | if [[ "$arg1" == "global" ]] 44 | then 45 | if which verilator &> /dev/null 46 | then 47 | echo "Verilator exists in PATH. Cowardly refusing to install globally." 48 | exit 1 49 | else 50 | sudo make install 51 | fi 52 | fi 53 | -------------------------------------------------------------------------------- /bin/regress: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2019, Steven F. Hoover 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | # A regression test. 35 | 36 | # Runs regression scripts for framework (framework/bin/regress) and apps (apps/*/bin/regress). 37 | 38 | # Each regress script must have the following usage:should use the following conventions (as run by this script on via command-line): 39 | # o use configuration from $CONFIG_FILE. 40 | # o do local testing first, then EC2 testing. 41 | 42 | 43 | # Process command-line arguments. 44 | 45 | usage() { 46 | echo "Usage: $0 [-a] [-c config-file] [-p] [-m] [-h]" 47 | } 48 | 49 | AWS_REGRESS="false" 50 | CONFIG_FILE="$HOME/1st-CLaaS_config.mk" 51 | PARALLEL="false" 52 | MONITOR="true" 53 | while getopts “:ac:ph” opt; do 54 | case $opt in 55 | a) AWS_REGRESS="true" 56 | c) export CONFIG_FILE=$OPTARG ;; 57 | p) PARALLEL="true" ;; 58 | m) MONITOR="true" ;; 59 | h) echo "Run regressions for framework and each app (as .../regress )." 60 | usage 61 | echo " -a: Include test that use AWS resources." 62 | echo " -c : Specifies config file created with 'make config CONFIG_FILE=' if other than $CONFIG_FILE." 63 | echo " -p: Run framework and each app regression in parallel." 64 | echo " -m: For use with -p. Monitor background processes and report real-time status updates." 65 | echo " -h: You figured this one out already." 66 | echo " For each regression script:" 67 | echo " : true/false indicating whether -a was present." 68 | echo " : from the -c argument value." 69 | ;; 70 | \? ) usage 71 | ;; 72 | esac 73 | done 74 | shift $((OPTIND -1)) 75 | 76 | 77 | 78 | cd "$( dirname "${BASH_SOURCE[0]}")/.." 79 | 80 | 81 | echo -e '\e[91m\e[1mWARNING: Failed regression tests might leave EC2 instance running and resources allocated. It is necessary to monitor EC2 usage during/after regression testing.\e[0m' 82 | 83 | # If init was not run yet, run it. 84 | 85 | if [[ ! -e terraform/terraform ]] 86 | then 87 | ./init 88 | fi 89 | 90 | 91 | # Run each regression test in sequentially or in parallel. 92 | 93 | if [[ $PARALLEL == "true" ]] 94 | then 95 | PROCS='' 96 | DIRS='' 97 | LOG_FILES='' 98 | STATUS_FILES='' 99 | fi 100 | 101 | for regression in $(ls framework/bin/regress apps/*/bin/regress) 102 | do 103 | DIR="$(dirname "$(dirname "$regression")")" 104 | LOG="$(dirname "$regression")/../log/regress.log" 105 | STATUS="$(dirname "$regression")/../out/regress_status.txt" 106 | mkdir -p $(dirname "$LOG") $(dirname "$STATUS") 107 | touch "$STATUS" # Create it so it can be watched. 108 | if [[ $PARALLEL == "true" ]] 109 | then 110 | # Parallel. 111 | ( "$regression" "$AWS_REGRESS" "$CONFIG_FILE" >& "$LOG" && echo $? > "$STATUS" ) & 112 | PROCS="$PROCS $!" 113 | DIRS="$DIRS $DIR" 114 | LOG_FILES="$LOG_FILES $LOG" 115 | STATUS_FILES="$STATUS_FILES $STATUS" 116 | else 117 | # Sequential. 118 | echo 119 | if "$regression" "$AWS_REGRESS" "$CONFIG_FILE" |& tee "$LOG" 120 | then 121 | echo -e '\e[32m\e[1mRegression PASSED!!!\e[0m' 122 | else 123 | echo -e '\e[91m\e[1mRegression FAILED!!!\e[0m' 124 | fi 125 | fi 126 | done 127 | 128 | if [[ $PARALLEL == "true" ]] 129 | then 130 | echo "Running regressions in: $DIRS" 131 | echo "Processes: $PROCS" 132 | echo "Logging to */log/regress.log" 133 | echo "Status will be written to: */out/regress_status.txt" 134 | 135 | # Monitor regressions. 136 | if [[ $MONITOR == "true" ]] 137 | then 138 | while sleep 1 && ps -p $PROCS > /dev/null 139 | do 140 | inotifywait -t 30 $STATUS_FILES 141 | echo 142 | echo "Still running:" 143 | ps -p $PROCS 144 | echo 145 | echo "Completed regressions:" 146 | for status_file in $STATUS_FILES 147 | do 148 | if [[ -e "$status_file" ]] 149 | then 150 | echo "$status_file: $(cat $status_file)" 151 | fi 152 | done 153 | done 154 | fi 155 | fi 156 | -------------------------------------------------------------------------------- /bin/vnc_ec2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2018, alessandrocomodi 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | # Connect to EC2 machine, launch vncserver and connect to it. 35 | # Usage: vnc_ec2 [-g XxY] 36 | # vnc_ec2 -k [] 37 | # -g: geometry as in -geometry arg of vncserver 38 | # : IP address of EC2 instance. If given, it is recorded in .ec2_ip file and can be omitted in future invocations to use the same EC2 instance. 39 | # -k: kill the running server 40 | # Assumptions: 41 | # - There must be a private key file ~/.ssh/id_rsa.pem with a corresponding public key on the EC2 instance. 42 | # - VNC server :7 is used. Any existing :7 server will be killed (if permissions permit). Port 5907 must be open to the EC2 machine. 43 | # - vncserver must be installed on EC2 instance. 44 | # - vncviewer must be installed locally. 45 | # - vnc password must be provided locally in ~/.vnc/passwd 46 | 47 | 48 | SCRIPT_PATH="${BASH_SOURCE[0]}" 49 | SCRIPT_DIR=`dirname "${SCRIPT_PATH}"` 50 | 51 | 52 | 53 | # Args 54 | 55 | GEOMETRY="" 56 | KILL=false 57 | while getopts "g:k" opt 58 | do 59 | case "${opt}" in 60 | g) GEOMETRY=" -geometry ${OPTARG}";; 61 | k) KILL=true;; 62 | esac 63 | done 64 | shift $((OPTIND -1)) 65 | 66 | IP="$1" 67 | shift 68 | 69 | 70 | 71 | # IP address 72 | 73 | if [ "$IP" = "" ]; then 74 | IP_GIVEN=false 75 | # Load IP from .ec2_ip 76 | IP=`cat "$SCRIPT_DIR/.ec2_ip"` 77 | else 78 | IP_GIVEN=true 79 | fi 80 | 81 | # Validate IP 82 | if ! [[ "$IP" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 83 | echo "Error: IP address '$IP' is malformed. Bye." 84 | exit 1 85 | fi 86 | 87 | if [[ $IP_GIVEN = true ]]; then 88 | # Write IP to .ec2_ip 89 | echo $IP > "$SCRIPT_DIR/.ec2_ip" 90 | fi 91 | 92 | 93 | 94 | # Kill 95 | 96 | if [ "$KILL" = true ]; then 97 | ssh -i /home/steve/.ssh/id_rsa.pem centos@$IP 'vncserver -kill :7' 98 | exit 99 | fi 100 | 101 | 102 | 103 | # Do it 104 | 105 | # ssh into EC2 instance 106 | echo "Starting new VNC server on :7 (unless already running)." 107 | echo "Kill using \"$0 -k.\"" 108 | ssh -i /home/steve/.ssh/id_rsa.pem centos@$IP "vncserver$GEOMETRY :7" 109 | 110 | # open local VNC viewer 111 | vncviewer $IP:7 passwd=~/.vnc/passwd & 112 | -------------------------------------------------------------------------------- /doc/F1Guide.md: -------------------------------------------------------------------------------- 1 | 2 | # Optimization and Deployment Guide 3 | 4 | THIS IS CURRENTLY A PILE OF MISCELLANEOUS STUFF. 5 | 6 | 7 | 8 | TODO: Instructions for using a specific AMI version and checking the latest version. 9 | 10 | These instructions were last debugged with SDx v2018.3. Check to see what version you have. If it differs, you might get to help us debug a new platform. 11 | 12 | ```sh 13 | sdx -version 14 | ``` 15 | 16 | -j8 17 | 18 | To the best of our understanding the actual AFI is stored permanently by AWS at no cost. 19 | 20 | sdaccel_setup breaks git. 21 | 22 | 23 | Tracing in hw_emu mode is TBD (see simon's answer to steve's xilinx post). 24 | 25 | 26 | 40 | 41 | 42 | # Instances for Development 43 | 44 | These instances allow TCP/IP traffic through on port 80 for running a production web server and ports 8880-8889 for development. Information about this instance is , and you can find all the instance parameters in `terraform.tfstate`. Note that this file contains the private TLS key. 45 | 46 | For access to these machines, TLS key pairs are placed into `~/.ssh//` (locally). The public IP address of each instance is reported on the terminal upon completion of each command, though, when stopped and restarted, instances will get new IP addresses. 47 | 48 | 49 | The following commands terminate the instance: 50 | 51 | Note that this also deletes the created storage. (This step can be disabled in the `ec2_instance.tf` file.) 52 | 53 | ### Remmina 54 | 55 | The Remmina configuration file used by `make` commands is in `/framework/build/template.remmina`. It can be copied into `~/.remmina` for interactive use, or modified to alter the options (such as adding SSH tunneling) 56 | 57 | 58 | ## Dynamic Start/Stop of Static F1 Instances 59 | 60 | 1st CLaaS has support for deploying applications with an associated F1 instance. This instance is created statically using: 61 | 62 | ``` 63 | make static_accelerated_instance 64 | ``` 65 | 66 | REST calls to the Web Server are responsible for starting and stopping the instance. Stopping is performed by an "EC2 Time Bomb" process that is run in the background. If it is not pinged with a certain frequency, it will shut down the instance, so the client application is responsible for sending this periodic ping. (This approach ensures that the instance will stopped when clients fail to stop them explicitly.) See `/framework/aws/ec2_time_bomb` comments for usage details. 67 | 68 | 69 | 74 | 75 | 76 | ## SSH keys 77 | 78 | In case you want to set up passwordless authentication from your Development Instance for git access or any other reason, you may need to generate ssh keys for your instance. 79 | 80 | ```sh 81 | ssh-keygen -o -t rsa -b 4096 -C "" 82 | sudo yum install xclip -y 83 | xclip -sel clip < ~/.ssh/id_rsa.pub 84 | ``` 85 | 86 | And paste this SSH key into the settings of your other account (e.g. gitlab/github). 87 | 88 | 89 | 90 | # Development of this Framework 91 | 92 | These are WIP notes: 93 | 94 | 95 | ## SDAccel 96 | 97 | This is how I was able to generate an RTL kernel in SDAccel manually and run hardware emulation. This is scripted as part of the build process, but not with the ability to run in SDAccel. These are notes to help figure that out. 98 | 99 | - `cd ~/workdisk/1st-CLaaS` 100 | - `source sdaccel_setup` 101 | - `sdx` 102 | - `echo $AWS_PLATFORM` (You will need to know this path.) 103 | - On Welcome screen "Add Custon Platform". 104 | - Add (+) `$AWS_PLATFORM/..` . 105 | - "New SDxProject": 106 | - Application. 107 | - name it, select only platform, accept linux on x86 and OpenCL runtime, and "Empty Application". "Finish". 108 | - Menu "Xilinx", "Create RTL Kernel". 109 | - name it; 2 clocks (independent kernel clock); 1 reset? 110 | - default scalars (or change them) 111 | - default AXI master (Global Memory) options (or change them) 112 | - wait for Vivado 113 | - In Vivado: 114 | - "Generate RTL Kernel" 115 | - wait 116 | - Close 117 | - Back in SDAccel: 118 | - in projects.sdx: 119 | - Add binary container under "Hardware Functions" by clicking the lightning bolt icon. There should be only one function identified as the target for the kernel. Click "OK". You will get "binary_container_1". 120 | - Select "Emulation-HW" 121 | - Menu "Run", "Run Configuration" 122 | - Tab "Main", "Kernel Debug", Check "Use RTL waveform...", and check "Launch live waveform". 123 | - Tab "Arguments", check "Automatically add binary container(s) to arguments" 124 | - Click "Run" (or "Apply" and click green circle w/ play arrow). 125 | 126 | 127 | # Tips and Tricks 128 | 129 | ## Verilog Development 130 | 131 | Use Vivado(TM) to develop your Verilog code (`make edit_kernel`). Vivado will show syntax errors (and more) as you type. If your code is clean in the editor you have a good chance of getting through synthesis and place-and-route. We've seen very misleading error messages on code that is not clean. For example, for `hw_emu` builds, we often see in `vivado.log`: `Cannot find design unit xil_defaultlib.emu_wrapper`, for which we have no explanation. 132 | 133 | ## TL-Verilog 134 | 135 | TL-Verilog development cannot be done using Vivado, but SandPiper(TM) tends to generate clean Verilog, so you are unlikely to see downstream errors. As a last resort, you can always (`make edit_kernel`) to get feedback from Vivado about the generated Verilog. Of course, the Verilog is not source code, but if you are careful, you can make experimental edits and compile with that edited Verilog code. The code will be overwritten by a build if the .tlv source is edited. 136 | -------------------------------------------------------------------------------- /doc/GettingStarted.md: -------------------------------------------------------------------------------- 1 | 2 | # Getting Started with 1st CLaaS 3 | 4 | ## Overview 5 | 6 | Getting started is easy. We'll show you a few commands to get your feet wet, test out your platform, and write your own "Hello World" application. Then you can either: 7 | 8 | - jump right into development with help from the [Developer's Guide](DevelopersGuide.md#top), or 9 | - test drive AWS F1 with [Getting Started with F1](GettingStartedF1.md#top) 10 | - Alternatively, if you want to setup development environment for Hardware Emulation on your compatible machine, read [Setting up Virtual Machine on Windows for Hardware Emulation](VMsetup.md) 11 | 12 | > Note that F1 use requires approval, which can take a day or more, so you may want to do the first step of the [Developer's Guide](doc/DevelopersGuide.md#top) now, so your F1 platform will be ready when you are. 13 | 14 | 15 | ## Platform 16 | 17 | 1st CLaaS was developed on: 18 | 19 | - Ubuntu 16.04 20 | - Ubuntu 18.04 21 | - Centos7 22 | 23 | Please help us debug other Linux/Mac platforms. If you don't have a compatible machine, you can provision a cloud machine from AWS, Digital Ocean, or other providers as your "local" machine. 24 | 25 | 26 | ## Setup 27 | 28 | To configure your local environment, including installation of tools for AWS development, clone and cd into this repo, then: 29 | 30 | ```sh 31 | ./init # This will require sudo password entry, and you may be asked to update your $PATH.) 32 | ``` 33 | 34 | 35 | ## Running Mandelbrot Locally 36 | 37 | ![mandelbrot](http://fractalvalley.net/img?json={%22x%22:-0.9836,%22y%22:-0.279,%22pix_x%22:0.00001906,%22pix_y%22:0.00001906,%22width%22:1018,%22height%22:74,%22max_depth%22:1225,%22modes%22:66,%22renderer%22:%22cpp%22}) 38 | 39 | To run the sample Mandelbrot application locally, without an FPGA: 40 | 41 | ```sh 42 | cd apps/mandelbrot/build 43 | make launch 44 | ``` 45 | 46 | You should see output indicating that the application is running with `TARGET` = `sim`, and that the web server is running. The `sim` `TARGET` uses the Verilator RTL simulation tool to emulate the FPGA kernel behavior. 47 | 48 | Open `http://localhost:8888/index.html` in a local web browser and explore Mandelbrot. You can choose for the Mandelbrot images to be rendered: 49 | 50 | - by the Python web server (very slowly) 51 | - by the C++ host application 52 | - in Verilator simulation of the custom RTL kernel (by selecting "FPGA") 53 | 54 | More instructions for the Mandelbrot application are [here](../apps/mandelbrot). 55 | 56 | Stop the web server with `-C` (in the terminal window). 57 | 58 | You'll be able to see the speedup you get from an FPGA when you get to [Getting Started with F1](GettingStartedF1.md#top). 59 | 60 | 61 | ## Running Vector Add Locally 62 | 63 | The `vadd` example is a "hello world" example. It simply contains a custom kernel in `/apps/vadd/fpga/src/vadd_kernel.sv` that returns each value sent in, incremented by one. The rest of the application is provided by the framework. You'll run it the same way as `mandelbrot` (but we'll start the web server on a different port so your browser isn't tempted to provide a cached mandelbrot page). 64 | 65 | ```sh 66 | cd /apps/vadd/build 67 | make launch PORT=8000 68 | ``` 69 | 70 | Open `http://localhost:8000/index.html`. 71 | 72 | `vadd` uses a default web client that allows you to send raw data through the server to the custom kernel. Click send, and you'll see that the kernel returns data where each value has been incremented by 1 by the RTL kernel. 73 | 74 | Stop the web server wth `-C`. 75 | 76 | 77 | 78 | ## Making Your Own Application 79 | 80 | Now you are ready to make an simple application of your own. 81 | 82 | `vadd` is a good starting point. We've provided a command to copy an application and update the application name throughout the copy. 83 | 84 | ```sh 85 | cd /apps/vadd/build 86 | make copy_app APP_NAME=toy 87 | ``` 88 | 89 | 90 | ### Web Client Application 91 | 92 | The web client is defined by the HTML, CSS, and JS content in `/apps/toy/client/`. In this case `/apps/toy/client/html/index.html` simply links to `/framework/client/html/testbench.html` to utilize the default test bench provided by the framework that you accessed for `vadd`. If you would like to modify the web client code, you can copy `/framework/client/*/testbench.*` into `/apps/toy/client` as a simple starting point. To develop a real application, you may have your own thoughts about the framework you would like to use. You can use what you like. Develop in a separate repo, or keep it in the same repo so it is consistently version controlled. 93 | 94 | 95 | ### Custom Kernel 96 | 97 | The vadd kernel is a good starting point for your own kernel. Though we strongly recommend using TL-Verilog, this kernel is written in SystemVerilog, which is currently more broadly familiar. If you'd like to try TL-Verilog: 98 | 99 | ```sh 100 | cd /apps/toy/fpga/src 101 | cp tlv_varients/toy_kernel.tlv.disabled toy_kernel.tlv 102 | ``` 103 | 104 | We'll add some [TL-Verilog Tutorials](TLV_Tutorials.md#top). 105 | 106 | Modify the kernel code as desired. Try subtraction or anything you like. 107 | 108 | 109 | ### Run 110 | 111 | Build and run as before: 112 | 113 | ```sh 114 | cd /apps/toy/build 115 | make launch 116 | ``` 117 | 118 | The client can be modified without relaunching. Just do a forced reload in your browser (`-F5` in Chrome and Firefox). Browser debug tools are quite useful: (`-J` in Chrome and Firefox). 119 | 120 | 121 | ### C++ Host Application 122 | 123 | It is not required to customize the host application, but if you would like to do so, you can override the one from the framework, following the example of the Mandelbrot application. (Refer to its `Makefile` as well as `/host` code.) 124 | 125 | 126 | ### Python Web Server 127 | 128 | It is not required to customize the Python web server, but if you would like to do so, you can override the one from the framework, following the example of the Mandelbrot application. (Refer to its `Makefile` as well as `/webserver` code.) 129 | 130 | 131 | ## Next Steps 132 | 133 | Now that you've got your feet wet, either: 134 | 135 | - continue development with help from the [Developer's Guide](DevelopersGuide.md#top), or 136 | - test drive AWS F1 with [Getting Started with F1](GettingStartedF1.md#top) 137 | -------------------------------------------------------------------------------- /doc/Story.md: -------------------------------------------------------------------------------- 1 | 2 | # A Personal History of this Project 3 | 4 | ![framework](img/SteveProfilePic.jpg) 5 | 6 | My name is Steve Hoover. I am the proud founder of Redwood EDA. After 18 years of banging my head against the wall designing silicon for Intel using the misguided tools this industry produces, I decided it was time to focus on making better tools. There's no reason circuit design has to be an exclusive club for experts trained in the obscurities of an arcane ecosystem. Digital logic is just 1s and 0s. It can't get any simpler. The difficulty was entirely self-inflicted. So, I set out to fix things and regain my own sanity. 7 | 8 | The first thing to fix, was the language. Verilog carries with it over 30 years of baggage, and other languages have missed the mark in various ways. So I created TL-Verilog as an incremental path to simpler and *way* better "transaction-level" design methodology. But let's not stop at language, as we've done in the past. We need web- and open-source-friendly tools. Transaction-level design needs to extend from the language into the platform, so I created the Makerchip IDE with the help of a few interns. 9 | 10 | As I got more into the open-source community, and as I saw FPGAs becoming available in the cloud, I realized there was a revolution about to unfold. Why? Well, let's get some perspective. Open-source software has been going gangbusters for years, transforming the software industry time and time again. All the while, circuit design has been done using Verilog and text editors. We've been standing still. But it gets worse. Since we started using Verilog, chips have gotten a bit bigger--not physically, but in terms of transistor counts. Any guess how much "bigger"? 100x? 1000x? Not even close. 100,000x!!! 11 | 12 | So we're ripe for change. We need circuit design to break out of its commercial fortress and discover what an open source ecosystem is capable of. And guess what. Having FPGAs in the cloud is going to release the flood gates. There have been three things holding back open source hardware: 13 | 14 | 1. Circuit design is fundamentally harder than software. Sure, I said "it's just 1s and 0s," but, in contrast to software, the bulk of your development effort tends to focus on the implementation of the logic, not just the functionality. 15 | 1. Access to hardware: Again, in contrast to software, you can't just download someone's RTL and use it. You have to turn it into hardware. For a hobbyist, that's not going to be an ASIC, so we're talking FPGAs. You've got to work this open-source RTL into your specific platform and your specific logic with your specific physical design constraints to make it do your bidding. You may as well start from scratch. 16 | 1. Access to software: Unlike compilers for software, Electronic Design Automation (EDA) tools for compiling hardware are ***expensive***. 17 | 18 | And I realized that all of these very serious obstacles were breaking down. 19 | 20 | 1. I have greatly simplified hardware design with Redwood EDA, TL-Verilog, and Makerchip. 21 | 2. Hardware access is totally solved by cloud FPGAs. Open source designs can be made available, packaged to run in hardware that is available to anyone! Just download, compile, and run in silicon, just like software. 22 | 3. Other folks, like the almighty Claire Wolf, have been developing open-source EDA tools, and FPGAs have now been designed exclusively using these open-source tools. Even commercially, with Amazon F1, Xilinx tools are now bundled with the platform using a rental model with no up-front cost. And my own Redwood EDA tools are free for open-source development at makerchip.com with no installation required. 23 | 24 | This is game-changer! And it's a really refreshing one for me, having spent almost 20 years in an industry that was standing still. So I started ramping up on Amazon F1. Yikes! Holy crap! What a friggin' nightmare! The hardware platform was amazing, but the infrastructure for developing on the platform has a long way to go. So, I turned my attention elsewhere... 25 | 26 | ...until, I struck up a conversation with Marco Santambrogio at a conference. Marco heads the NECSTLab at Politecnico di Milano with reasearch on the Amazon F1 platform. We started a small collaboration leading to Alessandro Comodi's early contributions to the project. This was enough to draw my attention in this direction. And this year (2019), Google is helping the project along with Akos Hadnagy contributing through Google Summer of Code. 27 | 28 | I hope you are able to benefit from the work. Please feed back into the project and become a "1st CLaaS citizen"--erg, did I really say that? Let me know what you are planning. Maybe I can help. 29 | 30 | Happy coding! 31 | 32 | _Steve Hoover_ 33 | -------------------------------------------------------------------------------- /doc/TLV_Tutorials.md: -------------------------------------------------------------------------------- 1 | 2 | # 1st CLaaS TL-Verilog Tutorials 3 | 4 | *Stay tuned...* -------------------------------------------------------------------------------- /doc/TmpORConfScreenCapture.md: -------------------------------------------------------------------------------- 1 | # 1st-CLaaS Screen-Capture Notes for ORConf 2019 2 | 3 | ## Prep 4 | 5 | ```sh 6 | cd /tmp/1st-CLaaS/apps/mandelbrot/build 7 | make destroy SETUP=1st-CLaaS_mandelbrot_accelerator 8 | rm -rf /tmp/1st-CLaaS 9 | ``` 10 | 11 | - Terminals: 12 | - Terminal 1 in /tmp `*** Part 1: Install and Run ***` 13 | - Terminal 2 contains command `*** Part 2: FPGA ***`, `cd /tmp/1st-CLaaS/apps/mandelbrot/build`. 14 | - Terminal 3 contains command `*** Part 3: Custom Kernel ***`, `cd /tmp/1st-CLaaS/apps/vadd/build`. 15 | - Chrome window with EC2 Console and new tab (open). 16 | - Note: [---] waiting for machine; [...] waiting for presenter 17 | 18 | ## Terminal 1: Clone/Init; run Mandelbrot (sim) 19 | 20 | - In Chrome: 21 | - New tab. Search "1st-CLaaS". Click repo link. 22 | - Open "Getting Started". 23 | - Copy 3-lines of clone/cd/init and paste into Terminal 1. [-] 24 | - In Terminal 1, make launch: 25 | - `cd apps/mandelbrot/build` 26 | - `make launch` 27 | - In Chrome, demo: 28 | - Open `localhost:8888` 29 | - Demo C++ (velocity mode, zoom, enlarge) 30 | - Shrink; Demo "FPGA" (sim) 31 | - In Terminal 1: 32 | - -C 33 | 34 | ## Terminal 2: Build F1 and Demo 35 | - In Terminal 2, make static_accelerated_instance: 36 | - to `cd /tmp/1st-CLaaS/apps/mandelbrot/build` 37 | `make static_accelerated_instance PREBUILT=true` 38 | [Create F1 instance. AWS already set up.] 39 | - Wait. Type "yes". 40 | - /STOP RECORDING/ 41 | - /START RECORDING/ 42 | - wait for F1 build 43 | - ctrl-click IP URL. 44 | - In Browser, Demo FPGA 45 | 46 | ## Make Custom App 47 | 48 | - In Terminal 3: 49 | 50 | ```sh 51 | cd /tmp/1st-CLaaS/apps/vadd/build 52 | make copy_app APP_NAME=toy 53 | cd ../../toy/build 54 | ``` 55 | 56 | - In Atom: 57 | - Open /etc/1st-CLaaS/apps/toy/fpga/src/toy_kernel.sv` & edit 58 | - `make launch` 59 | - In Chrome: 60 | - Show that it does a subtract. 61 | -------------------------------------------------------------------------------- /doc/VMsetup.md: -------------------------------------------------------------------------------- 1 | 2 | # Setting up Virtual Machine on Windows for Hardware Emulation 3 | 4 | ## Overview 5 | The focus of this document is to list down a number of steps which a user can opt for to set up the virtual machine specifically to do Hardware emulation. At the end of these steps, your VM is exactly like c4.4x EC2 instance and you can emulate your kernel on hardware just like AWS's Alveo Accelerator Card. Following are the list of steps: 6 | 7 | - [Setting up Virtual Machine](#setting-up-vm) (Can be skipped if you have CentOS 7.5 machine) 8 | - [Installing Xilinx Tools](#installing-xilinx-tools) 9 | - [Installing XRT and other libraries](#installing-xrt-and-other-libraries) 10 | - [Kernel Mismatch](#kernel-mismatch) 11 | - [Updating Yum Package Manager](#updating-yum-package-manager) 12 | 13 | > Note: The scope of work for this document is tested on July 2024 on the Windows 10 Operating System. The Xilinx Tools installed are of 2021.1v (Vitis, Vivado etc.) 14 | 15 | ## System Requirements 16 | Following are the pre requisites before starting to setup your environment 17 | 18 | - Make sure your system has enough RAM probably more than 12GB. You can workaround with 8GB of RAM too but it will be slow 19 | - Storage capacity of about 150-200 GB. The Vitis Unified Installer itself is 50+ GBs. 20 | - [VMWare Workstation 17 Pro](https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion) (They have waived off the commercial license too) 21 | - Windows/Linux Operating System. If you have already CentOS 7.5 running as your default OS, you can skip the step to setup Virtual Machine. 22 | 23 | ## Setting Up VM 24 | - After installing the VMware Workstation you can download the CentOS 7.5 from the following link [CentOS 7.5 Vault](https://ftp.jaist.ac.jp/pub/Linux/CentOS-vault/7.5.1804/isos/x86_64/). Make sure to download the **Everything ISO** which is of 8+ GB. 25 | - After downloading the CentOS Image, open up the VMware workstation and setup the new virtual machine. 26 | 27 | ![VMWare](/doc/img/vmware.png "VMWare") 28 | - Go for typical recommended settings. 29 | 30 | ![VMWare](/doc/img/vmware_2.png "VMWare") 31 | - Provide the CentOS ISO that you have downloaded. 32 | 33 | ![VMWare](/doc/img/vmware_3.png "VMWare") 34 | - Provide a storage capacity of about 200GB and split the virtual storage into multiple files 35 | 36 | ![VMWare](/doc/img/vmware_5.png "VMWare") 37 | - Before finishing it off, click **Customize Hardware** and increase the RAM up to 8 GB or more. 38 | 39 | ![VMWare](/doc/img/vmware_6.png "VMWare") 40 | - After installation, you will be automatically prompted to your login for the virtual machine. 41 | - After July 1st-2024, the yum package manager retrieves packages from vault of CentOS instead of mirror links. Refer to [Updating YUM package manager](#updating-yum-package-manager) for details to avoid any issues when running yum commands 42 | 43 | ## Installing Xilinx Tools 44 | The main part is to download and install Xilinx Tools. All the essential Xilinx Tools are packed in their unified runner. We will move forward with Vitis 2021.1 version as this is what's been used in the FPGA Developer AWS Image from their [marketplace](https://aws.amazon.com/marketplace/pp/prodview-gimv3gqbpe57k) 45 | 46 | - Install Vitis Unified Runner Setup of upto 50+ GBs from [AMD Website](https://www.xilinx.com/member/forms/download/xef.html?filename=Xilinx_Unified_2021.1_0610_2318.tar.gz) 47 | - Run **xsetup** which is located in main downloaded folder after extracting the tar/zip file. 48 | 49 | ![Vitis](/doc/img/vitis_1.png "Vitis") 50 | - Choose Vitis and make sure to unselect any custom hardware platforms. Otherwise installing them will take extra space. 51 | 52 | ![Vitis](/doc/img/vitis_2.png "Vitis") 53 | - Once you agree the terms and conditions , move forward with installation and it will take time depending upon your system. 54 | - Once the Vitis is installed, you have to add it in the environmental path by sourcing the settings script placed in your tools installed directory (/tools/Xilinx/...) 55 | ```bash 56 | source /tools/Vitis/2021.1/settings64.sh 57 | ``` 58 | 59 | ## Installing XRT and other libraries 60 | XRT is Xilinx Runtime Library and it is kernel dependent. Following kernels are supported for Alveo Accelerator Cards: 61 | 62 | ``` 63 | 3.10.0-862.11.6.el7.x86_64 64 | 3.10.0-693.21.1.el7.x86_64 65 | 3.10.0-957.1.3.el7.x86_64 66 | 3.10.0-957.5.1.el7.x86_64 67 | 3.10.0-957.27.2.el7.x86_64 68 | 3.10.0-1062.4.1.el7.x86_64 69 | 3.10.0-1062.9.1.el7.x86_64 70 | 3.10.0-1127.10.1.el7.x86_64 71 | 3.10.0-1160.31.1.el7.x86_64 72 | 4.14.209-160.339.amzn2.x86_64 73 | ``` 74 | Note that the kernels are for CentOS 7 and Amazon Linux. 75 | The XRT Libraries are available on [Xilinx website](https://xilinx.github.io/Alveo-Cards/master/debugging/build/html/docs/common-steps.html#xrt-release-versions-and-download-locations) along with release versions. 76 | You can either manually download the .deb file or use this script which is extracted from [AWS FPGA Repository for Setting up XRT instructions](https://github.com/aws/aws-fpga/blob/master/Vitis/docs/XRT_installation_instructions.md) 77 | 78 | 79 | ```bash 80 | XRT_RELEASE_TAG=202110.2.11.634 # 81 | 82 | git clone https://github.com/aws/aws-fpga.git 83 | cd aws-fpga 84 | source vitis_setup.sh 85 | cd $VITIS_DIR/Runtime 86 | export XRT_PATH="${VITIS_DIR}/Runtime/${XRT_RELEASE_TAG}" 87 | git clone http://www.github.com/Xilinx/XRT.git -b ${XRT_RELEASE_TAG} ${XRT_PATH} 88 | 89 | cd ${XRT_PATH} 90 | sudo ./src/runtime_src/tools/scripts/xrtdeps.sh 91 | 92 | cd build 93 | scl enable devtoolset-6 bash 94 | ./build.sh 95 | 96 | mkdir -p Release 97 | cd Release 98 | sudo yum install xrt_*.rpm -y 99 | ``` 100 | If XRT is installed properly, you will be successful to run the vitis runtime setup 101 | ```bash 102 | source $AWS_FPGA_REPO_DIR/vitis_runtime_setup.sh 103 | ``` 104 | ## Kernel Mismatch 105 | If in case the **vitis_runtime_setup** script throws error for kernel mismatch, you can install it as following: 106 | 107 | ```bash 108 | uname -r #To check which kernel version you have 109 | ``` 110 | It will show you the list of available kernels 111 | ```bash 112 | sudo yum list --showduplicates kernel 113 | ``` 114 | If some other kernel is available from the list you can use that too 115 | ```bash 116 | sudo install kernel-3.10.0-1160.31.1.el7.x86_64 117 | ``` 118 | 119 | ## Updating Yum Package Manager 120 | 121 | You can run the following set of commands to substitute the mirrorlist links to vault from the CentOS repository files 122 | 123 | ```bash 124 | cd /etc/yum.repos.d/ 125 | sudo sed -i s/^mirrorlist/#mirrorlist/ CentOS-*.repo 126 | sudo sed -i 's|http://mirror\.|http://vault\.|g' CentOS-*.repo 127 | sudo sed -i s/^#baseurl/baseurl/ CentOS-*.repo 128 | ``` 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /doc/img/1stCLaaS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/1stCLaaS.png -------------------------------------------------------------------------------- /doc/img/1stCLaaS_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/1stCLaaS_big.png -------------------------------------------------------------------------------- /doc/img/RDC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/RDC.png -------------------------------------------------------------------------------- /doc/img/RDC_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/RDC_color.png -------------------------------------------------------------------------------- /doc/img/SteveProfilePic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/SteveProfilePic.jpg -------------------------------------------------------------------------------- /doc/img/framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/framework.png -------------------------------------------------------------------------------- /doc/img/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/header.png -------------------------------------------------------------------------------- /doc/img/header_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/header_big.png -------------------------------------------------------------------------------- /doc/img/simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/simple.png -------------------------------------------------------------------------------- /doc/img/simplify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/simplify.png -------------------------------------------------------------------------------- /doc/img/vitis_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vitis_1.png -------------------------------------------------------------------------------- /doc/img/vitis_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vitis_2.png -------------------------------------------------------------------------------- /doc/img/vmware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware.png -------------------------------------------------------------------------------- /doc/img/vmware_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware_2.png -------------------------------------------------------------------------------- /doc/img/vmware_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware_3.png -------------------------------------------------------------------------------- /doc/img/vmware_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware_4.png -------------------------------------------------------------------------------- /doc/img/vmware_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware_5.png -------------------------------------------------------------------------------- /doc/img/vmware_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/os-fpga/1st-CLaaS/82a17bcbfa77e35ad45f6dc35a0d9d0a8ee65b4b/doc/img/vmware_6.png -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos 2 | LABEL Name=1stclaas Version=0.0.1 3 | COPY ./docker-image-init.sh /scripts/docker-image-init.sh 4 | RUN chmod +x /scripts/docker-image-init.sh 5 | RUN cd /etc/yum.repos.d/ && sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* 6 | RUN yum update -y && yum install git sudo which python3 -y && yum groupinstall 'Development Tools' -y 7 | RUN pip3 install awscli 8 | ENTRYPOINT [ "/scripts/docker-image-init.sh" ] -------------------------------------------------------------------------------- /docker/docker-image-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Cloning 1st-CLaaS repo..." 3 | git clone https://github.com/os-fpga/1st-CLaaS 4 | cd 1st-CLaaS 5 | echo "Instaling verilator..." 6 | ./bin/install_verilator 7 | echo "Initializing 1st-CLaaS..." 8 | ./init 9 | echo "Running Mandelbrot example..." 10 | cd apps/mandelbrot/build 11 | make launch 12 | -------------------------------------------------------------------------------- /framework/aws/ec2_time_bomb_server.py: -------------------------------------------------------------------------------- 1 | """ 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2019, Steven F. Hoover 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | """ 32 | 33 | """ 34 | This mini web server provides a REST API to reset an ec2_time_bomb. 35 | (NOTE: There is similar support built into server.py, which is used by examples. 36 | THIS SCRIPT IS NOT IN USE AND IS PROBABLY BROKEN.) 37 | 38 | 39 | Usage: 40 | 41 | nohup python3 ec2_time_bomb_server.py & 42 | 43 | (Nohup ensures that the service continues running after its shell is closed.) 44 | 45 | API: 46 | 47 | GET request to :/reset_ec2_time_bomb resets the time bomb. 48 | 49 | """ 50 | 51 | import tornado.httpserver 52 | import tornado.ioloop 53 | import tornado.web 54 | import os.path 55 | import subprocess 56 | import sys 57 | import json 58 | 59 | 60 | """ 61 | Time Bomb Reset Handler 62 | """ 63 | 64 | class TimeBombHandler(tornado.web.RequestHandler): 65 | # Set the headers to avoid access-control-allow-origin errors when sending get requests from the client 66 | def set_default_headers(self): 67 | self.set_header("Access-Control-Allow-Origin", "*") 68 | self.set_header("Access-Control-Allow-Headers", "x-requested-with") 69 | self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') 70 | self.set_header("Connection", "keep-alive") 71 | self.set_header("Content-Type", "text/plain") 72 | 73 | # Reset GET request. 74 | def get(self): 75 | status = 0 76 | args = [TimeBombApplication.mydir + "/ec2_time_bomb", "reset", TimeBombApplication.time_bomb_file] 77 | try: 78 | out = subprocess.check_output(args, universal_newlines=True) 79 | except: 80 | out = "Error: " + ' '.join(args) 81 | status = 1 82 | print("Time bomb reset returned: %s" % (out)) 83 | self.write(str(status)) 84 | 85 | 86 | class TimeBombApplication(tornado.web.Application): 87 | 88 | def __init__(self, time_bomb_file, port): 89 | 90 | TimeBombApplication.time_bomb_file = time_bomb_file 91 | TimeBombApplication.mydir = os.path.dirname(__file__) 92 | if TimeBombApplication.mydir == "": 93 | TimeBombApplication.mydir = "." 94 | print(TimeBombApplication.mydir) 95 | routes = [ 96 | (r"/reset_ec2_time_bomb", TimeBombHandler) 97 | ] 98 | super(TimeBombApplication, self).__init__(routes) 99 | server = tornado.httpserver.HTTPServer(self) 100 | server.listen(port) 101 | 102 | # Report external URL for the web server. 103 | # Get Real IP Address using 3rd-party service. 104 | # Local IP: myIP = socket.gethostbyname(socket.gethostname()) 105 | port_str = "" if port == 80 else ":" + str(port) 106 | try: 107 | external_ip = subprocess.check_output(["wget", "-qO-", "ifconfig.me"], universal_newlines=True) 108 | print('*** Time Bomb Server Started, (http://%s%s) ***' % (external_ip, port_str)) 109 | except: 110 | print("Python: TimeBombApplication failed to acquire external IP address.") 111 | external_ip = None 112 | print('*** Time Bomb Server Started (http://localhost%s) ***' % port_str) 113 | 114 | # Starting web server 115 | tornado.ioloop.IOLoop.instance().start() 116 | 117 | 118 | if __name__ == "__main__": 119 | 120 | # Command-line options 121 | 122 | if len(sys.argv) < 2: 123 | print("Usage: python3 ec2_time_bomb_server ") 124 | sys.exit(1) 125 | 126 | port = 65261 # (0xFEED in decimal) 127 | if len(sys.argv) > 2: 128 | port = int(sys.argv[2]) 129 | 130 | application = TimeBombApplication(sys.argv[1], port) 131 | -------------------------------------------------------------------------------- /framework/bin/patch_gtkwave: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # GTKWave seems to have an issue with scopes that begin with "|", so traces produced with "\m4_TLV_version 1d --debugSigs: tl-x.org" 4 | # cannot be used in GTKWave. This script patches the trace file. 5 | # 6 | # Usage: $0 7 | 8 | sed -i 's/|\([a-z][a-z]\)/_I_\1/' "$1" 9 | -------------------------------------------------------------------------------- /framework/bin/regress: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2019, Steven F. Hoover 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | set -e # Fail on any failure. 34 | 35 | 36 | # Args: 37 | AWS_REGRESS="$1" 38 | export CONFIG_FILE="$2" 39 | 40 | 41 | cd "$( dirname "${BASH_SOURCE[0]}")/../build" 42 | 43 | echo "Running framework regression." 44 | 45 | 46 | if [[ "$AWS_REGRESS" ]] 47 | then 48 | 49 | echo "Running AWS tests for Framework." 50 | 51 | # Create and destroy development instance and run instance. 52 | 53 | make development_instance AUTO_APPROVE=true INSTANCE_NAME=1st-CLaaS_devel_regress 54 | make list_setups 55 | make destroy SETUP=1st-CLaaS_devel_regress AUTO_APPROVE=true 56 | 57 | make f1_instance AUTO_APPROVE=true INSTANCE_NAME=1st-CLaaS_run_regress 58 | make destroy SETUP=1st-CLaaS_run_regress AUTO_APPROVE=true 59 | 60 | fi 61 | -------------------------------------------------------------------------------- /framework/build/template.remmina: -------------------------------------------------------------------------------- 1 | [remmina] 2 | disableclipboard=0 3 | ssh_auth=1 4 | clientname= 5 | quality=0 6 | ssh_charset= 7 | ssh_privatekey=TBD 8 | sharesmartcard=0 9 | resolution= 10 | group= 11 | password= 12 | name=Temp RDP EC2 13 | ssh_loopback=0 14 | shareprinter=0 15 | ssh_username=centos 16 | ssh_server= 17 | security=rdp 18 | protocol=RDP 19 | execpath= 20 | sound=off 21 | exec= 22 | ssh_enabled=1 23 | username=centos 24 | sharefolder= 25 | console=0 26 | domain= 27 | server=TBD 28 | colordepth=24 29 | window_maximize=0 30 | window_height=1760 31 | window_width=3182 32 | viewmode=1 33 | -------------------------------------------------------------------------------- /framework/client/css/testbench.css: -------------------------------------------------------------------------------- 1 | #tx-data-js { 2 | resize: both; 3 | } 4 | -------------------------------------------------------------------------------- /framework/client/html/testbench.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 13 | 15 | 16 | 17 | 18 | Test Bench 19 | 20 | 21 | 22 | 23 |

Test Bench for FPGA Kernel

24 |

Send

25 |

Enter data to send to the server as a list of JS objects, where each object represents a 512-bit value, partitioned as 32-bit integer values. 26 | Each object can contain the following fields:

27 |
28 | default_int: {int},  // Default value for all 64 integers, used if not defined otherwise.
29 | high_int: {int},  // Lost-significant integer value.
30 | low_int: {int},  // Least-significent integer value.
31 | 
32 | 33 | 34 | 35 |
36 | 

Number of chunks expected:

37 | 38 |
39 |

Receive

40 |

Response data as hex strings, 512 bits per line, space-delimeted at 32-bit boundaries.

41 |
42 | 
43 | 
44 |

45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /framework/client/js/ec2_instance_status.js: -------------------------------------------------------------------------------- 1 | // 2 | // This file creates a web component that represents the state of an AWS EC2 instance. 3 | 4 | window.customElements.define('ec2-instance-status', class extends HTMLElement { 5 | static get observedAttributes() { 6 | return ['status', 'size']; 7 | } 8 | constructor() { 9 | super(); 10 | var shadowRoot = this.attachShadow({mode: 'open'}); 11 | shadowRoot.innerHTML = ` 12 | 15 | 16 | 17 | 18 | `; 19 | this.span = $(shadowRoot).find("span"); 20 | // Status => color map. 21 | this.status_map = { 22 | "running": {color: "#00CC00", icon: "fa-circle"}, 23 | "stopping": {color: "#CC0000", icon: "fa-spinner fa-spin"}, 24 | "stopped": {color: "#CC0000", icon: "fa-circle"}, 25 | "pending": {color: "blue", icon: "fa-spinner fa-spin"}, 26 | "unknown": {color: "gray", icon: "fa-circle"} 27 | } 28 | } 29 | attributeChangedCallback(name, old_val, new_val) { 30 | switch (name) { 31 | case 'status': 32 | $(this.span).css("color", this.status_map[new_val].color); 33 | $("i", this.span).attr("class", `fa ${this.status_map[new_val].icon}`); 34 | break; 35 | case 'size': 36 | $(this.span).css("font-size", new_val); 37 | break; 38 | } 39 | } 40 | connectedCallback() { 41 | // Default attributes. 42 | if (!this.hasAttribute("status")) {this.setAttribute("status", "stopped")}; 43 | if (!this.hasAttribute("size" )) {this.setAttribute("size" , "25px" )}; 44 | } 45 | 46 | set status(val) { 47 | this.setAttribute("status", val); 48 | } 49 | get status() { 50 | return this.getAttribute("status"); 51 | } 52 | set size(val) { 53 | this.setAttribute("size", val); 54 | } 55 | get size() { 56 | return this.getAttribute("size"); 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /framework/client/js/testbench.js: -------------------------------------------------------------------------------- 1 | // BSD 3-Clause License 2 | // 3 | // Copyright (c) 2018, alessandrocomodi 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // * Redistributions of source code must retain the above copyright notice, this 10 | // list of conditions and the following disclaimer. 11 | // 12 | // * Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // * Neither the name of the copyright holder nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // This file contains content to help develop webpage test benches for apps. 33 | 34 | 35 | // Main 36 | $(document).ready(function () { 37 | new RawTestBench(); 38 | }); 39 | 40 | class RawTestBench { 41 | constructor () { 42 | // Member Variables: 43 | this.tracing = false; 44 | this.server = new fpgaServer(); 45 | this.server.connect(); 46 | 47 | this.tx_data_array = null; 48 | this.tx_data_valid = false; 49 | 50 | // Attach handlers. 51 | 52 | this.server.ws.onmessage = (msg) => { 53 | try { 54 | let data = JSON.parse(msg.data); 55 | if (data.hasOwnProperty('type')) { 56 | this.log(`Received message: ${data.type}`); 57 | } else { 58 | this.receiveData(msg); 59 | } 60 | } catch(err) { 61 | this.log(`Failed to parse returned json string: ${msg.data}`); 62 | } 63 | } 64 | 65 | $("#tx-data-js").change( (evt) => { 66 | this.parseTxData(); 67 | }); 68 | $("#num-resp-chunks").change( (evt) => { 69 | this.parseTxData(); 70 | }); 71 | 72 | $("#send-button").click( (evt) => { 73 | this.sendData(); 74 | }); 75 | 76 | 77 | $("#tx-data-js").val( 78 | `{default_int: parseInt('55555555', 16), 79 | high_int: parseInt('12345678', 16), 80 | low_int: parseInt('04030201', 16) 81 | }` 82 | ); 83 | $("#tx-data-js").change(); 84 | $("#num-resp-chunks").change(); 85 | 86 | $('#trace-button').click( (evt) => { 87 | if (this.tracing) { 88 | this.tracing = false; 89 | this.server.stopTracing(); 90 | $('#trace-button').text("Trace On"); 91 | } else { 92 | this.tracing = true; 93 | this.server.startTracing(); 94 | $('#trace-button').text("Trace Off"); 95 | } 96 | }); 97 | } 98 | 99 | parseTxData() { 100 | // Parse Tx Data. 101 | let txt = $("#tx-data-js").val(); 102 | this.tx_data_array = null; 103 | this.tx_data_valid = false; 104 | $("#send-button").prop("disabled", true); 105 | let exp_num_resp_chunks = 0; // Incremented for each expected output chunk. 106 | try { 107 | this.tx_data_array = eval(`[${txt}]`); 108 | // Interpret as integer arrays. 109 | this.tx_data_array = this.tx_data_array.map( (val) => { 110 | let ret = []; 111 | for (let i=0; i < 16; i++) { 112 | ret[i] = val.default_int; 113 | } 114 | if (typeof val.high_int !== "undefined") { 115 | ret[15] = val.high_int; 116 | } 117 | if (typeof val.low_int !== "undefined") { 118 | ret[0] = val.low_int; 119 | } 120 | 121 | // For checking data consistency with #num-resp-chunks 122 | // under the assumption that the kernel will produce a number of output chunks equal to the low byte of the input data. 123 | exp_num_resp_chunks += ret[0] % 256; 124 | 125 | return ret; 126 | }); 127 | this.tx_data_valid = true; 128 | $("#send-button").prop("disabled", false); 129 | } catch(err) { 130 | $("#message").text("Failed to parse Tx Data:" + err); 131 | } 132 | 133 | $("#num-resp-chunks").css("background-color", (parseInt($("#num-resp-chunks").val()) == exp_num_resp_chunks) ? "white" : "red"); 134 | } 135 | 136 | sendData() { 137 | if (! this.tx_data_valid) { 138 | console.log("Bug: Refusing to send invalid data."); 139 | } else { 140 | this.server.sendChunks(parseInt($("#num-resp-chunks").val()), this.tx_data_array); 141 | } 142 | } 143 | 144 | receiveData(msg) { 145 | // Translate msg to hex. 146 | try { 147 | let data = JSON.parse(msg.data); 148 | let display_data = []; 149 | data.forEach( (chunk, i) => { 150 | let display_chunk = chunk.map( (val) => {return val.toString(16);} ); 151 | display_data[i] = display_chunk; 152 | }); 153 | $("#rx-data").text(JSON.stringify(display_data)); 154 | } catch(err) { 155 | $("#message").text(`Failed to parse returned json string: ${msg.data}`); 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /framework/fpga/default_shell_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "clocks" : 2, 3 | "args" : [ 4 | { 5 | "id" : "ctrl_length" 6 | }, 7 | { 8 | "id" : "resp_length" 9 | } 10 | ], 11 | 12 | "master" : [ 13 | { 14 | "port" : [ 15 | { 16 | "id" : "read_mem" 17 | }, 18 | { 19 | "id" : "write_mem" 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /framework/fpga/scripts/hack_vadd_example.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | # This script hacks the Xilinx vector add example produced by the rtl_kernel_wizard into an inner shell for the user kernel 7 | # for this 1st-CLaaS infrastructure. 8 | # The file mandelbrot_example_vadd.sv is provided in STDIN and STDOUT is the hacked version. 9 | # $1 is the name of the kernel. 10 | 11 | 12 | if ($#ARGV != 0) { 13 | print STDERR "Error: $0 requires an argument providing kernel name.\n"; 14 | exit(1); 15 | } 16 | my $kernel = $ARGV[0]; 17 | 18 | 19 | 20 | my $status = 0; # Return status. 21 | 22 | # To keep track of replacements. 23 | my $interface_additions = 0; # Incremented when the interface substitutions are made. 24 | my $axi_wr_master_subst1 = 0; # Incremented when the 1st AXI write master substitution is made. 25 | my $axi_wr_master_subst2 = 0; # Incremented when the 2nd AXI write master substitution is made. 26 | my $block_repl = 0; # Lines deleted from block of code. 27 | while (my $line = ) { 28 | # TODO: Should we reduce wr_fifo depth? 29 | # TODO: Could expose FIFO depth to user kernel (for now, we keep the interface simple and leave it to the kernel to provide it's own output FIFO if necessary). 30 | 31 | # Add lines to the module interface. 32 | if ($line =~ /ctrl_xfer_size_in_bytes,$/) { 33 | $line .= " input wire [C_M_AXI_ADDR_WIDTH-1:0] resp_addr_offset, input wire [C_XFER_SIZE_WIDTH-1:0] resp_xfer_size_in_bytes,"; 34 | $interface_additions++; 35 | } 36 | 37 | # Replace the following block of code: 38 | # // Adder is combinatorial 39 | # _example_adder #( 40 | # .C_AXIS_TDATA_WIDTH ( C_M_AXI_DATA_WIDTH ) , 41 | # .C_ADDER_BIT_WIDTH ( C_ADDER_BIT_WIDTH ) 42 | # ) 43 | # inst_adder ( 44 | # .aclk ( kernel_clk ) , 45 | # .aresetn ( ~kernel_rst ) , 46 | # .ctrl_constant ( ctrl_constant_kernel_clk ) , 47 | # .s_axis_tvalid ( rd_tvalid ) , 48 | # .s_axis_tready ( rd_tready ) , 49 | # .s_axis_tdata ( rd_tdata ) , 50 | # .s_axis_tkeep ( {C_M_AXI_DATA_WIDTH/8{1'b1}} ) , 51 | # .s_axis_tlast ( rd_tlast ) , 52 | # .m_axis_tvalid ( adder_tvalid ) , 53 | # .m_axis_tready ( adder_tready ) , 54 | # .m_axis_tdata ( adder_tdata ) , 55 | # .m_axis_tkeep ( ) , // Not used 56 | # .m_axis_tlast ( ) // Not used 57 | # ); 58 | 59 | 60 | # assign rd_fifo_tready = ~wr_fifo_prog_full; 61 | # 62 | # mandelbrot_example_pipeline #( 63 | # .C_DEPTH ( LP_RD_FIFO_READ_LATENCY ) 64 | # ) 65 | # inst_rd_fifo_valid_pipeline[C_M_AXI_NUM_THREADS-1:0] ( 66 | # .aclk ( kernel_clk ) , 67 | # .areset ( kernel_rst ) , 68 | # .aclken ( 1'b1 ) , 69 | # .din ( ~rd_fifo_tvalid_n & ~wr_fifo_prog_full ) , 70 | # .dout ( rd_fifo_tvalid ) 71 | # ); 72 | # 73 | # // Adder has 2 pipeline stages (1 cycle latency) 74 | # mandelbrot_example_adder #( 75 | # .C_DATA_WIDTH ( C_M_AXI_DATA_WIDTH ) , 76 | # .C_ADDER_BIT_WIDTH ( C_ADDER_BIT_WIDTH ) 77 | # ) 78 | # inst_adder[C_M_AXI_NUM_THREADS-1:0] ( 79 | # .aclk ( kernel_clk ) , 80 | # .areset ( kernel_rst ) , 81 | # .ctrl_constant ( ctrl_constant ) , 82 | # .s_tvalid ( rd_fifo_tvalid ) , 83 | # .s_tdata ( rd_fifo_tdata ) , 84 | # .m_tvalid ( adder_tvalid ) , 85 | # .m_tdata ( adder_tdata ) 86 | # ); 87 | if ($line =~ /_example_adder/) { 88 | # Find 'inst_adder'. 89 | do { 90 | $block_repl++; 91 | if (!$line) { 92 | print STDERR "Error: $0 failed to find end of adder kernel instantiation for replacement."; 93 | $status = 1; 94 | last; 95 | } 96 | $line = ; 97 | } while ($line !~ /\);/); 98 | $line = <<'CODE_BLOCK'; 99 | 100 | // -------------------------------------------------------- 101 | // BEGIN hack of adder example to insert user kernel. 102 | 103 | user_kernel #( 104 | .C_DATA_WIDTH (C_M_AXI_DATA_WIDTH ) 105 | ) 106 | inst_adder ( 107 | .clk ( kernel_clk ) , 108 | .reset ( kernel_rst ) , 109 | .in_ready ( rd_tready ), 110 | .in_avail ( rd_tvalid ) , 111 | .in_data ( rd_tdata ) , 112 | .out_ready ( adder_tready ), 113 | .out_avail ( adder_tvalid ) , 114 | .out_data ( adder_tdata ) 115 | ); 116 | 117 | // END hack of adder example to insert user kernel. 118 | // -------------------------------------------------------- 119 | 120 | CODE_BLOCK 121 | # rename the module in the above code. 122 | my $kernel_module_name = $kernel . "_kernel"; 123 | $line =~ s/\buser_kernel\b/$kernel_module_name/g; 124 | } 125 | 126 | 127 | # Replace args for AXI write master. The kernel is generated doing reads and writes to the same memory. This memory becomes the read memory, 128 | # and we replace the write memory. 129 | if ($block_repl && # The AXI write master appears in the code after the kernel instantiation, whereas read appears before. 130 | $line =~ s/\(\s*ctrl_addr_offset\s*\)/\( resp_addr_offset \)/ 131 | ) { 132 | $axi_wr_master_subst1++; 133 | } 134 | if ($block_repl && 135 | $line =~ s/\(\s*ctrl_xfer_size_in_bytes\s*\)/\( resp_xfer_size_in_bytes \)/ 136 | ) { 137 | $axi_wr_master_subst2++; 138 | } 139 | 140 | 141 | print $line; 142 | } 143 | 144 | 145 | # Make sure the proper replacements were performed. 146 | 147 | if ($interface_additions != 1) { 148 | print STDERR "Error: $0 failed to add to interface definition exactly once. Added $interface_additions times.\n"; 149 | $status = 1; 150 | } 151 | if ($block_repl > 24 || $block_repl < 12) { 152 | print STDERR "Error: $0 failed to replace about 26 lines of adder core module instantiation. Replaced $block_repl.\n"; 153 | $status = 1; 154 | } 155 | if ($axi_wr_master_subst1 != 1 || $axi_wr_master_subst2 != 1) { 156 | print STDERR "Error: $0 failed to replace AXI write master inputs correctly. (Debug: $axi_wr_master_subst1 != 1 || $axi_wr_master_subst2 != 1)\n"; 157 | $status = 1; 158 | } 159 | 160 | 161 | 162 | exit($status); 163 | -------------------------------------------------------------------------------- /framework/fpga/scripts/tcl/rtl_kernel_wiz.tcl: -------------------------------------------------------------------------------- 1 | # This file has been automatically produced by the python script 2 | # 3 | # This tcl file produces a rtl_kernel_wizard 4 | # Usage: insert the name of the kernel and the workspace where to create the project. 5 | # According to the different configurations (Master ports and arguments) the 6 | # produced verilog files and the host program will change 7 | 8 | # Configuration variables 9 | set kernelName [lindex $argv 0] 10 | set workspace [lindex $argv 1] 11 | set kernelVendor xilinx 12 | 13 | set kernelPrjName ${kernelName}_ex 14 | set wizardDir $workspace/kernel_wizard 15 | set kernelDir $workspace/$kernelPrjName 16 | 17 | # We first create a dummy project for the kernel wizard, which will create the 18 | # actual kernel project 19 | create_project kernel_wizard $wizardDir -force 20 | 21 | # Instantiate the SDx kernel wizard IP 22 | create_ip -name rtl_kernel_wizard -vendor xilinx.com -library ip -module_name $kernelName 23 | 24 | set cmd "set_property -dict \[list CONFIG.NUM_CLOCKS {2} CONFIG.NUM_INPUT_ARGS {1} CONFIG.ARG00_NAME {ctrl_length} CONFIG.NUM_M_AXI {1} CONFIG.M00_AXI_NUM_ARGS {1} CONFIG.M00_AXI_ARG00_NAME {a} CONFIG.KERNEL_NAME {$kernelName} CONFIG.KERNEL_VENDOR {$kernelVendor}] \[get_ips $kernelName]" 25 | eval $cmd 26 | set kernelXci $wizardDir/kernel_wizard.srcs/sources_1/ip/$kernelName/$kernelName.xci 27 | 28 | # Generate kernel wizard IP core 29 | generate_target {instantiation_template} [get_files $kernelXci] 30 | set_property generate_synth_checkpoint false [get_files $kernelXci] 31 | generate_target all [get_files $kernelXci] 32 | # Reopen project to generate cache 33 | close_project 34 | open_project $wizardDir/kernel_wizard.xpr 35 | 36 | # Export files (potentially a lot of things can be removed here) 37 | export_ip_user_files -of_objects [get_files $kernelXci] -no_script -sync -force -quiet 38 | export_simulation -of_objects [get_files $kernelXci] -directory $wizardDir/kernel_wizard.ip_user_files/sim_scripts -ip_user_files_dir $wizardDir/kernel_wizard.ip_user_files -ipstatic_source_dir $wizardDir/kernel_wizard.ip_user_files/ipstatic -lib_map_path [list {modelsim=$wizardDir/kernel_wizard.cache/compile_simlib/modelsim} {questa=$wizardDir/kernel_wizard.cache/compile_simlib/questa} {ies=$wizardDir/kernel_wizard.cache/compile_simlib/ies} {vcs=$wizardDir/kernel_wizard.cache/compile_simlib/vcs} {riviera=$wizardDir/kernel_wizard.cache/compile_simlib/riviera}] -use_ip_compiled_libs -force -quiet 39 | 40 | # The IP will generate a script to generate the example project, which we now 41 | # source. This implicitly closes the wizard project and opens the kernel 42 | # project instead 43 | open_example_project -force -dir $workspace [get_ips $kernelName] 44 | 45 | 46 | # Close and clean up wizard project 47 | close_project 48 | 49 | open_project $kernelDir/$kernelPrjName 50 | source $kernelDir/imports/package_kernel.tcl 51 | file delete -force $wizardDir 52 | -------------------------------------------------------------------------------- /framework/fpga/scripts/tcl/sdaccel.ini: -------------------------------------------------------------------------------- 1 | [Emulation] 2 | launch_waveform=gui 3 | -------------------------------------------------------------------------------- /framework/fpga/src/clk_gate.sv: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Steven F. Hoover 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Steven F. Hoover 13 | may not be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // Clock gate module used by SandPiper default project. 29 | 30 | // Note: No X injection for X on free_clk.) 31 | module clk_gate (output logic gated_clk, input logic free_clk, func_en, pwr_en, gating_override); 32 | logic clk_en; 33 | logic latched_clk_en /*verilator clock_enable*/; 34 | always_comb clk_en = func_en & (pwr_en | gating_override); 35 | always_latch if (~free_clk) latched_clk_en = clk_en; 36 | // latched_clk_en <= (~free_clk) ? clk_en : latched_clk_en; 37 | always_comb gated_clk = latched_clk_en & free_clk; 38 | endmodule 39 | -------------------------------------------------------------------------------- /framework/fpga/src/kernel_module.tlvlib: -------------------------------------------------------------------------------- 1 | \m4_TLV_version 1d: tl-x.org 2 | \SV 3 | // This TL-Verilog library defines macros useful for developing using the 1st CLaaS Framework. 4 | 5 | // The kernel module definition one-liner. (Currently there's no good solution for a multi-line outside of \TLV. Could put a multiline SV macro in a .vh file. 6 | m4_define(['m4_kernel_module'], ['module $1 #(parameter integer C_DATA_WIDTH = 512) (input wire clk, input wire reset, output wire in_ready, input wire in_avail, input wire [C_DATA_WIDTH-1:0] in_data, input wire out_ready, output wire out_avail, output wire [C_DATA_WIDTH-1:0] out_data);']) 7 | 8 | // Macro that defines the necessary kernel module interface and provides a streaming interface compatible with the 9 | // https://github.com/stevehoover/tlv_flow_lib. By default, the provided TLV interface is: 10 | // |input // kernel input (shell output) 11 | // @1 12 | // $reset = *reset; 13 | // $avail = *in_avail; 14 | // ?$avail 15 | // $in_data[C_DATA_WIDTH:0] = *in_data; 16 | // *in_ready = ! $blocked; 17 | // |output // kernel output (shell input) 18 | // @1 19 | // $blocked = ! *out_ready; 20 | // *out_avail = $avail; 21 | // ?$avail 22 | // *out_data = $data; 23 | 24 | // Sample usage: 25 | // A kernel that passed data through directly: 26 | // 27 | // \SV 28 | // m4_kernel_module(empty_kernel) 29 | // \TLV 30 | // m4+kernel_flow_shell(|kernel, @1, |kernel, @1); 31 | // \SV 32 | // endmodule 33 | // 34 | // Or, more illustrative, explicitly connecting default |input and |output: 35 | // 36 | // \SV 37 | // m4_kernel_module(empty_kernel) 38 | // \TLV 39 | // m4+kernel_flow_shell() 40 | // |input 41 | // @1 42 | // $blocked = /top|output<>0$blocked; 43 | // |output 44 | // @1 45 | // $avail = /top|input<>0$avail; 46 | // ?$avail 47 | // /trans 48 | // $data[511:0] = /top|input<>0$data; 49 | // \SV 50 | // endmodule 51 | // 52 | // The tlv_flow_lib can be used to create other kernel microarchitectures. For example, this creates 53 | // a kernel with a 3-stage backpressured pipeline from input to output. (It just passes the data along, but, 54 | // of course, with TLV, we can operate on it within |kernel<0-3>@1/trans). 55 | // \SV 56 | // m4_kernel_module(empty_kernel) 57 | // m4+flow_shell(|kernel0, @1, |kernel3, @1, /trans) 58 | // \TLV 59 | // m4+bp_pipeline(/top, |kernel, 0, 3, /trans) 60 | // \SV 61 | // endmodule 62 | // 63 | \TLV flow_shell(|_in_pipe, @_in_at, |_out_pipe, @_out_at, /_trans) 64 | m4_pushdef(['m4_in_pipe'], m4_ifelse(|_in_pipe, [''], input, |_in_pipe)) 65 | m4_pushdef(['m4_in_at'], m4_ifelse(@_in_at, [''], @1, @_in_at)) 66 | m4_pushdef(['m4_out_pipe'], m4_ifelse(|_out_pipe, [''], output, |_out_pipe)) 67 | m4_pushdef(['m4_out_at'], m4_ifelse(@_out_at, [''], @1, @_out_at)) 68 | m4_pushdef(['m4_trans_ind'], m4_ifelse(/_trans, [''], [''], [' '])) 69 | 70 | m4_in_pipe 71 | m4_in_at 72 | $reset = *reset; // TODO: Take this a cycle earlier. 73 | $avail = *in_avail; 74 | ?$avail 75 | /_trans 76 | m4_trans_ind $in_data[C_DATA_WIDTH-1:0] = *in_data; 77 | *in_ready = ! $blocked; 78 | m4_out_pipe 79 | m4_out_at 80 | $blocked = ! *out_ready; 81 | $accepted = $avail && ! $blocked; 82 | `BOGUS_USE($accepted) 83 | *out_avail = $avail; 84 | ?$avail 85 | /_trans 86 | m4_trans_ind *out_data = $out_data; 87 | -------------------------------------------------------------------------------- /framework/fpga/src/sandpiper.vh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, Steven F. Hoover 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of Steven F. Hoover 13 | may not be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // Project-independent SandPiper header file. 29 | 30 | `ifndef SANDPIPER_VH 31 | `define SANDPIPER_VH 32 | 33 | 34 | // Note, these have no SP prefix, so collisions are possible. 35 | 36 | 37 | `ifdef WHEN 38 | // Make sure user definition does not collide. 39 | !!!ERROR: WHEN macro already defined 40 | `else 41 | `ifdef SP_PHYS 42 | // Phys compilation disabled X-injection. 43 | `define WHEN(valid_sig) 44 | `else 45 | // Inject X. 46 | `define WHEN(valid_sig) !valid_sig ? 'x : 47 | `endif 48 | `endif 49 | 50 | 51 | // SandPiper does not generate set/reset flops. Reset is implemented as combinational 52 | // logic, and it is up to synthesis to infer set/reset flops when possible. 53 | //`ifdef RESET 54 | // // Make sure user definition does not collide. 55 | // !!!ERROR: RESET macro already defined 56 | //`else 57 | // `define RESET(i, reset) ((reset) ? '0 : i) 58 | //`endif 59 | // 60 | //`ifdef SET 61 | // // Make sure user definition does not collide. 62 | // !!!ERROR: SET macro already defined 63 | //`else 64 | // `define SET(i, set) ((set) ? '1 : i) 65 | //`endif 66 | 67 | // Since SandPiper required use of all signals, this is useful to create a 68 | // bogus use and keep SandPiper happy when a signal, by intent, has no uses. 69 | `define BOGUS_USE(ignore) 70 | 71 | `endif // SANDPIPER_VH 72 | -------------------------------------------------------------------------------- /framework/fpga/src/sandpiper_gen.vh: -------------------------------------------------------------------------------- 1 | // This just verifies that sandpiper.vh has been included. 2 | `ifndef SANDPIPER_VH 3 | !!!ERROR: SandPiper project's sp_.vh file must include sandpiper.vh. 4 | `endif 5 | -------------------------------------------------------------------------------- /framework/fpga/src/sp_default.vh: -------------------------------------------------------------------------------- 1 | `ifndef SP_DEFAULT 2 | `define SP_DEFAULT 3 | 4 | // File included by SandPiper-generated code for the default project configuration. 5 | `include "sandpiper.vh" 6 | 7 | 8 | `endif // SP_DEFAULT 9 | -------------------------------------------------------------------------------- /framework/host/default_main.c: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | // This file provides a default main method for the host application. 34 | // It can be specified in the project Makefile as the PROJ_C_SRC for projects (apps) that use the default host application. 35 | // KERNEL_NAME must be defined in the g++ compile command using '-DKERNEL_NAME="foo"'. 36 | 37 | #include "server_main.h" 38 | 39 | using namespace std; 40 | 41 | int main(int argc, char const *argv[]) 42 | { 43 | //cout << "Hello from host application.\n"; 44 | (new HostApp())->server_main(argc, argv, KERNEL_NAME); 45 | } 46 | -------------------------------------------------------------------------------- /framework/host/hw_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** Header file for the Kernel class which provides the interface through which to communicate with 36 | ** the custom FPGA kernel logic. 37 | ** All OpenCL calls are performed within this class. 38 | ** 39 | ** We have created different functions in order to gain more control on 40 | ** the FPGA device: 41 | ** - initialize_platform --> initializes the platform 42 | ** - initialize_kernel --> initializes the kernel 43 | ** - write_kernel_data --> writes data to FPGA board memory 44 | ** - read_kernel_data --> reads data from FPGA board memory 45 | ** - start_kernel --> injects the start signal to the FPGA 46 | ** - clean_kernel --> clean the OpenCL variables 47 | ** 48 | ** Author: Alessandro Comodi, Politecnico di Milano 49 | */ 50 | 51 | #ifndef HEADER_HW_KERNEL 52 | #define HEADER_HW_KERNEL 53 | 54 | #define COLS 4096 55 | #define ROWS 4096 56 | 57 | 58 | class HW_Kernel : public Kernel { 59 | 60 | public: 61 | /* 62 | ** OpenCL characterization of the FPGA. 63 | */ 64 | cl_platform_id platform_id; // platform id 65 | cl_device_id device_id; // compute device id 66 | cl_context context; // compute context 67 | cl_command_queue commands; // compute command queue 68 | cl_program program; // compute programs 69 | cl_kernel kernel; // compute kernel 70 | cl_mem read_mem; // device memory read by kernel 71 | cl_mem write_mem; // device memory written by kernel 72 | int status = 1; 73 | bool initialized = false; 74 | static const int verbosity = 0; // 0: no debug messages; 10: all debug messages. 75 | 76 | HW_Kernel(); 77 | 78 | /* 79 | ** Utility function to print errors 80 | */ 81 | void perror(const char * msg); 82 | 83 | /* 84 | ** Function to load the binary program in RAM in order to write it into the FPGA device 85 | */ 86 | cl_uint load_file_to_memory(const char *filename, char **result); 87 | 88 | 89 | 90 | /***************************** 91 | ** ** 92 | ** FPGA Interface functions ** 93 | ** ** 94 | *****************************/ 95 | 96 | /* 97 | ** Initialize FPGA platform 98 | */ 99 | void initialize_platform(); 100 | 101 | 102 | /* 103 | ** Initialize the Kernel application. 104 | ** Allocation of the memory space for the various arguments passed to the device 105 | */ 106 | void initialize_kernel(const char *xclbin, const char *kernel_name, int memory_size); 107 | 108 | /* 109 | ** Write data onto the board or device memory that will be consumed by the Kernel 110 | ** h_a_input: array containing data to be written on the device memory 111 | ** data_size: size of the data array in bytes 112 | */ 113 | void write_kernel_data(double h_a_input[], int data_size); 114 | void writeKernelData(void * input, int data_size, int resp_data_size); 115 | void write_kernel_data(input_struct * input, int data_size); 116 | 117 | /* 118 | ** Starts the computation of the Kernel by injecting the "ap_start" signal 119 | */ 120 | void start_kernel(); 121 | 122 | /* 123 | ** Read data from the board or device memory. The data is produced by the Kernel 124 | ** h_a_output: array pointer on which data will be written 125 | ** data_size: size of data to be read by the kernel 126 | */ 127 | void read_kernel_data(int h_a_output[], int data_size); 128 | 129 | /* 130 | ** Releases all the OpenCL components 131 | */ 132 | void clean_kernel(); 133 | 134 | void reset_kernel() {}; 135 | 136 | }; 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /framework/host/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** Header file for the Kernel class which provides the interface through which to communicate with 36 | ** the custom FPGA kernel logic. 37 | ** All OpenCL calls are performed within this class. 38 | ** 39 | ** We have created different functions in order to gain more control on 40 | ** the FPGA device: 41 | ** - initialize_platform --> initializes the platform 42 | ** - initialize_kernel --> initializes the kernel 43 | ** - write_kernel_data --> writes data to FPGA board memory 44 | ** - read_kernel_data --> reads data from FPGA board memory 45 | ** - start_kernel --> injects the start signal to the FPGA 46 | ** - clean_kernel --> clean the OpenCL variables 47 | ** 48 | ** Author: Alessandro Comodi, Politecnico di Milano 49 | */ 50 | 51 | #ifndef HEADER_KERNEL 52 | #define HEADER_KERNEL 53 | 54 | #define COLS 4096 55 | #define ROWS 4096 56 | 57 | 58 | 59 | /* 60 | ** Definition of the input data structure for the kernel 61 | ** To be modified by the user if he sends different kind of data 62 | ** The following struct is specific to mandelbrot set calculation 63 | ** TODO: Doesn't belong here. 64 | */ 65 | typedef struct data_struct { 66 | double coordinates[4]; 67 | long width; 68 | long height; 69 | long max_depth; 70 | } input_struct; 71 | 72 | 73 | class Kernel { 74 | 75 | protected: 76 | int status = 1; 77 | bool initialized = false; 78 | 79 | public: 80 | virtual void perror(const char * msg) = 0;; 81 | virtual void reset_kernel() = 0; 82 | virtual void writeKernelData(void * input, int data_size, int resp_data_size) = 0; 83 | virtual void write_kernel_data(input_struct * input, int data_size) = 0; 84 | virtual void start_kernel() = 0; 85 | virtual void read_kernel_data(int h_a_output[], int data_size) = 0; 86 | virtual void clean_kernel() {}; 87 | virtual void enable_tracing() {}; 88 | virtual void disable_tracing() {}; 89 | virtual void save_trace() {}; 90 | 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /framework/host/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** This header file contains the definition of the protocol used 36 | ** to synchronize and understand the various commands that are sent 37 | ** to the host application. 38 | ** 39 | ** Author: Alessandro Comodi, Politecnico di Milano 40 | ** 41 | */ 42 | 43 | #ifndef PROTOCOL_H 44 | #define PROTOCOL_H 45 | 46 | // Types of commands 47 | // TODO: Rethink protocol. 48 | #define INIT_PLATFORM "INIT_PLATFORM" 49 | #define INIT_KERNEL "INIT_KERNEL" 50 | #define START_KERNEL "START_KERNEL" 51 | #define WRITE_DATA "WRITE_DATA" 52 | #define READ_DATA "READ_DATA" 53 | #define CLEAN_KERNEL "CLEAN_KERNEL" 54 | #define CLOSE_CONN "CLOSE_CONN" 55 | #define GET_IMAGE "GET_IMAGE" 56 | #define DATA_MSG "DATA_MSG" // Generic data message containing JSON array of 16-entry arrays of unsigned integer (32-bit) data to be sent to FPGA. 57 | #define START_TRACING "START_TRACING" 58 | #define STOP_TRACING "STOP_TRACING" 59 | 60 | 61 | #define INIT_PLATFORM_N 1 62 | #define INIT_KERNEL_N 2 63 | #define START_KERNEL_N 3 64 | #define WRITE_DATA_N 4 65 | #define READ_DATA_N 5 66 | #define CLEAN_KERNEL_N 6 67 | #define GET_IMAGE_N 7 68 | #define DATA_MSG_N 8 69 | #define START_TRACING_N 9 70 | #define STOP_TRACING_N 10 71 | 72 | // Types of messages 73 | #define DATA_MSG "DATA_MSG" 74 | #define COMMAND_MSG "COMMAND_MSG" 75 | 76 | #endif -------------------------------------------------------------------------------- /framework/host/sim_kernel.c: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2019, Akos Hadnagy 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** This library performs the Verilator-based simulation of the user kernel. 36 | ** 37 | */ 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include "kernel.h" 55 | #include "sim_kernel.h" 56 | #include "verilated_vcd_c.h" 57 | 58 | 59 | const int SIM_Kernel::MAX_PHASES = 100000000; 60 | const int SIM_Kernel::MAX_TRACE_PHASES = 1000; 61 | 62 | SIM_Kernel::SIM_Kernel() { 63 | this->verilator_kernel = new VERILATOR_KERNEL; 64 | Verilated::traceEverOn(true); 65 | this->tfp = new VerilatedVcdC; 66 | 67 | } 68 | 69 | SIM_Kernel::~SIM_Kernel() { 70 | tfp->close(); 71 | delete tfp; 72 | delete verilator_kernel; 73 | } 74 | 75 | void SIM_Kernel::perror(const char * msg) { 76 | cout << msg; 77 | status = EXIT_FAILURE; 78 | } 79 | 80 | void SIM_Kernel::enable_tracing() { 81 | verilator_kernel->trace (tfp, 99); 82 | tfp->open ("../out/sim/trace.vcd"); 83 | tracing_enabled = true; 84 | trace_phase_cnt = 0; 85 | } 86 | 87 | void SIM_Kernel::disable_tracing() { 88 | tracing_enabled = false; 89 | } 90 | 91 | void SIM_Kernel::save_trace() { 92 | tfp->close(); 93 | } 94 | 95 | void SIM_Kernel::tick() { 96 | //verilator_kernel->reset = 0; 97 | verilator_kernel->clk = !verilator_kernel->clk; 98 | verilator_kernel->eval(); 99 | if (tracing_enabled) { 100 | tfp->dump (phase_cnt); 101 | trace_phase_cnt++; 102 | 103 | // A quick-n-dirty protection against kernels that don't complete. 104 | // Close the trace and exit if phase_cnt > MAX. 105 | if (trace_phase_cnt > MAX_TRACE_PHASES) { 106 | save_trace(); 107 | cout << "Traced more than " << MAX_TRACE_PHASES << " phases. Exiting." << endl; 108 | exit(1); 109 | } 110 | } 111 | if (phase_cnt > MAX_PHASES) { 112 | cout << "Kernel failed to complete within " << MAX_PHASES << " phases. Exiting." << endl; 113 | exit(1); 114 | } 115 | phase_cnt++; 116 | } 117 | 118 | void SIM_Kernel::reset_kernel() { 119 | verilator_kernel->in_avail = 0; 120 | verilator_kernel->out_ready = 0; 121 | verilator_kernel->reset = 1; 122 | //TODO: parameterize the reset duration 123 | for(int rst_cntr=0; rst_cntr<10; rst_cntr++) { 124 | tick(); 125 | } 126 | verilator_kernel->reset = 0; 127 | } 128 | 129 | void SIM_Kernel::writeKernelData(void * input, int data_size, int resp_data_size) { 130 | input_buff = input; 131 | output_buff = new uint32_t[(resp_data_size/HostApp::DATA_WIDTH_BYTES)*HostApp::DATA_WIDTH_WORDS]; 132 | this->data_size = data_size/HostApp::DATA_WIDTH_BYTES; 133 | this->resp_data_size = resp_data_size/HostApp::DATA_WIDTH_BYTES; 134 | } 135 | 136 | void SIM_Kernel::write_kernel_data(input_struct * input, int data_size) { 137 | uint resp_length = (uint)(input->width * input->height) / HostApp::DATA_WIDTH_WORDS; 138 | cout << "Verilator: (" << input->width << "x" << input->height << "), resp_length = " << resp_length << endl; 139 | 140 | input_buff = input; 141 | output_buff = new uint32_t [resp_length*HostApp::DATA_WIDTH_WORDS]; 142 | this->data_size = data_size/HostApp::DATA_WIDTH_BYTES; 143 | this->resp_data_size = resp_length; 144 | } 145 | 146 | 147 | // A data buffer is available to send. 148 | void SIM_Kernel::start_kernel() { 149 | verilator_kernel->clk = 0; 150 | 151 | unsigned int send_cntr=0; 152 | unsigned int recv_cntr=0; 153 | 154 | while ((send_cntr < data_size) || (recv_cntr < resp_data_size)) { 155 | tick(); 156 | 157 | if(recv_cntr < resp_data_size) { 158 | verilator_kernel->out_ready = 1; 159 | } else { 160 | verilator_kernel->out_ready = 0; 161 | } 162 | //For the case where out_ready combinatorially effects the signals read in the code below. Such as vadd, which is purely combinatorial. 163 | //TODO: unnecessary overhead in most cases, migh want a mechanism to diasble 164 | verilator_kernel->eval(); 165 | 166 | if(recv_cntr < resp_data_size && verilator_kernel->out_avail) { 167 | uint32_t * output = (uint32_t *)output_buff; 168 | for(int words = 0; words < HostApp::DATA_WIDTH_WORDS; words++) { 169 | output[recv_cntr*HostApp::DATA_WIDTH_WORDS + words] = verilator_kernel->out_data[words]; 170 | } 171 | recv_cntr++; 172 | //printf("Verilator recv_cntr: %d\n", recv_cntr); 173 | } 174 | 175 | if(send_cntr < data_size) { 176 | uint32_t * input = (uint32_t *)input_buff; 177 | verilator_kernel->in_avail = 1; 178 | for(int words = 0; words < HostApp::DATA_WIDTH_WORDS; words++) { 179 | verilator_kernel->in_data[words] = input[send_cntr*HostApp::DATA_WIDTH_WORDS + words]; 180 | } 181 | if(verilator_kernel->in_ready) { 182 | //printf("Verilator send_cntr: %d\n", send_cntr); 183 | send_cntr++; 184 | } 185 | 186 | } else { 187 | verilator_kernel->in_avail = 0; 188 | } 189 | 190 | tick(); 191 | } 192 | } 193 | 194 | void SIM_Kernel::read_kernel_data(int h_a_output[], int data_size) { 195 | memcpy(h_a_output, output_buff, sizeof(uint32_t)*resp_data_size*HostApp::DATA_WIDTH_WORDS); 196 | delete output_buff; 197 | } -------------------------------------------------------------------------------- /framework/host/sim_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2019, Akos Hadnagy 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | ** 35 | ** This library performs the Verilator-based simulation of the user kernel. 36 | ** 37 | */ 38 | 39 | 40 | #include "kernel.h" 41 | #include 42 | #include "verilator_kernel.h" 43 | #include "verilated.h" 44 | #include "server_main.h" 45 | 46 | #ifndef HEADER_SIM_KERNEL 47 | #define HEADER_SIM_KERNEL 48 | 49 | #define COLS 4096 50 | #define ROWS 4096 51 | 52 | 53 | 54 | class SIM_Kernel: public Kernel { 55 | 56 | private: 57 | 58 | const static int MAX_PHASES; 59 | const static int MAX_TRACE_PHASES; 60 | 61 | VERILATOR_KERNEL *verilator_kernel; 62 | VerilatedVcdC* tfp; 63 | void* input_buff = 0; 64 | uint32_t* output_buff = 0; 65 | unsigned int data_size = 0; 66 | unsigned int resp_data_size = 0; 67 | int phase_cnt = 0; // Count of simulation phases. 68 | int trace_phase_cnt = 0; // Count of phases in the trace file (valid when tracing_enabled). 69 | bool tracing_enabled = false; 70 | 71 | /* 72 | ** Step test bench 73 | */ 74 | void tick(); 75 | 76 | public: 77 | 78 | int status = 1; 79 | bool initialized = false; 80 | 81 | SIM_Kernel(); 82 | ~SIM_Kernel(); 83 | 84 | void perror(const char * msg); 85 | 86 | /*********************************** 87 | ** ** 88 | ** Simulation Interface functions ** 89 | ** ** 90 | ************************************/ 91 | 92 | /* 93 | ** Save the pointer to the input data 94 | */ 95 | void writeKernelData(void * input, int data_size, int resp_data_size); 96 | void write_kernel_data(input_struct * input, int data_size); 97 | 98 | /* 99 | ** Enables trace waveform recording 100 | */ 101 | void enable_tracing(); 102 | /* 103 | ** Disables trace waveform recording 104 | */ 105 | void disable_tracing(); 106 | /* 107 | ** Saves trace waveform 108 | */ 109 | void save_trace(); 110 | 111 | /* 112 | ** Performs reset on user kernel 113 | */ 114 | void reset_kernel(); 115 | /* 116 | ** Starts computation 117 | */ 118 | void start_kernel(); 119 | /* 120 | ** Copy received data to an output buffer 121 | */ 122 | void read_kernel_data(int h_a_output[], int data_size); 123 | }; 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /framework/terraform/config_instance_dev.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # An EC2 instance configuration script for a development instance. 4 | # It sets up RDP. 5 | 6 | # TODO: This setup_gui.sh script is currently broken, apparently due to: 7 | # https://bugzilla.redhat.com/show_bug.cgi?id=1738669 8 | # Hoping this resolves itself soon enough. 9 | wget https://s3.amazonaws.com/aws-fpga-developer-ami/1.5.0/Scripts/setup_gui.sh -P /tmp/ 10 | chmod +x /tmp/setup_gui.sh 11 | sed -i 's|^setup_password$|#setup_password|' /tmp/setup_gui.sh 12 | /tmp/setup_gui.sh 13 | # TODO: 14 | echo 'We have not enabled password authentication, so you will need to do that.' 15 | -------------------------------------------------------------------------------- /framework/terraform/config_instance_dummy.sh: -------------------------------------------------------------------------------- 1 | !/usr/bin/bash 2 | # Default EC2 instance configuration script. Do nothing. -------------------------------------------------------------------------------- /framework/terraform/config_static_f1_instance.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | 3 | # Initialization script for Accelerated Web Server. 4 | # o Call common init.sh. 5 | # o Setup passwordless ssh for localhost ssh. This is used for reboot cron job which needs an environment, and the only reliable 6 | # way I can find to establish the right environment is to ssh. 7 | # o Establish cron @reboot command to start web server. 8 | # o Compile and start web server for manual testing at :80. 9 | echo \ 10 | && echo "Running config_static_f1_instance.sh" \ 11 | && echo \ 12 | && echo "Setting up localhost ssh." \ 13 | && ssh-keygen -N '' -f ~/.ssh/id_rsa \ 14 | && cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys \ 15 | && echo \ 16 | && echo "Setting up cron job to start web server." \ 17 | && sudo bash -c 'echo "@reboot centos /home/centos/src/project_data/repo/framework/terraform/static_f1_reboot.sh" >> /etc/crontab' \ 18 | && echo \ 19 | && echo "Running reboot script to pre-build and start web server for manual testing." \ 20 | && /home/centos/src/project_data/repo/framework/terraform/static_f1_reboot.sh \ 21 | && echo \ 22 | && echo "YAY!!! The web server has been launched." \ 23 | && echo -e "\e[1m\e[33mYOU HAVE 3 MINUTES to test it out at http://$1 (-click), then the machine will be shutdown, if not stopped manually (but check to be sure).\e[0m" \ 24 | && sleep 180; 25 | STATUS=$? 26 | nohup bash -c 'sleep 1 && sudo shutdown now &> /dev/null < /dev/null &' 27 | exit $STATUS # Exit (before shutdown). 28 | -------------------------------------------------------------------------------- /framework/terraform/static_f1_reboot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # This script starts or restarts the webserver (using 'make live') based on configuration variables saved by Terraform. It is run by Terraform on initialization, 4 | # and terraform configures cron to run this @reboot. 5 | # Cron output is sent to /var/spool/mail/root. 6 | # Running via ssh establishes the proper environment. 7 | # TODO: Look into EC2 user_data or cloud-init to replace this mechanism. 8 | source /home/centos/server_config.sh 9 | WEBSERVER_LOG="/home/centos/src/project_data/repo/apps/$KERNEL_NAME/build/log/webserver.log" 10 | PASSWORD_ARG=$(if [[ -n "$ADMIN_PWD" ]]; then echo PASSWORD=$ADMIN_PWD; fi) 11 | PREBUILT_ARG=$(if [[ -n "$USE_PREBUILT_AFI" ]]; then echo PREBUILT=$USE_PREBUILT_AFI; fi) 12 | 13 | SSH_CMD="cd ~/src/project_data/repo && source ./sdaccel_setup && cd apps/$KERNEL_NAME/build" 14 | SSH_CMD="$SSH_CMD && make $PREBUILT_ARG $PASSWORD_ARG build && echo '$0: Going live with web server with output in: $WEBSERVER_LOG'" 15 | SSH_CMD="$SSH_CMD && make $PREBUILT_ARG $PASSWORD_ARG live" 16 | ssh -o 'StrictHostKeyChecking=no' localhost "$SSH_CMD" 17 | -------------------------------------------------------------------------------- /framework/webserver/default_server.py: -------------------------------------------------------------------------------- 1 | """ 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | """ 32 | 33 | 34 | import sys 35 | import os 36 | from server import * 37 | 38 | # The default Python webserver application. 39 | # This creates routes for html, js, and css files to serve web content. 40 | if __name__ == "__main__": 41 | 42 | # Webserver 43 | application = FPGAServerApplication( 44 | FPGAServerApplication.defaultRoutes(), 45 | FPGAServerApplication.commandLineArgs() 46 | ) 47 | application.run() 48 | -------------------------------------------------------------------------------- /framework/webserver/server_api.py: -------------------------------------------------------------------------------- 1 | """ 2 | BSD 3-Clause License 3 | 4 | Copyright (c) 2018, alessandrocomodi 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | """ 32 | 33 | 34 | """ 35 | # 36 | # The following file contains a set of functions that 37 | # allow the communication with the host application 38 | # through a UNIX socket. 39 | # 40 | # They are intended to be as general as possible. For the 41 | # sake of this example though we have specialized the python 42 | # server in order to request specific images of the Mandelbrot 43 | # set. 44 | # 45 | # Author: Alessandro Comodi, Politecnico di Milano 46 | # 47 | """ 48 | 49 | import struct 50 | import base64 51 | import socket 52 | import sys 53 | import time 54 | import traceback 55 | 56 | # Socket with host messages defines 57 | CHUNK_SIZE = 4096 58 | 59 | class Socket(): 60 | 61 | VERBOSITY = 0 # 0-10 (quiet-loud) 62 | 63 | # Connect on construction. 64 | def __init__(self, filename): 65 | # Opening socket with host 66 | self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 67 | server_address = (filename) 68 | 69 | connected = False 70 | cnt = 0 71 | while not connected: 72 | try: 73 | self.sock.connect(server_address) 74 | connected = True 75 | except socket.error as e: 76 | if cnt > 10: 77 | print("Giving up.") 78 | sys.exit(1) 79 | print("Couldn't connect to host application via socket. Waiting...") 80 | time.sleep(3) 81 | cnt = cnt + 1 82 | 83 | 84 | def send_string(self, tag, str): 85 | #print("Python: sending", len(str), "-byte", tag) 86 | self.send(tag + " size", struct.pack("I", socket.htonl(len(str)))) # pack bytes of len properly 87 | self.send(tag, str.encode()) 88 | 89 | 90 | ### Send/receive over socket and report. 91 | def send(self, tag, data): 92 | if self.VERBOSITY > 5: 93 | print("Python: Sending", len(data), "-byte", tag, "over socket:", data) 94 | try: 95 | # To do. Be more graceful about large packets by using sock.send (once multithreading is gracefully supported). 96 | self.sock.sendall(data) 97 | except socket.error: 98 | print("sock.send failed with socket.error.") 99 | traceback.print_stack() 100 | def recv(self, tag, size): 101 | if self.VERBOSITY > 5: 102 | print("Python: Receiving", size, "bytes of", tag, "from socket") 103 | ret = None 104 | try: 105 | ret = self.sock.recv(size) 106 | except socket.error: 107 | print("sock.recv failed.") 108 | traceback.print_stack() 109 | #print("Python: recv'ed:", ret) 110 | return ret 111 | 112 | def close(self): 113 | self.sock.close() 114 | 115 | ### This function requests an image from the host 116 | ### Parameters: 117 | ### - sock - socket channel with host 118 | ### - header - command to be sent to the host 119 | ### - payload - data for the image calculation 120 | ### - b64 - to be eliminated 121 | def get_image(sock, header, payload, b64=True): 122 | 123 | # Handshake with host application 124 | #print("Header: ", header) 125 | sock.send_string("command", header) 126 | sock.send_string("image params", payload) 127 | 128 | image = read_data_handler(sock, None, b64) 129 | return image 130 | 131 | ### This function reads data from the FPGA memory 132 | ### Parameters: 133 | ### - sock - socket channel with host 134 | ### - isGetImage - boolean value to understand if the request is 135 | ### - performed within the GetImage context 136 | ### - header - command to be sent to host (needed if isGetImage is False) 137 | ### - b64 - encode a string in base64 and return base64(utf-8) string 138 | ### (else return binary string) (default=True) 139 | def read_data_handler(sock, header=None, b64=True): 140 | # Receive integer data size from host 141 | response = sock.recv("size", 4) 142 | 143 | # Decode data size 144 | (size,) = struct.unpack("I", response) 145 | size = socket.ntohl(size) 146 | print("Python: Size: ", size) 147 | 148 | ### Receive chunks of data from host ### 149 | data = b'' 150 | while len(data) < size: 151 | to_read = size - len(data) 152 | data += sock.recv("chunk", CHUNK_SIZE if to_read > CHUNK_SIZE else to_read) 153 | 154 | #byte_array = struct.unpack("<%uB" % size, data) 155 | if b64: 156 | data = base64.b64encode(data) 157 | 158 | # Does the decode("utf-8") below do anything? Let's check. 159 | tmp = data 160 | if (data != tmp.decode("utf-8")): 161 | print("FYI: UTF-8 check mismatched.") 162 | 163 | data = data.decode("utf-8") 164 | 165 | return data 166 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Let this package be a module (so it can be found via npm package "require-resolve-cli". 2 | module.export {} 3 | -------------------------------------------------------------------------------- /init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # One-time initialization of this repository, to be run after cloning. 4 | 5 | 6 | cd "$( dirname "${BASH_SOURCE[0]}" )" 7 | mkdir -p log 8 | LOG=log/init.log 9 | echo "Logging stdout and stderr to $LOG" 10 | 11 | ( 12 | 13 | # Install submodules. 14 | git submodule update --init --recursive 15 | 16 | 17 | # Install required packages 18 | 19 | 20 | # Platform-specific installs. 21 | echo "Installing linux packages." 22 | mkdir -p local 23 | COMMON_PACKAGES='make inotify-tools bc remmina jq perl unzip python3-tornado' 24 | DEBUG_PACKAGES='vim htop tmux' 25 | if [[ -n "$(which apt-get 2> /dev/null)" ]] 26 | then 27 | # Ubuntu 28 | sudo apt-get update 29 | sudo apt-get -y install curl g++ python3 python3-pip python3-pil $COMMON_PACKAGES 30 | sudo apt -y install $DEBUG_PACKAGES 31 | #sudo python3 -m pip install Pillow 32 | elif [[ -n "$(which yum 2> /dev/null)" ]] 33 | then 34 | # CentOS 35 | 36 | # For Python: 37 | sudo yum makecache 38 | sudo yum -y install yum-utils curl 39 | sudo yum -y install https://repo.ius.io/ius-release-el7.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # new URLs by IUS "https://ius.io/setup" 40 | sudo yum makecache 41 | sudo yum -y install python3 python3-pillow # this will install python3.6 version 42 | # To look like Ubuntu, we need python3 and pip3. 43 | 44 | sudo yum -y install $COMMON_PACKAGES # python-tornado python-imaging redundant w/ pip install? 45 | sudo yum -y install $DEBUG_PACKAGES 46 | 47 | ## bash lives at /usr/bin/bash in CentOS, but in /bin/bash for Ubuntu. Create /bin/bash. 48 | #sudo ln -s /bin/bash /usr/bin/bash # TODO: So far, untested. Test and delete this comment. 49 | fi 50 | 51 | 52 | # Install python libraries for user only so as not to affect system installs. 53 | echo "Installing Python packages for user $USER." 54 | sudo python3 -m pip install --upgrade pip 55 | USER_PYTHON_PACKAGES='Pillow tornado awscli boto3 sandpiper-saas' 56 | python3 -m pip install --user --upgrade $USER_PYTHON_PACKAGES 57 | #sudo python3 -m pip install --user --upgrade $USER_PYTHON_PACKAGES 58 | 59 | 60 | # Configure remmina to disble the tray icon (so, it isn't left running when launched via Makefile). 61 | if [[ -e "$HOME/.remmina/remmina.pref" ]] 62 | then 63 | sed -i 's/^disable_tray_icon=false$/disable_tray_icon=true/' "$HOME/.remmina/remmina.pref" 64 | else 65 | mkdir -p "$HOME/.remmina" 66 | echo [remmina_pref] > "$HOME/.remmina/remmina.pref" 67 | echo 'disable_tray_icon=true' >> "$HOME/.remmina/remmina.pref" 68 | fi 69 | # Protect remmina.pref as this contains an encryption key. (No idea why remmina leaves this open.) 70 | # Passwords stored in remmina can be decrypted by anyone with access to this file. 71 | chmod 400 "$HOME/.remmina/remmina.pref" 72 | 73 | 74 | # Make sure ~/.local/bin is in path for python installs. 75 | # 76 | echo "Making sure Python installs are in \$PATH." 77 | if [[ $( which aws > /dev/null 2>&1 )$? != 0 ]] 78 | then 79 | # Need to add ~/.local/bin to $PATH. 80 | echo 81 | if [[ "$SHELL" == "/bin/bash" ]] 82 | then 83 | if [[ -e "$HOME/.bashrc" ]] 84 | then 85 | if ( grep fpga-webserver "$HOME/.bashrc" > /dev/null 2>&1 ) || 86 | ( grep 1st-CLaaS "$HOME/.bashrc" > /dev/null 2>&1 ) 87 | then 88 | echo "INFO: Strange, it looks like ~/.bashrc has already been modified, but 'aws' command is not currently in \$PATH. Might need to add ~/.local/bin to your \$PATH manually." 89 | else 90 | echo >> "$HOME/.bashrc" 91 | echo "export PATH=\$PATH:$HOME/.local/bin # Added by 1st-CLaaS repository." >> ~/.bashrc 92 | echo "===================================" 93 | echo "Modified ~/.bashrc to add ~/.local/bin to path, and sourcing ~/.bashrc." 94 | echo "===================================" 95 | source "$HOME/.bashrc" 96 | if ( ! which aws > /dev/null 2>&1 ) 97 | then 98 | echo "WARNING: Still cannot find 'aws' command." 99 | fi 100 | fi 101 | else 102 | echo "WARNING: Cannot find ~/.bashrc. You must add ~/.local/bin to your \$PATH manually." 103 | fi 104 | else 105 | echo "NOTE: You must add ~/.local/bin to your \$PATH manually." 106 | fi 107 | echo 108 | fi 109 | 110 | 111 | # Download Terraform binary. 112 | # TODO: Move this into /local. 113 | if [[ ! -d terraform ]] 114 | then 115 | echo "Downloading Terraform" 116 | mkdir terraform 117 | ( cd terraform && \ 118 | curl https://releases.hashicorp.com/terraform/1.5.2/terraform_1.5.2_linux_amd64.zip > terraform.zip \ 119 | && unzip terraform.zip \ 120 | && rm terraform.zip \ 121 | && chmod +x terraform ) 122 | fi 123 | # Note that framework/Makefile and bin/regress use the existence of terraform/terraform to indicate that this script was run. 124 | 125 | 126 | # Check Verilator installation. 127 | # Need Verilator 4+ (ish). 128 | # Installation runs long, so here, we just report what should be done. 129 | echo -e "\e[1m\e[33m" # Report in bold yellow. 130 | # if [[ no local install ]] && ( no verilator || verilator is not version 4+ ) 131 | if [[ ! -n "$(ls "local/verilator/bin/verilator" 2> /dev/null)" ]] && ( ! which verilator &> /dev/null || ! (( $(verilator --version | sed 's/^Verilator \([[:digit:]]\+\)\..*$/\1/') > 3 )) > /dev/null ) 132 | then 133 | echo "Could not find Verilator 4+." 134 | if which verilator &> /dev/null 135 | then 136 | echo "You have: $(verilator --version)" 137 | if which verilator &> /dev/null 138 | then 139 | # Ubuntu 140 | echo "Uninstall first (sudo apt-get remove verilator?), then:" 141 | else 142 | echo "Uninstall first, then:" 143 | fi 144 | fi 145 | echo "Install using ./bin/install_verilator, or visit veripool.org for information about the latest version." 146 | fi 147 | echo -e "\e[0m" # Back to normal font. 148 | ) |& tee $LOG 149 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "1st-claas", 3 | "version": "1.0.0", 4 | "description": "1st CLaaS framework for hosting FPGA logic as a microservice for a new world of FPGA-accelerated web and cloud applications.", 5 | "main": "none", 6 | "directories": { 7 | "doc": "doc" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/os-fpga/1st-CLaaS.git" 15 | }, 16 | "keywords": [ 17 | "FPGA", 18 | "microservice", 19 | "hardware", 20 | "acceleration", 21 | "high-performance", 22 | "computing", 23 | "RedwoodEDA" 24 | ], 25 | "author": "Steve Hoover", 26 | "license": "BSD-3-Clause", 27 | "bugs": { 28 | "url": "https://github.com/os-fpga/1st-CLaaS/issues" 29 | }, 30 | "homepage": "https://github.com/os-fpga/1st-CLaaS#README.md", 31 | "dependencies": { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vitis_setup: -------------------------------------------------------------------------------- 1 | pushd $AWS_FPGA_REPO_DIR; source ./vitis_setup.sh; popd 2 | --------------------------------------------------------------------------------