← ProblemsCircuits / Sequential Logic / Finite State Machines
Lemmings 1: walking
15%fsmfsm-designLemmings are simple-minded creatures: a Lemming walks left or right, and keeps going until something bumps into it.
Build a Moore FSM with two states — walking left and walking right:
- If the Lemming is walking left and is bumped on the left (
bump_left = 1), it turns around and walks right. - If it is walking right and is bumped on the right (
bump_right = 1), it turns around and walks left. - If it is bumped on both sides at once, it still turns around.
- A bump on the side it is walking away from has no effect (e.g.
bump_rightis ignored while walking left).
Outputs (functions of state only): walk_left = 1 while walking left, walk_right = 1 while walking right — exactly one is high at any time.
The active-high areset is asynchronous and resets the Lemming to walking left.