answersLogoWhite

0


Best Answer

/************************************************************** * This is main module for state machine of TrafficLight **************************************************************/ module TrafficLight(state, RedLight, GreenLight, YellowLight, clk, reset, malfunction, ready); input clk, reset, ready; //ready is high when maintenance of TrafficLight finished input malfunction; //system input malfunction when error occured output [1:0] state; output RedLight,GreenLight,YellowLight; //active-high output for Lights reg [1:0] state; //register to store current state reg RedLight,GreenLight,YellowLight; //define parameter or name of each state parameter redstate = 2'b00; parameter greenstate = 2'b01; parameter yellowstate = 2'b10; parameter maintenance = 2'b11; always@ (posedge reset or posedge clk) begin RedLight = (!state[1] & !state[0]); GreenLight = (!state[1] & state[0]); YellowLight = (state[1] & !state[0]); if(reset) begin state = redstate; //default state is RedLight on end else case(state) redstate: begin if(malfunction) state = maintenance; else state = greenstate; end greenstate: begin if(malfunction) state = maintenance; else state = yellowstate; end yellowstate: begin if(malfunction) state = maintenance; else state = redstate; end maintenance: begin if(ready) state = redstate; else state = maintenance; end endcase end endmodule /************************************************************** * This module is for testing and display outputs. **************************************************************/ module test_module; // declare test module reg clk, reset, malfunction, ready; wire [1:0] state; wire RedLight, GreenLight, YellowLight; parameter clockDelay = 50; TrafficLight myTrafficLight(state, RedLight, GreenLight, YellowLight, clk, reset, malfunction, ready); always begin #(clockDelay/2) clk = 0; #(clockDelay/2) clk = 1; end initial begin //$dumpfile("Trafficlight.dump"); //$dumpvars; $monitor ("stat= %b, RedLight = %b, Green = %b, YellowLight = %b",state, RedLight, GreenLight, YellowLight); $shm_open("db1.shm"); // Open a directory to store waveforms $shm_probe(state, RedLight, GreenLight, YellowLight, reset, malfunction, ready); // Specify any signals you want waveforms for #(clockDelay) reset = 1'b1; #(clockDelay) reset = 1'b0; #(clockDelay) malfunction = 1'b1; #(clockDelay) reset = 1'b0; #(clockDelay) malfunction = 1'b0; #(clockDelay) #(clockDelay) #(clockDelay) ready = 1'b1; #(clockDelay) ready = 1'b0; #(clockDelay) #(clockDelay) #(clockDelay) #(clockDelay) reset = 1'b1; #(clockDelay) reset = 1'b0; #(clockDelay) #(clockDelay) malfunction = 1'b1; #(clockDelay) malfunction = 1'b0; #(clockDelay) #(clockDelay) #(clockDelay) ready = 1'b1; #(clockDelay) ready = 1'b0; #(80*clockDelay) $finish; end endmodule

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Design a State machine for Traffic Control at a Four point Junction?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why is traffic engineering needed?

You need traffic engineers to design road/highway systems that are effective and safe.


What were computers used for in the metal forming machines tools sector?

Trends in technology in the metal forming machine tools sector were closely tied to computer and electronic innovations, including those for design and control.


How can design stick-slip machine?

Stick-slip machines are designed to provide more controllable motion than a traditional electric motor. The basic design consists of a motor a control board and a stick-slip mechanism. The motor is used to provide the power to move the stick-slip mechanism while the control board is used to regulate the speed and position of the mechanism. The stick-slip mechanism consists of an elastic element such as a spring or rubber band that is connected to a shaft. When the shaft rotates the elastic element is compressed and then released creating a stick-slip effect. To design a stick-slip machine the following steps must be taken: Choose an appropriate motor and control board. Design the stick-slip mechanism and select an appropriate elastic element. Select the appropriate shaft and bearing system. Integrate the motor control board stick-slip mechanism and shaft into a single system. Test the system and adjust as necessary for optimal performance.By following these steps it is possible to design and build a reliable controllable stick-slip machine.


Design a form in vb to stimulate traffic signals using timer?

ja pal ghari


Can a machine multiply distances?

...yes... due to the mechanical advantage that the machine or simple machine has. adn im not a virgin anymore

Related questions

How ladder diagram traffic light 3 junction?

design plc ladder diagram for three junction traffic light


What has the author Jack Bishop Humphreys written?

Jack Bishop Humphreys has written: 'Identification of traffic management problems in work zones' -- subject(s): Control, Roads, Traffic control, Interference, Communication and traffic, Design and construction


When was Machine Design created?

Machine Design was created in 1929.


What has the author George H Hall written?

George H. Hall has written: 'Motor and control applications' -- subject(s): Electric driving, Electric motors, Machine design, Machine-tools


What is the scope of machine design?

what is the scope of machine designe


What is a machine design to do?

make work easier


What has the author PH Hyland written?

P.H Hyland has written: 'Machine design' -- subject(s): Machine design


What are the advantages of hardwired control design and microprogrammed control design?

fast


What has the author E D McConkey written?

E. D. McConkey has written: 'RNAV route design' -- subject(s): Navigation (Aeronautics), Air traffic control


What is the minimum anchorage length for reinforcement?

It is the length of the main bar provided at the column beam junction or column footing junction to allow for the development of stresses to its design strength.


What is a machine designer do?

design machines


When was Kharkiv Morozov Machine Building Design Bureau created?

Kharkiv Morozov Machine Building Design Bureau was created in 1927.