Sensor Based Traffic Light Controller using FSM Technique -
Output Waveform : Sensor Based Traffic Light Controller |
Verilog CODE -
//-----------------------------------------------------------------------------
//
// Title : TLC_Sensor
// Design : verilog upload 4
// Author : Naresh Singh Dobal
// Company : nsdobal@gmail.com
// Verilog Programs & Exercise with Naresh Singh Dobal
//
//-----------------------------------------------------------------------------
//
// File : sensor based single way Traffic Light Controller.v
module TLC_Sensor ( clk ,sensor ,r ,y ,g );
output r ;
reg r ;
output y ;
reg y ;
output g ;
reg g ;
input clk ;
wire clk ;
input sensor ;
wire sensor ;
parameter red = 0;
parameter yellow = 1;
parameter green = 2;
reg [1:0] p_state;
reg [1:0] n_state;
initial p_state = red;
always @ (posedge (clk)) begin
p_state <= n_state;
end
always @ (p_state or sensor) begin
case (p_state)
red : n_state = green ;
green : begin
if (sensor)
n_state = green;
else
n_state = yellow;
end
yellow : n_state = red ;
endcase
end
always @ (p_state) begin
case (p_state)
red : begin
r = 1;
y = 0;
g = 0;
end
yellow : begin
r = 0;
y = 1;
g = 0;
end
green : begin
if (sensor)
n_state = green;
else
n_state = yellow;
r = 0;
y = 0;
g = 1;
end
endcase
end
endmodule
1 comments :
please send me full detail of this project including hardware on saba.asifff@gmail.com. i will be very thank full to you.
Post a Comment