← ProblemsCircuits / Sequential Logic / Finite State Machines

Lemmings 3: digging

15%fsmfsm-design

Lemmings can also be told to dig. Extend the walking/falling Lemming with a dig input:

  • If dig = 1 while the Lemming is walking on ground, it starts digging and the digging output goes high.
  • While digging, the Lemming keeps digging until the ground gives way (ground = 0), at which point it starts falling (aaah!). Bumps and dig are ignored while digging.
  • When a falling Lemming lands (ground = 1), it resumes walking in its previous direction, even if it was digging before the fall.
  • Bumps are ignored while falling or digging.

Precedence when several things happen at once (evaluated in a walking state): falling > digging > switching direction. That is: if ground = 0, fall (regardless of dig or bumps); else if dig = 1, start digging (regardless of bumps); else if bumped on the facing side, turn around.

Six states are needed: walking, falling, and digging, each in two flavours (facing left / facing right). Direction is preserved through falls and digs.

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