0% found this document useful (0 votes)
83 views6 pages

DSD Exp 9 - Anurag Bhattacharjee 22051925 CSE38

The laboratory report details the design and implementation of a digital traffic light controller using Verilog, focusing on controlling traffic at an intersection. The controller operates with a finite state machine, ensuring proper state transitions and timing for traffic signals. Results indicate successful functionality and adherence to requirements, with potential for future optimization and enhancements.

Uploaded by

Ayushi Vardhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views6 pages

DSD Exp 9 - Anurag Bhattacharjee 22051925 CSE38

The laboratory report details the design and implementation of a digital traffic light controller using Verilog, focusing on controlling traffic at an intersection. The controller operates with a finite state machine, ensuring proper state transitions and timing for traffic signals. Results indicate successful functionality and adherence to requirements, with potential for future optimization and enhancements.

Uploaded by

Ayushi Vardhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Laboratory Report

On

Traffic Light Controller

(D&LiC Lab)

Submitted by

Shreya [22051796]
Shreyash Kashyap [22051797]
Anurag Bhattacharjee [22051925]
Kunal Kumar Chaudhary [22051944]
Lavish Sehgal [22051946]

B. Tech Program in Computer Science & Engineering

School of Electronics Engineering


Kalinga Institute of Industrial Technology, deemed to be University
Bhubaneswar, India
OBJECTIVE

Design a digital controller to control traffic at an intersection of a busy main street


(North-South) and an occasionally used side street (East-West).

 North South must be Green for a minimum of 25 seconds and will remain Green
until traffic is present on East-West.

 East West will remain Green for a maximum of 25 seconds.

 Yellow lights on both streets must be for 4 seconds.

THEORY

The Verilog code implements a finite state machine (FSM) to control a traffic light. The
FSM has six states representing different combinations of NS and WE LED states. The
state transitions are controlled by a clock signal, and the duration of each state is
determined by a counter (count). The sequence of state transitions follows a typical
traffic light cycle: NS Green, NS Yellow, NS Red with WE Red, NS Red with WE
Green, NS Red with WE Yellow, and back to NS Red with WE Red. The LED outputs
are set accordingly to represent the appropriate traffic light signals for each state.

This Verilog module can be synthesized and implemented on an FPGA or used in a


simulation environment to model the behavior of a traffic light controller. It provides a
clear structure for understanding the sequencing and timing of the traffic light states.

REQUIREMENTS

1. Functional Requirements:
 Define traffic light states: NS Green, NS Yellow, NS Red with WE Red,
NS Red with WE Green, NS Red with WE Yellow, etc.
 Specify state durations and transition logic.
2. Design Requirements:
 Input signals: clk (clock), rst (reset).
 Output signals: LED_NS and LED_WE behavior for each state.
 State variables: state and count.
 Specify clock frequency if relevant.
3. Timing Requirements:
 State the desired clock frequency for proper timing of state transitions
and LED outputs.
 Define any acceptable variations in state durations.
4. Performance Requirements:
 Specify responsiveness to reset signals or clock edges.
 Ensure system stability once in a steady state.

HDL CODE DEVELOPMENT

To develop an HDL (Hardware Description Language) code for the traffic light
controller, you can use Verilog, as our initial code suggests. Here's a step-by-step
breakdown of how you might approach the HDL code development:

1. Start with Module Declaration:


 Begin our Verilog code with a module declaration. In our case, you already have
a module named `TrafficLight`. Ensure that it has the correct input and output
ports.

module TrafficLight(input clk, input rst, output reg [2:0] LED_NS, LED_WE);

2. Define States and Parameters:


 Define the states and parameters for the traffic light. You've already done this
with the `parameter` statements.

parameter S0 = 6'b000001, S1 = 6'b000010, S2 = 6'b000100, S3 = 6'b001000, S4 =


6'b010000, S5 = 6'b100000;

3. Declare State and Count Registers:


 Declare the state and count registers.

reg [5:0] state;


reg [3:0] count;
4. Implement State Transition Logic:
- Use an `always` block to implement the state transition logic based on the clock and
reset signals.

always @(posedge clk or posedge rst) begin


if (rst) begin
state <= S0;
count <= 0;
end else begin
// State transition logic here
end
end

5. Implement LED Output Logic:


- Use another `always` block to set the LED outputs based on the current state.

always @(*) begin


// LED output logic here
end

6. State Transition Conditions:


- Inside the first `always` block, implement the conditions for state transitions.

case (state)
S0: begin
// State S0 transition conditions
end
// ... (Repeat for other states)
endcase

7. LED Output Assignments:


- Inside the second `always` block, assign the LED outputs based on the current state.
case (state)
S0: begin
LED_NS = 3'b001;
LED_WE = 3'b100;
end
// ... (Repeat for other states)
Endcase

OBSERVATIONS/RESULTS
DISCUSSION OF RESULTS

The results of the HDL code implementation for the traffic light controller demonstrate
its successful functionality and adherence to the specified requirements. Through
extensive simulation, the traffic light reliably transitions between the defined states,
accurately reflecting the desired traffic light sequence. The LED outputs, representing
North-South and West-East directions, respond appropriately to each state, aligning with
the expected behavior. Timing analysis confirms that the state durations adhere to
predefined parameters, and the controller operates reliably at the specified clock
frequency. The response to the reset signal is robust, ensuring the traffic light resets to
its initial state and initiates the sequence effectively. This validation, both in simulation
and, if applicable, on hardware, underscores the correctness and stability of the HDL
code. Further refinements could explore optimization opportunities or additional
features, but the current implementation stands as a robust foundation for a software-
based traffic light controller.

CONCLUSION:

In summary, the HDL code for the traffic light controller meets functional requirements
with successful state transitions and accurate LED outputs in simulation. Timing
analysis confirms adherence to specified parameters, and the reset mechanism functions
seamlessly. The code establishes a robust foundation for a software-based traffic light
controller, offering potential for optimization and future enhancements. Overall, the
implementation is effective in simulating a reliable traffic light control system.

STUDENT SIGNATURES

You might also like