logo

Traffic Light Controller Implementation

   

Added on  2023-04-19

11 Pages1543 Words154 Views
Contents
Introduction:...............................................................................................................................................2
State Diagram:.............................................................................................................................................2
State Table:..................................................................................................................................................2
Implementation:..........................................................................................................................................3
HDL Code:....................................................................................................................................................4
Test Bench:..................................................................................................................................................9
Simulation Results:....................................................................................................................................10
Design Summary:.......................................................................................................................................10
Dataflow Diagram:.....................................................................................................................................10

Introduction:
Traffic light controller has 4 inputs namely clock, reset, car and Pedestrian. The controller generates 6
individual outputs for 6 lights in set of 2. The controller starts in initial state with main light green and
side light as Red. And stays in state until minimum of 60 seconds are completed. Afterwards, it waits for
input from Car or pedestrian to change to yellow state. It stays in Yellow state for total of 10 states after
which main light transitions to Red and side light becomes green.
If car input is still on at the end of 30 seconds, the red light on green is extended by another 30 seconds
else side lights transition to Yellow state and to red state after 10 seconds. At this moment, the Main
lights turn green. The cycle then continues. The same is represented as State transition diagram here.
State Diagram:
State Table:
The above state transitions can be mapped in to form of a table along with set of input control signals
that are required to change states. Table also mentions the outputs as generated based on present state
of the controller.
Main_Green
Main_Interupti
ble
Main_Yellow
Main_Red,Side
_Green
Side_Yellow
Side_extended

Present State Inputs Next State Output
Ca
r
Pe
d
yellow_u
p
side_u
p
main_u
p
M_Light
(RM,YM,GM
)
S_Light
(RS,YS,GS
)
MAIN_GREEN X X X X 0 MAIN_GREEN 0, 0, 1 1, 0, 0
MAIN_GREEN X X X X 1 MAIN_INTERUPTIBLE 0, 0, 1 1, 0, 0
MAIN_INTERUPTIBLE 0 X X X X MAIN_INTERUPTIBLE 0, 0, 1 1, 0, 0
MAIN_INTERUPTIBLE 1 X X X X MAIN_YELLOW 0, 0, 1 1, 0, 0
MAIN_YELLOW X X 0 X X MAIN_YELLOW 0, 1 ,0 1, 0, 0
MAIN_YELLOW X X 1 X X SIDE_GREEN 1, 0, 0 0, 0, 1
SIDE_GREEN X X X 0 X SIDE_GREEN 1, 0, 0 0, 0, 1
SIDE_GREEN 0 X X 1 X SIDE_YELLOW 1, 0, 0 0, 0, 1
SIDE_GREEN 1 X X 1 X SIDE_GREEN_EXTENDE
D
1, 0, 0 0, 0, 1
SIDE_GREEN_EXTENDE
D
X X X X 0 SIDE_GREEN_EXTENDE
D
1, 0, 0 0, 0, 1
SIDE_GREEN_EXTENDE
D
X X X X 1 SIDE_YELLOW 1, 0, 0 0, 0, 1
SIDE_YELLOW X X 0 X X SIDE_YELLOW 1, 0, 0 0, 1, 0
SIDE_YELLOW X X 1 X X MAIN_GREEN 1, 0, 0 0, 1, 0
Implementation:
The state table is implemented using 3 flip flops. Since number of states is 6, we will need at least 3 flip
flops to keep track of states. For each input, a separate next state logic has to be designed using selected
flip flops excitation table. Based on the excitation table, the next state is computed and assigned to the
flip flops on next positive edge of clock.
Assigning states to binary values assume p[2:0] for present state and n[2:0] for next state:
N [0] = main_up + ~p2&~p1&p0&~car&~ped + ~p2&p1&~p0&yellow_up + ~p2&p1&p0&~side_up +
~p2&p1&p0&~car +p2&~p1&p0&~yellow_up
N[1] = ~p2&~p1&p0&car + ~p2&~p1&p0&ped + ~p2&p1&~p0 + ~p2&p1&p0&~side_up
N[2] = ~p2&p1&p0&side_up + p2&~p1&~p0 + p2&~p1&p0&yellow_up
The equations have not been optimized completely as approach in modelling is different. The case
statement is used to model decoder logic and make suitable next state values.

HDL Code:
`timescale 1ns / 1ns
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date:
// Design Name:
// Module Name: TrafficLight
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module TrafficLight(car,ped,reset,clk,RM,YM,GM,RS,YS,GS);
// inputs to DUT
input car,ped,reset,clk;
// OUTPUT from DUT
output RM,YM,GM,RS,YS,GS;
reg [5:0] main_counter;
wire main_up;
reg main_start;

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Traffic Light Control System
|8
|750
|406

SOP and Traffic Light Circuit Design using Logic Gates
|8
|598
|290

State Diagram:.
|13
|839
|100

Fundamentals of Electrical and Electronic Engineering
|6
|816
|26

Desklib Online Library for Study Material with Solved Assignments
|12
|2074
|254

Computer Architecture and Organization I CMPE 263
|12
|1578
|375