Lab 1
Lab 1
Introduction to Spartan-3E
and
Xilinx ISE
Mainak Chaudhuri
Indian Institute of Technology Kanpur
Sketch
• Brief on Xilinx Spartan-3E FPGA
• Xilinx Integrated Synthesis Environment
(ISE)
– Example implementation of a full adder
• Verilog HDL
• Schematic
2
Field-programmable gate array
• Two-dimensional array of generic
logic/storage cells interconnected by
programmable switches
– Each cell can be programmed to carry out simple
combinational functions
– The interconnection switches can be
programmed to decide how the result of one
function is input to another function or stored in
memory
– Typically the programming bits are downloaded
to the FPGA and the circuit is ready
• Done in the field as opposed to in the fabrication
facility; hence the name FPGA
3
Field-programmable gate array
10
Xilinx ISE
• Rest of the slides go over multiple examples
demonstrating how to use Xilinx ISE
– Can simulate Verilog code
– Can synthesize hardware on Spartan-3E FPGA
• Synthesizing a hardware means programming the
FPGA so that it models the desired hardware
• A subset of the CLBs, RAM blocks, multipliers, and the
switches will participate in implementing the specified
hardware
• In this lab, you will do two syntheses
– Full adder: Verilog to synthesis
– Full adder: Mixed Verilog and schematic to
synthesis
– Each synthesis task carries two marks 11
Xilinx ISE
• Insert your USB stick in the USB drive and
accept ok when it prompts for opening the
medium
• Create a new directory/folder in your USB
stick
– You may call it CS220Labs
– For today’s lab, create two directories/folders
under CS220Labs
• You may name them Lab1_1, Lab1_2
12
Xilinx ISE
• Open a terminal and enter the command
/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ise
– Will start Xilinx ISE
• Click ok on “Tip of the Day” panel
13
Xilinx ISE
• In the Xilinx Project Navigator
– Click on File->New Project
– In Location box, write /media/CS220Labs/Lab1_1
– In Name box, write full_adder
– Select HDL in top-level source type
– Click on Next
– For Evaluation Development Board, select
Spartan-3E Starter Board
– Leave everything else unchanged and click Next
– Click Finish
14
Xilinx ISE
• In the Xilinx Project Navigator
– Click on Project->New Source
– Select Verilog Module from left menu
– Write full_adder in File name box
– Tick the Add to project box
– Click Next
– Leave everything blank in the next page and
click on Next
– Click Finish
– full_adder.v should automatically open in the
right pane of Xilinx Project Navigator
– You need to fill in the module full_adder
15
Xilinx ISE
module full_adder(a, b, cin, sum, cout
);
input a;
input b;
input cin;
output sum;
wire sum;
output cout;
wire cout;
endmodule
16
Xilinx ISE
• In the Xilinx Project Navigator
– Save your Verilog module by clicking the save
icon in the menu bar above
– Up to this point the procedure is same for
simulation and synthesis
– We will now explore how to simulate the full
adder design using the Xilinx ISim simulator
17
Xilinx ISE: Simulation
• In the Xilinx Project Navigator
– We need to build a top-level environment Verilog
module
– Project -> New Source
– Select Verilog Test Fixture from the left menu
– Write full_adder_top in File name
– Tick Add to project box
– Click Next
– Click Next
– Click Finish
– The code for full_adder_top.v will open
automatically for editing
18
Xilinx ISE: Simulation
• In the Xilinx Project Navigator
– Remove the initial block and insert the following
code; leave everything else unchanged
initial begin
a = 0; b = 0; cin = 0;
#5
a = 0; b = 1; cin = 0;
#5
a = 1; b = 0; cin = 1;
#5
a = 1; b = 1; cin = 1;
#5
$finish;
end 19
Xilinx ISE: Simulation
• In the Xilinx Project Navigator
– Save the top-level module
– On left top side, change View from
Implementation to Simulation
21
Xilinx ISE: Synthesis
• Synthesis on FPGA does not require a top-
level module
– The FPGA board provides the environment
– The inputs are provided through switches and
buttons
– The outputs are observed through LEDs
– The inputs and outputs are specified through a
user constraints file (UCF)
• Close ISim and switch to ISE Project
Navigator
– Change View from Simulation to Implementation
22
Xilinx ISE: Synthesis
• We will map the three inputs on three slide
switches in the FPGA board
• We will map the two outputs on two LEDs
• Need to know the FPGA pin numbers
connecting to the switches and the LEDs
• Refer to Xilinx Spartan-3E user guide
– https://www.xilinx.com/support/documentation/
boards_and_kits/ug230.pdf
– Download and save it for future use
23
Xilinx ISE: Synthesis
• Pages 15 and 16 of Spartan-3E user guide
discuss the slide switches
– The UCF location constraints specify the pin
numbers (L13, L14, H18, N17) and IO standards
of the switches
– Note the location of the switches on your FPGA
board (should be in one of the corners)
27
Xilinx ISE: Synthesis
• PlanAhead pin assignment
– For each input (a, b, cin), select its row, and set
Site (L13, L14, H18), check Fixed, set I/O Std to
LVTTL, and Pull Type to PULLUP
– For each output (sum, cout), select its row, and
set Site (F12 and F9), check Fixed, Set I/O Std to
LVTTL, and Drive Strength to 8
29
Xilinx ISE: Synthesis
• Return back to the ISE Project Navigator
– Next step is to synthesize and implement the
design
– Double-click on Synthesize – XST option in the
second pane on the left (below User Constraints
option which you expanded)
– Once you get a green tick indicating completion
of synthesis, you can click on Design Summary
(Synthesized) at the bottom of the pane on the
right
• See how many CLB slices and LUTs your design has
consumed
30
Xilinx ISE: Synthesis
• In the ISE Project Navigator
– Double-click Implement Design option (just
below Synthesize – XST)
– Once this step completes successfully, you can
go back to the Design Summary (Implemented)
tab and select Pinout Report from the left menu
• Check that a, b, cin, sum, cout are mapped to the
correct pins
– Double-click Generate Programming File option
(just below Implement Design option on the
second left pane)
• This will generate the bits needed to program the
FPGA so that it can implement your design 31
Xilinx ISE: Synthesis
• In the ISE Project Navigator
– Double-click Configure Target Device option (just
below Generate Programming File)
• Click ok
• This will launch iMPACT, the Xilinx tool for
programming the FPGA
– In the FPGA board, the JTAG jumpers need to
configured correctly first
• Page 26 of the user guide shows the correct jumper
configuration (you need to keep only the middle
jumper connected)
• DO NOT LOSE ANY OF THE JUMPERS; BEFORE
RETURNING THE BOARD, REMEMBER TO PLACE THE
JUMPERS BACK
32
Xilinx ISE: Synthesis
• JTAG jumper configuration
33
Xilinx ISE: Synthesis
• After doing the jumper setting, power on the
FPGA board
– The red LED beside the power switch should
light up
– Connect the USB cable between the computer
and the FPGA board
• The green LED beside the cable port on the FPGA
board should light up indicating a healthy connection
• In iMPACT menu
– Double-click on Boundary Scan
– Right-click on the main area and select Initialize
Chain; select Yes 34
Xilinx ISE: Synthesis
• In iMPACT
– Automatically a file selection will open for
programming the FPGA
• Select
/media/CS220Labs/Lab1_1/full_adder/full_adder.bit
• It will ask you if you want to attach a PROM; say No
• Select Bypass for the next one
• Select Bypass for the next one too
– A Programming Properties selection menu will
open
• Click on Apply and then Ok
– You will see a chain of three devices
• The green one is the FPGA; the other two are memory
devices which we bypassed 35
Xilinx ISE: Synthesis
• Right-click on the green FPGA
– Select Program
– If the FPGA is programmed correctly it will say
Program Succeeded and you will see the orange
Done LED light up
• Now the FPGA is running your hardware
– We need to give inputs and observe the outputs
– Use the slide switches to provide values for a, b,
cin
– Check if the correct LEDs glow
• This concludes the first assignment of Lab1
36
Notes for healthy FPGA
• Always power on the FPGA after doing the
jumper setting
– Never change jumper setting with the FPGA
powered on
• Always connect the USB cable after powering
on the FPGA
• Always power off the FPGA before
disconnecting the USB cable
– Do not pull out the USB cable when the FPGA is
powered on
• Keep all jumpers connected to the board
when you are not using the board
37
Xilinx ISE: Synthesis
• Save the iMPACT project
– /media/CS220Labs/Lab1_1/full_adder/full_adder.i
pf
• File->Exit
– Agree to save when it asks
– This will close iMPACT
• We will now start the second assignment
38
Xilinx ISE: Assignment#2
• We will learn how to create schematics of
digital design in Xilinx
• Start a new project in Project Navigator
– File -> New Project
– Location: /media/CS220Labs/Lab1_2
– Name: full_adder_schematic
– Top-level Source Type: Schematic
– Click Next
– Select Evaluation Board
– Click Next
– Click Finish 39
Xilinx ISE: Assignment#2
• Idea of the assignment
– We will create a Verilog module to define a two
input xor gate
– We will use this xor gate to create a schematic of
the full-adder
– Next we will simulate this by writing a Verilog
Test Fixture
– We will also synthesize it on FPGA
40
Xilinx ISE: Assignment#2
• In Xilinx ISE Project Navigator
– Project -> New Source -> Verilog Module
• Name: myxor
• Next, Next, Finish
module myxor(x, y, z);
input x;
input y;
output z;
wire z;
46