









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










information you need to know to successfully implement and verify your designs on the Digilent boards. If you follow the instructions carefully, you will have a pleasant and productive lab experience.
In this lab you will be implementing your designs on Field Programmable Gate Arrays (FPGA). This device contains many logic blocks that can be used to realize different kinds of functions. The interconnections between the logic blocks as well as the function each of these blocks realize can be programmed by the user. The FPGA has internal RAM memory cells for each connection on the device. By writing a '1' or a '0' in a given memory cell you are instructing the device to make a particular connection between logic blocks. The function that each logic block realizes also depends on the data that is stored in its internal memory. Basically, you have all the components that you will need for any of your designs but they are all unconnected and writing data in the memory cells will allow for the right connections to be made between the required components. But don't worry, except for your prelab you won't have to write any "ones" and "zeros" to implement your designs- the computer will do it for you.
You will be using the Digilent boards which include the Spartan XS10XL FPGA and many accessories to test the hardware, such as 4 seven-segment display units, eight LEDs, four push-buttons and eight logic switches. There are 84 pins on the board. But this doesn't mean they are all available for use. Many of these pins are special-purpose pins used to program or power-up the device and should be left unconnected.
There is a clock oscillator on the board (CCLK 1) that will be used to generate the clock signal required for your sequential circuits. It is
already connected to one of the pins (pin 13). Since the frequency of the oscillator is too high we will need to include a clock divider to generate a slower clock, suitable for counters and simple state machines. All the LEDs and input terminals are already connected to some of the pins on the board and can be controlled from within the FPGA. Don't worry if you don't understand what I mean by a clock or a sequential circuit. You will learn all this in class.
To be able to program the FPGA you need a bitstream file. The computer can generate this file but you still need to enter your design description in some way or another. This could be done by drawing schematics, by entering the HDL code of your design (HDL stands for Hardware Description Language), by drawing the state diagram or by any combination of these three methods. To generate your program file you will be using the Xilinx Foundation Series 3.3i. To enter the design specification you will use schematic capture. Once you have your .bit file you are ready to program the device and verify that it works.
I will try to include all the information that you need for all your designs. However, if you want to know more about the equipment you'll be using you can access the tutorials available online. Several related links are included at the end of this document. You should study this and/or other manuals to prepare for your lab session. Keep in mind that will be using state-of-the-art technology to implement your designs. There are about 10,000 usable gates inside the XS10XL FPGA, which means it can realize very complex logic, including small processors and microcontrollers. The digilent board can also be connected to a VGA monitor and can display up to 64 different colors on the screen and generate distinct patterns controlled by the device. In addition to this VGA port, there are also ports for audio, a mouse and a keyboard. If this is not enough, there are bigger boards available with around 250,000 gates. You can fit a complete computer inside them. The possibilities are endless. Be always prepared for your lab and get the most out of this experience.
Figure 1. Project Navigator Window. Notice the location of the Source, Process and Transcript windows. (Source: Xilinx Software manuals)
The source window presents the sources available in your project. A source is simply a file or module containing your design description or a component of it. You can double click on any of the sources to access and/or modify its contents. When you select a source, the process window shows you all the different options available for that particular type of file. From this window you can run all the process required to synthesize, implement and finally create the programming file for the FPGA. When you run a process you should pay close attention to the transcript window. You will find here all the information derived from the given process, including any warnings and errors produced during compilation time.
Under the Design Entry Utilities menu on the process window you will find the UCF file and express editor. We will be using this tool extensively to specify the location of the inputs and outputs of the designs. The User Constraints File (UCF) can also be used to enter time constraints, but you won't be required to do so. Below the UCF file you will find another very useful tool which allows you to create a schematic symbol with your design specifications. You will then be able to use this symbol as part of a higher level schematic and connect its inputs and outputs to other symbols and logic elements.
You can also access various processes' reports from the process window. You will need the Pad report to find the pins where your inputs and outputs are located on the board. The pad report also contains a list of the special pins on your device. Make sure nothing is connected to
these pins. The Place and Route report will tell you the amount of logic that your design utilizes and will give you a list of all the resources that are still available. If you would like to see an image of the FPGA containing your design, you should run Floor Planner. It will show you the final mapping of your design with all your inputs and outputs and the internal connections in the FPGA. Note that all these tools can be found under the Implementation menu on the process window.
Finally, after introducing the equipment and software tools, we are ready to start using them. The first thing you need to do after opening Project Navigator is to create a new project. This can be done by going to File ---> Create New Project and entering the project and device information. The following window will appear on the screen:
-Image from Xilinx Software manuals-
Choose an adequate project name. You will be assigned a directory on the D drive of the computer you are using or you might have to create a new one, ask your TA about it. Select Spartan as the device family, XS10XL 84-4 as the device and FPGA Express VHDL as the synthesis tool. Press "OK" and you are ready to create your first source. Select Project---> New Source and choose "schematic" as the source type. Press "Next" after you name it and "OK" to run the schematic editor. To add more sources to your project just follow the same procedure.
Position the mouse on top of each item to find out what it does. For example, the first item should be used to get a new symbol or component as shown next:
To illustrate how to enter schematics on the editor, we will design a simple 2-bit adder. The adder will add two binary numbers (A1A0 and B1B0) and a Carry input (Cin). It will output the Sum (Sum1Sum0) and a carry out (Cout). We will start by designing a Full Adder and we will use this design to create the 2-bit adder. The full adder equations are: Cout = (A and B) or (A and Cin) or (B and Cin) Sum = (A xor B) xor Cin ,
where A and B represent two single-bit numbers.
We will need three and-gates, two or-gates and two xor-gates to realize the full adder. All these gates can be found on the symbol menu of the editor. First click on the Add Symbol icon:
Select "all symbols" and look for the and2 item. Select this item and click on the screen to place it where you want. If you want to move it to a different place on the screen, select the "drag" item on the toolbar and click on the symbol. You can now drag your gate to the desired location and click again to put it there. It will look as follows:
Next, you need to add wires to the inputs and outputs of the gate. Select the "add wire icon" on the drawing toolbar. Click on a gate terminal to start drawing a wire and click again where you want the wire to end. Do the same for all the terminals until your gate looks like this:
Now, you need to name your inputs. Click on the "abc" icon on the
toolbar :. You can now type the name of your input net. Type "A" and press enter. Position the mouse right where the wire connected to the first gate input ends and click enter again. Then, name the second input "B". Make sure the schematic looks as follows
Next, you need to insert input marks to your schematic to make sure they are mapped to input pins on the board. Click on the "Add marker" item on the drawing toolbar.
Then, select "input" from the menu as shown next.
Now, you can click on each of your inputs to add the input pad mark. You will need to do the same for the outputs. Use the "Bidir" (bidirectional) mark for outputs that are also used as inputs to other
to create a new schematic source. Run the schematic editor for your new source. The symbol you just created should be located under the "local symbols" menu which can be accessed by selecting the "add symbol" item on the toolbar. Select the full adder symbol and put it on your schematic. The name of the symbol is the same name as the source containing the full adder. The symbol will look like this:
Add as many instances of your schematic symbol as you need. The 2-bit adder can be easily realized with two instances as follows:
You can now check for errors, save your work and close the editor.
Note that the two bit adder is a combinational circuit and does not require a clock input. For your sequential circuits you will need to include a clock divider block which will be connected to the 25.125MHz oscillator on the board and will output a clock with a frequency of around 1Hz, suitable for your counters and state machines. The complete schematic of a 2-bit counter realized with two JK flip-flops is shown below.
Ignore the chipsel and reset outputs, they are used here for a different purpose. Notice, however, that the schematic shows how to pull high or low any of your outpus by simply connecting them to the symbols Vcc or ground and using an output buffer (OBUF). If the clock divider symbol is not available from the local symbols menu, ask your TA to open the module for you.
You can also connect the outputs of the two-bit adder to a decoder and use them to drive a 7-segment display on the board and display the result of the sum. You can use the 7-segment devices for any of your
If you are planning to use a seven segment display unit, you need to direct each of the nets that drive the segments to the corresponding pins on the board. The LED segments are controlled by the following pins:
Ca P Cb P Cc P Cd P Ce P Cf P Cg P
Similarly, the anodes that "select" or enable the displays are connected to the pins:
To use the input switches and LEDs on the board, you need to direct your nets to the corresponding pins, as follows:
Finally, the puss-buttons can be accessed from the following pins:
The UCF file for the counter described in the previous section could look as follows. Note the clock (CLK) input is tied to pin 13. This pin is internally connected to the 25.125Mz oscillator. Unless you are using XSport to control your clock, you should always direct your clock input to this pin. The input "clear" is applied from the XSport utility (P4). In this example the two outputs Q0 and Q1 are sent to the second and first LEDs, respectively (P68 and P69).
NET CLK LOC = P13; # 25.125Mz oscillator NET Clear LOC = P4; # One of the inputs controlled from XSport NET Q0 LOC = P68; # Q0 and Q1 are sent to individual LEDs on board. NET Q1 LOC = P69;
The UCF file for a 2-bit adder that displays the sum on the 7- segment LED could look like this:
menu of the process window. Double click on it but first make sure the parallel cable is connected to the board and the device is correctly powered-up (you should be using a 5V DC adapter). Also, switch 9 on the board (SW9) should be set to "PROG". Run Hardware Debugger. It will detect the parallel connection automatically. Create a new project (File---
New -->Project). Next, choose the bitstream file you just created. It should be named after your source file and should have a "bit" extension. Now go to the "Download" menu and download your design. Wait until you see a message saying that the device is configured.
You are ready to verify the device configuration. Use the logic switches to verify your truth table entries. If you are using the parallel port input signals, you will need to run Xsport. First, change the setting on SW9 (switch 9 on board) to "PORT". Run XSPORT, modify the inputs and click on "strobe". This will effectively inject the values you entered. Repeat the same procedure until you are satisfied.
One important thing I noticed after implementing a few designs, is that the first two parallel port inputs (D0 and D1) seem to be driven HIGH when they are given a value of '0' through XSport and vice versa. The rest of the signals follow positive logic (HIGH is '1' and LOW is '0').
*Always verify you made the right connections in your schematic. Symbols that are too close will appear to be connected.
Remember that two nets (inputs, outputs or internal signals) cannot have the same name.
When you name a terminal you have to put the label right where the wire ends. No net was named if there is a red square below the label.
Remember to save your updated schematic before running any of the processes.
When editing the user constraint file, make sure the net names are exactly those you specified in your schematics. Don't forget the semicolon at the end of a line and to precede your comments with the # sign.
You cannot root more than one net to the same pin and you should not use any of the special purpose pins on the FPGA- Review the tables provided to root inputs to switches or outputs to LEDs.
When creating the programming file, make sure that the top level schematic is the one selected. The same applies for the UCF file: make sure you are editing the UCF file of
the source you want to implement.
*Remember to set SW9 to PORT when using XSPort and after the device was configured. Keep in mind the first two bits are inverted (D0 and D1) and be sure to click "strobe" to inject the values you entered.
There abundant resources on the web with more information about FPGAs and the Xilnx tools. · Xilinx Software Manuals: http://toolbox.xilinx.com/docsan/3_1i/ · Digilent board manual: http://www.digilent.cc/digilab_xl.html · Xilinx Data Book: http://support.xilinx.com/partinfo/databook.htm · Xilinx University Resource Center: http://xup.msu.edu/