Design and Implementation of Traffic Lights Controller Using Fpga
Design and Implementation of Traffic Lights Controller Using Fpga
Design and Implementation of Traffic Lights Controller Using Fpga
Submitted by
Lab Instructor
Dr.Fazal NoorBasha
Department of ECE,
KL University, Vaddeswaram, Guntur, AP – 522502
Academic Year : 2013-2014
Department of Electronics and Communication Engineering
KL University, Vaddeswaram, Guntur, AP – 522502
CERTIFICATE
Working on this Project based Lab is certainly a memorable and enjoyable event in our life.
We have learned a lot of interesting new things that have broadened our view of the
technology field. In here, we would like to offer our appreciation and thanks to several
grateful and helpful individuals. Without them, this work could not have been completed and
We are very grateful to our esteemed Professors Dr. Fazal Noorbasha (Section Instructor),
Dr. K Harikishore, Mr.B.Kali Vara Prasad and Ms. M Preeti, Department of ECE, KL
University, Vaddeswaram, Guntur, A.P., INDIA, for their valuable guidance and creative
Furthermore, we are also very thankful Dr. Fazal Noorbasha, Microelectronics Group Head,
to have an opportunity to learn from him on the aspect of using the advancing FPGA
technology to improve the performance for different memory and processor applications.
Hopefully, this experience will inspire us to come up with new and interesting research ideas
in the future.
Furthermore, we want to offer our thanks to Dr. ASCS Sastry, Professor & Head,
Department ECE, KL University, Vaddeswaram, Guntur, A.P., INDIA, for providing the
We would like to thank all those helped us directly or indirectly during this
project work.
Red, Green & Amber lights in a particular sequence. The Traffic Light
sequences that can be used to control the traffic lights of a typical four
mode and night mode operations. It plays more and more important role in
modern management and control of urban traffic to reduce the accident and
synthesis sequence. The methods that are used in this project are design
Certificate i
Declaration ii
Acknowledgements iii
Abstract iv
List of Figures V
List of Tables Vi
Contents Vii
Chapter – 1
Introduction 1-2
1.1 Traffic lights 1
1.2 Electronic design with FPGA’S 2
1.3 FPGA design flow 3
Chapter – 2
System Block Diagram and Working Principle 3-4
2.1 System block diagram 3
2.2 Working Principle 4
Chapter – 3 5-6
System Modeling 5
Chapter – 4
Implementation results 7-8
4.1 System Analysis 7
4.2 Results Report 8
Chapter 5
Conclusions and Applications 9-10
5.1 Conclusion 9
5.2 Applications 10
Appendix 11-13
Appendix – A: Verilog Code and Test Bench 11
Appendix – B: References 13
Chapter – 1
INTRODUCTION
Standard products
Custom Logic
There are several options on how to implement custom logic, FPGAs being
one amongst them.
Synthesis
The process which translates VHDL or Verilog code into a device netlist
format .i.e a complete circuit with logical elements( gates, flip flops, etc…) for
the design.If the design contains more than one sub designs, ex. to
implement a processor, we need a CPU as one design element and RAM as
another and so on, then the synthesis process generates netlist for each
design element
Synthesis process will check code syntax and analyze the hierarchy of the
design which ensures that the design is optimized for the design
architecture, the designer has selected. The resulting netlist(s) is saved to an
NGC( Native Generic Circuit) file (for Xilinx® Synthesis Technology (XST)).
Translate process combines all the input netlists and constraints to a logic
design file. This information is saved as a NGD (Native Generic Database)
file. This can be done using NGD Build program. Here, defining constraints
is nothing but, assigning the ports in the design to the physical elements
(ex. pins, switches, buttons etc) of the targeted device and specifying time
requirements of the design. This information is stored in a file named UCF
(User Constraints File).
Tools used to create or modify the UCF are PACE, Constraint Editor etc.
Map process divides the whole circuit with logical elements into sub blocks
such that they can be fit into the FPGA logic blocks. That means map
process fits the logic defined by the NGD file into the targeted FPGA
elements (Combinational Logic Blocks (CLB), Input Output Blocks (IOB))
and generates an NCD (Native Circuit Description) file which physically
represents the design mapped to the components of FPGA. MAP program is
used for this purpose.
Device Programming
Now the design must be loaded on the FPGA. But the design must be
converted to a format so that the FPGA can accept it. BITGEN program deals
with the conversion. The routed NCD file is then given to the BITGEN
program to generate a bit stream (a .BIT file) which can be used to configure
the target FPGA device. This can be done using a cable. Selection of cable
depends on the design.
Design Verification
Static Timing Analysis This can be done after MAP or PAR processes Post
MAP timing report lists signal path delays of the design derived from the
design logic. Post Place and Route timing report incorporates timing delay
information to provide a comprehensive timing summary of the design.
Chapter – 2
Design of Traffic Light Controller
In this structure, there are four traffic signals, represented by R1, R2, R3
and R4 to be controlled. All the four signals have same priority as they all
are main roads.
First of all the signal controller is in the reset mode where in the signal of
road (R1) is green whereas all the other roads R2, R3 and R4 are red. This
state we have assigned as S0.
Later the controller sends the control to state S1 where the R1 is yellow
whereas all the other signals are still red only. In this state the controller
checks whether the sensor at road R2 which is X2 is low or not. If the
sensor gives a low signalling that there is no traffic on that road, then that
signal on road R2 is skipped transferring control to the state S4 where
signal on road R3 is turned whereas rest of the signals are showing red. On
the hand if the traffic is present on the road R2 then the control is sent to
state S2 which switches on the signal on road R2 to green and rest of the
signals are red only when the control is with state S2 after showing the
green signal the signal light changes from green to yellow for signal on the
road R2 while all the other signals continue to be in red light mode only
which is the operation of state S3.
Again when the controller is in state S3 it checks for the response of sensor
X3 on road R3. If the output of sensor is low the control of the system will
be transferred to state S6 skipping the working of the signal on road
R3 otherwise the control is given to corresponding next state S4.
When in S4 the traffic signal of road R3 turns green on the other hand the
signals of roads R1, R2 and R4 remain red itself. The control is then
transferred to state S5.
When the control is with state S5 it checks for the output of the sensor X4
on the road R4. Depending on the output of X4 the further state change
takes place accordingly. If low then the control is transferred to state S0
skipping the operation of the signal on road R4 otherwise the control is with
the S6. When the controller is in state S5 there is change of signal on road
R3 from green to yellow.
When the control is with state S6 the signal of road R4 turns green whereas
all the signal turn or remain in red signal only. Thee control is then shifted
to state S0.
The TLC state diagram shown in Fig 2.3 illustrates that whenever cnt=00
and dir=00,then green light in north direction will be ON for few seconds
and red signal light in all other directions namely west, south and east will
be ON. When cnt=01 and dir=00 then yellow light (y1) will be ON for few
seconds and when cnt=01 yellow light (y2) and pedestrian north will be ON
and then dir is incremented by one and cnt is assigned to zero. So when
cnt=00 and dir=01, the green light in east direction will be ON for few
seconds and all red lights in other directions be ON. Whenever cnt=01 and
dir=01 then yellow light (y1) will be ON for few seconds and when cnt=01
yellow light (y2) and pedestrian east will be ON and then dir is incremented
by one and cnt is assigned to zero.
So whenever cnt=00 and dir=10, the green light in south direction will be
ON for few seconds and all red lights in other directions will be ON.
Whenever cnt=01 and dir=10 then yellow light (y1) will be ON for few
seconds and when cnt=01 yellow light (y2) and pedestrian south will be ON
and then dir is incremented by one and cnt is assigned to zero. So whenever
cnt=00 and dir=11, the green light in west direction will be ON for few
seconds and all red lights in other directions will be ON. Whenever cnt=01
and dir=11 then yellow light (y1) will be ON for few seconds and when
cnt=01 yellow light (y2) and pedestrian west will be ON and then dir is
assigned to 00 and cnt is assigned to zero. This sequence repeats and the
traffic flow will be controlled by assigning time periods in all the four
directions.
Chapter – 3
Simulation Results
The below figure shows the RTL Schematic of the Traffic Light Controller.
The below figure shows the Technology Schematic of the Traffic Light Controller.
The below figure shows the Wave form of the Traffic Light Controller when the test
bench is applied to the source code.
The future scope of this project is it can be directly applied in real time by
employing more number of such circuits.
Bibliography
input[1:0] state;
input reset;
always@(reset or state)
begin
if(reset==0)
begin
grn=4'b0000;
//ylw=4'b0000;
ylw=4'b1111;
rd=4'b1111;
end
else
case (state)
2'b00:
begin
grn=4'b0001;
//ylw=4'b0010;
ylw=4'b1101;
rd=4'b1100;
end
2'b01:
begin
grn=4'b0010;
//ylw=4'b0100;
ylw=4'b1011;
rd=4'b1001;
end
2'b10:
begin
grn=4'b0100;
//ylw=4'b1000;
ylw=4'b0111;
rd=4'b0011;
end
default:
begin
grn=4'b1000;
//ylw=4'b0001;
ylw=4'b1110;
rd=4'b0110;
end
endcase
an=4'b1110;
end
endmodule
Test bench :
module tb;
// Inputs
reg reset;
// Outputs
prjctr uut (
.state(state),
.reset(reset),
.grn(grn),
.ylw(ylw),
.rd(rd)
);
initial begin
// Initialize Inputs
state = 2'b00;
reset = 1;
#100;
state = 2'b01;
reset = 0;
#100;
state = 2'b01;
reset = 1;
#100;
state = 2'b10;
reset = 1;
#100;
state = 2'b11;
reset = 1;
#100;
state = 2'b00;
reset = 1;
#100;
state = 2'b01;
reset = 1;
#100;
state = 2'b10;
reset = 1;
#100;
state = 2'b11;
reset = 1;
#100;
state = 2'b00;
reset = 1;
#100;
end
endmodule
UCF FILE:
net "reset" loc=p11;