Lemmings4

From HDLBits

lemmings3Previous

See also: Lemmings1, Lemmings2, and Lemmings3.

Although Lemmings can walk, fall, and dig, Lemmings aren't invulnerable. If a Lemming falls for too long then hits the ground, it can splatter. In particular, if a Lemming falls for more than 20 clock cycles then hits the ground, it will splatter and cease walking, falling, or digging (all 4 outputs become 0), forever (Or until the FSM gets reset). There is no upper limit on how far a Lemming can fall before hitting the ground. Lemmings only splatter when hitting the ground; they do not splatter in mid-air.

Extend your finite state machine to model this behaviour.

Falling for 20 cycles is survivable:

123...181920clkgroundwalk_leftaaah

Falling for 21 cycles causes splatter:

123...18192021oopsclkgroundwalk_leftaaah

Module Declaration

module top_module(
    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 ); 

Use the FSM to control a counter that tracks how long the Lemming has been falling.

Write your solution here

x
 
1
module top_module(
2
    input clk,
3
    input areset,    // Freshly brainwashed Lemmings walk left.
4
    input bump_left,
5
    input bump_right,
6
    input ground,
7
    input dig,
8
    output walk_left,
9
    output walk_right,
10
    output aaah,
11
    output digging ); 
12
13
endmodule
14
Upload a source file...