I implemented an arcade-style Wack-a-Mole game on the Digilent Basys-3. The “mole” is an LED that lights up; the player “whacks” it by toggling the matching slide switch up, then back down before hitting the next one. The design uses memory-mapped I/O for switches, LEDs, seven-segment display, and a piezo buzzer. The game runs for 10 levels; when complete, the seven-segment shows ACE and the buzzer jumps to a higher pitch. LED order, HEX/decimal display mode, and buzzer tones are all configurable in code.
Platform: Digilent Basys-3 FPGA board
Inputs: 16 slide switches (mole “hit” + down-to-reset between hits), BTNC pushbutton for game reset
Outputs: 16 user LEDs (mole indicator), 7-segment display (score / “ACE”), piezo buzzer (tone feedback)
Game flow: 10 levels; score increments per correct hit; game ends on level 10 with “ACE” + tone change
Configurable features: LED sequence, HEX vs. decimal score display, buzzer tone table
Memory-mapped I/O (addresses):
Switch base: 0x11000000
LEDs: 0x11000020
Seven-segment: 0x11000040
Buzzer: 0x11000060
The game runs on the Basys-3 FPGA board using LEDs (moles), slide switches (player hits), seven-segment display (score), and a buzzer (sound).
A clock divider slows the 100 MHz board clock into usable game ticks, display refresh, and audio frequencies.
A pattern generator chooses which LED (mole) lights up each round.
A simple state machine controls the flow: Reset → Show Mole → Wait for Hit → Update Score → Next Mole → Win.
The switch interface debounces player inputs so only clean hits are registered.
The LED driver, seven-segment driver, and buzzer driver handle all outputs:
LEDs show the mole location
Seven-segment shows the score or “ACE” at the end
Buzzer plays normal tones during play and a higher tone at victory
Basys3 Board
Code Logic Flowchart
Timing Diagram
Results
Correct-switch detection works reliably at human reaction speeds.
Score increments per successful hit and caps at 10; end-of-game banner ACE + high-pitch tone confirms completion.
LED order and tone table can be reprogrammed for different experiences (faster rounds, custom patterns).
Lessons Learned
Practical MMIO: mapping peripherals to addresses and doing clean read/modify/write cycles.
Control flow with branches: using branch-if-equal to synchronize human input with LED state.
Simple state machine design: Reset → WaitForHit → UpdateScore/NextMole → Finish.
Clear separation of game logic (score/levels) and I/O layer (LEDs/switches/seven-seg/buzzer).
Full Wack-A-Mole Report