Lab #3: FPGA Design
Fall 1997
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.
In ~pc/352/lab3 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.
Draw a schematic of this circuit at the block diagram level. Each block should be a process.
The PCs are setup as network PCs. This means that they run diskless and all the files are found on the network. This makes for much easier system administration because each PC will be exactly the same. Security is also easier because you cannot introduce any viruses! The system software partitions are not writable by users.
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.
Double click on the FPGA Express (Synopsys) icon. For the rhythmically challenged, the middle button will do a double click.
At this point, your file is being analyzed, which is doing a first-pass compile of your program. If you are bored, you can watch the train zoom along in the logo. This is the step where syntax errors will be flagged. The program you copied should work correctly so you will see a 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. You can select the file with the errors and go to View Errors/Warnings. To get more information on an error, you can double click on it.
To edit the file, you can right click on it (lc.vhd) in the source window. To analyze the file, use Synthesis Analyze All or find the shortcut button on the tool bar.
Next you must identify the top-level design. This is in case your circuit is in several files. Pull down the list in the middle of the tool bar and select lc-RTL. The RTL comes from the architecture specification in the source code.
In the Create Implementation window, you will specify the target chip:
If you get errors, you can double click the message in the error viewer for more information. Here, you should see a design name show up called lc-RTL-0. Double click this and go to the Ports tab. Here we have to specify some information about pin 13 (XCBUS13). Observe on the schematic, that this pin is connected to the clock and it is also labeled as PGCK1. This means that this pin has a special internal buffer that is connected to an internally routed clock network. To use this buffer, go to the cell under Global Buffer for XCBUS13 and select bufgp. Use the X icon to close the window and save the file.
Now, you can do the final step. At this point, the circuit is in an intermediate form that must now be optimized and targetted for the actual chip. Select Synthesize Optimize or find the shortcut button.
You will now see lc-RTL-0-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. Go to File Export Netlist or find the short cut button. (Observe that the main steps you need to carry out are in the three buttons on 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.
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. For our purposes, we will try to skip this step as your circuits should not be too complex.
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. Again, 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 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 signal is high, independent of the clock. You should put Reset on 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. Put it on pin 45. The four bits to be loaded can be put on pins 46-49. Make pin 49 be the most significant bit. Since you only have six input bits, you should can 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.