Doorbell
A press of button 0 starts a little tune: 660 Hz for 0.4 s, then 440 Hz for 0.6 s, then silence until the next press.
That is a state machine (quiet, ding, dong) where each state has a pitch and a length, the same pattern as the traffic light, with the beep's tone generator underneath.
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 until button 0 is pressed
- ○Ding: 660 Hz for 0.4 s, then dong: 440 Hz for 0.6 s
- ○It stops by itself after the dong
Hints
- Three states and one timer; the state picks the half-period (
CLK_HZ / 1320orCLK_HZ / 880). - Start on the button going down, so holding it doesn't restart the tune.
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.