Академический Документы
Профессиональный Документы
Культура Документы
on
Prepared by
Shahzad Asif
Lecturer
MS (System on Chip)
Linköping University
Sweden
Outline
An Interactive Workshop
¾ Introduction to FPGA and HDLs
on
¾ Xilinx Design Flow
Field Programmable Gate Array (FPGA)
¾ How the code is synthesized to hardware
¾ Difference between synthesis and
Speaker: Shahzad Asif implementation
Lecturer (EE Department)
¾ Coding in VHDL
MS(System-
MS(System-on-
on-Chip)
Linkö
Linköping University, Sweden.
BEGIN
Flow Graph, Pseudo Code, .. 1
3
1
2 9
a_gt_b
IF a > b THEN 2 8
1
a_gt_b <= ‘0’;
a_eq_b
3
Logic Design 1
2
ELSIF a = b THEN
Physical Design a_gt_b <= ‘0’; 1 2 1
3
1
2 9
a_lt_b
2 8
END IF;
Manufacturing
END PROCESS;
END xyz;
Chip or Board 3 4
5 6
Page 2 of 66
An Interactive Workshop on FPGA
7 8
Page 3 of 66
An Interactive Workshop on FPGA
Block RAMs
Block RAMs
z usually refers to PLA or PAL.
¾ Complex PLD (CPLD) Blocks
z Consists of an arrangement of multiple SPLD-
SPLD-like blocks on a
single chip.
Field- Block
¾ Field-Programmable Gate Array
z Whereas CPLDs feature logic resources with a wide number of RAMs
inputs (AND planes), FPGAs offer more narrow logic resources.
z Offer a higher ratio of flip-
flip-flops to logic resources compared to
CPLDs.
13 14
31% 11%
FPGA Nomenclature
Design Implementation in LUT
2-input Lookup Table 2-input Lookup Table
performance
17 18
Page 4 of 66
An Interactive Workshop on FPGA
111 1 111 1 19 20
21 22
Shift operators
z NOT, AND, OR, NAND, NOR, XOR, XNOR z Shift left logic ’sll’
sll’
z Shift right logic ’srl’
srl’
¾ Arithmetic operators z Shift left arithmetic ’sla’
sla’
z Shift right arithmetic ’sra’
sra’
z Addition ’+’
Note: For shift operations, left operand must be of type BIT_VECTOR,
BIT_VECTOR, while the
z Subtraction ’-’ right operand must be an INTEGER.
z Multiplication ’*’ ¾ Concatenation operators
z &
z Division ’/’ (shift operation is used for division) z (, , , )
z Example: z <= x & ”10010”
10010”, z <= (’
(’1’, ’1’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’)
23 24
Page 5 of 66
An Interactive Workshop on FPGA
ENTITY MUX2to1 IS
¾ VHDL code is inherently concurrent (parallel) PORT (a, b : IN STD_LOGIC;
¾ Only statements inside a PROCESS, sel : IN STD_LOGIC;
q : OUT STD_LOGIC);
FUNCTION, or PROCEDURE are sequential. END MUX2to1;
¾ Concurrent code cannot be used to implement
ARCHITECTURE mux1 OF MUX2to1 IS
synchronous circuits. SIGNAL s1, s2 : STD_LOGIC;
BEGIN
a1 <= a and (not sel);
sel);
a2 <= b and sel;
sel;
q<= a1 or a2;
END mux1;
27 28
2-1 MUX using WHEN statement 2-1 MUX using WITH statement
29 30
Page 6 of 66
An Interactive Workshop on FPGA
Tri-
Tri-state Buffer Half Adder (Structural)
31 32
Components (Continued)
Components PORT MAP
¾ Allows the construction of hierarchical designs. ¾ Positional mapping (also called in-
in-order mapping)
¾ Used for partitioning a code, code sharing, and code
reuse. COMPONENT inverter
¾ To use (instantiate) a COMPONENT, it must first be PORT (a : IN STD_LOGIC;
declared. b : OUT STD_LOGIC);
END COMPONENT;
COMPONENT component_name
PORT (port_name : signal_mode signal_type; ... -- other code
port_name : signal_mode signal_type;
...); U1: inverter PORT MAP (x, y);
END COMPONENT;
33 34
Components (Continued)
PORT MAP
Full Adder
¾ Nominal mapping (also called out-
out-of-
of-order mapping)
¾ Ports can also be left unconnected by using the keyword ’OPEN’
OPEN’.
¾ Note that you should never leave the input port unconnected.
COMPONENT inverter
PORT (a : IN STD_LOGIC;
b : OUT STD_LOGIC; W1
W2
c : OUT STD_LOGIC);
END COMPONENT;
35 36
Page 7 of 66
An Interactive Workshop on FPGA
W3
37 38
DEVICE
DEVICE RESPONSE CAPTURE UNDER TEST
STIMULUS (DUT)
UNDER TEST AND
GENERATOR
(DUT) COMPARISON
39 40
41 42
Page 8 of 66
An Interactive Workshop on FPGA
Synthesis
Implementation
VHDL description Circuit netlist
ARCHITECTURE MLU_DATAFLOW OF MLU IS
SIGNAL A1:STD_LOGIC;
SIGNAL B1:STD_LOGIC;
SIGNAL Y1:STD_LOGIC;
SIGNAL MUX_0, MUX_1, MUX_2, MUX_3: STD_LOGIC;
BEGIN
A1<=A WHEN (NEG_A='0') ELSE
NOT A;
B1<=B WHEN (NEG_B='0') ELSE
NOT B;
Y<=Y1 WHEN (NEG_Y='0') ELSE
NOT Y1;
END MLU_DATAFLOW;
43 44
Translation
45 46
LUT0
LUT4
LUT1
FF1
LUT5
LUT2
FF2
LUT3
47 48
Page 9 of 66
An Interactive Workshop on FPGA
Placing Routing
FPGA CLB SLICES
FPGA CLB SLICES
Programmable Connections
49 50
Configuration Signals
¾ Once a design is implemented, you must create SIGNAL a : STD_LOGIC;
STD_LOGIC;
a file that the FPGA can understand
z This file is called a bit stream: a BIT file (.bit a
extension) 1 wire
51 52
c c
53 54
Page 10 of 66
An Interactive Workshop on FPGA
55 56
Page 11 of 66
An Interactive Workshop on FPGA
65 66
Page 12 of 66
An Interactive Workshop on FPGA
Page 13 of 66
An Interactive Workshop on FPGA
73 74
PROCESS(clk)
BEGIN
PROCESS(clk)
x(6) <= x(5);
BEGIN Equavalent Code x(5) <= x(4);
FOR i IN 0 TO 5 LOOP
x(4) <= x(3);
x(i+1) <= x(i);
x(3) <= x(2);
END LOOP;
x(2) <= x(1);
x(0) <= ’0’;
x(1) <= x(0);
END PROCESS;
x(0) <= ’0’;
END PROCESS;
75
Page 14 of 66
An Interactive Workshop on FPGA
Introduction to Modelsim
Page 15 of 66
An Interactive Workshop on FPGA
Page 16 of 66
An Interactive Workshop on FPGA
Step 2: Right click on the name of the file, and select Edit.
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY half_adder IS
PORT (a,b : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END half_adder;
Page 17 of 66
An Interactive Workshop on FPGA
Step 3: Simulate your VHDL code to verify that it is functioning correctly. If after
simulating the design you find an error, you can go back and make changes, recompile
the code, and re-simulate
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY half_adder_test IS
END half_adder_test;
COMPONENT half_adder
PORT (a,b : IN STD_LOGIC;
sum,cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
PROCESS
BEGIN
in1 <= '0';
in2 <= '0';
WAIT FOR 20 ns;
Page 18 of 66
An Interactive Workshop on FPGA
END arch_half_adder_test;
• Compile all the files(if an error occurs edit that particular file)
• Now click on menu Simulate ÆSimulate, following window will appear
Figure 5: Simulate
• Select the work and the test file. Then click OK.
• The design will be loaded.
• Now Select the Simulation Æ Run Æ Run All
• The results will be displayed in the text form.
• To, view the wave forms click on View Æ Signal, and View ÆWave.
• The following windows will appear.
Page 19 of 66
An Interactive Workshop on FPGA
Page 20 of 66
An Interactive Workshop on FPGA
Figure 8: Waveform
Page 21 of 66
An Interactive Workshop on FPGA
Page 22 of 66
An Interactive Workshop on FPGA
Step 1: First of all we need to start a new project. Do this by clicking FileÆ New Project.
The following window will appear.
Here you can set the project name, and other information.
Step 2: Now, we have to add a .VHDL file to the project. Click on, Project Æ New
Source. The following window will appear.
Page 23 of 66
An Interactive Workshop on FPGA
Step 3: Continue to next steps. We do not need to write any information during this.
Step 4: Now write the VHDL code as shown in the figure. After this select the “Edit
Implementation Constraints Editor”. We have to run the Editor for locking the pins. By
only double clicking this option we can run the Editor.
Page 24 of 66
An Interactive Workshop on FPGA
A new window will be opened. We have to lock the pins according to the Spartan I/Os.
The following are the pin numbers which we have assigned to our modules inputs and
output. All the inputs are connected to the switches on the Board and the we assign the
output to an LED.
You have to save this file and the close the Editor and return to the XILINX main
window.
Page 25 of 66
An Interactive Workshop on FPGA
Step 5: After giving the pin configuration run the synthesize command by simply double
clicking it or by selecting the synthesize option and then using the run command. The
green TICK on the ‘Synthesize’ button will indicate correct syntheses.
Step 6: After this double click the ‘Implement Design’ option. Green TICK on the
Implement button will indicate correct Implementation.
Step 7: The next step is to generate a bit file which can be downloaded in the FPGA.
This can be easily done by simply double clicking the ‘Generate Programming File’
option. If the bit file is generated successfully you will see the same green TICK on it.
Page 26 of 66
An Interactive Workshop on FPGA
Step 5: For the downloading of the bit file we have to use the utility of “Configure
Device iMPACT”.
Page 27 of 66
An Interactive Workshop on FPGA
This window tells us that the device connected is a valid device and it is ready to be
loaded with the bit file.
Page 28 of 66
An Interactive Workshop on FPGA
If no configuration file is assigned or if you want to assign a new configuration file then
select the 2nd option. A browser window will be opened and from here you can select the
bit file which you want to down load in the FPGA. In this example the bit file Name is
“and_gate.bit”.
After selecting the bit file you have to Program the device. After the successful
downloading has been done you will be given a success message.
Page 29 of 66
An Interactive Workshop on FPGA
ENTITY and_gate IS
PORT (a,b : IN STD_LOGIC;
output : OUT STD_LOGIC);
END and_gate;
BEGIN
END Behavioral;
Page 30 of 66
An Interactive Workshop on FPGA
Page 31 of 66
An Interactive Workshop on FPGA
LAB # 01
In this lab, we will design some small circuits in VHDL using the ModelSim tool. You
will use a typical HDL flow, write the HDL code, and run a functional HDL simulation.
• Half Adder
• Full Adder
• 4-bit Ripple Carry Adder (Structural)
• 4-to-1 Multiplexer
• Perform the basic design flow for writing VHDL code using concurrent statements.
• Understand the basic design for a testbench.
• Simulate a VHDL file using Modelsim.
• Analyze the simulation Results.
Page 32 of 66
An Interactive Workshop on FPGA
Half Adder
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY half_adder IS
PORT (a,b : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END half_adder;
ENTITY half_adder_test IS
END half_adder_test;
COMPONENT half_adder
PORT (a,b : IN STD_LOGIC;
sum,cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
PROCESS
BEGIN
in1 <= '0';
in2 <= '0';
WAIT FOR 20 ns;
Page 33 of 66
An Interactive Workshop on FPGA
END arch_half_adder_test;
Page 34 of 66
An Interactive Workshop on FPGA
Full Adder
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY full_adder IS
PORT (a,b,cin : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END full_adder;
ENTITY full_adder_test IS
END full_adder_test;
COMPONENT full_adder
PORT (a,b,cin : IN STD_LOGIC;
sum,cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
PROCESS
BEGIN
WAIT FOR 20 ns;
in_vector <= in_vector + '1'; -- std_logic_unsigned.all is
required
END PROCESS;
a <= in_vector(0);
b <= in_vector(1);
cin <= in_vector(2);
END arch_full_adder_test;
Page 35 of 66
An Interactive Workshop on FPGA
ENTITY RCA_4bit IS
PORT (a,b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
cin : IN STD_LOGIC;
sum : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cout : OUT STD_LOGIC);
END RCA_4bit;
COMPONENT full_adder2
PORT (a,b,cin : IN STD_LOGIC;
sum,cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
END arch_RCA_4bit;
ENTITY RCA_4bit_test IS
END RCA_4bit_test;
COMPONENT RCA_4bit
PORT (a,b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
cin : IN STD_LOGIC;
sum : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
Page 36 of 66
An Interactive Workshop on FPGA
input_a: PROCESS
BEGIN
WAIT FOR 20 ns;
a <= a + '1'; -- std_logic_unsigned.all is required
END PROCESS input_a;
input_b: PROCESS
BEGIN
WAIT FOR 20 ns;
b <= b + "0010"; -- std_logic_unsigned.all is required
END PROCESS input_b;
END arch_RCA_4bit_test;
Page 37 of 66
An Interactive Workshop on FPGA
4 to 1 Multiplexer
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY MUX_4to1 IS
PORT (in1, in2, in3, in4 : IN STD_LOGIC;
sel : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
mux_out : OUT STD_LOGIC);
END MUX_4to1;
4 to 1 Multiplexer Testbench
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
USE IEEE.STD_LOGIC_unsigned.all;
ENTITY MUX_4to1_test IS
END MUX_4to1_test;
COMPONENT MUX_4to1
PORT (in1, in2, in3, in4 : IN STD_LOGIC;
sel : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
mux_out : OUT STD_LOGIC);
END COMPONENT;
BEGIN
PROCESS
BEGIN
WAIT FOR 100 ns;
in_vector <= in_vector + '1';
END PROCESS;
PROCESS
BEGIN
WAIT FOR 10 ns;
sel <= sel + '1';
Page 38 of 66
An Interactive Workshop on FPGA
END PROCESS;
mux1: MUX_4to1 PORT MAP (in1, in2, in3, in4, sel, mux_out);
END arch_MUX_4to1_test;
Page 39 of 66
An Interactive Workshop on FPGA
LAB # 02
In this lab, we will design some small circuits in VHDL using the Xilinx 4.1. You will
use a typical HDL flow, write the HDL code, and run a functional HDL simulation
(Modelsim is integrated with the Xilinx for simulation purpose). After simulation, you
will synthesize the HDL code and implement it on Spartan-I FPGA.
• Full Adder
• 4-bit Ripple Carry Adder (Using loop)
• 7-Segment Decoder
• 4-bit Ripple Carry Adder with 7-Segment decoder for observing output
• Perform the basic design flow for writing VHDL code using concurrent statements.
• Perform the hierarchical design, using component instantiation.
• Simulate a VHDL file using Modelsim (from Xilinx environment).
• Synthesize the VHDL code, and implement it on FPGA.
Page 40 of 66
An Interactive Workshop on FPGA
ENTITY full_adder2 IS
PORT (a,b,cin : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END full_adder2;
COMPONENT half_adder
PORT (a,b : IN STD_LOGIC;
sum,cout : OUT STD_LOGIC);
END COMPONENT;
BEGIN
END arch_full_adder2;
Page 41 of 66
An Interactive Workshop on FPGA
ENTITY RCA_4bit_2 IS
GENERIC (length : INTEGER := 4);
PORT (a,b : IN STD_LOGIC_VECTOR(length-1 DOWNTO 0);
cin : IN STD_LOGIC;
sum : OUT STD_LOGIC_VECTOR(length-1 DOWNTO 0);
cout : OUT STD_LOGIC);
END RCA_4bit_2;
END arch_RCA_4bit_2;
Page 42 of 66
An Interactive Workshop on FPGA
7-Segment Decoder
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
ENTITY seven_segment_decoder IS
PORT (data_in : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
data_out : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END seven_segment_decoder;
BEGIN
-- data_out(6,5,4,3,2,1,0) --> a, b, c, d, e, f, g
WITH data_in SELECT
data_decoded <= ('1','1','1','1','1','1','0') WHEN "0000",
('0','1','1','0','0','0','0') WHEN "0001",
('1','1','0','1','1','0','1') WHEN "0010",
('1','1','1','1','0','0','1') WHEN "0011",
('0','1','1','0','0','1','1') WHEN "0100",
('1','0','1','1','0','1','1') WHEN "0101",
('1','0','1','1','1','1','1') WHEN "0110",
('1','1','1','0','0','0','0') WHEN "0111",
('1','1','1','1','1','1','1') WHEN "1000",
('1','1','1','1','0','1','1') WHEN "1001",
('1','1','1','0','1','1','1') WHEN "1010",
('0','0','1','1','1','1','1') WHEN "1011",
('1','0','0','1','1','1','0') WHEN "1100",
('0','1','1','1','1','0','1') WHEN "1101",
('1','0','0','1','1','1','1') WHEN "1110",
('1','0','0','0','1','1','1') WHEN "1111",
(OTHERS=>'0') WHEN OTHERS;
END arch_seven_segment_decoder;
ENTITY seven_segment_decoder_test IS
END seven_segment_decoder_test;
ARCHITECTURE arch_seven_segment_decoder_test OF
seven_segment_decoder_test IS
COMPONENT seven_segment_decoder
PORT (data_in : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
Page 43 of 66
An Interactive Workshop on FPGA
BEGIN
PROCESS
BEGIN
WAIT FOR 10 ns;
data_in <= data_in + '1';
END PROCESS;
END arch_seven_segment_decoder_test;
Page 44 of 66
An Interactive Workshop on FPGA
ENTITY RCA_7_segment IS
PORT (a,b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
Seven_segment_out : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END RCA_7_segment;
Page 45 of 66
An Interactive Workshop on FPGA
LAB # 03
In this lab, we will design sequential circuits in VHDL using the Xilinx 4.1. You will use
a typical HDL flow, write the HDL code, and run a functional HDL simulation
(Modelsim is integrated with the Xilinx for simulation purpose). After simulation, you
will synthesize the HDL code and implement it on Spartan-I FPGA.
• Perform the basic design flow for writing VHDL code using concurrent and
sequential statements (Inside a Process).
• Understand of how to design a positive-edge or negative-edge flip-flop.
• Understand the working of a Process.
• Synthesize the VHDL code, and implement it on FPGA.
Page 46 of 66
An Interactive Workshop on FPGA
ENTITY freq_division IS
PORT (clk_in, rst : IN STD_LOGIC;
clk_out : OUT STD_LOGIC);
END freq_division;
BEGIN
PROCESS (clk_in,rst)
BEGIN
IF(rst='1') THEN
counter <= (OTHERS=>'0');
clk2 <= '0';
ELSIF (clk_in'EVENT AND clk_in='1') THEN
IF(counter=12500000) THEN
counter <= (OTHERS=>'0');
clk2 <= NOT clk2;
ELSE
counter <= counter + '1';
END IF;
END IF;
END PROCESS;
END arch_freq_division;
ENTITY freq_division_test IS
END freq_division_test;
COMPONENT freq_division
PORT (clk_in, rst : IN STD_LOGIC;
clk_out : OUT STD_LOGIC);
END COMPONENT;
Page 47 of 66
An Interactive Workshop on FPGA
BEGIN
clk_gen: PROCESS
BEGIN
LOOP
WAIT FOR 20 ns;
clk_in <= NOT clk_in;
END LOOP;
END PROCESS clk_gen;
rst_gen: PROCESS
BEGIN
rst <= '1';
WAIT FOR 30 ns;
rst <= '0';
WAIT;
END PROCESS rst_gen;
END arch_freq_division_test;
Page 48 of 66
An Interactive Workshop on FPGA
4-bit Counter
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
USE IEEE.STD_LOGIC_UNSIGNED.all;
ENTITY counter_4bit IS
PORT (clk, rst : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END counter_4bit;
COMPONENT freq_division
PORT (clk_in, rst : IN STD_LOGIC;
clk_out : OUT STD_LOGIC);
END COMPONENT;
BEGIN
PROCESS (clk_divided,rst)
BEGIN
IF(rst='1') THEN
counter <= "0000";
ELSIF (clk_divided'EVENT AND clk_divided='1') THEN
counter <= counter + '1';
END IF;
END PROCESS;
END arch_counter_4bit;
ENTITY counter_4bit_test IS
END counter_4bit_test;
COMPONENT counter_4bit
PORT (clk, rst : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END COMPONENT;
Page 49 of 66
An Interactive Workshop on FPGA
BEGIN
clk_gen: PROCESS
BEGIN
LOOP
WAIT FOR 5 ns;
clk <= NOT clk;
END LOOP;
END PROCESS clk_gen;
rst_gen: PROCESS
BEGIN
rst <= '1';
WAIT FOR 30 ns;
rst <= '0';
WAIT;
END PROCESS rst_gen;
END arch_counter_4bit_test;
Page 50 of 66
An Interactive Workshop on FPGA
ENTITY comb_multiplier4bit IS
PORT ( A : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
B : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
P : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END comb_multiplier4bit;
COMPONENT full_adder
PORT (a,b,cin : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END COMPONENT;
COMPONENT half_adder
PORT (a,b : IN STD_LOGIC;
sum, cout : OUT STD_LOGIC);
END COMPONENT;
SIGNAL C10, C11, C12, C13, C20, C21, C22, C23, C30, C31, C32, C33 :
STD_LOGIC;
SIGNAL S10, S11, S12, S13, S20, S21, S22, S23, S30, S31, S32, S33 :
STD_LOGIC;
BEGIN
Page 51 of 66
An Interactive Workshop on FPGA
P <= C33 & S33 & S32 & S31 & S30 & S20 & S10 & A0B0;
END arch_comb_multiplier4bit;
ENTITY comb_multiplier4bit_test IS
END comb_multiplier4bit_test;
COMPONENT comb_multiplier4bit
PORT ( A : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
B : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
P : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
END COMPONENT;
BEGIN
input_1: PROCESS
BEGIN
WAIT FOR 40 ns;
A <= A + '1'; -- std_logic_unsigned.all is required
END PROCESS input_1;
input_2: PROCESS
BEGIN
WAIT FOR 20 ns;
B <= B + "0010"; -- std_logic_unsigned.all is required
END PROCESS input_2;
Page 52 of 66
An Interactive Workshop on FPGA
END arch_comb_multiplier4bit_test;
Page 53 of 66
An Interactive Workshop on FPGA
LAB # 04
In this lab, we will design sequential circuits in VHDL using the Xilinx 4.1. You will use
a typical HDL flow, write the HDL code, and run a functional HDL simulation
(Modelsim is integrated with the Xilinx for simulation purpose). After simulation, you
will synthesize the HDL code and implement it on Spartan-I FPGA.
• Perform the basic design flow for writing VHDL code for an iterative algorithm.
• Perform the design flow for a circuit having combinational and sequential blocks.
• Synthesize the VHDL code, and implement it on FPGA.
Page 54 of 66
An Interactive Workshop on FPGA
ENTITY Booth_Multiplier4bit IS
PORT ( multiplier : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
multiplicand : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
product : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
valid_out : OUT STD_LOGIC);
END Booth_Multiplier4bit;
BEGIN
PROCESS(clk,rst)
VARIABLE state : integer;
VARIABLE count : integer;
BEGIN
IF rst='1' THEN
M <= "0000";
Q <= "0000";
Q2 <= "0000";
A <= "0000";
count := 4;
C <= '0';
valid_out <= '0';
state := 0;
t5bits_1 <= "00000";
ELSIF clk='1' AND clk'EVENT THEN
CASE state IS
WHEN 0 => state := state + 1;
M <= multiplicand;
Q <= multiplier;
Q2 <= multiplier;
t5bits_1 <= "00000";
C <= '0';
A <= "0000";
valid_out <= '0';
count := 4;
WHEN 1 =>
IF Q(0)='1' THEN
state := 2;
Page 55 of 66
An Interactive Workshop on FPGA
END arch_Booth_Multiplier4bit;
ENTITY Booth_Multiplier4bit_test IS
END Booth_Multiplier4bit_test;
Page 56 of 66
An Interactive Workshop on FPGA
ARCHITECTURE arch_Booth_Multiplier4bit_test OF
Booth_Multiplier4bit_test IS
COMPONENT Booth_Multiplier4bit
PORT ( multiplier : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
multiplicand : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
product : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
valid_out : OUT STD_LOGIC);
END COMPONENT;
BEGIN
input_1: PROCESS
BEGIN
-- WAIT FOR 600 ns;
WAIT UNTIL valid_out='1';
multiplier <= multiplier + '1'; -- std_logic_unsigned.all is
required
END PROCESS input_1;
input_2: PROCESS
BEGIN
-- WAIT FOR 600 ns;
WAIT UNTIL valid_out='1';
multiplicand <= multiplicand + "0010"; -- std_logic_unsigned.all
is required
END PROCESS input_2;
clk_gen: PROCESS
BEGIN
LOOP
WAIT FOR 20 ns;
clk <= NOT clk;
END LOOP;
END PROCESS clk_gen;
rst_gen: PROCESS
BEGIN
rst <= '1';
WAIT FOR 30 ns;
rst <= '0';
WAIT;
END PROCESS rst_gen;
Page 57 of 66
An Interactive Workshop on FPGA
END arch_Booth_Multiplier4bit_test;
Page 58 of 66
An Interactive Workshop on FPGA
ENTITY binary_BCD_converter IS
PORT(binary: IN std_logic_vector(7 DOWNTO 0);
unit_out,ten_out: OUT std_logic_vector(3 DOWNTO 0);
hundred_out: OUT std_logic_vector(1 DOWNTO 0));
END binary_BCD_converter;
COMPONENT add3
PORT(binary_in: IN std_logic_vector(3 DOWNTO 0);
BCD_out: OUT std_logic_vector(3 DOWNTO 0));
END COMPONENT;
SIGNAL add_in1,add_in2,add_in3,add_in4,add_in5,
add_in6,add_in7:std_logic_vector(3 DOWNTO 0);
SIGNAL add_out1,add_out2,add_out3,add_out4,add_out5,
add_out6,add_out7:std_logic_vector(3 DOWNTO 0);
BEGIN
END arch_binary_BCD_converter;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY add3 IS
PORT(binary_in: IN std_logic_vector(3 DOWNTO 0);
Page 59 of 66
An Interactive Workshop on FPGA
BEGIN
PROCESS(binary_in)
BEGIN
CASE binary_in IS
WHEN "0000" => BCD_out <= "0000";
WHEN "0001" => BCD_out <= "0001";
WHEN "0010" => BCD_out <= "0010";
WHEN "0011" => BCD_out <= "0011";
WHEN "0100" => BCD_out <= "0100";
WHEN "0101" => BCD_out <= "1000";
WHEN "0110" => BCD_out <= "1001";
WHEN "0111" => BCD_out <= "1010";
WHEN "1000" => BCD_out <= "1011";
WHEN "1001" => BCD_out <= "1100";
WHEN OTHERS => BCD_out <= "0000";
END CASE;
END PROCESS;
END arch_add3;
ENTITY binary_BCD_converter_test IS
END binary_BCD_converter_test;
ARCHITECTURE arch_binary_BCD_converter_test OF
binary_BCD_converter_test IS
COMPONENT binary_BCD_converter
PORT(binary: IN std_logic_vector(7 DOWNTO 0);
unit_out,ten_out: OUT std_logic_vector(3 DOWNTO 0);
hundred_out: OUT std_logic_vector(1 DOWNTO 0));
END COMPONENT;
BEGIN
input: PROCESS
BEGIN
WAIT FOR 20 ns;
binary <= binary + '1'; -- std_logic_unsigned.all is required
END PROCESS input;
Page 60 of 66
An Interactive Workshop on FPGA
END arch_binary_BCD_converter_test;
Page 61 of 66
An Interactive Workshop on FPGA
ENTITY counter_4bit_7_segment IS
PORT (clk, rst : IN STD_LOGIC;
data_out : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END counter_4bit_7_segment;
Page 62 of 66
An Interactive Workshop on FPGA
LAB # 05
In this lab, we will design a circuit of Ripple Carry Adder and Multiplier. At one time
only one operation can be performed and user can select the desired operation. The
output of the addition will be displayed on 7-segment display in hexadecimal format
(carry out will be discarded). The output of the multiplier will be displayed on 7-segment
in BCD format.
The block diagram of the circuit, and pin configuration is given, and you will write the
VHDL code yourself using whatever style you like. Some of the blocks in this design
have been implemented in previous labs, so it would be wise to use those blocks
wherever possible.
Note: To make the debugging easier, use the same wire names as given in block
diagram.
• Write the synthesizable VHDL code for any given block diagram.
Page 63 of 66
An Interactive Workshop on FPGA
RCA_Multiplier_Combined
Page 64 of 66
An Interactive Workshop on FPGA
RCA_Multiplier_Combined Testbench
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY RCA_Multiplier_combined_test IS
END RCA_Multiplier_combined_test;
ARCHITECTURE arch_RCA_Multiplier_combined_test OF
RCA_Multiplier_combined_test IS
COMPONENT RCA_Multiplier_combined
PORT (clk, rst : STD_LOGIC;
a,b : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
sel : STD_LOGIC;
seven_seg_out : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);
seven_seg_Anode : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END COMPONENT;
BEGIN
clk_gen: PROCESS
BEGIN
WAIT FOR 20 ns;
clk <= NOT clk;
END PROCESS clk_gen;
rst_gen: PROCESS
BEGIN
rst <= '1';
WAIT FOR 30 ns;
rst <= '0';
WAIT;
END PROCESS rst_gen;
input_a: PROCESS
BEGIN
WAIT FOR 400 ns;
a <= a + '1'; -- std_logic_unsigned.all is required
END PROCESS input_a;
input_b: PROCESS
BEGIN
WAIT FOR 400 ns;
b <= b + "0010"; -- std_logic_unsigned.all is required
END PROCESS input_b;
sel_signal: PROCESS
Page 65 of 66
An Interactive Workshop on FPGA
BEGIN
sel <= '0';
WAIT FOR 2000 ns;
sel <= '1';
WAIT FOR 2000 ns;
END PROCESS sel_signal;
END arch_RCA_Multiplier_combined_test;
Page 66 of 66
Digilent, Inc. PRELIMINARY
125 SE High Street
Pullman, WA 99163
(509) 334 6306 (Voice and Fax)
www.digilentinc.com
Overview
Power 25MHz Prototype/expansion
The Digilab XLA circuit board provides an 5VDC SPROM
jack CLK connector
regulator
ideal platform for experimenting with digital 5-9VDC
converter
board features a Xilinx Spartan XCS10 FPGA,
RS-232
Port BNC
a large collection of I/O devices and ports, and
1/8"
an integral breadboard, so a wide array of audio
circuits can be implemented without the need EPP or SPP
parallel port Spartan(XL)
Parallel Port
Port
VGA
port
• A Xilinx XCS10 or XCS10XL FPGA;
• On-board 1.5A regulator (5.0V or 3.3V); Port/prog
• A socketed 25MHz oscillator; switch
• An EPP-capable parallel port for serial-slave
FPGA programming and user data transfers; Integral 630
• tie- point
Eight LEDs, eight slide switches, four breadboard 4 7-seg. 8 LEDs 8 switches 4 buttons
pushbuttons, and a four-digit seven-segment displays
display provide circuit I/O’s;
• PS/2 mouse/keyboard, serial, and 3-bit color XLA circuit board block diagram
VGA ports;
Spartan XL devices can be accommodated (the
• An integral 630 tie-point breadboard;
board also supports the XC4010 5V FPGA). The
• A large prototyping/expansion connector
XLA board works seamlessly with the Xilinx
provides easy access to FPGA and I/O CAD tools, including the Foundation Student
signals;
Edition tool (but not WebPack at this time). The
• BNC and audio connectors for support of large integral breadboard allows accessory
bread-boarding applications; circuits (like A/D and D/A converters) to be
• An SPROM socket for non-volatile easy constructed. The XLA board ships with a
applications. power supply and programming cable, so
designs can be implemented immediately
A simple resistor change generates a 5V or without the need for any additional supplies.
3.3V power supply, so both Spartan and
Functional Description
The XLA board provides a self-contained digital circuit design environment that offers an ideal
platform for experimenting with digital circuit designs and/or modern CAD tools. A large-capacity
gate array, provide allow a wide array of designs to be implemented without the need for any
additional hardware.
Signals
Signal Definition Connections
The Digilab board has been A1 - A4 Seven-segment Anodes SSDs, FPGA, J1
designed to allow rapid circuit CA - CG Seven-segment Cathodes SSDs, FPGA, J1
construction and convenient DP Seven-segment Decimal Point SSDs, J1
test lead attachment. Most BTN1 - 4 Push Button connections Buttons, FPGA, J1
signals are routed to the SW1 - SW8 Slide switch connections Switches, FPGA, J1
prototyping connector (J1), to LD1 - LD8 LED connections LEDs, FPGA, J1
the gate array, and to a test LDG Gate connection on 74HC373 74HC373, FPGA, J1
lead connector. Depending on ASFT Audio connector shaft Audio connector, J1
function, the signals arise from ATIP Audio connector tip Audio connector, J1
devices or connectors on the CLK1 CLK1 connected to PGCK1 CLK1, FPGA
board, or they drive devices or CLK2 CLK2 connected to PGCK2 CLK2, FPGA, J1
connectors on the board. The O1 - O5 Unassigned FPGA pins FPGA, J1, J2
table defines all Digilab PD0 - PD7 Parallel port data pins J7 (par. port), FPGA, J1, J3
signals and shows all their PWE Parallel port Write Enable (EPP) J7 (par. port), FPGA, J1, J3
connections. PAS Parallel port Address Strobe (EPP) J7 (par. port), FPGA, J1, J3
PDS Parallel port Data Strobe (EPP) J7 (par. port), FPGA, J1, J3
Circuit board PINT Parallel port Interrupt (EPP) J7 (par. port), FPGA, J1, J3
PRS Parallel port Reset (EPP) J7 (par. port), FPGA, J1, J3
The FR-4 fiberglass circuit PWT Parallel port Wait/Busy (EPP) J7 (par. port), FPGA, J3
board uses a 1oz. copper, two BNCS BNC connector shield BNC connector, J1
layer, plated through-hole
BNCP BNC connector center post BNC connector, J1
process with 6mil minimum
R, G, B VGA Red, Green, and Blue signals J6 (vga), FPGA, J2
trace size and .039” through-
HS VGA Horizontal Sync J6 (vga), FPGA, J2
holes. Solder mask is provided
VS VGA Vertical Sync J6 (vga), FPGA, J2
on both sides, a silk-screen is
RXD, TXD RS-232 receive and send signals J4 (serial), FPGA, J2
provided on the component
PS2D, PS2C PS2 port data and clock signals J5 (PS/2), FPGA, J1, J2
side, and all connectors can
accommodate mechanical
stays. Four 6/32”-sized corner holes are provided for stand-offs (to keep the board from contacting the
work surface).
U6
Power Supply Vin LM317T
J8 Power Vout Vdd
The circuits and components R5 R4
connector Adj
C24 240 240
on the Digilab XL board 1.5uF
require a 5VDC or 3.3VDC C23 R6
power supply. The board is 10uF LD9
750
equipped with a LM317T GND
adjustable LDO voltage regulator (U6) that can produce either 5V or 3.3V depending on the R6
resistor value (750 ohms for 5V; 390 ohms for 3.3V). The regulator will produce the selected voltage
whenever a 6V-12VDC wall-plug transformer is attached at the power jack J8. Any 6-12VDC wall-
plug transformer can be used, provided it has a coaxial 2.1mm center positive connector. The power
circuit uses several bulk decoupling capacitors (C20, C23, C24) to produce a stable Vdd supply that
typically has less than 50mV of ripple, even under heavy loads. An LED (LD9) in series with a 240-
ohm resistor illuminates whenever power is present. With all IC’s loaded in their sockets, including a
25MHz oscillator, the board consumes between 300 and 400 milliamps (depending on the size of
FPGA-based circuits). Breadboard circuits or connected devices can markedly increase current
consumption. For loads greater than about 500mA or power supply voltages greater than about 10V,
the LM317T can be attached to the metalized pad on the circuit board with a 6/32 nut and screw to
increase its heat-sinking capacity.
Push Buttons
Slide switches
The eight slide switches can be used to connect either Vdd or Vdd
GND to eight pins on the FPGA as well as to connections on RP4 & 5
4.7 KOhm
J1. The switches exhibit about 2ms of bounce, and no active To J1 and
debouncing circuit is employed. As shown on the right, a 4.7K- FPGA
ohm series resistor is used to provide nominal input protection,
and to allow the switch-connected inputs to the FPGA to be GND
used as outputs if necessary.
LEDs
Vdd
U1
Eight red LEDs are provided R1
74HC373
for circuit outputs. The LED 10K Ohms
LD signals From
cathodes are tied to ground via FPGA and J1 D Q
270-ohm resistors (in resistor LD1- LD8
LDG signal From G
pack RP9). The anodes are FPGA and J1
driven by U1, a 74HC373 RP9
RP8
CMOS D-register with 24mA 10K Ohm 270 Ohm
per pin output current. Inputs to
the 74HC373, each of which
GND GND
have a 10K pull-down resistor
(RP8), arise from a common circuit node tied to both the FPGA and connections on J1. Thus, care
should be taken not to drive the LED inputs from both the J1 connector and from the FPGA
simultaneously. A 74HC373 is used so that the LED drive signals can be decoupled from the FPGA,
allowing the LED pins on the FPGA to serve a dual purpose if needed. The 74HC373 gate signal,
which has a 10K pull-up (R1), can be driven from the FPGA or from a connection on J1.
BNC connector
Audio connector
PS2 connector
Serial Port
Serial port signal definitions and connector and circuit details are shown below. The Digilab serial port
is compatible with RS232 two-wire communication protocols; that is, only the RXD and TXD signals
from the serial port are routed to the FPGA. When using the serial port to communicate with a
computer, a two-wire protocol such as XON/XOFF must be used. Specified RS232 voltages are +12V
to +3V for a logic “0” and –12V to –3V for a logic “1” (the "dead area" between -3v and +3v is
designed to absorb line noise). The Digilab board uses a MAX202 RS232 voltage converter to convert
these signals to 5VDC for a logic “1” and GND for a logic “0”.
The two devices connected to either end of a serial cable are known as the Data Terminal Equipment
(DTE) and the Data Communications Equipment (DCE). The DCE was originally conceived to be a
modem, but now many devices connect to a computer as a DCE. A DTE device uses a male DB-9
connector, and a DCE device uses a female DB-9 connector. The DTE is considered the source of data,
and the DCE the peripheral device. Two DTE devices can be connected via a serial cable only if lines
two and three are crossed – this is known as a null modem cable. A DTE and DCE device can be
connected with a straight-through cable. The XLA board is configured as a DCE device.
1
6
2 RXD_12V 12 13 To RXD on FPGA and J6
7 RTS 10 14 To TXD on FPGA and J6
3 TXD_12V 11 7
8 CTS 9 8
4 RTS and CTS not routed from
MAX202
9
5
VGA connector
The five standard VGA signals (Red, Green, Blue, Horizontal Sync, and Vertical Sync) are routed
from the FPGA to the VGA connector and to the J2 header (the J6 header allows for easy connection
of test and measurement equipment). Standard VGA R, G, and B signals are terminated with a 75-ohm
pull-down resistor. As shown below, a 470-ohm series resistor drives the R, G, and B signals, and the
resistor-divider that is formed ensures the video signals never exceed the VGA-specified maximum of
0.7VDC. Note that each color is either on or off, which allows for eight different colors.
470 Ohm
1 RP11
To R on FPGA and J2
6
11 470 Ohm
2 RP11
To G on FPGA and J2
7
12 470 Ohm
3 RP11
To B on FPGA and J2
8
13 To HS on FPGA and J2
4
9
14 To VS on FPGA and J2
5
10
15
GND
DB15
Connector
Parallel Port
possible 3.3VDC Digilab Vdd voltage. The Xilinx programming circuit, discussed in the following
section, also uses the parallel port connector. Refer to that discussion for more information regarding
the parallel port circuit.
Pin 13 Pin 1
Pin 1
The programming circuit (below) has been designed to accommodate a standard parallel cable and the
Xilinx xchecker configuration protocol. The parallel cable will be auto-detected from with the Xilinx
project manager, so that no external programming software is required. If the cable is not automatically
detected the first time the Xilinx software is run with the board, it may be necessary to manually set the
cable type in the Xilinx Design Manager “communications” pull-down menu.
The xchecker interface uses the DB25 connector and a standard parallel cable to connect to the FPGA
programming port (readback functions are not supported). 4.7K pull-ups are provided on the PROG,
INIT, and DONE signals. The parallel port interface serves both programming and functional needs. A
circuit has been designed that allows the port to be manually switched from programming mode to port
mode. Slide-switch SW9, located near the parallel port connector, can be placed in the “PROG” mode
for programming and “PORT” mode to use the parallel port as a parallel port. Note that to program the
FPGA and then use the parallel port, care must be taken in the application circuit design to not drive
the port data signals until after the switch is moved to the “PORT” position. See the parallel port demo
project at the Digilent website for more details.
The Digilab board can also accommodate a Xilinx SPROM in the 8-pin socket labeled ROM. To
program from the ROM, load the ROM into the socket, place SW9 in the “PORT” position, and apply
power to the board.
Vdd
PORT
Programming
Vdd "decoupling"
Circuit
Program enable
GND switch (SW9) GND
PROG
Two half-size (i.e., 8-pin DIP) sockets designated CLK1 and CLK2 have been provided near the FPGA
for system clocks. Two clocks have been provided to accommodate peripherals that demand particular
clocks (e.g., the VGA and serial devices), while still allowing a general system clock. CLK1, attached
to the Spartan PGCK1 input, is considered the primary clock (pin 13), and CLK2 has been routed to
the PGCK2 input (pin 35). No special system reset circuits have been provided – typically, one of the
buttons is used as a functional system reset.
J1 is a 72-pin socket connector that allows easy access to all Digilab signals for breadboarding
purposes. All J1 pin definitions are provided in silk-screen labels immediately adjacent to the
connector. In its intended use, individual wire-jumpers can be inserted into socket pins on J1 and into
the breadboard area, thereby connecting breadboard circuit devices to the Digilab circuits. Note that J1
has seven pins providing GND connections and seven providing Vdd connections – these provide
breadboard circuit with easy access to Vdd and GND.
J2 and J3 are single-row header connectors intended to allow easy connection of test and measurement
equipment. Both J2 and J3 have GND pins that can serve as references for test and measurement
equipment. All pins definitions are provided in silk-screen labels immediately adjacent to the
connectors.
Schematic representations of the J1, J2, and J3 header connectors follow. Refer to the table of signal
definitions provided earlier in this section.
VDD VDD
GND GND
DP SW1
CA SW2
CB SW3
CC SW4
CD SW5
CE SW6
CF SW7
CG SW8
A1 LD1
A2 LD2
A3 LD3
A4 LD4
RXD LD5
TXD LD6
O4 LD7
O5 LD8
CLK2 LDG
BTN3 BTN1
BTN4 BTN2
VDD VDD GND PWE
GND GND O1 PD0
O3 O2 O2 PD1
PINT O1 O3 PD2
PAS PD0 O4 PD3
PDS PD1 O5 PD4
PWE PD2 R PD5
VDD PD3 G PD6
VDD PD4 B PD7
VDD PD5 HS PAS
GND PD6 VS PINT
GND PD7 RXD PRS
GND GND TXD PWT
BNCS ASFT PS2C PDS
BNCP ATIP PS2D GND
J1 J2 J3
Breadboarding Test lead Test lead
connector connector connector
FPGA
The Digilab board can accommodate a Xilinx Spartan XCS05, XCS10, XCS05XL, and XCS10XL
FPGA in the 84-pin PLCC socket (the XL parts require a 390 ohm R6 for 3.3V operation). Any of
these SRAM-based FPGA’s may be programmed using a parallel cable or an SPROM (see above). The
parallel cable provides an inexpensive programming solution that is compatible with the Xilinx CAD-
tool cable detection software, so that the FPGA can be programmed without leaving the Xilinx
environment. Refer to the Xilinx Spartan data sheet (http://www.xilinx.com/partinfo/spartan.pdf) for
technical data regarding the FPGA’s.
The table on the right shows all Pin # Function Pin # Function Pin # Function
FPGA pin connections. In this
pin-list, gray boxes indicate 1 GND 29 O1 57 BTN3
dedicated pins that are not 2 Vdd 30 M1_NC 58 BTN2
available for use. Italicized 3 PWE 31 GND 59 BTN1
names indicate dual-purpose
pins; for these pins, the Xilinx 4 PD0 32 MODE 60 LD8
function is shown first followed 5 PD1 33 Vdd 61 LD7
by Digilab’s assignment in 6 PD2 34 M2_NC 62 LD6
parenthesis. 7 PD3 35 CLK2 63 Vdd
8 PD4 36 O2 64 GND
Some FPGA signals, including
9 PAS 37 O3 65 LD5
the LED drive signals and the
unassigned (or open) signals are 10 PRS 38 A4 66 LD4
available on the J1 prototyping 11 Vdd 39 A3 67 LD3
connector. Care should be taken 12 GND 40 A2 68 LD2
to ensure that these signals are 13 CLK1 41 INIT (O4) 69 LD1
not simultaneously driven by
14 PDS 42 Vdd 70 LDG
both the FPGA and by other
drivers. If the FPGA is loaded 15 PWT 43 GND 71 DIN (O5)
in the U3 socket and external 16 PD5 44 A1 72 DOUT (RXD)
circuits must drive these signals, 17 PD7 45 CG 73 CCLK
it would be best to tri-state the 18 PD6 46 CF 74 Vdd
FPGA signals. 19 SW8 47 CE 75 TXD (PINT)
The parallel port connector can 20 SW7 48 CD 76 GND
Any CAD-tool-designed circuit that requires fewer than about 5K – 10K gates can be programmed into
the Xilinx FPGA. However, the circuit description must first be transformed into the format required
by the FPGA. This transformation proceeds in several steps, typically beginning with an EDIF, VHDL,
or Verilog file format and ending with a Xilinx “bit” file format. Xilinx (of course) produces a tool that
accomplishes this transformation, which is available in the Xilinx Alliance and Foundation products
(see the Xilinx web site). Although other methods of transforming files may be available, only the
Xilinx solution has been used with the Digilab board. Although the use of the Xilinx tools is beyond
the scope of this document, Xilinx has several good tutorials and helpful documentation available at
their web site.
All signals on the Digilab board that connect the buttons, switches, and LEDs to the J1 connector are
connected to the Xilinx FPGA chip as well. Any circuit implemented in the FPGA can use the buttons
and switches as inputs and the LEDs as outputs. When the Digilab board was fabricated, the buttons,
switches, and LEDs were connected to particular pins on the FPGA (see the table in the previous
section for all FPGA pin definitions). To connect an FPGA-based circuit to these devices, you must
include information in your schematic to “map” circuit inputs and outputs to particular FPGA pins.
Mapping is accomplished by including special components in your schematic called IPADs, IBUFs,
OPADs and OBUFs. These components exist solely to allow you to define physical pin connections,
and so they only need be used in circuit schematics that you intend to download.
Once you have a complete and error-free schematic, you may add IBUFs and IPADs to all inputs, and
OBUFs and OPADs to all outputs. Then, the IPADs and OPADs can be connected to particular pins
by double-clicking the pads and entering the “LOC” parameter and pin number in the appropriate
fields (Name and Description, respectively). In the example circuit below, two switches (SW1 on pin
P28 and SW2 on pin P27) are connected via an AND gate to LED1 (LD1 on pin P69). If this circuit
were downloaded to the FPGA, then LD1 would illuminate whenever SW1 and SW2 were asserted.
For simulation purposes, labes can be added to wires between the IBUF's and the circuit.
Labels are added by doule-clicking the wire and entering the name in the dialog box.
LOC=P28 IPAD
IBUF OPAD LOC=P69
OBUF
LOC=P27 IPAD
AND2
IBUF
"LOC" parameters are added by double-clicking the pad symbol and entering LOC in the Parameters
Name feild and Pnn in the Parameters Description feild, and then pressing Add and OK.
Once all IPADs, IBUFs, OPADs, and OBUFs have been added and edited with pin locations, you can
begin the implementation process by choosing the “Implementation” button from the Xilinx main
screen. In the first dialog box that appears, choose Yes to update the netlist from the schematic editor.
In the second dialog box, make sure the device is S10PC84 and speed is 3 before proceeding; the
version and revision names can use the defaults. Press the Run button, and then wait for the status
window showing Translate, Map, Place & Route, Timing, and Configure processes to terminate.
Before proceeding, make sure that the Digilab board is powered on and connected to the PC via the
parallel cable, and that SW9 is in the PROG position. Then select the Programming option from the
Xilinx main window, and “hardware debugger” from the subsequent dialog box. The cable should be
auto-detected; if not, manually choose the parallel cable in the Cable à communications dialog box.
Once the cable has been detected, you can download your design simply by double-clicking on the
appropriate file name in the hardware debugger window.
Two 8-pin DIP clock sockets have been provided for use with the FPGA. Labeled CLK1 and CLK2,
they connect to pin 13 (Xilinx primary clock buffer #1) and pin 35 (Xilinx primary clock buffer #2).
Clock sources up to 80MHz have been successfully used with the board.
The FPGA programming circuit has been designed to accommodate a standard parallel cable or an
SPROM. When programming the FPGA from within the Xilinx CAD tool, the parallel cable will be
automatically detected (so no external programming software is required). If a cable is not
automatically detected the first time the Xilinx software is run with the board, it may be necessary to
manually set the cable type in the Xilinx Design Manager “communications” pull-down menu.
The parallel port interface serves both programming and functional needs. A circuit has been designed
that allows the port to be manually switched from programming mode to port mode. Slide-switch
SW9, located near the parallel port connector, must be placed in the “PROG” mode for programming
from a host PC and “PORT” mode to use the parallel port as a parallel port or to program from an
onboard ROM at power-up. Note that to program the FPGA and then use the parallel port, care must be
taken in the application circuit design to not drive the port data signals until after the switch is moved
to the “PORT” position.