Question

1. Lets implement the traffic light controller from the previous assignment in Verilog, working with the following state and

0 0
Add a comment Improve this question Transcribed image text
Answer #1

module trafficController (car, clock, MG, MY, MR, SG, SY, SR);

input car, clock;

output MG, MY, MR, SG, SY, SR;

parameter A = 4'b0001, B = 4'b0010, C = 4'b0100, D = 4'b1000;

reg [3:0] current_state, next_state;

always @(posedge clock)

   current_state    <= next_state;

always @(current_state, car)

begin

   case (current_state)

           A :    if (car)
                   next_state <= B;
               else
                   next_state <= A;

           B :    next_state <= C;
          
           C :    if (~car)
                   next_state <= D;
               else
                   next_state <= C;

           D :    next_state <= A;

       default   :    next_state <= A;

   endcase

end

assign MG = (current_state == A) ? 1'b1 : 1'b0;
assign SR = (current_state == A | current_state == B) ? 1'b1 : 1'b0;
assign MY = (current_state == B) ? 1'b1 : 1'b0;
assign MR = (current_state == C | current_state == D) ? 1'b1 : 1'b0;
assign SG = (current_state == C) ? 1'b1 : 1'b0;
assign SY = (current_state == D) ? 1'b1 : 1'b0;

endmodule

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Wave File Edit View Add Format Tools Bookmarks Window Help Wave -Default a x tat t ,票 44. 43-4 te 。.he 9 t←짜 R7 00 p.劃ELE Sk
              

Add a comment
Know the answer?
Add Answer to:
1. Let's implement the traffic light controller from the previous assignment in Verilog, working with the following...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. To demonstrate a Mealy state machine, let's design a simple arbiter between two requesting entities. We're g...

    2. To demonstrate a Mealy state machine, let's design a simple arbiter between two requesting entities. We're going to have two request inputs: reqA and reqB. And two outputs: grantA and grantB. Any combination of requests can be asserted at any time: one of them, both of them, or neither. But at most only one grant can be asserted in any given cycle; if neither request is asserted then neither grant should be asserted. We'll need a state machine to...

  • 1 L, as a dynamical system (Notes from Assignment #2) We take our definition of dynamical system ...

    1 L, as a dynamical system (Notes from Assignment #2) We take our definition of dynamical system to be an "object" along with a specific set of modifications that can be performed (dynamically) upon this object. In this case, the object is a bi-infinite straight road with a lamp post at every street corner and a marked lamp (the position of the lamplighter). There are two possible types of modifications: the lamplighter can walk any distance in either direction from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT