This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
labs:structural_verilog [2020/01/28 08:39] nelson [Exercise #2: Creating a Vivado Project] |
labs:structural_verilog [2020/04/20 14:35] (current) nelson [Exercise #2: Implement Logic Functions in Structural SystemVerilog] |
||
---|---|---|---|
Line 16: | Line 16: | ||
===== Exercises ===== | ===== Exercises ===== | ||
- | ==== Exercise #1: Implement Logic Functions in Structural SystemVerilog ==== | + | ==== Exercise #1: 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. | ||
+ | |||
+ | - Create a new Vivado project by following the instructions in the [[tutorials:vivado_project_setup]] tutorial. __Make sure you follow the steps in red to properly configure the error messages in your project.__ | ||
+ | - Now, create a new SystemVerilog file to hold a module by following the instructions in the [[tutorials:creating_a_new_module]] tutorial. Your module will be called "FourFunctions". Do not add any ports to it in this exercise, you just want an empty module definition. | ||
+ | |||
+ | |||
+ | ==== Exercise #2: 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. | 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. | ||
- | - Open up your favorite **text** editor such as VS Code, 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 files. | + | - Open up the FourFunctions.sv module you created in Exercise #1 by double-clicking it in the figure you just saw above. |
- | - 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. | + | - Start your file by creating a **header** in your SystemVerilog file that conforms to this class's [[:verilog_coding_standards]]. If Vivado has pre-populated the file with header information you are free to remove that or modify it (do not delete the first line that contains `timescale 1ns / 1ps, however. Either way, your design must have a **header** that conforms to the class's [[:verilog_coding_standards]] |
- | - Start your file by creating a **header** in your SystemVerilog file that conforms to this class's [[:verilog_coding_standards]]. (NOTE: the coding standards are very specific on how to declare the inputs and outputs of modules. If you read carefully, you will note that they require the inclusion of the word "wire" in certain places. This is not reflected in the textbook examples. The need to include this is due to specific requirements of Vivado when the `default_nettype none macro directive is included.) | + | - NOTE: the coding standards are very specific on how to declare the inputs and outputs of modules. If you read carefully, you will note that they require the inclusion of the word "wire" in certain places. This is not reflected in the textbook examples. The need to include this is due to specific requirements of Vivado when the `default_nettype none macro directive is included.) |
- | - Define a module named "FourFunctions" with the following ports. Make sure to match everything described below exactly (including the port names). | + | - Now, define a module named "FourFunctions" with the following ports. Make sure to match everything described below exactly (including the port names). |
+ | |||
+ | NOTE: if you are fuzzy on module declarations, consult the textbook. In particular, review Sections 8.3, 8.4, and 8.6.1 in the textbook. And, just remember that due to our using Vivado, you also need to include the word "wire" in certain places. Consult the [[:verilog_coding_standards]] for details on that. | ||
+ | |||
+ | Finaly, at this point remember there is no reason to get creative - just copy the structure and syntax (including indentation) of the code examples in the book sections noted. And, carefully follow the coding standard. This goes for this lab as well as all future labs. | ||
**Module Name**: FourFunctions | **Module Name**: FourFunctions | ||
Line 40: | Line 52: | ||
* **O1**: O1 = AC+A'B | * **O1**: O1 = AC+A'B | ||
+ | |||
* **O2**: O2 = (A+C')(BC) | * **O2**: O2 = (A+C')(BC) | ||
- | * **O3**: The logic function in the textbook Figure 5.2 (Page 45) | ||
- | * **O4**: The logic function in the textbook Figure 5.25a (Page 58) //Make sure you look carefully in the end of the chapter to find the correct circuit diagram -- it is subfigure **a** (the one on the left).// | ||
- | You do not need to minimize these functions, just implement the logic functions directly using basic gates (AND, OR, NOT, etc). | + | * **O3**: The logic function below: |
- | 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. | + | {{:labs:simpleschem.png?400|Function for O3}} |
- | **Exercise 1 Pass-off:** There is no pass off for this exercise.\\ \\ | + | * **O4**: The logic function below: |
+ | {{:labs:hwb.png?300|Function for O4}} | ||
+ | If these functions require intermediate signals (signals that are not module ports), you will need to declare them using the 'logic' keyword (see text for details). Also, choose meaninful names or (probably better yet) put a comment above them to tel what they are used for. | ||
- | ==== Exercise #2: Creating a Vivado Project ==== | + | You do not need to minimize these functions, just implement the logic functions directly using basic gates (AND, NAND, OR, NOR, NOT, etc). |
- | 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. | + | As you type and save your SystemVerilog code, Vivado will identify syntax errors in the code. Edit the code until there are no syntax errors. |
- | + | ||
- | - Create a new Vivado project by following the instructions in the [[tutorials:vivado_project_setup]] tutorial. __Make sure you follow the steps in red to properly configure the error messages in your project.__ | + | |
- | - Add the SystemVerilog file you created in exercise 1 to your project by following the [[tutorials:creating_a_new_module#adding_a_previously_created_module|adding a design file]] section of the Adding a SystemVerilog Module tutorial. As you do so, create a NEW source file but don't bpther with setting up ports in the GUI. Then, copy and paste the SystemVerilog code you created earlier into this new design file. When you do so, the Vivado tools will perform basic syntax checking on the file. Any syntax errors will be highlighted and summarized in the messages tab. | + | |
- | - 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 [[tutorials:viewing_design_elaboration]] tutorial to view a schematic of your code. | With no syntax errors in your HDL code you can perform **elaboration** and generate a notional schematic of the circuit. Follow the [[tutorials:viewing_design_elaboration]] tutorial to view a schematic of your code. | ||
Line 63: | Line 72: | ||
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). | 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 2 Pass-off:** Review your code with a TA as well as your circuit schematic (the schematic under "RTL Analysis"). Be able to explain what each of the components are and how Vivado has implemented your four functions.\\ \\ |
/* I think it would be useful to add a question that asks them to compare the schematic to their logic functions. In particular, it would be useful to have them create a logic equation for each output based on the gates that were chosen. Then, have them prove that the logic equations are the same. This may be difficult to do in learning suite but it is an interesting exercise for them to complete. | /* I think it would be useful to add a question that asks them to compare the schematic to their logic functions. In particular, it would be useful to have them create a logic equation for each output based on the gates that were chosen. Then, have them prove that the logic equations are the same. This may be difficult to do in learning suite but it is an interesting exercise for them to complete. | ||
Line 125: | Line 134: | ||
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. | 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 [[tutorials:making_an_xdc_file]] tutorial. | To make an XDC file, follow the instructions in the [[tutorials:making_an_xdc_file]] tutorial. | ||
- | Your constraints file should have seven different constraint commands, one for each of the inputs and outputs of your circuit. | + | Your constraints file should have seven different constraint commands, one for each of the inputs and outputs of your circuit. Remember that it is easier to include the Master XDC File (found on the bar on the left) and uncomment the lines you need rather than making the file yourself. |
<color red>Include the text of your XDC file in your laboratory report.</color> | <color red>Include the text of your XDC file in your laboratory report.</color> | ||
Line 217: | Line 226: | ||
[[labs:ta:structural_verilog|TA Notes and Feedback]] | [[labs:ta:structural_verilog|TA Notes and Feedback]] | ||
+ | |||
+ | [[testDev]] |