User Tools


This is an old revision of the document!


Structural SystemVerilog

In this lab you will implement several logic functions using the SystemVerilog HDL (Hardware Description Language). You will simulate your SystemVerilog designs using commercial simulation tools and synthesize them into circuits that will be downloaded onto the NEXYS 4 board.

Learning Outcomes

  • Describing circuits using SystemVerilog.
  • Use the Vivado design suite for project creation.
  • Use Vivado simulation and synthesis tools.
  • Learn to create TCL simulation scripts.

Preliminary

  • Review Chapter 8 of the textbook (you will need to be familiar with SystemVerilog before starting this lab).
  • This laboratory will involve a lot of tutorials. You may want to start working through these tutorials before you arrive at the laboratory to get a head start.

Exercises

Exercise #1: Implement Logic Functions in Structural SystemVerilog

In this exercise you will create the structural SystemVerilog description of four logic functions. Note that you must use structural SystemVerilog rather than Dataflow SystemVerilog to complete this assignment. Follow the steps below to begin this exercise.

  1. Open up your favorite text editor such as Notepad++, notepad, emacs, etc. Note that your editor must save the file as “text” - programs such as Microsoft Word do not by default save files as text.
  2. Create an empty file named FourFunctions.sv (note the extension “.sv” indicating a SystemVerilog file). This will be the text file that contains the SystemVerilog file for your lab.
  3. Start your file by creating a header in your SystemVerilog file that conforms to this class's verilog_coding_standards.
  4. Define a module named “FourFunctions” with the following ports. Make sure to match everything described below exactly (including the port names).

Module Name: FourFunctions

Port Name Size (bits) Direction
A 1 Input
B 1 Input
C 1 Input
O1 1 Output
O2 1 Output
O3 1 Output
O4 1 Output

Implement the following four logic functions inside of this module.

  • O1: O1 = AC+A'B
  • O2: O2 = (A+C')(BC)
  • O3: The logic function in the textbook Figure 5.2 1)
  • O4: The logic function in the textbook Figure 5.25a 2)

You do not need to minimize these functions, just implement the logic functions directly using basic gates (AND, OR, NOT, etc).

Complete your initial attempt at the SystemVerilog for these four functions before proceeding. In the next exercise you will have the opportunity to find and correct errors when you analyze the syntax and behavior of your SystemVerilog.

Exercise 1 Pass-off: There is no pass off for this exercise.

Exercise #2: Creating a Vivado Project

Many software tools are needed to convert your SystemVerilog file into a configuration bit file that you can download onto an FPGA device. We will be using a set of tools called Vivado developed by Xilinx, the manufacturer of the FPGA devices in the lab. You will use Vivado throughout the rest of the semester.

  1. Create a new Vivado project by following the instructions in the Creating a new Vivado Project tutorial.
  2. Add the SystemVerilog file you created in exercise 1 to your project by following the adding a design file section of the Adding a SystemVerilog Module tutorial. When you add your SystemVerilog file, the Vivado tools will perform basic syntax checking on the file. Any syntax errors will be highlighted and summarized in the messages tab.
  3. Fix any syntax errors in your code.

With no syntax errors in your HDL code you can perform elaboration and generate a notional schematic of the circuit. Follow the Viewing SystemVerilog as a Schematic tutorial to view a schematic of your code.

Although it is difficult to find logic errors in the schematic view, it is easy to see problems such as missing connections between the gates, inputs, and outputs. Look for unconnected top-level ports or missing connections in your gates (missing connections are annotated with n/c on the schematic).

Exercise 2 Pass-off: Show a TA your circuit schematic. Be able to explain what each of the components are and how Vivado has implemented your four functions.

Exercise #3: SystemVerilog Simulation

Simulating your design is the most important phase of digital logic design. You will do extensive simulations of all your digital circuits and it is very important that you learn how to use the logic simulation tools. The greater skill you have at using these simulation tools, the easier and more successful you will be in all future labs.

Complete the following steps for this exercise:

1. Begin the simulation process by following the Starting the Vivado HDL Simulation Tool tutorial.

2. Read through this tutorial to get a feel for the TCL commands you will be using. Then, create a .tcl file and simulate your module by issuing a number of add_force commands.

The following .tcl code snippet demonstrates one way to simulate two of the eight input combinations. In your own .tcl file you will need to make sure to test all possible input combinations.

# Comments are written with the '#' character instead of // or /**/.
 
# Simulate A=0, B=0, C=0 for 10 ns
add_force A 0
add_force B 0
add_force C 0
run 10 ns

# Simulate A=0, B=0, C=1 for 10 ns
add_force A 0
add_force B 0
add_force C 1
run 10 ns

3. Compare the resulting waveform with a truth table for your four functions. Verify that your simulation outputs match the expected outputs. If there are errors, fix your SystemVerilog file and simulate again until your circuit operates as intended.

Exercise 3 Pass-off: Show a TA your simulation and explain how you know that your circuit is working correctly. The TA will also check your tcl commands to see if you have tested all possible input combinations.

Exercise #4: Synthesis and Implementation

