BitFlow

Reaction game

Press button 0 to start a round: the LEDs go dark, and 2 seconds later LED 5 lights. Hit button 1 as fast as you can, and the display shows how long you took in hundredths of a second (hex2 hex1 hex0, so 034 is 0.34 s).

This is a state machine (waiting, light on, showing the time) with a timer in each state and a decimal counter like the stopwatch's.

lab.v
drag to turn · scroll to zoom

Loading the board…

Press Run on the board: your Verilog is turned into gates in this browser and runs here, cycle by cycle.

Goals

  • ○Button 0 starts a round: LED 5 lights 2 s later
  • ○Button 1 shows the reaction time in hundredths of a second
  • ○The time stays on the display until the next round
Hints
  1. Three states: IDLE, WAIT (count 2 s), GO (count hundredths until button 1).
  2. Clear the digits when a round starts.

Pin log

Run the design to see its outputs change.

Put it on a real board

  • The Sipeed Tang Nano 9K (Gowin GW1NR-9) has no a 7-segment display: those ports go to header pins, where you can wire them.
  • The clock is set to the board's 27 MHz, and its active-low buttons and LEDs are flipped for you.
Waveform