Part of Curriculum: Memory and FIFO Design (Module 1: Fun & Games)
View Full Roadmap →
Level 4 Hard 50 pts ✓ Solved

Reaction Game Scorer

Fun & Games · sequential, fsm, game-logic

Score a simple reflex game: a light comes on, the player presses a button, and the circuit measures how many cycles it took — flagging jumping the gun or dozing off.

Write a synthesizable Verilog module named top_module matching the ports below exactly.
📐 Circuit Schematic Diagram
stimulusbuttonreaction_time[3:0]too_slowtoo_early>clkrst_nREACTION GAME SCORERDIGITAL HARDWARE BLOCK
⚡ Timing & Synthesizability Constraints

Timing Contract: Strict synchronous timing aligned to posedge clk or zero-delay combinational propagation.

RTL Constraints: Synthesizable Verilog-2001. No # delays in synthesizable RTL.

Concept: A 3-state FSM (idle → armed → done) times the gap between stimulus and button: pressing before the stimulus is too_early, pressing within the window gives a valid reaction_time, and letting a counter hit a fixed threshold without a press sets too_slow. That timeout check is the easy piece to forget — an implementation that only reacts to button in the armed state and never checks whether the counter has run out will simply wait forever for a press that never comes, silently dropping the entire "too slow" case instead of ever flagging it.
NameDirWidthDescription
clkinput1Clock
rstinput1Sync active-high reset, returns to idle
stimulusinput1Pulses for 1 cycle: the light turns on
buttoninput11 while the player is pressing the button
reaction_timeoutput4Cycles between stimulus and a valid press
too_slowoutput11 if 5 cycles pass after stimulus with no press
too_earlyoutput11 if the button is pressed before any stimulus
validoutput11 once a valid in-window press has been scored
Expected Waveform (Golden Timing Contract)
Verilog-2001 / SV Saved
Font: |
// Click Run Tests (or press Ctrl+Enter) to compile your RTL and simulate against hidden testbenches.
Simulation Timing Diagram (VCD Waveform)
100%
No simulation waveform yet. Run tests to simulate and generate VCD traces.
No compilation run yet. Syntax warnings and elaboration messages will appear here.
No simulation output yet. Raw stdout from vvp will appear here.

RTL Problems / Level 4 · Fun & Games

What You Will Learn

By solving Reaction Game Scorer, you will acquire core industry skills:

  • Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
  • Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
  • Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
  • Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.

Problem Statement & Requirements

Score a simple reflex game: a light comes on, the player presses a button, and the circuit measures how many cycles it took — flagging jumping the gun or dozing off.

Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.

Concept: A 3-state FSM (idle → armed → done) times the gap between stimulus and button: pressing before the stimulus is too_early, pressing within the window gives a valid reaction_time, and letting a counter hit a fixed threshold without a press sets too_slow. That timeout check is the easy piece to forget — an implementation that only reacts to button in the armed state and never checks whether the counter has run out will simply wait forever for a press that never comes, silently dropping the entire "too slow" case instead of ever flagging it.

Port List & Interface Timing

The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:

NameDirWidthDescription
clkinput1Clock
rstinput1Sync active-high reset, returns to idle
stimulusinput1Pulses for 1 cycle: the light turns on
buttoninput11 while the player is pressing the button
reaction_timeoutput4Cycles between stimulus and a valid press
too_slowoutput11 if 5 cycles pass after stimulus with no press
too_earlyoutput11 if the button is pressed before any stimulus
validoutput11 once a valid in-window press has been scored

Timing Constraints & Synthesizable RTL Rules

⚡ Synthesizable Implementation Guidelines

Timing Contract: Strict synchronous timing aligned to posedge clk or zero-delay combinational propagation.

Synthesis Constraints: Synthesizable Verilog-2001. No # delays in synthesizable RTL.

Starter RTL Code

module top_module(
  input  clk,
  input  rst,
  input  stimulus,
  input  button,
  output reg [3:0] reaction_time,
  output reg too_slow,
  output reg too_early,
  output reg valid
);

  // Your code here — idle: too_early if button pressed with no stimulus yet, else move to armed on stimulus.
  // armed: on button, latch reaction_time=cycle count and set valid; if 5 cycles pass with no button, set too_slow.
  // Both outcomes move to a done state that holds until reset.

endmodule

Related RTL Problems in Level 4

Frequently Asked Questions

What does Reaction Game Scorer require?

Score a simple reflex game: a light comes on, the player presses a button, and the circuit measures how many cycles it took — flagging jumping the gun or dozing off. Implement it as Verilog module top_module matching the listed ports.

Is this design combinational or sequential?

Tags: sequential, fsm, game-logic. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.

How is my solution graded?

A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.

How does this challenge help with semiconductor interviews?

Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of Reaction Game Scorer to assess real-world synthesizability and race-condition awareness.