During this exercise you will translate your SystemVerilog HDL file into an actual digital circuit that can operate on the FPGA device. There are three specific steps you must complete in order to perform this translation. These steps include:

  1. HDL Synthesis,
  2. Implemetnation, and
  3. Bitfile Generation

This exercise will describe each of these steps and guide you through the process of completing these steps for your design.

Creating a Constraints File

Before proceeding with the first “HDL synthesis” step, you must create a constraints file, or XDC (Xilinx Design Constraints) file. This tells the synthesis tool which pins on the FPGA board are being connected to which inputs and outputs of your circuit. Without this file, your design will not be able to synthesize even if your circuit is logically correct. This table shows the mapping we will use for this module.

Port Name Pin NEXYS 4
A M13 Switch 2 (SW2)
B L16 Switch 1 (SW1)
C J15 Switch 0 (SW0)
O1 N14 LED 3 (LD3)
O2 J13 LED 2 (LD2)
O3 K15 LED 1 (LD1)
O4 H17 LED 0 (LD0)

For example, this table indicates that the “A” input to your logic circuit should be mapped to pin “M13” of the FPGA on the NEXYS 4 board. The table also indicates that the “M13” pin is attached to Switch 2 on the board. To make an XDC file, follow the instructions in the Using Constraint Files (XDC) tutorial. Your constraints file should have seven different constraint commands, one for each of the inputs and outputs of your circuit.

Include the text of your XDC file in your laboratory report.

After creating your XDC file, you need to add it to your project. Follow the Adding a Constraints File to your Project tutorial to learn how to add this to your project.

HDL Synthesis

HDL synthesis (also called logic synthesis) is the process of converting your HDL code into an intermediate circuit netlist of gates and logic primitives. Synthesis tools are complex and use a lot of sophisticated algorithms to perform this translation. Follow the Running the HDL Synthesis Tool tutorial to run the synthesis tool on your design.

During the synthesis process you may encounter synthesis warnings from the synthesis tool. It is common to receive many warnings especially for large circuits. It is essential that you review the warnings of the synthesis step before proceeding to the implementation step. In most cases these warnings can be ignored but it is essential to review them as subtle warnings in the logic synthesis tool are often are the cause of complex problems later in the design process.

List the warnings in your synthesis report. State that there were no warnings if none show up. Warnings can be found in the Messages tab at the bottom of the screen. They can also be found in the Reports tab at the bottom of the screen under Vivado Synthesis Report.

Summarize some of the differences between the schematic you captured earlier and the synthesis schematic. The synthesis schematic is found under Open Synthesized Design > Schematic, as explained in the Running the HDL Synthesis Tool tutorial video.

Implementation

The Implementation step will map the circuit netlist created in the synthesis step onto specific resources of the FPGA. This involves placement of your circuit resources and routing of your logic signals. Follow the Running the Implementation Design Step tutorial to complete the implementation process on your design.

Open the Project Summary tab, which should be near the tab for your SystemVerilog file. If you closed the Project Summary earlier, it can be opened with the following icon in the tool bar.

Review the Utilization box within the Project Summary to determine the size of your design in terms of logic resources. Use the Post-Implementation and Table tabs.

Indicate the number of LUTs (Look-up Tables) and I/O (Input/Output) pins for your design. These are in the Utilization column of the table.

Exercise 4 Pass-off: Show a TA your xdc file and explain what this file is doing. Then show the TA your synthesized schematic and explain some of the differences between this schematic and the previous one.

Exercise #5: Generate Bitstream and Download to FPGA Board

The “Bit File Generation” step will convert your design that has been placed and routed to a binary file that can be downloaded onto the FPGA. Follow the Running the bitgen Design Step tutorial to generate your bitstream.

Now that you have a bit file, you can configure the FPGA and test your circuit on the board. You may want to review the Downloading a bit file to the Nexys 4 Board Using Adept tutorial to remind yourself how to configure the board with your bit file.

You can also download a bit file to the NEXYS 4 straight out of Vivado using the downloading a bitstream file section of this tutorial.

Test all four functions in your circuit on the board to make sure that it works correctly. When you are convinced that your circuit is correct, proceed to the final pass off.

Include your final SystemVerilog code in your laboratory report. (Make sure your SystemVerilog conforms to the lab SystemVerilog coding standards).

Final Pass Off

The following must be shown to a TA to pass off this laboratory:

  • Completed pass-offs for Exercise 2, 3 and 4.
  • The circuit operating correctly on the FPGA board.

How many hours did you work on the lab?

Provide any suggestions for improving this lab in the future.

Personal Exploration

Here are some ideas for personal exploration in this laboratory:

  • Compare and contrast the difference between the circuit you specified in your original SystemVerilog file and the schematic that is generated from your file.
  • Add an additional fifth logic function to your SystemVerilog file and synthesize it using the steps described in the laboratory instructions.
  • Explore a variety of different features and aids in the simulation tool and summarize them.
  • Explore various options available in the Vivado design suite and summarize what they do.

Describe your personal exploration activities


TA Notes and Feedback

1)
Page 47
2)
Page 60