Software apps and online services
Tha aim of this project is to show you how implement a simple BCD decoder using BASYS 3 board.
Before starting I want to remind you what is a decoder circuit.
A decoder is a combinational circuit that is able to select one of the 2^N lines of output depending the particular combination of the N input boolean variables.
If we are operating in positive logic, then the selected output line goes to high value while the others go to low value, in case of negative logic the behaviour is the opposite.
In this project we'll use the switches on the board as inputs of the decoder circuit, then each output line will be connected to a particolar segment of the 7 segments display. So we can say that our design requires 4 inputs and 7 outputs.
I suggest you to go at this page, here you'll find a reference manual of the board and a lot of useful information to get start your designs using BASYS 3.
The BASYS 3 is equipped with a four digit 7 segments display as you can see on the reference manual. The displays are connected in common anode while every cathode is separate. For the project we will use only the display labeled as AN0.
For doing this, we will use a 4 digit enable signal in order to turn on only the AN0 display.
The picture below shows the routing between the display and the Artix-7. As you can see, the board uses 4 PNP transistors to drive each display. In order to drive only AN0 display, the PNP transistor must operate in saturation region, as an electronic switch. This behaviour is simply obtained by putting U2 high and the other signals (W4,V4 and U4) low. Therefore we have defined the output block, concerning the inputs we will use the first four switches SW0,SW1,SW2,SW3. As you can see they can commutate between 3.3V and GND that corresponds respectively to '1' and '0' for our combinational circuit.
Note that you can easily identify the switches since there is a serigraphy under every one, you have to search for V17, V16, W16 and W17.
Now that we have completely understand the functional specifications we can switch to Vivado Design Suite in order to write the Verilog code for the implementation.
I'll guide you through each steps. First of all start Viviado design suite by double clicking on the icon. Once it's started, you have to click on CreateProject under the Quick Start (upper left corner).
At this point you should see the wizard guide. Click on NEXT. Now name your project and select a location which you want to store it, if you want you can check the Create project subdirectory option. Once you finished, as before, click on NEXT.
Now you have to select RTL Project then click on NEXT
Now click on Create File then in the new tab select Verilog as File type, under file name you can use decoder, do not modify the file location tab. Click on OK to close the window (you should see a new file added) then click on NEXT.
Now you have to add the Basys3.xdc file by clicking Add files. You can find this file either on this tutorial or on the Basys3 webpage. Check the Copy constraints files into project so you'll add a local copy of the file to the project folder, then click on NEXT.
At this point you have to select the target FPGA. Be sure to select the appropriate target otherwise the design will not work. Basys 3 uses a Xilinx Artix-7 family FPGA, in particular it uses the XC7a35tcpg236-1. Let's explain how to read the part number:
- XC stands for Xilinx, for example EPM refers to Altera products
- cpg236 is the package with pin number
- -1 is the speed grade
After you select the correct target click on next. You'll see an overview of the choice made, if everything is corrent click on finish. On the next page that will appear click OK and skip the warning (it's not a problem, we'll define the ports after).
At this point you should see something like this:
After you have copied the code (decoder.v) you can run the Synthesis by clicking on it (flow navigator, red arrow). After the synthesis you can see the Synthesized design by clicking on schematic (green arrow).
Now we have almost finished the project. At this point we have to edit the.xdc constraints file by selecting it under Sources (double click on it).
At this point you can modify yourself the.xdc file (if you want to use other switch for example) or you can paste and copy the Basys3.xdc modified. Once you've done you can click directly on Generate Bitstream. The time during this phase depends on your PC performances. After this phase click on Open Hardware Manager (make sure the Basys 3 is connected at the PC via usb and is powered up).
At this point click on Oper Target, then auto connect.
Now under the Hardware tab, you should see the target. You can program the FPGA by clicking on program device and then by selecting the target. Do not modify anything, just press on the program button.
Congratulations !!! You've just programmed the FPGA. If everything went well, by moving the switches you should see the number display on the 7 segments display. This is my first project here on Hackster.io, I'll be very happy if you can provide me any kind of feedback on how to improve the presentation. See you soon :)