Professional Documents
Culture Documents
1. Introduction .................................................................................................................................... 3
1.1– Packages .................................................................................................................................. 3
1.2- Technical or Customer Support ................................................................................................. 3
2. Key Components and Features ........................................................................................................ 4
2.1 - General Block Diagram ............................................................................................................. 5
3. Jumper Details................................................................................................................................. 6
4. Connector Details ............................................................................................................................ 7
5. Power Supply .................................................................................................................................. 8
6. On-board Peripherals ...................................................................................................................... 9
6.1 - Light Emitting Diodes ............................................................................................................. 10
6.2 – Digital Inputs......................................................................................................................... 11
6.3 - RS-232 Communication(USART) ............................................................................................. 12
6.4 – JTAG Programmer ................................................................................................................. 13
6.5 – Clock Source ......................................................................................................................... 14
6.6 - VGA Interface ........................................................................................................................ 15
6.7 - PS/2 Interface ........................................................................................................................ 18
7. Board Layout ................................................................................................................................. 21
8. VLSI Lab Experiments ......................................................................................................................... 23
9 - Getting Started with Xilinx ISE ........................................................................................................... 93
Thank you for purchasing the Xilinx Spartan-3 Evaluation Kit. You will find it useful in developing
your Spartan-3 FPGA application.
FPGASP3 Kit (STK) is an exclusive general-purpose kit for the SPARTAN family. The intention of
the design is to endorse the engineers and scholars to exercise and explore the capabilities of
FPGA architectures with many interfacing modules on board point LEDs, Slide switches, UART,
VGA, and PS/2 with ease to create a stand-alone versatile test platform.
1.1 – Packages
9V Input JTAG
+5V/3.3V/1.2V Port
USB UART
Power Supply Serial Comm
3 2 1 PROM Execution
PROM
JTAG/
J3
3 2 1 JTAG Executions
IO123 1 2 IO124
IO125 3 4 IO128
IO129 5 6 IO130
IO131 7 8 IO132
IO135 9 10 IO137
IO140 11 12 IO141
IO1 13 14 IO2
IO4 15 16 IO5
17 18
+5V 19 20 +5V
GND 21 22 GND
3V3 23 24 3V3
IO6 25 26 IO7
IO11 27 28 IO12
IO13 29 30 IO14
IO15 31 32 IO17
IO18 33 34 IO20
IO21 35 36 IO23
IO24 37 38 IO25
IO26 39 40 IO27
EXTENSION CONN
J6 J7 J8
JTAG Connector
J2
1 TMS
2 TDI
3 TDO
4 TCK
5 GND
6 VCC
CON6
The external power can be AC or DC, with a voltage between (9V, 1A output) at 230V AC input.
The SPARTAN3 board produces +5V using an LM7805 voltage regulator, which provides supply to
the peripherals.
USB socket meant for power supply and USB communication, user can select either USB or Ext
power supply through SW1. Separate On/Off Switch (SW1) for controlling power to the board.
There are multiple voltages supplied on the Spartan-3 Evaluation Kit, 3.3V, 2.5V and 1.2V
regulators. Similarly, the 3.3V regulator feeds all the VCCO voltage supply inputs to the FPGA’s
I/O banks and powers most of the components on the board. The 2.5V regulator supplies power
to the FPGA’s VCCAUX supply inputs. The VCCAUX voltage input supplies power to Digital Clock
Managers (DCMs) within the FPGA and supplies some of the I/O structures.
In specific, all of the FPGA’s dedicated configuration pins, such as DONE, PROG_B, CCLK, and the
FPGA’s JTAG pins, are powered by VCCAUX. The FPGA configuration interface on the board is
powered by 3.3V. Consequently, the 2.5V supply has a current shunt resistor to prevent reverse
current. Finally, a 1.2V regulator supplies power to the FPGA’s VCCINT voltage inputs, which
power the FPGA’s core logic. The board uses four discrete regulators to generate the necessary
voltages.
Light Emitting Diodes (LEDs) are the most commonly used components, usually for displaying
pin’s digital states.
The FPGASP3 KIT has 8 nos., of Point LEDs, connected with port pins (details tabulated
below); the cathode of each LED connects to ground via a 220Ω resistor. To light an
individual LED, drive the associated FPGA control signal to High.
SPARTAN3
Point LEDs LED Selection
FPGA Lines
LED-D11 P97
R1 330E
LED-D9 P99
LED-D8 P100
LED-D7 P102 Make Pin High – LED ON
LED-D6 P103 Make Pin Low – LED OFF
LED-D5 P104
LED-D4 P105
This is another simple interface, of 8-Nos. of slide switch, mainly used to give an input to the
port lines, and for some control applications also.
The FPGASP3 KIT, slide switches (SW3-SW10) directly connected with FPGA I/O lines (details
tabulated below), user can give logical inputs high through slide switches.
The switches are connected to +3.3V, in order to detect a switch state, by default lines are pull-
downed through resistors. The switches typically exhibit about 2 ms of mechanical bounce and
there is no active de-bouncing circuitry, although such circuitry could easily be added to the FPGA
design programmed on the board. A 10KΩ series resistor provides nominal input protection.
Slide SPARTAN3
Slide Switch Logic
Switches FPGA Lines
SW3 P86
VCC
SW4 P87
R 10k
2 1
SW5 P89
DIGITAL INTPUTS
R SW1
10k
SW6 P90
SW7 P92
Make Switch Close – High
SW8 P93
Make Switch Open – Low
SW9 P95
SW10 P96
USART stands for Universal Synchronous Asynchronous Receiver Transmitter. FPGASP3 Kit provides
an RS232 port that can be driven by the Spartan-3 FPGA. A subset of the RS232 signals is used on the
Spartan 3 kit to implement this interface (RxD and TxD signals).
The voltage levels of a FPGA and PC are not directly compatible with those of RS-232, a level
transition buffer such as MAX3232 be used.
UART SPARTAN3
Serial Port Section
DB-9 Connector FPGA Lines
TXD P122
MAX
UART
SPARTAN3 3232
RXD P127
The FPGASP3 Kit includes a JTAG programming and debugging chain. Pantech JTAG3 low-cost
parallel to JTAG cable is included as part of the kit and connects to the JTAG header. DB-25
parallel port connector to 6 pin female header connector. The JTAG cable connect directly to the
parallel port of a PC and to a standard 6 pin JTAG programming header in the kit, can program a
devices that have a JTAG voltage of 1.8V or greater.
6-Pin SPARTAN3
JTAG Signals
Header FPGA Lines
JTAG Cable – III
1 TMS P111
2 TDI P144
Programmer
3 TDO P109
JTAG
4 TCK P110
5 GND
6 VCC
The Pantech low-cost parallel port to JTAG cable fits directly over the header stake pins, as
shown in above figure. When properly fitted, the cable is perpendicular to the board. Make sure
that the signals at the end of the JTAG cable align with the labels listed on the board. The other
end of the Pantech cable connects to the PC’s parallel port. The Pantech cable is directly
compatible with the Xilinx iMPACT software.
The FPGASP3 Kit has a dedicated 50 MHz series clock oscillator source and an optional socket for
another clock oscillator source.
SPARTAN3
U10 Signal Crystal Oscillator
FPGA Lines
Oscillator
The FPGASP3 Kit includes a VGA display port through DB15 connector, Connect this port directly
to most PC monitors or flat-panel LCD displays using a standard monitor cable As shown in table,
the Spartan-3 FPGA controls five VGA signals: RED (R) its 1ST pin in connector, GREEN (G) its 2nd
pin, BLUE (B) its 3rd pin, Horizontal Sync (HS) 13th pin, and Vertical Sync (VS) its 14th pin, all
available on the VGA connector.
DB-15 SPARTAN3
VGA Signals
Connector FPGA Lines
Vertical Sync(VS) P12
Horizontal Sync(HS) P13
Blue P16
Green P18
Red P19
Each color line has a series resistor to provide 3-bit color, with one bit each for Red, Green, and
Blue. The series resistor uses the 75 ohm VGA cable termination to ensure that the color signals
remain in the VGA-specified 0V to 0.7V range. The HS and VS signals are TTL level. Drive the R, G,
and B signals High or Low to generate the eight possible colors shown in below table.
0 0 0 BLACK
0 0 1 BLUE
0 1 0 GREEN
0 1 1 CYAN
1 0 0 RED
1 0 1 MAGNETA
1 1 0 YELLOW
1 1 1 WHITE
VGA signal timing is specified, published, copyrighted, and sold by the Video Electronics
Standards Association (VESA). The following VGA system and timing information is provided as
http://www.vesa.org
CRT-based VGA displays use amplitude-modulated, moving electron beams (or cathode rays) to
display information on a phosphor-coated screen. LCD displays use an array of switches that can
impose a voltage across a small amount of liquid crystal, thereby changing light permittivity
through the crystal on a pixel by- pixel basis.
Although the following description is limited to CRT displays, LCD displays have evolved to use
the same signal timings as CRT displays. Consequently, the following discussion pertains to both
CRTs and LCD displays. Within a CRT display, current waveforms pass through the coils to
produce magnetic fields that deflect electron beams to transverse the display surface in a
“raster” pattern, horizontally from left to right and vertically from top to bottom.
As shown in below figure, information is only displayed when the beam is moving in the
“forward” direction—left to right and top to bottom—and not during the time the beam returns
back to the left or top edge of the display. Much of the potential display time is therefore lost in
“blanking” periods when the beam is reset and stabilized to begin a new horizontal or vertical
display pass.
The size of the beams, the frequency at which the beam traces across the display, and the
frequency at which the electron beam is modulated determine the display resolution. Modern
VGA displays support multiple display resolutions, and the VGA controller indicates the
resolution by producing timing signals to control the raster patterns. The controller produces
TTL-level synchronizing pulses that set the frequency at which current flows through the
deflection coils, and it ensures that pixel or video data is applied to the electron guns at the
The Spartan-3 Evaluation Kit uses three bits per pixel, producing one of the eight possible colors
shown in above table. The controller indexes into the video data buffer as the beams move
across the display. The controller then retrieves and applies video data to the display at precisely
the time the electron beam is moving across a given pixel.
The VGA controller generates the HS (horizontal sync) and VS (vertical sync) timings signals and
coordinates the delivery of video data on each pixel clock. The pixel clock defines the time
available to display one pixel of information. The VS signal defines the “refresh” frequency of the
display, or the frequency at which all information on the display is redrawn. The minimum
refresh frequency is a function of the display’s phosphor and electron beam intensity, with
practical refresh frequencies in the 60 Hz to 120 Hz range.
The number of horizontal lines displayed at a given refresh frequency defines the horizontal
“retrace” frequency.
The FPGASP3 Kit includes a PS/2 port and the standard 6-pin mini-DIN connector, labeled U11 on
the board. User can connect PS/2 Devices like keyboard, mouse to the FPGASP3 KIT. PS/2’s DATA
(P8) and CLK (P10) lines connected to SPARTAN3 FPGA I/O Lines.
PS/2
CLK P10
Both a PC mouse and keyboard use the two-wire PS/2 serial bus to communicate with a host
device, the Spartan-3 FPGA in this case. The PS/2 bus includes both clock and data. Both a mouse
and keyboard drive the bus with identical signal timings and both use 11-bit words that include a
start, stop and odd parity bit. However, the data packets are organized differently for a mouse
and keyboard. Furthermore, the keyboard interface allows bidirectional data transfers so the
host device can illuminate state LEDs on the Keyboard.
The PS/2 bus timing appears as shown in above figure. The clock and data signals are only driven
when data transfers occur; otherwise they are held in the idle state at logic High. The timing
defines signal requirements for mouse-to-host communications and bidirectional keyboard
communications. The attached keyboard or mouse writes a bit on the data line when the clock
signal is High, and the host reads the data line when the clock signal is Low.
The keyboard uses open-collector drivers so that either the keyboard or the host can drive the
two-wire bus. If the host never sends data to the keyboard, then the host can use simple input
pins. A ps/2-style keyboard uses scan codes to communicate key press data nearly all keyboards
in use today are ps/2 style. Each key has a single, unique scan code that is sent whenever the
corresponding key is pressed.
The scan codes for most keys appear in below figure. If the key is pressed and held, the keyboard
repeatedly sends the scan code every 100 ms or so. When a key is released, the keyboard sends
an “f0” key-up code, followed by the scan code of the released key. the keyboard sends the
same scan code, regardless if a key has different shift and non-shift characters and regardless
whether the shift key is pressed or not. The host determines which character is intended. Some
keys, called extended keys, send an “e0” ahead of the scan code and furthermore, they might
send more than one scan code. When an extended key is released, an “e0 f0” key-up code is
sent, followed by the scan code.
The host can also send commands and data to the keyboard. Below figure provides a short list of
some often-used
Command Description
ED Turn on/off Num Lock, Caps Lock, and Scroll Lock LEDs
EE Echo. Upon receiving an echo command, the keyboard replies with the same
scan code “EE”.
F3 Set scan code repeat rate. The keyboard acknowledges receipt of an “F3” by
returning an “FA”, after which the host sends a second byte to set the repeat
rate.
FE Resend. Upon receiving a resend command, the keyboard resends the last scan
code sent
FF Reset. Resets the keyboard
The keyboard sends commands or data to the host only when both the data and clock lines are
High, the Idle state, Because the host is the bus master, the keyboard checks whether the host is
sending data before driving the bus. The clock line can be used as a clear to send signal. If the
host pulls the clock line Low, the keyboard must not send any data until the clock is released.
The keyboard sends data to the host in 11-bit words that contain a ‘0’ start bit, followed by eight
bits of scan code (LSB first), followed by an odd parity bit and terminated with a ‘1’ stop bit.
Description
Arithmetic operators can perform a variety of operations in VHDL such as addition, subtraction,
multiplication and division. VHDL arithmetic operators operate on numeric and physical operand
data types. The below table shows the VHDL arithmetic operators and data types required for
input as A ,B and output as Y.
Connection Details
Consider the addition of two numbers of a + b, where a and b are 4 bit numbers and the output
of addition is taken in y as 8 bit number.
Output Y as 8
Input A as 4 Input B as 4 = bit
bit
+ bit
Flow Chart
START
Initialize
Entity
SET input A
SET input B
Verify output Y
END
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; -- Library declaration
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
A half adder ADD 2 input bits A , B and output the results as 2 bits - 1 bit for the Sum and
another 1 bit for the Carryout.
Flow Chart
Logical Diagram
START
Initialize
Entity
SET input A
Truth Table
SET input B
A B Sum Carryout
0 0 0 0
Verify Truth table 0 1 1 0
1 0 1 0
1 1 1 1
END
Code Listing
library IEEE; -- Library declaration
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity halfadder is
Port ( a: in std_logic;
b: in std_logic; -- input / output declaration
Sum: out std_logic;
carryout: out std_logic);
end halfadder;
Consider the subtraction of two numbers of a - b, where a and b are 4 bit numbers and the
output of subtraction is taken in y as 4 bit number.
Flow Chart
START
Initialize
Entity
SET input A
SET input B
Verify output Y
END
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; -- Library declaration
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0); -- input / output declaration
b : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (3 downto 0));
end code;
Consider the multiplication of two numbers as 2 x2 a * b, where a and b are 4 bit numbers and
the output of multiplication is taken in y as 8 bit number.
Flow Chart
START
Initialize
Entity
SET input A
SET input B
Verify output Y
END
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; -- Library declaration
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
Port ( a : in STD_LOGIC_VECTOR (3 downto 0); -- input / output declaration
b : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (7 downto 0));
end code;
Consider the multiplication of two numbers as 2 x2 a * b, where a and b are 2 bit numbers and
the output of multiplication is taken in P as 4 bit number.
A (1) A (0)
B (1) B (0)
START
Initialize
Entity
SET input A
SET input B
END
Code Listing
library IEEE; -- Library declaration
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity mult_arry is
Port (a, b: in std_logic_vector (1 downto 0); -- input / output declaration
P: out std_logic_vector (3 downto 0));
end mult_arry;
Consider the division of two numbers as a / b, where ‘a’ is 8 bit numbers and the output of
division is taken in Y as 8-bit number.
Flow Chart
START
Initialize
Entity
SET input A
Dividend
SET input B
Divisor
END
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
port ( a : in std_logic_vector(7 downto 0); --dividend
b : out std_logic_vector (7 downto 0));
end code;
begin
b <= CONV_STD_LOGIC_VECTOR((CONV_INTEGER(a)/4),8);
end Behavioral;
Hardware Description
LED & Switch Card has 8 nos. of Point LEDs, are the most commonly used components, usually
for displaying Logical output of Device pin’s states.
LED & Switch Card has 8 Nos. of Slide Switch, to give a digital input to the devices to evaluate the
pin states. LED Lines/Switch lines connected by 20pin box connector.
20PIN
MODULES LED & Switch Card Pin Details
CONNECTOR
1 SW1
VCC
2 SW2
R 10k
3 SW3
SLIDE SWITCH
2 1
SW1
4 SW4 R
10k
5 SW5
6 SW6 Make Switch Close – High
7 SW7 Make Switch Open – Low
8 SW8
9 LED1
10 LED2
LED1
R1 330E
11 LED2
12 LED2
LED
Description
In this program to blink 8 Nos. of point LEDs at once in 250msec delay, Spartan3 FPGA
lines (P77 - P80 and P82 – P85) are configured has LED Outputs. User could verify the
result by using “LED & Switch Card” connected to the FPGASP3 Kit at connector J6
Flow Chart
START
Initialize
Entity
END
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
port ( clk : in std_logic; -- clock i/p
led : out std_logic_vector(7 downto 0)); -- 8-led o/p
end code;
begin
process(clk)
variable i,j : integer := 0;
begin
if clk'event and clk = '1' then
if i < 25000000 then --on delay logic
i := i + 1;
led(j) <= '1';
elsif i = 25000000 then
i := 0;
led(7 downto 0) <= "00000000";
if j < 7 then --checking for 8 display
j := j + 1;
elsif j = 7 then
j := 0;
end if;
end if;
end if;
end process;
end Behavioral;
RESULT
SW : PSTYRO-FPGASP3\Code\EXA-2a\..............
Description
In this program to give digital inputs from slide switches and switch status could be
viewed by point LEDs, In Spartan3 FPGA lines (P60, P63, P68, P69, P70, P73, P74, P76)
are configured has Digital Inputs and LEDs configured as (P77-P80 and P82-P85) outputs.
User could verify the result by using “LED & Switch Card” connected to the FPGASP3 Kit
at connector J6
Flow Chart
START
Initialize
Entity
END
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity code is
port ( SW : in std_logic_vector(7 downto 0); ---data i/p
LED : out std_logic_vector(7 downto 0)); ---data o/p
end code;
RESULT
Hardware Description
Key arranged by matrix format, FOR each row and column section pulled by high, all row lines
(R1 – R4) and column lines (C1 – C4) connected directly by the 20pin box connector.
20PIN
MODULES 4X4 Matrix Keypad Card
CONNECTOR
1 R1
C2
C3
C4
C1
4 R4 R2
6 C2 R3
Description
In this example to scan Row and Column lines in 4 X 4 Matrix Keypad and view the result
in LED. In Spartan3 FPGA lines (P60, P63, P68 and 69) are configured for Horizontal
(ROW) lines. Pins (P70, 73, 74 and P76) are configured for Vertical (column) lines. User
could verify the result by “4 X 4 Matrix Keypad Interface Card” connected to the
FPGASP3 Kit at connector J6.
Flow Chart
Truth Table
START
4 x4 Matrix Row LEDs lines Column LEDs lines
Keypad D4 D5 D6 D7 D8 D9 D10 D11
Initialize Entity SW1 1 0 0 0 1 0 0 0
SW2 1 0 0 0 0 1 0 0
SW3 1 0 0 0 0 0 1 0
SW4 1 0 0 0 0 0 0 1
Send ROW lines = ‘1’ SW5 0 1 0 0 1 0 0 0
SW6 0 1 0 0 0 1 0 0
SW7 0 1 0 0 0 0 1 0
Scan Column lines with
respect to GND SW8 0 1 0 0 0 0 0 1
SW9 0 0 1 0 1 0 0 0
SW10 0 0 1 0 0 1 0 0
SET LED in on board high in SW11 0 0 1 0 0 0 1 0
Column & Row lines
SW12 0 0 1 0 0 0 0 1
SW13 0 0 0 1 1 0 0 0
END
SW14 0 0 0 1 0 1 0 0
SW15 0 0 0 1 0 0 1 0
SW16 0 0 0 1 0 0 0 1
RESULT
Description
In Spartan3 FPGA lines (P60, P63 and P68) - LCD control lines Pins (P77 to P80 and P82
to P85) LCD data lines. (P32, P33 P35 and P36) - Horizontal (ROW) lines. Pins (P40, P41,
P44 and P46) - Vertical (column) lines. User could verify the result by “4X4 Matrix
Keypad Interface Card” connected to the FPGASP3 Kit at connector J7 and “2X16 LCD
Interface Card” connected to the FPGASP3 Kit at connector J6.
Flow Chart
START
Initialize Entity
END
Hardware Description
Relay & Buzzer Card , consists of 6 Nos. 5V SPDT Relay with output terminations, and 2 Nos. of
continuous buzzer connected to the 20pin box connector to study relay and buzzer modules.
ULN2803 is used as a driver for port I/O lines, drivers output connected to relay modules and
buzzers. Connector provided for external power supply if needed.
Relay / Buzzer Module : Make port pins high devices “relay/buzzer” activated.
20PIN
MODULES Relay & Buzzer Card
CONNECTOR
1 RELAY1
VCC
5
2 RELAY2 3
4
RELAYS
3 RELAY3 1 0
1
I/P - HIGH
2 RELAY
4 RELAY4
DRIVER
RELAY SPDT
5 RELAY5
LS1
1
6 RELAY6 I/P - HIGH 0 BUZZER
7 BUZZER1
BUZZER
Make Pins High – Relay/Buzzer ON
8 BUZZER2
9-16 NC Pins 9-16 Not used
17,19 Vcc
PWR Supply form FPGASP3 Kit
18,20 Gnd
Description
In this program to toggle relays On/Off continuously with 1 sec delay time. In Spartan3
FPGA lines (P60, P63, P68, P69, P70, and P73) are configured for relays. User could verify
the result by using “Relay & Buzzer Card” connected to the FPGASP3 KIT at connector
J6.
Flow Chart
START
Initialize Entity
IF relay R0-R5
>>1
Relay - ON
1sec Delay
Relay - OFF
1sec Delay
END
entity first is
port ( clk : in std_logic;
relay : out std_logic_vector(5 downto 0) := "000000");
end first;
Result
Description
In this program to generate sound signal continuously with delay of 1sec interval using
piezo-electric buzzer. In Spartan3 FPGA lines Buzzer1 (P74) and Buzzer2 (P76) are
configured for Buzzers. User could verify the result by using “Relay & Buzzer Card”
connected to the FPGASP3 KIT at connector J6.
Flow Chart
START
Initialize Entity
Buzzer 1 - ON
Buzzer 2 - OFF
Buzzer 1 - OFF
Buzzer 2 - ON
END
entity first is
port ( clock : in std_logic;
buzzer1 : out std_logic; --i/o declaration
buzzer2 : out std_logic);
end first;
Result
Hardware Description
It has 6 nos. of common anode seven segment displays are used. The segment lines of seven
segments LED is being terminated at 20pin connector pin 9-to 16. The digit select lines are
connected to the 20pin box connector pin1- to pin6. All the common anode displays consume
very small amount of current.
20PIN
MODULES 7-Segment Display Card
CONNECTOR
1 Digit - 1
2 Digit – 2 VCC
Digit select lines
3 Digit – 3
1
1K
Digit - 1 2
4 Digit - 4
5 Digit – 5 3
6 Digit – 6 U1
3
seg-a 7
7 NC
CA
CA
Seg-b 6 A
Seg-c 4 B
8 NC seg-d 2 C
seg-e 1 D
9 Seg - a seg-f 9 E
seg-g 10 F
10 Seg – b seg--dp 5 G
DP
11 Seg – c
Segment Lines
7 SEG DISP
12 Seg – d
a
13 Seg – e
f g b Make high to - digit selection
14 Seg – f e d c Make low to - segment
15 Seg – g
16 Seg – dp
PWR 17,19 Vcc
Supply form FPGASP3 Kit
18,20 Gnd
Description
In this program to display simple message “000000” to”FFFFFF” the 7-seg display
module. In Spartan3 FPGA lines (P60, P63, P68, P69, P70, and P73) are configured for
digit selection lines. Pins (P77 - P80 and P82 – P85) are configured by data lines. User
could verify the result by “7-SEG Display Card” connected to the FPGASP3 KIT at
connector J6.
Flow Chart
START
Initialize Entity
Display Message
‘000000’ –‘FFFFFF’
END
Result
Description
In This example to display simple counter for “0- 1000” to the 7-seg display module. In
Spartan3 FPGA lines (P60, P63, P68, P69) are configured for (Digit-1 to Digit-4) selection
lines. Pins (P77 - P80 and P82 – P85) are configured by data lines. User could verify the
result by “7-SEG Display Card” connected to the FPGASP3 KIT at connector J6.
Flow Chart
START
Initialize Entity
Counter Display
(0-1000)
END
Result
Hardware Description
Stepper Motor
Bipolar Stepper Motor driven by h-bridge driver, facility to connect external power supply to the
motor. 5V Stepper Motor speed, direction (clockwise/counterclockwise) and angle rotation
through user program.
DC Motor
5V DC Motor speed has controlled through PWM signal. Motor can run both clockwise/counter
clockwise, Motor speed controlled by varying ENA (duty cycle) signal through program.
20PIN
MODULES Stepper Motor / DC motor Card
CONNECTOR
1 COIL-A VCC MOTOR_PWR
STEPPER
STEPPER MOTOR
2 COIL-B COIL-A 1
VS
VSS
6
EN1
EN2
5-8 NC
9 PWM1 VCC
10 PWM2
DC MOTOR
MOTOR SERVO
VS
VSS
11 ENA PWM1 1 2
A
+
Description
In this example to rotate stepper motor clockwise/counter clockwise continuously the
motor interface card. For that in Spartan3 FPGA lines (P60, P63, P68, P69) are configured
for (Coil-A to Coil-D). Separate switch provided for changing direction of the motor to
the FPGASP3 KIT board Switch SW0 (P86). User could verify the result by “Stepper/DC
motor Card” connected to the FPGASP3 KIT at connector J6.
Flow Chart
START
Initialize Entity
OFF
IF SW0?
ON
Send Data Sequence Send Data Sequence
with delay with delay
‘0001’ ‘1000’
‘0010’ ‘0100’
0100’ ‘0010’
‘1000’ ‘0001’
END
entity stepper is
port
(
Clk : in STD_LOGIC; -- clock I/P
CW_CCW : in STD_LOGIC; -- direction control
Rst : in STD_LOGIC; -- system reset
Step_En : in STD_LOGIC; -- step enable
FS_HS : in STD_LOGIC; -- Half step / Full step control
W1, W2, W3, W4 : out STD_LOGIC ); -- Winding o/ps
end stepper;
begin
------------------------------------------------------------------------
process (Clk,rst)
begin
if Rst='0' then --starting process
div <= (others=>'0');
elsif Clk'event and Clk='1' then
div <= div + 1;
end if;
end process;
------------------------------------------------------------------------
-- divided clock signal
-- change this value to control the speed of motor.
clk_s <= div(16);
------------------------------------------------------------------------
process (clk_s,rst)
begin
if Rst='0' then
Ps_state <= reset;
elsif clk_s'event and clk_s='1' then
if Step_en='1' then
Ps_state <= Nx_state;
end if;
end if;
end process;
------------------------------------------------------------------------
process (ps_state,CW_CCW,Step_en,rst,FS_HS)
begin
case(ps_state) is
Hardware Description
Traffic light controller card consist of 12 Nos. point led arranged by 4Lanes. Each lane has
Go(Green), Listen(Yellow) and Stop(Red) LED is being placed. Each LED has provided for current
limiting resistor to limit the current flows to the LEDs. LED1 to LED12 are terminated by the
20pin box header.
LAN 20PIN
MODULES Traffic Light Controller Card
Direction CONNECTOR
SOUTH 1 GO
330E
2 LISTEN GO
3 STOP LISTEN
330E
EAST 4 GO
330E
5 LISTEN STOP
6 STOP
NORTH 7 GO LANE
NORTH
8 LISTEN
9 STOP
LANE LANE
WEST 10 GO WEST EAST
11 LISTEN
12 STOP Make high to - LED On
Make low to – LED Off LANE
SOUTH
13-16 NC
PWR 17,19 Vcc
Supply form FPGASP3 Kit
18,20 Gnd
Description
In this example to control 4-way traffic light module with sequence delay. In Spartan3 FPGA lines
(P60, P63 and P68) are configured for (NORTH GO, LISTEN & STOP) lines. Pins (P69, P70 and P73)
are configured for (EAST GO, LISTEN & STOP) lines. Pins (P74, P76 and P77) are configured for
(SOUTH GO, LISTEN & STOP) lines. Pins (P78, P79 and P80) are configured for (WEST GO, LISTEN
& STOP) lines. Pins P86 are configured for control switches. User could verify the result by
“Traffic light controller cad” connected to the FPGASP3 KIT at connector J6.
Flow Chart
START
IF SWITCH?
ON
Send Data Sequence with delay
NORTH GO
SOUTH STOP
EAST STOP
WEST STOP
entity first is
port ( clk : in std_logic;
rst : in std_logic;
northgreen : out std_logic;
northred : out std_logic;
northyel : out std_logic;
southgreen : out std_logic;
southred : out std_logic;
southyel : out std_logic; --------- I / O declaration
eastgreen : out std_logic;
eastred : out std_logic;
eastyel : out std_logic;
westred : out std_logic;
westgreen : out std_logic;
westyel : out std_logic);
end first;
Result
HW : FPGASP3 KIT CON ( J6 ) Traffic Light Controller Card
SW : PSTYRO-FPGASP3\Code\EXA-7\..............
COUNTERS
A counter is a device which stores the number of times a particular event or process has occurred,
often in relationship to a clock signal. There are two types of counters:
up counters
down counters
Up counters
Each of the higher-order flip-flops are made ready to toggle (both J and K inputs "high") if the Q
outputs of all previous flip-flops are "high." Otherwise, the J and K inputs for that flip-flop will
both be "low," placing it into the "latch" mode where it will maintain its present output state at
the next clock pulse. Since the first (LSB) flip-flop needs to toggle at every clock pulse, its J and K
inputs are connected to Vcc or Vdd, where they will be "high" all the time.
Description
In this program an up counter has a 1- bit input and a 4- bit output. Additional control signals
may be added such as enable. The output of the multiplexers depends on the level of the select
line.
Flow Chart
START
Initialize Entity
IF CLR=1
ON
Enable Clock
Counter
Value Increase from
(0 to 15)
END
entity counter is
port(Clock, CLR : in std_logic;
Q : out std_logic_vector(3 downto 0));
end counter;
architecture archi of counter is
signal tmp: std_logic_vector(3 downto 0);
begin
process (Clock, CLR)
begin
if (CLR='1') then
tmp <= "0000";
elsif (Clock'event and Clock='1') then
tmp <= tmp + 1;
end if;
end process;
Q <= tmp;
end archi;
Result
SW : PSTYRO-FPGASP3\Code\EXA-8a\..............
Description
In this program a down counter has a 1- bit input and a 4- bit output. Additional control signals
may be added such as enable. The output of the multiplexers depends on the level of the select
line.
Flow Chart
START
Initialize Entity
IF CLR=1
ON
Enable Clock
Counter
Value
Decreases from (15 to 0)
END
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(Clock, CLR : in std_logic;
Q : out std_logic_vector(3 downto 0));
end counter;
Q <= tmp;
end archi;
Result
SW : PSTYRO-FPGASP3\Code\EXA-8b\..............
Description
The Up/Down control input line simply enables either the upper string or lower string of AND
gates to pass the Q/Q' outputs to the succeeding stages of flip-flops. If the Up/Down control line
is "high," the top AND gates become enabled. If the Up/Down control line is made "low," the
bottom AND gates become enabled.
Flow Chart
START
Initialize Entity
NO
IF CLR=1
YES
Counter Counter
Value Value
Increases Decreases
from (0 to 15) From (15 to 0)
END
entity counter is
port(C, CLR, up_down : in std_logic;
Q : out std_logic_vector(3 downto 0));
end counter;
Result
SW : PSTYRO-FPGASP3\Code\EXA-8c\..............
Hardware Description
The 2x16 character LCD interface card with supports both modes 4-bit and 8-bit interface, and
also facility to adjust contrast through trim pot. In 8-bit interface 11 lines needed to create 8-bit
interface; 8 data bits (D0 – D7), three control lines, address bit (RS), read/write bit (R/W) and
control signal (E). The LCD controller is a standard KS0070B or equivalent, which is a very well-
known interface for smaller character based LCDs.
LCD’s Control Lines and Data lines are terminated with 20pin box connector.
20PIN
LCD
CONNECT LED & Switch Card Pin Details
MODULES
OR
1 RS
CONTROL
2 RW
LINES
3 E
4-8 NC
9 D0
+LED-
GND
VCC
LED
R/W
VEE
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
10 D1
LCD – DATA LINES
11 D2
12 D3
13 D4
14 D5
15 D6
16 D7
PWR 17,19 Vcc
Supply form FPGASP3 Kit
18,20 Gnd
Description
In this example to display message “PANTECH SOLUTIONS” in 2 X 16 LCD first line. In Spartan3
FPGA lines (P60, P63 and P68) are configured for LCD control lines like (RS, RW & E). Pins (P77 to
P80 and P82 to P85) are configured for LCD data lines. User could verify the result by “2 X 16 LCD
Interface Card” connected to the FPGASP3 KIT at connector J6. User can modify the LCD display
message by changing the data in VHDL code.
Flow Chart
START
Initialize Entity
END
entity lcd is
port ( clk : in std_logic; ----clock i/p
begin
lcd_rw <= '0'; ----lcd write
process(clk)
variable i : integer := 0;
variable j : integer := 1;
begin
Description
In this example to display message “PANTECH SOLUTIONS” in 2 X 16 LCD second line. In
Spartan3 FPGA lines (P60, P63 and P68) are configured for LCD control lines like (RS, RW &
E). Pins (P77 to P80 and P82 to P85) are configured for LCD data lines. User could verify the
result by “2 X 16 LCD Interface Card” connected to the FPGASP3 KIT at connector J6. User
can modify the LCD display message by changing the data in VHDL code.
Flow Chart
START
Initialize Entity
END
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity lcd is
port(clock:in std_logic;
led:out std_logic;
rw: out std_logic;
rs:out std_logic;
en:out std_logic;
data:out std_logic_vector(7 downto 0));
end lcd;
process(current_state,next_state)
begin
en<='1';
rw<='0';
case current_state is
when state1=>
data<="00111000";
en<='1';
rs<='0';
rw<='0';
when state8=>
next_state<=state8;
when others=>
next_state<=state8;
end case;
end process;
end arch;
Result
Description
In this example to rotate DC motor clockwise/counter clockwise continuously the motor
interface card. For that in Spartan3 FPGA lines (P77, P78) are configured for (Coil-A to
Coil-B). FPGA Lines (P79) to enable the dc motor. User could verify the result by
“Stepper/DC motor Card” connected to the FPGASP3 KIT at connector J6.
Flow Chart
START
Initialize Entity
IF EN=1
Clock Wise
Coil ‘A’ = 1;
Coil ‘B’ = 0;
END
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity first is
port ( clk : in std_logic;
rst : in std_logic;
enable : out std_logic;
output1 : out std_logic;
output2 : out std_logic);
end first;
begin
process(rst,clk)
variable i : integer := 0;
begin
if rst = '1' then
if clk'event and clk = '1' then
enable <= '1';
if i <= 1005000 then
i := i + 1;
output1 <= '0';
output2 <= '0';
elsif i > 1005000 and i < 1550000 then
i := i + 1;
output1 <= '1';
output2 <= '0';
elsif i = 1550000 then
i := 0;
end if;
end if;
end if;
end process;
end Behavioral;
Result
Description - MULTIPLEXERS
Multiplexer is a logic circuit that receives binary information from several inputs and transmits
information to single output. The input selected is controlled by a set of select inputs.
Description
In this program a 2 x 1 multiplexer has two 1- bit inputs, a 1-bit select line and a 1- bit output.
Additional control signals may be added such as enable. The output of the multiplexers depends
on the level of the select line.
Facts:
Data flow descriptions simulate the system by showing the signals flows from system inputs to
outputs. For example the Boolean function of the output or logical structure of the system shows
such a signal flow. Signal assignment statements are concurrent.
Code Listing
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; ------ library declaration
entity mux2x1 is
port (A, B, SEL, Gbar : in std_logic;
Y : out std_logic); ------ I/O declaration
end mux2x1;
Result
HW : FPGASP3 Starter Kit (Switches - SW3 , SW4, SW5) Selection Lines
LED | Switch Card - LED1 ( Mux O/P)
- SW1 - SW8 ( Mux I/P)
SW : PSTYRO-FPGASP3\Code\EXA-11a1\..............
Description
In this program an 8 x 1 multiplexer has 8- bit inputs, a 3-bit select line and a 1- bit output.
Additional control signals may be added such as enable. The output of the multiplexers depends
on the level of the select line.
Flow Chart
START
Initialize
Entity
IF
ENABLE = 1
IF
Y=A
SELECT = 1
Y=B
Facts:
The behavioral description describes the system by showing how the outputs behave according
to changes in the inputs.
In this description we don’t need to know the logic diagram of the system what must be known
is how the output behaves in response to change in the input.
In VHDL the major behavioral description statement is process.
entity MUX_if is
port (A, B, SEL, Gbar : in std_logic; Y : out std_logic);
end MUX_if;
begin
if Gbar = '0' then
if SEL = '1' then
temp := B;
else
temp := A;
end if;
Y <= temp;
else
Y <= 'Z';
end if;
end process;
end MUX_bh;
Result
HW : FPGASP3 Starter Kit (Switches - SW3 , SW4, SW5) Selection Lines
LED | Switch Card - LED1 ( Mux O/P)
- SW1 - SW8 ( Mux I/P)
SW : PSTYRO-FPGASP3\Code\EXA-11a2\..............
Description
A de-multiplexer performs the reverse operation of a multiplexer. It is a digital function that
receives information on a single line and transmits this information to one of the 2n possible
output lines. The output line being selected is determined by the bit combination of the selected
lines.
Description
In this program a 1 x 8 de-multiplexer have two 1- bit inputs, a 3-bit select line and a 8- bit
output. Additional control signals may be added such as enable. The output of the multiplexers
depends on the level of the select line.
Flow Chart
START
Initialize
Entity
END
entity demultiplexer is
port(e : in std_logic;
s : in std_logic_vector(0 to 2);
y : out std_logic_vector(0 to 7));
end demultiplexer;
Result
Encoder:
An encoder has 2n input lines and n output lines. The output lines generate a binary code
corresponding to the input value. For example a single bit 4 to 2 encoder takes in 4 bits and
outputs 2 bits. It is assumed. That there are only 4 types of input signals these are 0001, 0010,
0100 and 1000.
Logical Diagram
Truth Table
A3 A2 A1 A0 F1 F0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
Description
In this program an 8 x 1 encoder has 4- bit inputs and a 2- bit output. The output of the encoders
depends on the level of the input line.
Flow Chart
START
Initialize
Entity
IF
Input = 0001
Output = 00
IF
Input = 0010
Output = 01
IF
Input = 0100
Output = 10
IF
Input = 1000
Output = 11
entity first is
port ( input : in std_logic_vector(3 downto 0);
output : out std_logic_vector(1 downto 0));
end first;
architecture Behavioral of first is
begin
process(input)
begin
case input is
when "0001" =>
output <= "00";
when "0010" =>
output <= "10";
when "0100" =>
output <= "01";
when "1000" =>
output <= "11";
when others =>
null;
end case;
end process;
end Behavioral;
Result
HW : FPGASP3 Starter Kit (Switches - SW3 , SW4, SW5) Selection Lines
LED | Switch Card - LED1 ( Encoder O/P)
- SW1 - SW8 ( Encoder I/P)
SW : PSTYRO-FPGASP3\Code\EXA-12a\..............
A decoder is a device which does the reverse of an encoder undoing so that the original
information can be retrieved. The same method used to encode is usually just reversed in order
to decode. In digital electronics this would mean that a decoder is a multiple input, multiple
output logic circuit that converts coded inputs into coded outputs where the input and output
codes are different. E.g. n-to-2n
Logical Diagram
Description
In this program a 2 x 4 de-coder has 2- bit inputs and a 4- bit output. The output of the decoders
depends on the level of the input line.
Flow Chart
START
Initialize Entity
When others
Output = “0000”
END
entity first is
port ( input : in std_logic_vector(1 downto 0);
output : out std_logic_vector(3 downto 0));
end first;
architecture Behavioral of first is
begin
process(input)
begin
case input is
when "00" =>
output <= "1110";
when "01" =>
output <= "1101";
when "10" =>
output <= "1011";
when "11" =>
output <= "0111";
when others =>
output <= "1111";
end case;
end process;
end Behavioral;
Result
Serial-in, serial-out shift registers delay data by one clock time for each stage. They will store a
bit of data for each register. The data string is presented at 'Data In', and is shifted right one
stage each time 'Data Advance' is brought high. At each advance, the bit on the far left (i.e. 'Data
In') is shifted into the output. The bit on the far right (i.e. 'Data Out') is shifted out and lost.
Description
In this program a 8bit shift register has one control line (SW1) made switch ‘ON’ position to
enable the shift register. Every negative edge clock pulses, 1-bit shifted alternatively to right
side, output could verified by ‘LED interface card’.
Flow Chart
START
Initialize
Entity
Enable Clock
END
Result
7. Click Next to proceed to the Create New Source window in the New Project Wizard.
5. Click Next.
6. Declare the ports for the counter design by filling in the port information as shown below:
Let us we will see source code for Four Digit 7 segment LED display to configure in Spartan 3 FPGA with
synthesis and implementation.
Step 1: copy the above source code and paste it in project window in ISE 8.1i as shown below.
Step 3: Add your source code in your source window place a cursor above the IC number xc3s200-
4tq144.
Step 4: verify that your code is added with synthesis and implementation.
Specify the pin locations for the ports of the design so that they are connected correctly on the Spartan-3
Advance development board.
To constrain the design ports to package pins, do the following before that refer the chapter 4 for giving
the pin location.
Verify that object_co is selected in the Sources window.
Double-click the Assign Package Pins process found in the User Constraints process group. The
Xilinx Pin out and Area Constraints Editor (PACE) opens.
Select the Package View tab.
Select File → Save. You are prompted to select the bus delimiter type window will open. Select
synplify VHDL/exemplar default [] and click OK.
Close PACE.
In the Welcome dialog box, select Configure devices using Boundary-Scan (JTAG).
Verify that Automatically connect to a cable and identify Boundary-Scan chain is selected.
Click Finish.
If you get a message saying that there are two devices found, click OK to continue.