BitFlow

Beep

A buzzer makes a sound when you switch it on and off quickly; how quickly sets the pitch. The note A is 440 Hz: 440 on-off cycles a second, so the output flips every CLK_HZ / 880 clock cycles.

Make buzz play A while button 0 is held, and stay quiet otherwise. Turn the sound on under the board to hear it (the virtual clock runs at 32 kHz for sound lessons).

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

  • ○Silent while the button is up
  • ○440 Hz while button 0 is held
Hints
  1. A counter that restarts at CLK_HZ / 880 - 1 and flips a tone register each time.
  2. assign buzz = btn[0] & tone;

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 buzzer: 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