Keypad scanner
A keypad is a grid of 4 row wires and 4 column wires; a key joins its row to its column. The columns are pulled high, so drive one row low at a time and see which column goes low: that is the key at that row and column.
Scan the rows over and over, and when a key is down, show it on hex0: digits as themselves, A–D as A–D, * as E and # as F.
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
- ○Digit keys show their digit
- ○A–D, * and # show A–D, E and F
- ○Only one row is driven low at a time
Hints
rowcycles 4'b1110, 4'b1101, 4'b1011, 4'b0111; a 2-bit counter picks which.- Look at
colwhile a row is driven; a 0 bit is a pressed key. A 16-entrycaseturns row and column into the key's value.
Pin log
Run the design to see its outputs change.
Keypad (hold a key)
Put it on a real board
- The Sipeed Tang Nano 9K (Gowin GW1NR-9) has no a 7-segment display or a keypad: 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.