xilinx vhdl tutorial
TRANSCRIPT
![Page 1: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/1.jpg)
VHDL TUTORIAL using Xilinx’s WEBPACK and ModelSim
![Page 2: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/2.jpg)
After you have installed the Xilinx’s WebPack and ModelSim, start the Xilinx ISE 6 > Project Navigator
![Page 3: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/3.jpg)
You will come to the blank project (next time will have the most-recent project loaded by default). Click on File > New Project to start a new project
![Page 4: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/4.jpg)
Be sure to select HDL as the top-level module type. You can name your project, but let’s keep it simple and called this “Project1”.
![Page 5: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/5.jpg)
Be sure to select VHDL for “Generated Simulation Language”. Leave everything else as default. There are Device family & Device on first two row. These are the actual hardware your VHDL will map to as the final product. You can buy these chips, but they can be costly (hundreds to thousands of dollars depending on what you select). Note, the tool is free, but hardware is not and that’s how Xilinx makes money.
![Page 6: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/6.jpg)
Leave everything as default because you are starting with no files. You may add new source file later also.
![Page 7: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/7.jpg)
Leave everything as default because you are starting with no files. You may add existing files later as well.
![Page 8: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/8.jpg)
Click Finish to create the new project.
![Page 9: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/9.jpg)
This is the environment without any VHDL Files
![Page 10: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/10.jpg)
Now, let’s create a full-adder using VHDL. Note, you can now add existing source (a pointer) or add Copy of Source (create a new file from the source). Source is usually a .vhd file. If your partner finished one vhdl and gives you the file, you want to select add Copy of Source. You can always Ctrl-c Ctrl-v
![Page 11: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/11.jpg)
Be sure to select VHDL Module
![Page 12: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/12.jpg)
Architecture Name: Structure (concurrent statement). Architecture Name can also be Behavioral if it’s a sequential process like while loop and if-else statements
![Page 13: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/13.jpg)
It shows a quick summary of what you are about to create, click “Finish”.
![Page 14: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/14.jpg)
Some code will be automatically generated (libraries, declarations, and skeleton of the VHDL code)
![Page 15: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/15.jpg)
Add in the VHDL code for full adder logic
![Page 16: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/16.jpg)
Now, you can create a test bench for the full-adder to test whether the logic is what you expected. (Be sure to click on FullAdder VHDL file and right click)
![Page 17: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/17.jpg)
Be sure to select VHDL Test Bench and give it a file name.
![Page 18: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/18.jpg)
If you have a list of modules already created, you will see it here. Click “Next” to continue.
![Page 19: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/19.jpg)
Click “Finish” after you verify what you about to create is correct.
![Page 20: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/20.jpg)
A test bench template will be created, similar to VHDL module but with different library & declarations.
![Page 21: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/21.jpg)
Add in the test bench code. This example shows a complete combination.
![Page 22: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/22.jpg)
The ASSERT will provide an error in the main window (not the waveform window) if value COUT & SUM values do not map to the truth table. Another example of using assert statement: assert COUT = '0' report "COUT output incorrect. Value 1 is expected instead" severity error;
![Page 23: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/23.jpg)
Before you can simulate a VHDL module, you need to tell it which simulation you are going to use. Make sure you have the xc2s15-6cs144 selected on the top left window, then right click on the Compile HDL Simulation > Properties…
![Page 24: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/24.jpg)
Select ModelSim SE which is the freeware version of simulation you have installed before.
![Page 25: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/25.jpg)
Now you are ready to compile the simulation library so you can run the simulation later.
![Page 26: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/26.jpg)
When it’s finished compiling the libraries, you see the Green Check Mark next to it.
![Page 27: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/27.jpg)
Now, select the test-bench file on the upper left window. Then the bottom window will show the ModelSim simulator option. Right click on the Simulate Behavioral Model to run the simulation. It will open up few windows.
![Page 28: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/28.jpg)
Note, you may need to experiment with the zoom in/out and horizontal scroll-bar in the wave-form! Note the window behind the wave form with a list of status (# Reading C:/Modeltech_xe_starter/tcl/vsim/pref.tcl), if an error occurred with the simulation, error messages will appear in that window. (After you verify the simulation is correct, you need to close the ModelSim. Otherwise, it will try to launch another one next time)
![Page 29: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/29.jpg)
Let’s create a 4-bit adder based on the full-adder we just built.
![Page 30: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/30.jpg)
Same as before…
![Page 31: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/31.jpg)
Note, we are setting A(3:0) and B(3:0) as input and SUM(3:0) as output by assigning MSB values It is also a “Structure” architecture
![Page 32: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/32.jpg)
Looks good! Click “Finish”.
![Page 33: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/33.jpg)
Here is the code for 4-bit adder by mapping 4 FullAdder components within the “begin” and “End structure”. It’s a ripple adder (carry-out of first full-adder goes to the carry-in of the next full-adder)
![Page 34: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/34.jpg)
Now, add a simple test bench for 4-bit adder.
![Page 35: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/35.jpg)
Same as before…
![Page 36: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/36.jpg)
Make sure adder4bit is selected. Click “Next” and then Finish on the next screen (omitted)
![Page 37: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/37.jpg)
Add the simple test bench code, only three cases we tested in this case. Sometimes, you just can’t test every possible case.
![Page 38: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/38.jpg)
With the test bench file selected on upper-left window, right click on the bottom left window’s “Simulate Behavioral Model” and Run.
![Page 39: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/39.jpg)
Note, you have to zoom in/out a bit and scroll the waveform window to the left.
![Page 40: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/40.jpg)
Again, make sure you exit ModelSim each time.
![Page 41: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/41.jpg)
With 4 bit adder selected, click on the Synthesis (generating the actual logic circuit).
![Page 42: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/42.jpg)
Expand the synthesize-XST dir on the bottom-left window, and double click on “View RTL Schematic”
![Page 43: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/43.jpg)
You can drill down what is inside the 4-bit adder by double click on the schematic symbol
![Page 44: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/44.jpg)
Double click again at the schematic and you’ll see the full-adder implementation
![Page 45: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/45.jpg)
Double click again on the component
![Page 46: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/46.jpg)
This is as far as it goes. Close this window.
![Page 47: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/47.jpg)
This is another example. A bus-splitting module. Splitting 32-bit input into two 16-bit output (upper 16 & lower 16)
![Page 48: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/48.jpg)
Note, you use “downto” as the keyword
![Page 49: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/49.jpg)
You can also check your syntax before you simulate or synthesize
![Page 50: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/50.jpg)
Add the test bench for SplitBus module (same steps as before… some windows skipped).
![Page 51: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/51.jpg)
Add the test bench code and run simulation
![Page 52: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/52.jpg)
After zooming in/out and scroll to the left, you can see the result of the BusSplit module.
![Page 53: Xilinx Vhdl Tutorial](https://reader033.vdocuments.us/reader033/viewer/2022050904/54715e0ab4af9f9a6e8b4699/html5/thumbnails/53.jpg)
THE END OF TUTORIAL