The memory game, in hardware
A Verilog implementation of Simon Says using four LEDs, four push buttons and a seven-segment score display.
The player watches an LED sequence and repeats it using the buttons. The state machine handles sequence playback, player input, round progression and game-over feedback, with memory for up to 16 steps.
Inside the Verilog
The design separates game control, button filtering, sequence generation and score display into individual modules. These excerpts come directly from the project source.
Game sequence
The game controller stores a two-bit LED choice for each step in a 16-entry sequence memory. At the start of a round, it adds the next choice and resets the playback counters.
View SS_SM.v excerpt
Generate: begin
SequenceMemory[CurrentLevel] <= RandomVal;
StepCounter <= 0;
FlashTimer <= 0;
state <= Sequence;
end
Download SS_SM.v
Pseudo-random choices
A 16-bit linear-feedback shift register generates a deterministic pseudo-random stream. The top-level module passes its lowest two bits to the game controller to select one of four LEDs.
View RNG.v excerpt
wire feedback = out[15] ^ out[14] ^ out[13] ^ out[12];
wire [15:0] nextOut;
assign nextOut = {out[14:0],feedback};
Download RNG.v
Button filtering
Each of the four buttons has its own debouncer. A counter waits for an input change to persist before updating the filtered button signal, reducing the effect of mechanical contact bounce.
View debouncer.v excerpt
always @(posedge clock) begin
if (NoisyButton !== ButtonState) begin
if (count < MAX) begin
count <= count + 1;
end else begin
ButtonState <= NoisyButton;
CleanButton <= NoisyButton;
count <= 0;
end
end else begin
count <= 0;
end
end
Download debouncer.v
Explore the source
The source bundle includes all eight design modules and three component testbenches. Top_SS.v connects the game controller to four buttons, four LEDs and a multiplexed seven-segment score display.
Download Verilog source (.zip)