BitFlow

Stopwatch

Count tenths of a second as decimal digits, one register per digit: hex0 tenths, hex1 seconds, hex2 tens of seconds, hex3 minutes. When a digit passes 9 (or 5 for tens of seconds), set it to 0 and add one to the next: that's the carry.

Button 0 starts and stops the watch, button 1 resets it to 0000. A button should act once when it goes down, so look for it changing from 0 to 1.

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 and stops it
  • ○It counts in tenths of a second
  • ○Digits roll over and carry (9 → 0, 59 s → 1 min)
  • ○Button 1 resets it to 0000
Hints
  1. wire start = btn[0] && !last[0]; with last <= btn; every cycle.
  2. A timer counts to CLK_HZ / 10 - 1 while running, then the tenths go up.

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