Introduction:
In this blog, I will walk through the steps to create our first project on the Arty S7-50 FPGA board. I received this board from E14 for the 7 Ways to Leave your Spartan-6 program.
In this blog, I will do the first start of the board and check if its working or not! Then I will list all the steps that I followed to create my first project.
The board comes with preloaded binary. So, if you connect the board to the power supply or your system, the LEDs on it will start blinking as shown below.
Setting Up:
To work with the Arty-S7 board, we need to install the Vivado design suite by Xilinx. There are two versions of Vivado available (Vivado ML and Vivado Enterprise). We need to install the Vivado ML (free) version.
Follow this tutorial if you need help with installation.
Some points to keep in mind while installing Vivado are:
- Download the Xilinx Unified Installer for the latest version. I am using Vivado 2021.2 (ML Edition). Latest boards might not be supported by older versions of Vivado.
- Selecting "Vitis" will install both Vivado and Vitis. I will recommend to select "Vitis". This blog doesn't need Vitis but the following blogs might need it.
- Vivado Design suite requires large space. It is a 40-50GB download. And after installing, it will take around 100GB of space.
- I will advice you to install it in some other disk space rather than your windows (boot) disk.
- One good thing is that the download can be paused and resumed. If you are using your mobile data, you will have to be patient to fully download and install it. It took me 5 days to download and install it.
Once you are ready with the software, you can go through the rest of the tutorial.
Controlling LEDs and Switches:
In this section, we will create our first project and try to control the LEDs and the Switches present on the board.
- Open Vivado and click on "Create Project".
- Give your project a name and select your project location. Click on "Next".
- Choose the type of project. In our case, it is "RTL Project". If you don't want to add your source file at this stage, select the corresponding option. You can always add new source files later. Click on "Next".
- If you didn't select the option to specify source file later, it will now ask you to add source files. Source file will contain the HDL code. Click on "Create File".
- Write the name of your source file and select the HDL which you want to use. I am using Verilog and named my file as "main.v" (You don't need to enter the extension). Click on "OK" then click on "Next".
- Now, it will ask to add constraint files. You can simulate your HDL code without constraint file but to deploy it on your board, you need a proper constraint file.
- Constraint files for Digilent boards can be downloaded from this link.
- Now click on "Add Files" in the "Add Constraints" wizard. Browse the downloaded folder and select the proper constraint file relevant to your board. In my case, it is "Arty-S7-50-Master.xdc". Click on "OK" then click on " Next".
(I would advice to select first make a copy of the original constraint file and select that because you will need to modify the contents of the file to build the project and you don't want to modify your original constraint file.) - Now, click on the "Boards" tab and select your board from the list. In case it is not present in the list, click on the "Refresh" button then search for it again and download it if its not downloaded already. I am using Arty S7-50. Click on "Next".
- Click on "Finish".
Now, since we have created our project, we can now start to write the HDL code.
- First, we will modify our constraint file.
- We will need a clock (12MHz), switches, RGB LEDs and Simple LEDs.
- So, in the constraint file, uncomment all those lines related to the above mentioned interfaces as shown below. You can also change the names of the interfaces as I have done. Leave everything else as it is in the constraint file.
- We can use these interfaces to access the LEDs and the switches on the board.
- Now, we can start writing the HDL code. Our HDL code will implement the following functions:
- The whole circuit will be driven by a 12 MHz clock.
- If sw[0] is turned on, led[0] will turn on.
- If sw[1] is turned on, led[0] and led[1] will turn on.
- If sw[2] is turned on, led[0], led[1] and led[2] will turn on.
- If sw[3] is turned on, led[0], led[1], led[2] and led[3] will turn on.
- If more than one switch is on, all the leds will turn off.
- The two RGB leds will keep changing their color according to some bits of a 32 bit counter.
- The HDL code is given below.
module main( input CLK12MHZ, input [3:0] sw, output reg [3:0] led, output reg [2:0] led_rgb0, output reg [2:0] led_rgb1); wire out0; wire out1; wire out2; wire out3; and sw0 (out0, sw[0], !sw[1], !sw[2], !sw[3]); and sw1 (out1, !sw[0], sw[1], !sw[2], !sw[3]); and sw2 (out2, !sw[0], !sw[1], sw[2], !sw[3]); and sw3 (out3, !sw[0], !sw[1], !sw[2], sw[3]); reg [31:0] counter = 32'h0; always @(posedge CLK12MHZ) begin counter <= counter + 1'b1; if (counter == 32'hFFFFFFFF) begin counter = 32'h0; end end always @(posedge CLK12MHZ) begin if (out0 || out1 || out2 || out3) begin if (out0 == 1'b1) begin led[0] <= 1'b1; end else if (out1 == 1'b1) begin led[0] <= 1'b1; led[1] <= 1'b1; end else if (out2 == 1'b1) begin led[0] <= 1'b1; led[1] <= 1'b1; led[2] <= 1'b1; end else if (out3 == 1'b1) begin led[0] <= 1'b1; led[1] <= 1'b1; led[2] <= 1'b1; led[3] <= 1'b1; end end else begin led[0] <= 1'b0; led[1] <= 1'b0; led[2] <= 1'b0; led[3] <= 1'b0; end led_rgb0[0] <= counter[25]; led_rgb0[1] <= counter[26]; led_rgb0[2] <= counter[27]; led_rgb1[0] <= counter[22]; led_rgb1[1] <= counter[23]; led_rgb1[2] <= counter[24]; end endmodule
- Now, after writing the HDL code, you can try to get its circuit schematic by clicking on "Schematic" under the "RTL Analysis" drop down menu in the left pane. My schematic is given below.
- If there are no errors in the code, the schematic will be build successfully otherwise it will show the errors.
- You can now connect the board to your system using a micro-USB cable.
- Next step is to generate the bitstream. Click on "Generate Bitstream" in the left pane. The following window will open.
- Select "Number of jobs" as your choice. The lower the number of jobs you choose, the more time it will take to generate the bitstream (but higher number of jobs will use more resources). Click on "OK".
- The process might take a few minutes (if it takes much longer, just click on cancel and then try to generate it again). You can see the status of the process at top right corner of the window.
- After the bitstream gets generated, open the "Hardware Manager" from the left pane under "Program and Debug" drop down menu.
- Click on "Open target" and then click on "Auto Connect". It will take a few minutes to connect to the device.
- Once connected, click on "program device". This will program your device with the bitstream we earlier generated.
- You can check your board by turning the switches on and off as shown below.
(Remember that if you disconnect your board from power supply and reconnect it you will have to reprogram it. The program doesn't get stored on the board. After reconnecting, the board will run the inbuilt binary code).
The device is shown below after programming it:
There is a button ("PROG") on the board, pressing which will load the preloaded binary code.
Conclusion:
Working with Vivado is quite easy. Sometimes it gets stuck but runs fine if I restart it. It was very simple to program the board. There are many other interesting features like the IP Integrator which I will cover in later blogs.
Actually, I am a little bit disappointed by the fact that I need to reprogram it every time I disconnect it from power supply and reconnect it. I don't know why it doesn't have the feature to store its state when power is disconnected! I hope there is some good reason behind it.