Lab #2: FPGA Design
Fall 1998
In this lab you will be introduced to the use of some commercial CAD tools for FPGA design. The tools that you will use are FPGA Express from Synopsys and the Xilinx Foundation Series software. Synopsys and Xilinx now have an agreement that will see Xilinx fully integrate the FPGA Express package into the Xilinx tools. This version, F1.4, is not quite there. For this lab we will only work with the back-end tool of the Xilinx tool set, called the Design Manager. This takes a netlist generated by FPGA Express and maps it into the chip.
In ~pc/352/lab2 you will find a sample vhdl program called lc.vhd and another file called lc.ucf. Make a new directory in your own account and copy the files there.
Examine lc.vhd and try to understand it. The circuit will use the seven-segment LED display on the board.
Signal names of the form XCBUSnn correspond to the pin names shown on the schematic for the board. You should be able to identify the signals that are connected to the display.
The board has a 12-MHz clock so to make things visible the clock is first divided down to generate a slower clock. You can see this being done in the CLOCK_DIVIDER_PROCESS process.
The COUNT_PROCESS implements a BCD counter that is clocked with the slow clock.
The LIGHT_DISPLAY_PROCESS does the decoding of the counter output into the signals to turn on the display.
The interconnection of the three processes is done by variables that are declared as signals, which you should think of as wires.
The PCs are setup with Windows'95 on the local drive. When you boot the machine, you will be asked whether to reinstall (1) or check (2) the current installation. If you suspect that something has been corrupted, then you can do the reinstall and that will copy a complete new version of everything onto your local drive. Be warned that this takes many minutes. Also, if the system has been upgraded, then you will need to do the reinstall to upgrade the version on your local disk. Normally, and if you do not answer quickly enough, it will just default to checking a bunch of files.
Most of the tools that we will be using are actually mounted on a network drive, X:, not the local drive.
To be able to save files, you can attach (or mount) your ugsparc directory to a drive on the PC. By convention our software assumes that user files are mounted on the w: drive. You can run an automatic script to do this.
Hit the Windows Start button and then Run. Enter xilinx your_ugsparc_login. This will do two things. It will mount your ugsparc account on w: and it will start up the Xilinx Design Manager. Minimize the Design Manager for now, using the icon in the upper right that looks like an underscore. Do not kill it using the X icon.
To start FPGA Express go to the Start Menu:
At this point, your file is being analyzed, which is doing a first-pass compile of your program. This is the step where syntax errors will be flagged. The program you copied should work correctly so you will see a Design Sources window with lc.vhd in it and a check mark.
If you happen to get errors at this point, then you will see an X instead of the check mark and errors in the Error window. To get more information on an error, you can double click on the error number.
To edit the file, you can right click on it (lc.vhd) in the source window and select the editor or you can edit it outside of the Foundation tool. After modifying the file, you should see a question mark (?) icon next to the name of the file. This means that the file needs to be analyzed again. To analyze the file, right click the file name in the Design Sources Window and Update or find the shortcut button on the tool bar.
Next you must identify the top-level design. This is required in case your circuit is in several files. Pull down the list in the middle of the tool bar and select lc. You can also double click the source file to expand it. Then select the lc icon, right click it, and select Create Implementation.
In the Create Implementation window, you will specify the target chip:
If you get errors, you can double click the error number in the error viewer for more information. Now, you should see a design name show up called lc in the Chips window. At this point, the circuit is in an intermediate form that must now be optimized and targeted for the actual chip. Select lc in the Chips window, right click it and select Optimize Chip or find the shortcut button. You will now see lc-Optimized show up in your list of designs. There are some warnings that you can view, but we can ignore them.
The final step is to create a net list of your circuit. This net list describes the actual interconnection of the logic cells and the function in each cell. This net list will be taken to the next step. Select lc-Optimized, right click it, and select Export Netlist or find the short cut button. (Observe that the main steps you need to carry out are in the tool bar on the right.) You will need to specify the directory where to put the net list file. You can just keep it in the directory that you are working in. You should find some files with the suffix .xnf. These are the Xilinx Netlist Format files.
The next major phase of this process is to do what is called Place and Route. Recall that you can think of an FPGA as having a number of fixed sites of programmable logic cells. The Place step tries to find a reasonable site for each of the gates that have been listed in the net list. Important constraints include the length of wires that are needed and critical path delays. The Route step tries to assign specific wires for each of the connections that are required once the placement of the cells has been done.
To do this phase of the design, you must use a Xilinx implementation tool. Start up the Design Manager that you originally started at the beginning. It should be on the tool bar at the bottom.
Go to File
New Project.
In the New Project window:
You should now select the design to implement. It should already be highlighted: lc.
Now hit Design
Implement.
This should get you the Implement window:
Now click Open
At this point, the Flow Engine starts up. This will show you what is happening to your design. You can also stop and back up the compilation, if for example, there is an error and you need to start over.
The final output of this process is a .bit file that contains the data to program the FPGA.
We have two versions of the FPGA board. Version 1.0 has two 25-pin DB-25 connectors. Version 1.2 has on 25-pin DB-25 for the parallel port and a VGA monitor connector. I guess if you want to make a graphical output, make sure that you get this board!
The schematics for the two boards are attached. They will also be made available via the web as a pdf file.
Now you need to download the bit file to the board to program the
FPGA.
Get a DOS window (Start
Run
command) or click the MS DOS shortcut icon on the desktop.
Go to the directory with your bit file.
Run the xsload command.
w:\labs\ledcount xsload lc.bit
When this completes, you should see the display counting.
Most of the manuals for modern tools are found online, so you can search the help directories. Often it is easier to find someone that has done it before.
After you get the net list from compiling the VHDL code, you should also be able to simulate it. This is where you may find problems that the VHDL compiler caused when it translated your circuit. This can be done with the front-end of the Foundation tools. I'll provide more information about it later.
After you place and route your circuit, you can extract timing information. The actual placement and wires will introduce different delays than were used during functional simulation. This will give you a much more accurate picture of how fast your circuit will run. We will skip this. Our emphasis will be on getting functionality.
w:\labs\ledcount xsport 1
will set a 1 on the least significant bit (XCBUS44) and zero on the rest. The pins that you can access are XCBUS49, XCBUS48, XCBUS47, XCBUS46, XCBUS45, and XCBUS44. The value 1011 will set a one on XCBUS47, XCBUS45, and XCBUS44. The rest will have zero.
Copy the program and try to add an asynchronous Reset signal. This signal should force the counter to zero as long as the Reset signal is high, independent of the clock. You should map Reset to pin 44 so that you can control it with xsport.
Once you have Reset working, add a synchronous preset. This means that on a clock edge you will want to load four bits into the counter. You will need a Preset signal. Map it to pin 45. The four bits to be loaded can be mapped to pins 46-49. Make pin 49 be the most significant bit. Since you only have six input bits, you should be able to manipulate your circuit using xsport.
If you still have time, try making your circuit count up or down, or even count by different increments. You can add other inputs using switches.
Prepare modified versions of the counter program that will implement the above functions.