Xilinx - Tutorial
Xilinx - Tutorial
Fundamentals of
Digital Systems
Objectives
To become competent in using the Xilinx ISE to:
Write VHDL code
Synthesize VHDL designs
Verify the results
View:
Block Diagram
Symbol Diagram
Logic Diagram
Truth Table
K-Maps
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
This is mainly a
summary page, but
make sure the
information is the
same as it appears
here. It specifies the
Spartan 3 boards
that we will use for
projects.
2/12/2013
10
2/12/2013
11
2/12/2013
New Source
12
2/12/2013
13
When finished, verify your info and click the [Next] button
2/12/2013
14
2/12/2013
15
This window
shows the files in
the project also
called the Design
Hierarchy window.
This window
shows the
summary
information and is
continually
updated. To get to
it, just click on the
tab.
This window
shows the
processes you
can execute for
the design file
highlighted
above just
double click when
you need to
execute one of
these
2/12/2013
16
The info on
this screen
will be
shown in
detail on the
next page
2/12/2013
17
entity adder4 is
Port ( Cin : in std_logic;
X3 : in std_logic;
X2 : in std_logic;
X1 : in std_logic;
X0 : in std_logic;
Y3 : in std_logic;
Y2 : in std_logic;
Y1 : in std_logic;
Y0 : in std_logic;
S3 : out std_logic;
S2 : out std_logic;
S1 : out std_logic;
S0 : out std_logic;
Cout : out std_logic);
end adder4;
architecture Structure of adder4 is
begin
end Structure;
2/12/2013
entity adder4 is
Port ( Cin : in std_logic;
X3 : in std_logic;
X2 : in std_logic;
X1 : in std_logic;
X0 : in std_logic;
Y3 : in std_logic;
Y2 : in std_logic;
Y1 : in std_logic;
Y0 : in std_logic;
S3 : out std_logic;
S2 : out std_logic;
S1 : out std_logic;
S0 : out std_logic;
Cout : out std_logic);
end adder4;
architecture Structure of adder4 is
begin
end Structure;
2/12/2013
begin
architecture Structure of adder4
is
end Structure;
2/12/2013
end Structure;
2/12/2013
entity adder4 is
Port ( Cin : in std_logic;
X3 : in std_logic;
X2 : in std_logic;
X1 : in std_logic;
X0 : in std_logic;
Y3 : in std_logic;
Y2 : in std_logic;
Y1 : in std_logic;
Y0 : in std_logic;
S3 : out std_logic;
S2 : out std_logic;
S1 : out std_logic;
S0 : out std_logic;
Cout : out std_logic);
end adder4;
architecture Structure of adder4 is
begin
end Structure;
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
Synthesize
The next step is to synthesize the design. The only
step you must take is to double click on
Synthesize XST
You may also double click on other actions or reports
Reports
Actions
2/12/2013
2/12/2013
2/12/2013
Double click on
the entity.
2/12/2013
2/12/2013
LUTs
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
50 of 130
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
Verification
The contents of the logic diagrams, truth
table, or K-Map should match the engineers
design.
If not, it is time to troubleshoot the VHDL files
If so, it is time to test the design
Develop a test bench and execute it
Download the file to the Spartan3 board and verify
the design
2/12/2013
56
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
Testbench Generator/Simulation
In version 7.1 of Xilinx, you could edit waveforms to create a test bench as shown below
To edit the waveforms, just click on
the blue box.
In this test bench, the ISE will add
the following numbers:
X=1, Y=1, Cin=0
X=2, Y=2, Cin=0
X=4, Y=4, Cin=0
X=8, Y=8, Cin=0
X=2, Y=1, Cin=0
X=7, Y=3, Cin=0
X=0, Y=1, Cin=1
Before moving on, save the project!!
2/12/2013
Testbench Generator/Simulation
No longer.
Version 11 was the last to use a graphical test
bench generator
Now we have to create a VHDL file
2/12/2013
Testbench Generator/Simulation
You create a test bench
program as a VHDL file to
simulate the logic of your
design.
2/12/2013
Testbench Generator/Simulation
2/12/2013
Testbench Generator/Simulation
The ISE will ask which VHDL file
you would like to simulate.
Because I want to simulate the
whole design, I will choose the
highest level design: adder4
Then click on [Next]
2/12/2013
Testbench Generator/Simulation
The next screen is an information
screen, click on [Finish]
2/12/2013
Testbench Generator/Simulation
A basic VHDL file template will appear
2/12/2013
Testbench Generator/Simulation
A basic VHDL file template will appear
Scrolling down
2/12/2013
Testbench Generator/Simulation
and down.
2/12/2013
Testbench Generator/Simulation
and down.
2/12/2013
Testbench Generator/Simulation
and then scrolling down.
2/12/2013
Testbench Generator/Simulation
and then scrolling down.
2/12/2013
Testbench Generator/Simulation
and then scrolling down.
2/12/2013
Testbench Generator/Simulation
and get.
2/12/2013
Testbench Generator/Simulation
and get. and .
2/12/2013
Testbench Generator/Simulation
Save everything
2/12/2013
Testbench Generator/Simulation
And the ISim window
appears
2/12/2013
Testbench Generator/Simulation
And the ISim window
appears
Zoom to full view
2/12/2013
Testbench Generator/Simulation
And this view come up,
but its hard to see with
everything packed
together.
2/12/2013
Testbench Generator/Simulation
And this view come up,
but its hard to see with
everything packed
together.
2/12/2013
Testbench Generator/Simulation
With the new dividers (I
also colored them black
an option on the pop up
menu), its easier to see
the different states of the
test.
2/12/2013
Testbench Generator/Simulation
With the new dividers (I
also colored them black
an option on the pop up
menu), its easier to see
the different states of the
test.
In the 1st division (from
100 to 200ns) we can see
that X=1 (x=0001) and
Y=1 (y=0001), so the sum
is 2 (s=0010).
2/12/2013
Testbench Generator/Simulation
With the new dividers (I
also colored them black
an option on the pop up
menu), its easier to see
the different states of the
test.
In the 1st division (from
100 to 200ns) we can see
that X=1 (x=0001) and
Y=1 (y=0001), so the sum
is 2 (s=0010).
In the 2nd division we
have X = 2, Y = 2, so the
Sum = 4
2/12/2013
Testbench Generator/Simulation
The marker is showing
the 6th division.
X = 7 (x=0111)
Y = 3 (y=0011)
and the sum is 10 with no
carry out
S = 10 (s=1010)
2/12/2013
Testbench Generator/Simulation
The marker is showing
the 6th division.
X = 7 (x=0111)
Y = 3 (y=0011)
and the sum is 10 with no
carry out
S = 10 (s=1010)
This also chows up in the
Value column
2/12/2013
Testbench Generator/Simulation
The marker is now
showing the 7th division.
Cin = 1
X = 0 (x=0000)
Y = 1 (y=0001)
and the sum is 2 with no
carry out
S = 2 (s=0010)
This also chows up in the
Value column
2/12/2013
2/12/2013
92
2/12/2013
Constraints File
# LEDs
# NET "LED0" LOC = "K12" ;
# NET "LED1" LOC = "P14" ;
# NET "LED2" LOC = "L12" ;
# NET "LED3" LOC = "N14" ;
# NET "LED4" LOC = "P13" ;
# NET "LED5" LOC = "N12" ;
# NET "LED6" LOC = "P12" ;
# NET "LED7" LOC = "P11" ;
# 50MHz oscillator
# NET "CLK50" LOC = "T9" ;
# pushbuttons
# NET "PB0" LOC = "M13" ;
# NET "PB1" LOC = "M14" ;
# NET "PB2" LOC = "L13" ;
# NET "PB3" LOC = "L14" ;
# NET "RSTPB" LOC = "M13" ;
# switches
# NET "SW0" LOC = "F12" ;
# NET "SW1" LOC = "G12" ;
# NET "SW2" LOC = "H14" ;
# NET "SW3" LOC = "H13" ;
# NET "SW4" LOC = "J14" ;
# NET "SW5" LOC = "J13" ;
# NET "SW6" LOC = "K14" ;
# NET "SW7" LOC = "K13" ;
2/12/2013
Constraints File
# LEDs
# NET "LED0" LOC = "K12" ;
# NET "LED1" LOC = "P14" ;
# NET "LED2" LOC = "L12" ;
# NET "LED3" LOC = "N14" ;
# NET "LED4" LOC = "P13" ;
# NET "LED5" LOC = "N12" ;
# NET "LED6" LOC = "P12" ;
# NET "LED7" LOC = "P11" ;
# 50MHz oscillator
# NET "CLK50" LOC = "T9" ;
# pushbuttons
# NET "PB0" LOC = "M13" ;
# NET "PB1" LOC = "M14" ;
# NET "PB2" LOC = "L13" ;
# NET "PB3" LOC = "L14" ;
# NET "RSTPB" LOC = "M13" ;
# switches
# NET "SW0" LOC = "F12" ;
# NET "SW1" LOC = "G12" ;
# NET "SW2" LOC = "H14" ;
# NET "SW3" LOC = "H13" ;
# NET "SW4" LOC = "J14" ;
# NET "SW5" LOC = "J13" ;
# NET "SW6" LOC = "K14" ;
# NET "SW7" LOC = "K13" ;
2/12/2013
Constraints File
# LEDs
# NET "LED0" LOC = "K12" ;
# NET "LED1" LOC = "P14" ;
# NET "LED2" LOC = "L12" ;
# NET "LED3" LOC = "N14" ;
# NET "LED4" LOC = "P13" ;
# NET "LED5" LOC = "N12" ;
# NET "LED6" LOC = "P12" ;
# NET "LED7" LOC = "P11" ;
# 50MHz oscillator
# NET "CLK50" LOC = "T9" ;
# pushbuttons
# NET "PB0" LOC = "M13" ;
# NET "PB1" LOC = "M14" ;
# NET "PB2" LOC = "L13" ;
# NET "PB3" LOC = "L14" ;
# NET "RSTPB" LOC = "M13" ;
# switches
# NET "SW0" LOC = "F12" ;
# NET "SW1" LOC = "G12" ;
# NET "SW2" LOC = "H14" ;
# NET "SW3" LOC = "H13" ;
# NET "SW4" LOC = "J14" ;
# NET "SW5" LOC = "J13" ;
# NET "SW6" LOC = "K14" ;
# NET "SW7" LOC = "K13" ;
2/12/2013
The names (in quotes) associated with the LOC keyword are
associated with the Spartan3 board.
These names must not be changed!!!
Constraints File
# LEDs
# NET "LED0" LOC = "K12" ;
# NET "LED1" LOC = "P14" ;
# NET "LED2" LOC = "L12" ;
# NET "LED3" LOC = "N14" ;
# NET "LED4" LOC = "P13" ;
# NET "LED5" LOC = "N12" ;
# NET "LED6" LOC = "P12" ;
# NET "LED7" LOC = "P11" ;
# 50MHz oscillator
# NET "CLK50" LOC = "T9" ;
# pushbuttons
# NET "PB0" LOC = "M13" ;
# NET "PB1" LOC = "M14" ;
# NET "PB2" LOC = "L13" ;
# NET "PB3" LOC = "L14" ;
# NET "RSTPB" LOC = "M13" ;
# switches
# NET "SW0" LOC = "F12" ;
# NET "SW1" LOC = "G12" ;
# NET "SW2" LOC = "H14" ;
# NET "SW3" LOC = "H13" ;
# NET "SW4" LOC = "J14" ;
# NET "SW5" LOC = "J13" ;
# NET "SW6" LOC = "K14" ;
# NET "SW7" LOC = "K13" ;
2/12/2013
The names (in quotes) associated with the LOC keyword are
associated with the Spartan3 board.
These names must not be changed!!!
Spatan3 Board
Xilinx IC
LEDs
7-Segment LEDs
2/12/2013
SPST Switches
2/12/2013
2/12/2013
100 of 130
# switches
NET X0" LOC = "F12" ;
NET X1" LOC = "G12" ;
NET X2" LOC = "H14" ;
NET X3" LOC = "H13" ;
NET Y0" LOC = "J14" ;
NET Y1" LOC = "J13" ;
NET Y2" LOC = "K14" ;
NET Y3" LOC = "K13" ;
# pushbuttons
NET Cin" LOC = "M13" ;
2/12/2013
The LEDs are assigned to S0, S1, S2, S3, and Carry out
The input SPST switches are assigned as follows:
X0 = SW0
X1 = SW1
X2 = SW2
X3 = SW3
Y0 = SW4
Y1 = SW5
Y2 = SW6
Y3 = SW7
There were no switches left for the Carry in, so Carry in
was assigned to Push Button 0, which means it will have
to be held steady when the design is executed
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
2/12/2013
Y switches X switches
I then tested:
3+4 (X=3, Y=4)
The result was 11
(Not so good)
hmmmmm.
2/12/2013
Y switches X switches
0011 = 3
Troubleshooting
The problem had to be
somewhere in the design or
in the *.ucf file. If in the
design, it could be in the
adder4 design or the fulladd
design (the sub-circuit)
hmmmm.
2/12/2013
Troubleshooting
The problem had to be
somewhere in the design or
in the *.ucf file. If in the
design, it could be in the
adder4 design or the fulladd
design (the sub-circuit)
hmmmm.
So, I opened the ISE and
staring me in the face was
the UCF!!
I noticed that I had
unintentionally, assigned S2
(sum, bit 2) to both LED2 and
LED3, but I left out S3 (sum
bit 3, the MSb of the result.
2/12/2013
Troubleshooting
The problem had to be
somewhere in the design or
in the *.ucf file. If in the
design, it could be in the
adder4 design or the fulladd
design (the sub-circuit)
hmmmm.
So, I opened the ISE and
staring me in the face was
the UCF!!
I noticed that I had
unintentionally, assigned S2
(sum, bit 2) to both LED2 and
LED3, but I left out S3 (sum
bit 3, the MSb of the result.
2/12/2013
Troubleshooting
So I fixed the problem and
saved everything
Then I re-implemented the
design, I re-generated the
programming file, I reconfigured the target device
And then I re-downloaded the
program
2/12/2013
I then tested:
3+4 (X=3, Y=4) again
The result was 7
(ahhh.)
Y switches X switches
2/12/2013
0011 = 3
I then tested:
3+4 (X=3, Y=4) again
2/12/2013
Y switches X switches
0011 = 3
Summary
In this topic, we :
Wrote VHDL code
The main design
A component (a sub-design or sub-circuit)
A UCF file
2/12/2013
Block Diagram
Symbol Diagram
Logic Diagram
Truth Table
K-Maps
130
Summary
In this topic, we :
Simulated the design
Developed a testbench waveform
Simulated the testbench with ModelSim
Verified the results
2/12/2013
131