LEFT: begin if (!ground) begin next_state = FALLING_LEFT; next_count = 0; end elseif (dig) next_state = DIGGING_LEFT; elseif (bump_left) next_state = RIGHT; else next_state = LEFT; end
RIGHT: begin if (!ground) begin next_state = FALLING_RIGHT; next_count = 0; end elseif (dig) next_state = DIGGING_RIGHT; elseif (bump_right) next_state = LEFT; else next_state = RIGHT; end
FALLING_LEFT: begin if (ground) begin if (count >= 20) begin next_state = SPLAT; next_count = count; end elsebegin next_state = LEFT; next_count = 0; end end elsebegin next_state = FALLING_LEFT; next_count = count + 1; end end
FALLING_RIGHT: begin if (ground) begin if (count >= 20) begin next_state = SPLAT; next_count = count; end elsebegin next_state = RIGHT; next_count = 0; end end elsebegin next_state = FALLING_RIGHT; next_count = count + 1; end end
DIGGING_LEFT: begin if (ground) next_state = DIGGING_LEFT; elsebegin next_state = FALLING_LEFT; next_count = 0; end end
DIGGING_RIGHT: begin if (ground) next_state = DIGGING_RIGHT; elsebegin next_state = FALLING_RIGHT; next_count = 0; end end
SPLAT: next_state = SPLAT;
default: next_state = LEFT;
endcase end
always @(posedge clk, posedge areset) begin if (areset) begin state <= LEFT; count <= 0; end elsebegin state <= next_state; count <= next_count; end end