How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
|1||Digilent 410-183 Basys Artix-7 Development Board||134-6451|
After completing this lab, you will be able to:
- Create a Vivado project sourcing HDL model(s) and targeting a specific FPGA device located on Basys 3 FPGA trainer board
- Use the provided Xilinx Design Constraint (XDC) file to constrain the pin locations
- Simulate the design using the Vivado simulator
- Synthesize and implement the design
- Generate the bitstream
- Configure the FPGA using the generated bitstream and verify the functionality
This lab is broken into steps that consist of general overview statements providing information on the detailed instructions that follow. Follow these detailed instructions to progress through lab1.
The design consists of some inputs directly connected to the corresponding output LEDs. Other inputs are logically operated on before the results are output on the remaining LEDs as shown in Figure 1.
Figure 1. The Completed Design
Step 1: Create a Vivado Project using IDE
Step 2: Simulate the Design using Vivado Simulator
Step 3: Synthesize the Design
Step 4: Implement the Design
Step 5: Perform the Timing Simulation
Step 6: Verify Functionality in Hardware
Create a Vivado Project using IDE (Step 1)
Launch Vivado and create a project targeting the XC7A35TCPG236-1 (Basys3) and using the VHDL HDL. Use the provided lab1.vhd and lab1.xdc files from the 2020_1_artix7_sources\lab1
Open Vivado by selecting Start > All Programs > Xilinx Design Tools > Vivado 2020.1> Vivado 2020.1
Click Create New Project to start the wizard. You will see Create A New Vivado Project dialog box. Click Next.
Click the Browse button of the Project location field of the New Project form, browse to C:/Digilent/Basys3Workshop/2020_1_artix7_labs, and click Select.
Enter lab1 in the Project name Make sure that the Create Project Subdirectory box is checked. Click Next.
Figure 2. Project Name and Location entry
Select RTL Project option in the Project Type Make sure that the Do not specify sources at this time box is unchecked. Click Next.
Using the drop-down buttons, select VHDL as the Target Language and Mixed Simulator Language in the Add Sources
Figure 3. Selecting Target and Simulator language
Click on the Add Files button, browse to the Downloads folder, select lab1.vhd, click OK. Make sure that the Copy sources into project box is checked. Click Next to get to the Add Constraints form.
The constraint file lab1_basys3.xdc and lab1_nexys4.xdc are automatically added. Highlight and delete the XDC file not for the target board by clicking on the “X” on the right-hand side of the window. Make sure that the Copy constrains files into project box is checked.
If no files are added, click on the Add Files… button, browse to the Downloads folder (if necessary), select lab1_basys3.xdc or lab1_nexys4.xdc and click OK (if necessary), and then click Next.
This Xilinx Design Constraints file assigns the physical IO locations on FPGA to the switches and LEDs located on the board. This information can be obtained either through the board’s schematic or the board’s user guide.
In the Default Part form, using the Parts option and various drop-down fields of the Filter If using the Basys3 board, select the XC7A35TCPG236-1. Click Next.
Figure 4. Part Selection for the Basys3
You can select the Boards Specify option, select Artix-7 under the Library filter, and select the appropriate board. Notice that Nexys4 and the Basys3 are not listed as they are not in the tool database.
Click Finish to create the Vivado project.
Use the Windows Explorer and look at the C:\Digilent\Basys3Workshop\2020_1_artix7_labs\lab1 directory. You will find that lab1.cache and lab1.srcs directories and the lab1.xpr (Vivado) project file have been created. The lab1.cache directory is a placeholder for the Vivado program database. Two directories, constrs_1 and sources_1, are created under lab1.srcs directory; deep down under them, the copied lab1.xdc (constraint) and lab1.v (source) files respectively are placed.
Figure 5. Generated directory
Open lab1.vhd source and analyze the content.
In the Sources pane, double-click lab1.vhd entry to open the file in text mode.
Figure 6. Opening the source file
In the VHDL code, lines 1-3 are comment lines describing the entity name and the purpose of the module. Lines 5-6 invoke the standard IEEE library and STD_LOGIC_1164 package.
Lines 8-11 declare the entity called lab1 and define the port interface signals. Two std_logic vectors are used, 8 signals each: inputs swt (switches) and outputs led.
Line 13 declares the architecture called Behavioral of the lab1 entity. Line 15 declares an internal signal to build the LED state.
Lines 19-24 describe the functionality, while line 26 assigns computed values to the output signals led.
Line 28 closes the architecture.
Open the lab1_basys3.xdc or lab1_nexys4.xdc source and analyze the content.
In the Sources pane, expand the Constraints folder and double-click lab1.xdc entry to open the file in text mode.
Figure 7. Opening the constraint file
Lines 5-20 define the pin locations of the input switches [7:0] and lines 25-40 define the pin locations of the output LEDs [7:0].
Perform RTL(register-transfer level ) analysis on the source file.
Expand the Open Elaborated Design entry under the RTL Analysis tasks of the Flow Navigator pane and click on Schematic.
The model (design) will be elaborated and a logic view of the design is displayed.
Figure 8. A logic view of the design
Notice that some of the switch inputs go through gates before being output to LEDs and the rest go straight through to LEDs as modelled in the file.
Simulate the Design using the Vivado Simulator Step 2
Add the lab1_tb.vhd testbench file.
Click Add Sources under the Project Manager tasks of the Flow Navigator pane.
Figure 9. Add Sources
Select the Add or Create Simulation Sources option and click Next.
Figure 10. Selecting Simulation Sources option
In the Add Sources Files form, click the Add Files… button. Browse to the c:\Digilent/Basys3Workshop/2020_1_artix7_sources/lab1 folder and select lab1_tb.vhd and click OK.
Make sure that the Copy sources into project box is checked. Click Finish. Select the Sources tab and expand the Simulation Sources group. The lab1_tb.vhd file is added under the Simulation Sources group, and lab1.vhd is automatically placed in its hierarchy as a dut (device under test) instance.
Figure 11. Simulation Sources hierarchy
Using the Windows Explorer, verify that the sim_1 directory is created at the same level as constrs_1 and sources_1 directories under the lab1.srcs directory, and that a copy of lab1_tb.vhd is placed under lab1.srcs > sim_1 > imports > lab1. Double-click on the lab1_tb in the Sources pane to view its contents.
---------------------------------------------------------------------------------- -- Entity Name: lab1_tb ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; entity lab1_tb is end lab1_tb; architecture Behavioral of lab1_tb is -- component declaration for the Unit Under Test (UUT) COMPONENT lab1 is Port (swt : in STD_LOGIC_VECTOR (7 downto 0); led : out STD_LOGIC_VECTOR (7 downto 0)); end COMPONENT; signal switches, leds, e_leds: std_logic_vector(7 downto 0); function expected_led (swt : std_logic_vector(7 downto 0)) return std_logic_vector is variable exp_led: STD_LOGIC_VECTOR (7 downto 0); begin exp_led(0) := not swt(0); -- exp_led(0) := swt(0); -- replace the previous line with this one, to fail the test exp_led(1) := swt(1) and not swt(2); exp_led(3) := swt(2) and swt(3); exp_led(2) := exp_led(1) or exp_led(3); exp_led(7 downto 4) := swt(7 downto 4); return exp_led; end expected_led; begin DUT: lab1 port map( swt => switches, led => leds); test: process begin for i in 0 to 255 loop wait for 50ns; switches <= conv_std_logic_vector(i,8); wait for 10ns; e_leds <= expected_led(switches); wait for 0ns; if leds = e_leds then report "LED output matched at " & time'IMAGE(now); else report "LED output mis-matched at " & time'IMAGE(now) & ": expected: " & std_logic'Image(e_leds(7)) & std_logic'Image(e_leds(6)) & std_logic'Image(e_leds(5)) & std_logic'Image(e_leds(4)) & std_logic'Image(e_leds(3)) & std_logic'Image(e_leds(2)) & std_logic'Image(e_leds(1)) & std_logic'Image(e_leds(0)) & " actual: " & std_logic'image(leds(7)) & std_logic'image(leds(6)) & std_logic'image(leds(5)) & std_logic'image(leds(4)) & std_logic'image(leds(3)) & std_logic'image(leds(2)) & std_logic'image(leds(1)) & std_logic'image(leds(0)); end if; end loop; end process; end Behavioral;
Figure 12. The self-checking testbench
The testbench invokes IEEE library and needed packages. The IEEE.STD_LOGIC_ARITH package is required for using the conv_std_logic_vector function.
The entity is void for a testbench (there is no input or output signal for the test).
The architecture declarations are:
- The tested component DUT (device under test)
- Some signals
- A function describing the same module functionality for the expected value computation
The architecture body:
- instantiates the DUT (device/module under test).
- define the stimuli generation, and compare the expected output with what the DUT provides.
- print the message in the simulator console window when the simulation is run.
Simulate the design for 200 ns using the Vivado simulator.
Select Simulation Settings under the Project Manager tasks of the Flow Navigator pane.
A Project Settings form will appear showing the Simulation properties form.
Select the Simulation tab, and set the Simulation Run Time value to 200 ns and click OK.
Figure 13. Setting simulation run time
Click on Run Simulation > Run Behavioral Simulation under the Project Manager tasks of the Flow Navigator pane.
The testbench and source files will be compiled and the Vivado simulator will be run (assuming no errors). You will see a simulator output similar to the one shown below.
Figure 14. Simulator output
You will see four main views: (i) Scopes, where the testbench hierarchy, as well as glbl instances, are displayed, (ii) Objects, where top-level signals are displayed, (iii) the waveform window, and (iv) Tcl Console where the simulation activities are displayed. Notice that since the testbench used is self-checking, the results are displayed as the simulation is run.
Notice that lab1.sim directory is created under the lab1 directory, along with several lower-level directories.
Figure 15. Directory structure after running behavioural simulation
You will see several buttons above the waveform window which can be used for the specific purpose as listed in the table below.
Table 1: Various buttons available to view the waveform
Click on the Zoom Fit button ( ) to see the entire waveform.
Notice that the output changes when the input changes.
You can also float the simulation waveform window by clicking on the Float button on the upper right-hand side of the view. This will allow you to have a wider window to view the simulation waveforms. To reintegrate the floating window back into the GUI, simply click on the Dock Window button.
Figure 16. Float Button
Figure 17. Dock Window Button
Change display format if desired.
Select switches[7:0] in the waveform window, right-click, select Radix, and then select Hexadecimal. Leave the leds[7:0] and e_led[7:0] radix to binary as we want to see each output bit.
Add more signals to monitor the lower-level signals and continue to run the simulation for 500 ns.
Expand the lab1_tb instance, if necessary, in the Scopes window and select the dut instance. The swt[7:0] and led[7:0] signals will be displayed in the Objects window.
Figure 18. Selecting lower-level signals
Select swt[7:0] and led[7:0] and drag them into the waveform window to monitor those lower-level signals.
On the simulator tool buttons ribbon bar, type 500 over in the simulation run time field, click on the drop-down button of the units field and select ns ( ) if we want to run for 500 ns (total of 700 ns), and click on the ( ) button. The simulation will run for an additional 500 ns.
Click on the Zoom Fit button and observe the output.
Figure 19. Running simulation for additional 500 ns
Observe the Tcl Console and see the output is being displayed as the testbench uses the report task.
Figure 20. Tcl Console output after running the simulation for additional 500 ns
Close the simulator by selecting File > Close Simulation. Click OK and then click No to close it without saving the waveform.
Synthesize the Design (Step 3)
Synthesize the design with the Vivado synthesis tool and analyze the Project Summary output.
Click on Run Synthesis under the Synthesis tasks of the Flow Navigator pane.
The synthesis process will be run on lab1.vhd file (and all its hierarchical files if they exist). When the process is completed a Synthesis Completed dialog box with three options will be displayed.
Select the Open Synthesized Design option and click OK as we want to look at the synthesis output before progressing to the implementation stage.
Click Yes to close the elaborated design if the dialog box is displayed.
Select the Project Summary tab and understand the various windows.
If you don’t see the Project Summary tab then select Layout > Default Layout, or click the Project Summary icon.
Figure 21. Project Summary view
Click on the various links to see what information they provide and which allows you to change the synthesis settings.
Click on the Table tab in the Project Summary tab.
Notice that there are an estimated three LUTs and 16 IOs (8 input and 8 output) that are used.
Figure 22. Resource utilization estimation summary for the Basys3
In The Flow Navigator, under Synthesis (expand Synthesized Design if necessary), click on Schematic to view the synthesized design in a schematic view.
Figure 23. Synthesized design’s schematic view
Notice that IBUFs and OBUFs are automatically instantiated (added) to the design as the input and output are buffered. The logical gates are implemented in LUTs (1 input is listed as LUT1, 2 input is listed as LUT2, and 3 input is listed as LUT3). Four gates in RTL analysis output are mapped onto four LUTs in the synthesized output.
Using Windows Explorer, verify that lab1.runs directory is created under lab1. Under the runs directory, synth_1 directory is created which holds several files related to synthesis.
Figure 24. Directory structure after synthesizing the design
Implement the Design (Step 4)
Implement the design with the Vivado Implementation Defaults (Vivado Implementation 2020) settings and analyze the Project Summary output.
Click on Run Implementation under the Implementation tasks of the Flow Navigator pane.
The implementation process will be run on the synthesized design. When the process is completed an Implementation Completed dialog box with three options will be displayed.
Select Open implemented design and click OK as we want to look at the implemented design in a Device view tab.
Click Yes, if prompted, to close the synthesized design.
The implemented design will be opened.
In the Netlist pane, select one of the nets (e.g. led_OBUF) and notice that the net is displayed in the X1Y1 clock region in the Device view tab (you may have to zoom in to see it).
If it is not selected, click the Routing Resources icon to show routing resources.
Figure 25. Selecting a net
Figure 26. Viewing implemented design for the Basys3
Close the implemented design view and select the Project Summary tab (you may have to change to the Default Layout view) and observe the results.
Select the Post-Implementation tab.
Notice that the actual resource utilization is three LUTs and 16 IOs. Also, it indicates that no timing constraints were defined for this design (since the design is combinatorial).
Figure 27. Implementation results for the Basys3
Using Windows Explorer, verify that impl_1 directory is created at the same level as synth_1 under lab1.runs directory. The impl_1 directory contains several files including the implementation report files.
In Vivado, select the Reports tab in the bottom panel (if not visible, click Window in the menu bar and select Reports), and double-click on the Utilization Report entry under the Place Design section. The report will be displayed in the auxiliary view pane showing resource utilization. Note that since the design is combinatorial no registers are used.
Figure 28. Available reports to view
Perform Timing Simulation (Step 5)
Run a timing simulation.
Select Run Simulation > Run Post-Implementation Timing Simulation process under the Simulation tasks of the Flow Navigator pane.
The Vivado simulator will be launched using the implemented design and lab1_tb as the top-level module.
Using Windows Explorer, verify that the timing directory is created under lab1.sim > sim_1 > impl directory. The timing directory contains generated files to run the timing simulation.
Click on the Zoom Fit button to see the waveform window from 0 to 200 ns.
Right-click at 50 ns (where the switch input is set to 0000000b) and select Markers > Add Marker.
Similarly, right-click and add a marker at around 55.000 ns where the leds change.
You can also add a marker by clicking on the Add Marker button (). Click on the Add Marker button and left-click at around 60 ns where e_led changes.
Figure 29. Timing simulation output
Notice that we monitored the expected led output at 10 ns after the input is changed (see the testbench) whereas the actual delay is about 5.000 ns.
Close the simulator by selecting File > Close Simulation without saving any changes.
Generate the Bitstream and Verify Functionality (Step 6)
Connect the board and power it ON. Generate the bitstream, open a hardware session, and program the FPGA.
Make sure that the Micro-USB cable is connected to the JTAG PROG connector (next to the power supply connector).
Make sure that the board is set to use USB power (via the Power Select jumper JP2 on the Basys3)
Figure 30. Board connection for the Basys3
Power ON the board.
Click on the Generate Bitstream entry under the Program and Debug tasks of the Flow Navigator pane.
The bitstream generation process will be run on the implemented design. When the process is completed a Bitstream Generation Completed dialog box with two options will be displayed.
Figure 31. Bitstream generation
This process will have generated a lab1.bit file under impl_1 directory in the lab1.runs directory.
Select the Open Hardware Manager option and click OK.
The Hardware Manager window will open indicating “unconnected” status.
Click on the Open target link.
Figure 32. Opening new hardware target
Click Auto Connect and wait for Vivado to find and connect.
The Hardware Session status changes from Unconnected to the server name and the device is highlighted. Also, notice that the Status indicates that it is not programmed.
Figure 33. Opened hardware session for the Basys3
Click on the Program link in the green information bar to program the target FPGA device.
Another way is to right-click on the device and select Program Device…
Figure 34. Selecting to program the FPGA
Click Program to program the FPGA.
The DONE light will light when the device is programmed. You may see some other LEDs lit depending on switch positions.
Verify the functionality by flipping switches and observing the output on the LEDs (Refer to the earlier logic diagram).
When satisfied, power OFF the board.
Close the hardware session by selecting File > Close Hardware Manager.
Click OK to close the session.
Close the Vivado program by selecting File > Exit and click OK.
The Vivado software tool can be used to perform a complete design flow. The project was created using the supplied source files (HDL model and user constraint file). A behavioural simulation using the provided testbench was done to verify the model functionality. The model was then synthesized, implemented, and a bitstream was generated. The timing simulation was run on the implemented design using the same testbench. The functionality was verified in hardware using the generated bitstream.