CSE141L Lab 1: Tools of the Trade


CSE 141L Homepage | Lab Overview | Lab Description | Useful Resources


Deadline: Oct. 8 at 6PM
Changes:
  1. Oct. 4, 6PM: The deadline for lab 1 has been extended to Oct. 8.
  2. Oct. 2, Noon: Added clarification about requirements for updating adder.v so both 'out' and 'isOdd' are updated simultaneously.
  3. Oct. 2, 11:30AM: Added requirement for Q2 to show the updated adder.v code.
  4. Sept 29, 11AM: Updated screenshot of behavioral synthesis setup. The total clock period should be 1ns (500ps high, 500ps low). Sorry for the confusion.

Lab Overview:

Since you are new around here, we need to make sure you have all the tools to be a successful member of the AwesomeCore team. We expect you to have proficiency in both Xilinx ISE and Verilog. In order to get you up to speed, this lab will have you work through a simple tutorial on using Xilinx ISE. If you have worked with this tool in the past, this lab should be very easy. If not, you should get started immediately so you don't fall behind right away. In the future, you will be working with a partner to complete labs but for this lab you should work alone. Good luck!

Lab Deliverables:

Since this is an introductory lab, you will not be required to demonstrate anything at the end. The requirements are stated below.


Lab Description:

Jump to: Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6

Part 1: Install Xilinx ISE:

Xilinx offers a free version of their ISE design suite called the WebPack. You can download version 10.1 of the Xilinx ISE WebPack by going to their
website here. You will be required to sign up for an account before you can download the tools. Luckily it is free for an account.

We encourage you to also work in the CSE labs in the basement of the CSE building. Xilinx 10.1 should be installed on the windows partitions of all the computers in the lab. Please let us know (via the WebBoard) if you find lab computers that don't have Xilinx installed or have an older version of the software.

Part 2: Xilinx Quick Tutorial:

Xilinx provides a nice
step-by-step tutorial which will guide you through the very basics of creating and working with projects in Xilinx ISE. Since we will be using Verilog for your project, you can skip the sections on VHDL. Also, ignore the section titled "Download Design to the Spartan-3 Demo Board." The tutorial is short; it shouldn't take you more than an hour or two.

Part 3: A Simple 8 bit Adder

Having completed the Xilinx ISE tutorial, we will now examine a few of the aspects of hardware design by having you implement an 8-bit Adder.

At AwesomeCore, we just bought a couple new Virtex4 XC4VLX15 FPGAs. To get you started, your manager has given you a Verilog file (adder.v) that describes a basic 8-bit adder. Look at the file and make sure you understand it thoroughly. After doing so, create a new project in Xilinx ISE that contains this adder. When creating the project, remember to set the correct device (Virtex4 XC4VLX15) and simulator (ISE Simulator) to avoid problems later.

Q1 Draw a schematic for adder.v. In your schematic, you should clearly show the function of the design by using flip-flops, various gates, a comparator, an adder, and wires. Try to infer a schematic from the Verilog source, but it is fine to use a generated schematic from Xilinx ISE as long as it is detailed enough.

To see what is really going on, perform a behavioral simulation. You need to make a proper Testbench Waveform file as you did in the Xilinx tutorial. Use timing parameters in the figure below - it is equivalent to 1 GHz. Does it behave as you expected?

You might have noticed that output 'isOdd' is updated one cycle later than 'out'. (Stupid...who wrote this?) Anyway, it is a good opportunity to show your ability to tweak a design to get maximum performance. Modify the verilog file so that 'isOdd' is simultaneously updated with 'out'. Perform the same behavioral simulation you did in the previous step again. (Hint: You may want to examine blocking vs non-blocking assignment in Verilog.) Note: When updating your adder.v, both 'out' and 'isOdd' should be updated the cycle after the input(s) change, not two cycles later.

Q2 Include the modified version of adder.v. Also, draw a schematic for this modified adder.

Now that you have verified that your adder is functionally correct, it is time to synthesize. In the synthesize stage, Xilinx ISE translates your Verilog design to what its backend stage (implementation stage) can understand. To synthesize a design, just double-click "Synthesize-XST" in the "processes" window. Xilinx ISE generates reports for each major stage. You can read them in the 'Design Summary' tab as shown in the figure below. Skim through the generated synthesis report.

Q3 How many flip flops are used for the design? How many LUTs does XC4VLX15 have, and how many LUTs does your design use? What is the 'estimated' achievable maximum frequency? (Ignore numbers in the figure below.)

