input clk,
input areset, // Freshly brainwashed Lemmings walk left.
input bump_left,
input bump_right,
input ground,
input dig,
output walk_left,
output walk_right,
output aaah,
output digging );
parameter LEFT=0, RIGHT=1, DIG_L=2, DIG_R=3, FALL_L=4, FALL_R=5, SPLAT =6;
reg [5:0] counter;
reg[3:0]state, next_state;
always@(*)begin
case(state)
LEFT: next_state = ground?(dig?DIG_L:(bump_left?RIGHT:LEFT)):FALL_L;
RIGHT: next_state = ground?(dig?DIG_R:(bump_right?LEFT:RIGHT)):FALL_R;
DIG_L: next_state = ground?DIG_L:FALL_L;
DIG_R: next_state = ground?DIG_R:FALL_R;
FALL_L:begin
if(counter<20)
next_state = ground?LEFT:FALL_L;
else
next_state = ground?SPLAT:FALL_L;
end
FALL_R:begin
if(counter<20)
next_state = ground?RIGHT:FALL_R;
else
next_state = ground?SPLAT:FALL_R;
end
SPLAT: next_state = SPLAT;
endcase
end
always@(posedge clk or posedge areset)begin
if(areset)
counter <= 6'd0;
else if((state==FALL_L) || (state==FALL_R))
counter <= counter + 1'b1;
else
counter <= 6'b0;
end
assign walk_left = (state==LEFT);
assign walk_right = (state==RIGHT);
assign aaah = (state==FALL_L) || (state==FALL_R);
assign digging = (state==DIG_L) || (state==DIG_R);
always@(posedge clk or posedge areset)begin
if(areset)
state<=LEFT;
else
state<=next_state;
end
把这个题目的地址连接发出来,帮你看看