Professional Documents
Culture Documents
Version 9.50.11
Jenniffer Estrada
EE365: Advanced Digital Design
Prof. Khondker
December 4, 2008
Executive Summary
A traffic intersection is simulated on the DE1 board, using a button press,
KEY0, for a pedestrian wanting to cross, a switch, SW0, to simulate a car waiting at
the low priority street. Unless there is a pedestrian or a car in the low priority street,
the green light will be set for the high priority street. Key1 is used to return the
system to the initial default state, and 3 red and 3 green LEDs as well as three 7
segment displays are used to display the output of the system.
Problem Description
The traffic light control system will be implemented in a two street
intersection that allows pedestrians to cross on request. A cross-walk button, KEY 0,
can be used to halt all traffic to allow pedestrians to cross. Each traffic signal uses
at two LEDs (green and red) per traffic light or the pedestrian crossing point, one of
the two streets has a priority over the other. For the high priority street, the traffic
signal will always remain green until the low priority street car sensor has been
tripped or a pedestrian has pressed a crosswalk button. The occurrence of such an
event gives the high priority street 5 seconds before the light changes to red.
Switch, SW0, to simulate a car sensor at the low priority street and a button KEY0 to
simulate the crosswalk request button for pedestrian use. Multiple button presses
would be treated as a single press until the pedestrian gets a WALK (green) signal.
The duration of the green light for the low priority street and the pedestrian crossing
is 9 and 4 seconds, respectively. The system utilizes a second button, KEY1, to reset
the circuit, at which the seven segment displays are set to their default values (5, 9,
and 4) and the highest priority street becomes a green light. At no time should there
ever be more than one green light in the system. Each traffic or pedestrian crossing
light of this system will use seven segment displays that will display the number of
seconds left that the light will remain green. When any of these seven segment
displays reach zero they should reset to the default value (5, 9 and 4) and await the
next countdown.
Problem Decomposition
TrafficControl:ControlIntersect
HiDone
Clock
CLOCK_50
Clock
Enable
7' h7F --
LEDR[2..0]
PED
DecodeHex:LowPriority
PedDone
reset
HiCount[3..0]
Edge_Detect:PedCross
LowCount[3..0]
BitInput[3..0]
PedCount[3..0]
Clock
Enable
Enable
HEX2[6..0]
HEX3[6..0]
HexOutput[6..0]
LowDone
lowpriortraffic
ClockCounter:OneMilliSec
BitInput[3..0]
LOWP
EffClock
crosswalktraffic
Clock
DecodeHex:HighPriority
HIP
ClockCounter:OneSec
HEX1[6..0]
HexOutput[6..0]
LEDG[2..0]
Output
Input
DecodeHex:Pedestrian
Edge_Detect:Rst
BitInput[3..0]
HEX0[6..0]
HexOutput[6..0]
Clock
Enable
KEY[1..0]
Output
Input
SW[0..0]
register9
Selector8_OUT
trip9~0
ENA
trip5
SEL[5..0]
OUT
SEL
0
1
countdown5[2]
1' h0 - -
PRE
Q
1' h1 - -
CLR
5' h1D - -
countdown5[1]
SEL
DATAA
4' h5 - -
count4Down~0
A [4.. 0]
B [4.. 0]
PRE
countdown4[3..0]
SEL
DATAA
4' h4 --
DATAB
lowpriortr affic
reset
OUT0
ENA
ENA
CLR
countdown9~[3..0]
Add1
1' h1 - 5' h1D - -
A[4 ..0]
B[4 ..0]
DATAB
PRE
OUT0
LowCount[3..0]
ENA
MUX21
CLR
CLR
SELECTOR
0
1
Selector10
COUNT5_Low
countdown5[3..0]
countdown9[3]
SEL
DATAA
4' h9 - -
ADDER
ENA
DATA[1..0]
LowPrior
Pedestrian
COUNT5_Ped
CLR
ADDER
1' h1 --
Hig hPrior
count9Down~0
NextS~2
L2Ped
Go2Ped~1
MUX21
3' h7 - OUT0
countdown9[3..0]
CLR
SEL[5..0]
5' h00 --
Selector13
LowDone
PedDone
trip9
MUX21
B[4 ..0]
SELECTOR
OUT
1' h1 --
1' h1 --
HiCount[3..0]
ENA
CLR
CurrentS_Pedes trian
CurrentS_COUNT5_Ped
CurrentS_COUNT5_Low
DATA[5..0]
EQUAL
PRE
D
EffClock
WideOr5_OUT0
NextS~2_OUT0
Go2Ped~1_OUT0
CurrentS_LowPrior
ENA
DATA[5..0]
Equal0
CLR
ADDER
PRE
Q
ENA
CLR
DATAB
A[4 ..0]
OUT0
DATAB
CLR
countdown4~[3..0]
Add2
OUT
PRE
ENA
A[4 ..0]
B[4 ..0]
2' h3 - -
countdown5~[3..0]
Add0
ENA
Count5Down~0
DATAA
countdown5[3]
PRE
D
regis ter[5..4]
PRE
trip5~[1..0]
NextS~6
trip9~1
cross walktraffic
0
countdown4[3]
PRE
0
1
countdown4[2]
SEL[1..0]
Go2Ped
Selector6
ENA
CLR
res et
PRE
crosswalktraffic
PRE
D
Selector9
CurrentS
clk
Go2Ped
MUX21
ENA
CLR
countdown5[0]
Works ~0
trip9~3
Works ~0_OUT0
1' h1 --
PED
CurrentS_HighPrior
DATA[5..0]
ENA
CLR
LOWP
CurrentS_L2Ped
OUT
PRE
D
SELECTOR
SEL[5..0]
3' h7 --
Works ~2
trip4~2
SELECTOR
1' h0 - -
countdown4[1..0]
Equal2
PRE
D
Works ~3
A [4.. 0]
Q
5' h00 --
B [4.. 0]
PedCount[3..0]
ENA
EQUAL
CLR
Works ~1
1' h0 - -
countdown9[0]
Equal1
PRE
D
A [4.. 0]
Q
5' h00 --
B [4.. 0]
ENA
EQUAL
CLR
trip9~5
Selector11
trip4
SEL[1..0]
PRE
OUT
trip4~0_OUT0
1' h1 --
Selector12
DATA[1..0]
ENA
CLR
SELECTOR
SEL[5..0]
OUT
2' h3 - -
trip9~4
DATA[5..0]
trip9~6
SELECTOR
lowpriortraffic
Clock
Add0
A [1 5..0]
16' h0001 --
B [1 5..0]
count[15..0]
SEL
DATAA
16' h0000 --
DATAB
ADDER
PRE
OUT0
Equal0
Q
16' hC34E --
B [15 ..0 ]
ENA
MUX21
CLR
Enable~reg0
A [15 ..0 ]
EQUAL
PRE
D
Enable
ENA
CLR
Clock
50 MHz clock, the counter will count up to 49999999 and 49999, to create a 1
second and 1 millisecond enable signal, respectively.
Q[2..0]
PRE
D
Input
Clock
Enable
OutSig~0
OutSig
PRE
D
Output
ENA
ENA
CLR
CLR
Mux0
BitInput[3..0]
SEL[3..0]
16' h1083 --
DATA[15..0]
OUT
MUX
Mux1
SEL[3..0]
16' h208E --
DATA[15..0]
OUT
MUX
Mux2
SEL[3..0]
16' h02BA --
DATA[15..0]
OUT
MUX
Mux3
SEL[3..0]
16' h8692 --
DATA[15..0]
OUT
HexOutput[6..0]
MUX
Mux4
SEL[3..0]
16' hD004 --
DATA[15..0]
OUT
MUX
Mux5
SEL[3..0]
16' hD860 --
DATA[15..0]
OUT
MUX
Mux6
SEL[3..0]
16' h2812 --
DATA[15..0]
OUT
MUX
Alternative Designs
An alternate design for this project is the extent of modularity for the
component, TrafficControl, could be explored further. Another change would be to
make the states on the case statement into numbers, instead of words. Instead of
having one giant file that does all the needed functions to control the intersection,
many small counters and signals could be implemented to help aide with the extent
of the projects modularity.
Design Documentation
HighPriority
COUNTDOWN5Ped
COUNTDOWN5Low
LowPriority
reset
Pedestrian
L2Ped
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
ENTITY TrafficLightIntersection IS
PORT (CLOCK_50: IN
std_logic;
KEY :
IN
std_logic_vector(1 downto 0);
SW :
IN
std_logic_vector(0 downto 0);
HEX0 :
OUT std_logic_vector(6 DOWNTO 0);
HEX1 :
OUT std_logic_vector(6 DOWNTO 0);
HEX2 :
OUT std_logic_vector(6 DOWNTO 0);
HEX3 :
OUT std_logic_vector(6 DOWNTO 0);
LEDR :
OUT std_logic_vector(2 DOWNTO 0);
LEDG :
OUT std_logic_vector(2 DOWNTO 0));
END TrafficLightIntersection;
ARCHITECTURE Behavior OF TrafficLightIntersection IS
COMPONENT DecodeHex IS
PORT ( BitInput:
HexOutput:
END COMPONENT DecodeHex;
COMPONENT ClockCounter IS
GENERIC (UpperBound: integer);
PORT (
Clock: IN std_logic;
Enable: OUT std_logic);
END COMPONENT ClockCounter;
component TrafficControl IS
PORT (
EffClock:
IN STD_LOGIC;
Clock :
IN STD_LOGIC;
crosswalktraffic:
IN STD_LOGIC;
lowpriortraffic:
IN STD_LOGIC;
reset :
IN STD_LOGIC;
HIP :
OUT STD_LOGIC;
LOWP :
OUT STD_LOGIC;
PED :
OUT STD_LOGIC;
HiDone :
OUT STD_LOGIC;
LowDone :
OUT STD_LOGIC;
PedDone :
OUT STD_LOGIC;
HiCount :
OUT STD_LOGIC_VECTOR (3 downto 0);
LowCount :
OUT STD_LOGIC_VECTOR (3 downto 0);
PedCount :
OUT STD_LOGIC_VECTOR (3 downto 0));
END component TrafficControl;
COMPONENT Edge_Detect is
Port( Clock:
IN std_logic;
Enable:
IN std_logic;
Input:
IN std_logic;
Output:
OUT std_logic);
END COMPONENT Edge_Detect;
signal
signal
signal
signal
signal
signal
signal
Enable1s :
Enable1ms :
PedXing :
reset :
HiCountsig :
LowCountsig :
PedCountsig :
STD_LOGIC;
STD_LOGIC;
STD_LOGIC;
STD_LOGIC;
STD_LOGIC_VECTOR (3 downto 0);
STD_LOGIC_VECTOR (3 downto 0);
STD_LOGIC_VECTOR (3 downto 0);
begin
PedCross: Edge_Detect port map (Clock => CLOCK_50,
Input => KEY(0),
Enable => Enable1ms,
Output=> PedXing);
Rst: Edge_Detect port map(
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
ENTITY ClockCounter IS
GENERIC (UpperBound: integer);
PORT (
Clock:
IN std_logic;
Enable:
OUT std_logic);
END ClockCounter;
ARCHITECTURE behavior OF ClockCounter IS
signal count : integer range 0 to(UpperBound-1);
BEGIN
PROCESS (Clock)
BEGIN
IF (rising_edge(Clock)) then
IF(count = (UpperBound-1)) then
count <= 0;
Enable <= '1';
else
count <= count+1;
Enable <= '0';
end if;
end if;
END PROCESS;
END behavior;
library ieee;
use ieee.std_logic_1164.all;
ENTITY DecodeHex IS
PORT(
BitInput:
IN std_logic_vector(3 downto 0);
HexOutput: OUT std_logic_vector(6 downto 0));
END DecodeHex;
ARCHITECTURE Behavior OF DecodeHex IS
BEGIN
WITH BitInput SELECT
HexOutput <=
"1000000" WHEN "0000",
"1111001" WHEN "0001",
"0100100" WHEN "0010",
"0110000" WHEN "0011",
"0011001" WHEN "0100",
"0010010" WHEN "0101",
"0000010" WHEN "0110",
"1111000" WHEN "0111",
"0000000" WHEN "1000",
"0011000" WHEN "1001",
"0001000" WHEN "1010",
"0000011" WHEN "1011",
"1000110" WHEN "1100",
"0100001" WHEN "1101",
"0000110" WHEN "1110",
"0001110" WHEN "1111",
"1111111" WHEN others;
END Behavior;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
Entity Edge_Detect is
Port( Clock: IN std_logic;
Input: IN std_logic;
Output: OUT std_logic);
END Edge_Detect;
Architecture structural of Edge_Detect IS
signal Q1:std_logic;
signal Q0:std_logic;
Begin
Process(Clock)
BEGIN
if (rising_edge (Clock)) then
Q0<=not Input;
Q1<=Q0;
Output <= not(Q0) and (Q1);
END IF;
end process;
end structural;
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Use ieee.std_logic_arith.all;
Entity TrafficControl is
PORT (EffClock: IN STD_LOGIC;
Clock : IN STD_LOGIC;
crosswalktraffic : IN STD_LOGIC;
lowpriortraffic : IN STD_LOGIC;
reset : IN STD_LOGIC;
HIP : OUT STD_LOGIC;
LOWP : OUT STD_LOGIC;
PED : OUT STD_LOGIC;
HiDone : OUT STD_LOGIC;
LowDone : OUT STD_LOGIC;
PedDone : OUT STD_LOGIC;
HiCount : OUT STD_LOGIC_VECTOR (3 downto 0);
LowCount : OUT STD_LOGIC_VECTOR (3 downto 0);
PedCount : OUT STD_LOGIC_VECTOR (3 downto 0));
end TrafficControl;
architecture Behavioral of TrafficControl is
type State is (HighPriority, LowPriority, Pedestrian, COUNTDOWN5Ped,
COUNTDOWN5Low, L2Ped);
signal CurrentState , NextState : State;
signal countdown9 : std_logic_vector (3 downto 0);
signal countdown4 : std_logic_vector (3 downto 0);
signal countdown5 : std_logic_vector (3 downto 0);
signal resetsig : std_logic;
signal HiEnable : std_logic;
signal LowEnable : std_logic;
signal PedEnable : std_logic;
signal register5 : std_logic;
signal register9 : std_logic;
signal register4 : std_logic;
signal trip5 : std_logic;
signal trip9 : std_logic;
signal trip4 : std_logic;
signal Go2Ped : std_logic;
begin
end process;