module top_module(
input clk,
input areset, // Freshly brainwashed Lemmings walk left.
input bump_left,
input bump_right,
input ground,
output walk_left,
output walk_right,
output aaah );
parameter LEFT=2'b10,RIGHT=2'b01,RSTOP=2'b00,LSTOP=2'b11;
reg [1:0]c_s,n_s;
always @(posedge clk or posedge areset)
begin
if(areset)
c_s<=LEFT;
else
c_s<=n_s;
end
always @(*)
begin
if(ground==1)
begin
if(c_s==RSTOP)
n_s=RIGHT;
else if(c_s==LSTOP)
n_s=LEFT;
else
case({bump_right,bump_left})
2'b00:n_s=c_s;
2'b01:n_s=RIGHT;
2'b10:n_s=LEFT;
2'b11:n_s=~c_s;
endcase
end
else if(ground==0)
n_s=(c_s==RIGHT||c_s==RSTOP)?RSTOP:LSTOP;
end
assign walk_left =(c_s==LEFT);
assign walk_right=(c_s==RIGHT);
assign aaah=(c_s==RSTOP)|(c_s==LSTOP);
endmodule