To actually program your FPGA, you need to "implement" your design. "Implement" is the term the Xilinx tools use for the stage which decides how to configure LUTs and networks of FPGA. For implementation, first you need to specify your timing constraints. You are targeting 1ns cycle time and 50% duty cycle as in the figure below. (You do not need to set 'clock-to-pad' and 'pad to setup' constraints.) With these constraints, Xilinx will generate a clock signal which alternates between high and low every 1ns. Then double-click "Implement Design". After implementation, Xilinx will generate a few reports. Skim through them.

If your timing constraint is unable to be met, you may get an an error during the "Place & Route" phase of implementation. Checking the 'static timing report' should give you a better idea of what your timing constraint needs to be changed to in order for the implementation to complete.

You can see detailed timing information in 'static timing report' (as in the picture below). In the report, you should look to see if you have any 'Slack' in your timing. Slack is the time delay difference between what you wanted (i.e. your timing constraints) and the actual delay. A positive slack implies that you met your constraints, while a negative slack implies just the opposite. To eliminate the negative slack, you need to loosen your timing constraints. If you have positive slack, you will not see all the detailed information shown in the screenshot below.

As you will learn in lecture, combination logic is implemented by using lookup tables (LUTs) in FPGAs. Input/Output Blocks (IOBs) provide an interface from the external world to the FPGA. Each FPGA has a set number of LUTs and IOBs that are available for use so you should be careful to not exceed that number when you are designing your processor.

Q4 How many 4-input LUTs and IOBs are used?
Q5 Was your initial time constraint met? If not, what is the minimum achievable cycle time? Change you timing constraints and implement your design again, making sure there is no negative slack in your implementation. In the figure above, the design has negative slack, which means it failed to meet timing constraints. What is the maximum operating frequency of your adder? Compare the frequency with 'estimated' minimum frequency you got in Q3. What caused the difference between the two values? (Hint: See how much time is used for logic and delay respectively.)

In order to prove that your adder works at a certain frequency, you need to do a post-route simulation. By comparing the results of your behavior simulation with post-route simulation, you can verify the validity of your implementation. Luckily, you can reuse the testbench from the behavior simulation you did earlier and the process for running the simualation is very similar. Select 'Post-route simulation' instead of 'Behavioral simulation' as shown in the following figure, then double-click 'Simulate Post-Place & Route Model'.


Q6 Include the two simulation results (behavioral and post-route) in your report. Are they the same as each other? If not, why are they different? If needed, modify the test bench file and make sure post-route simulation works correctly. (Hint: Behavioral simulations do not have a sense of frequency while post-route simulations do.)

Part 4: 32-bit Adder

Now that you have a working, validated 8-bit adder, you should turn your attention towards bigger and better designs. One simple extension you can do is to modify your adder to support 32-bit addition rather than just 8-bit. Modify your Verilog source file then synthesize and implement it.

Generally, the bigger and more complex your design is, the slower it will be. It is important to understand the main causes of this phenomenon:

Q7 Since your FPGA has limited hardware resources and you are always concerned about your performance, you should try to characterize the cost of different sizes of adders. Fill out the following table with information on adders ranging from 8 bits to 64 bts.
Width Max Freq (Synthesis report) Max Freq (post P&R report) # of used 4 input LUTs # of used IOBs
8-bit        
16-bit        
32-bit        
64-bit        

Part 5: Multiplier

Now that you are a master of adders, it is time to move on to bigger and better things. Your next task is to design a 32-bit multiplier. You can easily do this by modifying the Verilog adder. You should remember from your days in CSE140 that, unlike adders, multipliers have an output of (2 * width of input). Create a new project for your multiplier and modify your adder file as necessary. Your design should retain the 'isOdd' output.

After synthesizing your multiplier, skim through the generated synthesis report. You should notice that a new device, DSP48s, are being used in your multiplier. Since multipliers are frequently used in digital designs, most Xilinx FPGAs include a few highly optimized multipliers such as the DSP48.

Q8 Fill out the following table for 32-bit, 48-bit, and 64-bit multipliers. Note that some mulipliers might not fit in the XC4VLX15 due to their demands on resources. In such cases, explain the reason.
Width Max Freq (Synthesis report) Max Freq (post P&R report) # of used DSP48 # of used IOBs
32-bit        
48-bit        
64-bit        
Q9 Draw two graphs for adders and multipliers with bit width on the X axis and frequency (MHz) on the Y axis.

Part 6: Free Form Experiment

Now that you have gotten a feel for working with the Xilinx tools, it is time to play around with them.

Q10 Design an experiment that answers some kind of question you have about the tool, and report on the results.

Useful Resources


This lab created by Donghwan Jeon, 2007. Modified by Sat Garcia, 2008.