Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| learn:software:tutorials:verilog-project-2:start [2017/01/17 23:04] – James Colvin | learn:software:tutorials:verilog-project-2:start [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ====== Verilog® HDL: Project 2 ====== | ====== Verilog® HDL: Project 2 ====== | ||
| + | |||
| ===== Using switches to control LEDs ===== | ===== Using switches to control LEDs ===== | ||
| ===== Project Overview ===== | ===== Project Overview ===== | ||
| - | The goal of this project is to take the [[learn/ | + | The goal of this project is to take the [[learn/ |
| A list of the previous projects can be found [[learn/ | A list of the previous projects can be found [[learn/ | ||
| - | //This project presumes you are using an FPGA development board that has external slide switches and LEDs built into the board, much like the [[http://store.digilentinc.com/fpga-programmable-logic/ | + | //This project presumes you are using an FPGA development board that has external slide switches and LEDs built into the board, much like the [[https://digilent.com/shop/boards-and-components/ |
| ===== Some Background Information ===== | ===== Some Background Information ===== | ||
| - | The digital circuit we are building from Project 1 is called led_sw. With this project, the FPGA is receiving an input signal, in this case from an embedded switch, that can be logic high, ' | + | The digital circuit we are building from Project 1 is called led_sw. With this project, the FPGA is receiving an input signal, in this case from an embedded switch, that can be logic high, ' |
| ===== Relooking at the Simple Example HDL ===== | ===== Relooking at the Simple Example HDL ===== | ||
| Line 45: | Line 46: | ||
| ===== Programming our FPGA ===== | ===== Programming our FPGA ===== | ||
| - | > 0) If you haven' | + | > 0) If you haven' |
| > 1) On the opening screen, click on the '' | > 1) On the opening screen, click on the '' | ||
| Line 71: | Line 72: | ||
| > | > | ||
| - | > 7) After clicking next on the IP cores since we don't have any to add, click '' | + | > 7) After clicking next on the IP cores since we don't have any to add, click '' |
| > | > | ||
| > | > | ||
| Line 103: | Line 104: | ||
| > | > | ||
| - | > 15) Now we just need to add the functionality of how our circuit module we are creating on the FPGA that has a single input and a single output is going to work. This is done between the '' | + | > 15) Now we just need to add the functionality of how our circuit module we are creating on the FPGA that has a single input and a single output is going to work. This is done by declaring our inputs and outputs |
| >'' | >'' | ||
| + | > Press Cntl+S to save your changes. | ||
| > | > | ||
| > | > | ||
| - | > 16) Now we'll edit our constraints file. We can find our copy of the XDC in the sources window in the '' | + | > 16) Now we'll edit our constraints file. We can find our copy of the XDC in the sources window in the '' |
| > | > | ||
| > | > | ||
| - | > 17) Our XDC will become visible in the workspace window (as mentioned in the step above). As this is a master XDC file (at least for me) there' | + | > 17) Our XDC will become visible in the workspace window (as mentioned in the step above). As this is a master XDC file (at least for me) there' |
| > | > | ||
| > | > | ||
| - | > 18) | + | > 18) The two lines I will uncomment in this project will be the line corresponding to the first switch (labeled SW0 on the silk screen of the Arty) and the line corresponding to the first mono-color LED (labeled LD4 on the silk screen of the Arty). I renamed the switch (pin A8 on the FPGA) to sw and renamed the LED (pin H5 on the FPGA) to led. Press Cntr+S to save your changes. |
| > | > | ||
| > | > | ||
| - | click run synthesis, | + | > 19) Click the '' |
| - | > 19) | + | |
| > | > | ||
| > | > | ||
| - | choose synthesis options; This can take awhile | + | > 20) A wizard will pop up that will allow you to choose |
| - | > 20) | + | > As a side note, the whole combination of synthesis, implementation, |
| + | > When you are happy with your selections, click '' | ||
| > | > | ||
| > | > | ||
| - | synthesis running | + | > 21) After you click ok, you'll need to wait for the synthesis |
| - | > 21) | + | |
| > | > | ||
| > | > | ||
| - | click run implementation | + | > 21) Click '' |
| - | > 21) | + | |
| > | > | ||
| > | > | ||
| - | implementation running | + | > 22) After you click ok, you'll need to wait for the implementation |
| - | > 22) | + | |
| > | > | ||
| > | > | ||
| - | click generate bitstream on the wizard | + | > 23) Another |
| - | > 23) | + | > As a side note, you may not necessarily want to click the '' |
| + | > After this screen you will be able to choose some bitstream generation options, much like for synthesis and implementation. When you are happy with your selections, click '' | ||
| > | > | ||
| > | > | ||
| - | generate | + | > 24) After you click ok, you'll need to wait for the bitstream |
| - | > 24) | + | |
| > | > | ||
| > | > | ||
| - | click open hardware manager | + | > 25) Click '' |
| - | > 25) | + | |
| > | > | ||
| > | > | ||
| - | if your FPGA is not connected already, you'll see a '' | + | > 26) If your FPGA is not connected |
| - | > 26) | + | |
| > | > | ||
| > | > | ||
| - | You'll be able to click the '' | + | > 27) Make sure your FPGA is connected to your computer |
| - | > 27) | + | |
| > | > | ||
| > | > | ||
| - | You'll then be asked to choose the bitstream file (we don't have a debug core in our code, so we won't put anything in that field) | + | > 28) You'll then be asked to choose the bitstream file that we are to program the FPGA with; we don't have a debug core in our code, so we won' |
| - | > 28) | + | |
| > | > | ||
| > | > | ||
| - | The bitstream file itself is a little unintuitive to find. You can find it by opening up the folder where you told Vivado to initially save your project, go to < | + | > 29) The bitstream file itself is a little unintuitive to find. You can find it by opening up the folder where you told Vivado to initially save your project, go to '' |
| - | > 29) | + | |
| > | > | ||
| > | > | ||
| - | click '' | + | > 30) Finally, we can click '' |
| - | > 30) | + | |
| > | > | ||
| > | > | ||
| Line 188: | Line 181: | ||
| Now we're done! The way this project was setup, the first switch (labeled '' | Now we're done! The way this project was setup, the first switch (labeled '' | ||
| - | + | {{: | |
| - | need to make this look pretty rather than crazy with the picture labels and orientation. Perhaps I should do the whole picture captions beneath the image and the steps 1.1) with the arrows >... bother FIXME | + | |
| ==== Multiple Switches and LEDs ==== | ==== Multiple Switches and LEDs ==== | ||
| + | But why restrict ourselves to a single input and a single output? Perhaps instead we want create a '' | ||
| + | |||
| + | As I am using the [[https:// | ||
| + | |||
| + | This tutorial presumes that you created a new project to for the bus inputs and outputs, but you can easily modify your existing project to accept these additions. | ||
| + | |||
| + | > 1) The same process of a creating a Vivado project was followed; a top module was created, no IP was added, and the Master XDC file was copied into the local directory. Once we confirm our project settings, we can then create our new module with buses on the module wizard that appears. For each input or output that you want to be a bus, check the '' | ||
| + | > | ||
| + | > | ||
| + | |||
| + | > 2) Once the corresponding Verilog module has been created, we can '' | ||
| + | > | ||
| + | > | ||
| + | |||
| + | > 3) The XDC file will also need to be edited so that Vivado knows which FPGA pins we intend to use. With this Master XDC file, the names of the pins for both the switches (shown) and the LEDs (not shown in the image) are already named in such a way so that they match the names used in our Verilog module. You could change the names in both the module and the XDC file to something else, but why do more work if it is already legible? | ||
| + | > | ||
| + | > | ||
| + | |||
| + | > 4) Here's what the Arty looks like with SW0 switched " | ||
| + | > | ||
| + | > {{learn: | ||
| + | |||
| + | > 5) It is also possible to assign a bus of outputs the value of a bus of inputs. The trick here is that you need to use the bit-wise negation operator, '' | ||
| + | > | ||
| + | > {{learn: | ||
| + | |||
| + | > 6) Here's what the Arty looks like for the above code with SW3 switched " | ||
| + | > | ||
| + | > {{learn: | ||
| - | The above assign statement gives the current value of sw (switch) to led (an LED). | + | ==== Taking it one step further ==== |
| - | Because HDL in general (not just Verilog) describes an actual circuit that will | + | Try using some of the external I/O rather than the embedded I/O on your system board. You can even keep the Verilog module code exactly |
| - | be implemented onto the FPGA, rather than telling a processor what to do like in | + | |
| - | a microcontroller which is limited by its internal clock that dictates | + | |
| - | the above statement that assigns | + | |
| - | in real time, or at least as fast as it takes the electricity | + | |
| - | the switch to the FPGA and then directly | + | |
| ===== Important Takeaways from Project 2 ===== | ===== Important Takeaways from Project 2 ===== | ||
| - | * | + | * Creating single bit and multi-bit inputs and outputs |
| + | * Assigning input ports to output ports for single bits, bits within bus's, and bus's to bus' | ||
| + | * Confidence in going through the Vivado design flow from creating a project, editing it, and programming the system board | ||
| - | tags to be added after I add in curly braces in the code below\\ | ||
| - | '' | ||

