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
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1. Let's implement the traffic light controller from the previous assignment in Verilog, working with the following...
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 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...