This document provides a detailed explanation of the implementation of a traffic light controller using state transitions and flip flops. It includes information on the HDL code, test bench, simulation results, and design summary.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
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
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
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_GreenMain_InteruptibleMain_YellowMain_Red,Side_GreenSide_YellowSide_extended
Present StateInputsNext StateOutput Ca r Pe d yellow_u p side_u p main_u p M_Light (RM,YM,GM ) S_Light (RS,YS,GS ) MAIN_GREENXXXX0MAIN_GREEN0, 0, 11, 0, 0 MAIN_GREENXXXX1MAIN_INTERUPTIBLE0, 0, 11, 0, 0 MAIN_INTERUPTIBLE0XXXXMAIN_INTERUPTIBLE0, 0, 11, 0, 0 MAIN_INTERUPTIBLE1XXXXMAIN_YELLOW0, 0, 11, 0, 0 MAIN_YELLOWXX0XXMAIN_YELLOW0, 1 ,01, 0, 0 MAIN_YELLOWXX1XXSIDE_GREEN1, 0, 00, 0, 1 SIDE_GREENXXX0XSIDE_GREEN1, 0, 00, 0, 1 SIDE_GREEN0XX1XSIDE_YELLOW1, 0, 00, 0, 1 SIDE_GREEN1XX1XSIDE_GREEN_EXTENDE D 1, 0, 00, 0, 1 SIDE_GREEN_EXTENDE D XXXX0SIDE_GREEN_EXTENDE D 1, 0, 00, 0, 1 SIDE_GREEN_EXTENDE D XXXX1SIDE_YELLOW1, 0, 00, 0, 1 SIDE_YELLOWXX0XXSIDE_YELLOW1, 0, 00, 1, 0 SIDE_YELLOWXX1XXMAIN_GREEN1, 0, 00, 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.