answersLogoWhite

0

/************************************************************** * 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

13y ago

What else can I help you with?

Continue Learning about Engineering

What do junction engineers do?

Junction engineers specialize in the design and management of transportation junctions, such as intersections, roundabouts, and interchanges. They analyze traffic flow, safety, and efficiency to optimize the movement of vehicles and pedestrians. Their work often involves using simulations and modeling tools to propose improvements and ensure compliance with safety regulations. Additionally, they may collaborate with urban planners and other engineers to integrate junction designs within broader transportation systems.


What is traffic engineering and objects?

Traffic engineering is a branch of engineering that focuses on the planning, design, and operation of transportation systems to ensure safe and efficient movement of people and goods. It involves analyzing traffic patterns, optimizing traffic flow, and implementing control measures such as signals, signage, and road design. Key objects of traffic engineering include roads, intersections, traffic signals, and signage, all aimed at improving safety and reducing congestion. The field also incorporates data analysis and modeling to predict and manage traffic behavior effectively.


Machine tool design notes?

Machine tool design involves creating equipment used for shaping or machining materials, focusing on precision, durability, and efficiency. Key considerations include the selection of materials, structural integrity, thermal stability, and ease of operation. Additionally, factors like vibration control, ergonomic design, and integration of advanced technologies, such as CNC systems, are crucial for modern machine tools. Ultimately, the goal is to enhance productivity while ensuring safety and maintainability.


Why is traffic engineering needed?

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


What did Garrett Morgan use to make the traffic light?

Garrett Morgan invented an early version of the traffic light using a simple design that included a system of signals to control traffic flow at intersections. His invention featured three positions: one for stop, one for go, and a third for an all-directional stop, allowing pedestrians to cross safely. Morgan's traffic signal utilized mechanical components and was operated manually before the development of electric signals. His innovative design significantly improved road safety and paved the way for modern traffic lights.

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


How do you clear the design in progress on tajima embroidery machine?

To clear the design in progress on a Tajima embroidery machine, first ensure the machine is in a stopped state. Navigate to the control panel and look for the option to delete or clear the current design, often found in the menu under "Design" or "File." Confirm the action when prompted to remove the design from the machine's memory. Finally, verify that the display shows no active design before proceeding with a new one.


When was Machine Design created?

Machine Design was created in 1929.


Who invented the three way traffic light?

The three-way traffic light was invented by Garrett Morgan in 1923. He patented the design for the T-shaped traffic signal that included a mechanism to control traffic flow at intersections.


Where did john peake knight invent the traffic light?

John Peake Knight invented the traffic light in London, England, in 1868. His design was a gas-lit signal that used colored lights to control the flow of traffic at intersections. Although it was primarily intended for horse-drawn carriages, this invention laid the groundwork for modern traffic control systems.


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 do junction engineers do?

Junction engineers specialize in the design and management of transportation junctions, such as intersections, roundabouts, and interchanges. They analyze traffic flow, safety, and efficiency to optimize the movement of vehicles and pedestrians. Their work often involves using simulations and modeling tools to propose improvements and ensure compliance with safety regulations. Additionally, they may collaborate with urban planners and other engineers to integrate junction designs within broader transportation systems.


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 is traffic engineering and objects?

Traffic engineering is a branch of engineering that focuses on the planning, design, and operation of transportation systems to ensure safe and efficient movement of people and goods. It involves analyzing traffic patterns, optimizing traffic flow, and implementing control measures such as signals, signage, and road design. Key objects of traffic engineering include roads, intersections, traffic signals, and signage, all aimed at improving safety and reducing congestion. The field also incorporates data analysis and modeling to predict and manage traffic behavior effectively.