Operate a hexadecimal display with four buttons
Online version: https://fpga.labsland.com/altera/computer-organization/lab-03/part-02/
Debugger setup
CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
keypad.s - Open the simulatorOpen CPUlator
Build a polled input loop for a Nios V processor. A press on KEY0 clears the digit. KEY1 counts up to F and KEY2 counts down to zero. KEY3 blanks the display. From blank, pressing any of the other three buttons returns to zero. Only the rightmost display should light.
Predict and assemble
Download keypad.s, open it in the CPUlator RISC-V DE1-SoC editor and complete the two digit updates. Compile and load, step once, then continue. Locate Push buttons and Seven-segment displays under Devices. The simulator represents each button with a checkbox. Check it to press, uncheck it to release. Operate one button at a time.
Test a sustained press
Hold KEY1 for at least one second. Record the digit while held and after release. Press KEY1 a second time and explain why it counts again. Find the instruction that prevents a held button from repeating. Compare an input poll at 0xFF200050 with a display write to 0xFF200020.
| Action | Predicted HEX0 | Observed HEX0 |
|---|---|---|
| Press KEY2 when the digit is zero | ||
| From zero, press and release KEY1 ten times | ||
| Count up to F, then press KEY1 again | ||
| Press KEY3, then KEY2 | ||
| Press KEY1 twice, then KEY0 |
On the simulator, lowercase b and d distinguish hexadecimal digits from 8 and 0. Describe how the program represents blank internally, and how its byte differs from the pattern for zero. Submit one observation at each limit and the register or instruction you would inspect if the display repeated a held press.
Adapted from FPGAcademy Computer Organization 24.1, Lab 3, Part II. LabsLand wrote the assembly and activities. MIT notice
