← ProblemsCircuits / Sequential Logic / Finite State Machines

Lemmings 2: falling

15%fsmfsm-design

In addition to walking left and right and changing direction when bumped, a Lemming falls (and yells "aaah!") when the ground disappears beneath it.

Extend the walking Lemming with a ground input:

  • While walking, if ground = 0 at a clock edge, the Lemming starts falling. Falling takes priority over bumps: if the ground vanishes and the Lemming is bumped at the same time, it falls.
  • While falling, aaah = 1 and both walk outputs are 0. Bump inputs are ignored while falling.
  • When ground = 1 again, the Lemming resumes walking in the same direction it was walking before it fell.

So you need (at least) four states: walking left, walking right, falling-while-facing-left, falling-while-facing-right.

The active-high areset is asynchronous and resets the Lemming to walking left.