Follow a run of ones as it shrinks
Online version: https://fpga.labsland.com/altera/computer-organization/lab-02/part-01/
Debugger setup
CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
bit_trace.s - Open the simulatorOpen CPUlator
Load bit_trace.s. The assembly shifts a 32-bit word right and ANDs the shifted result with the previous word. Before running it, sketch what one pass does to 00111100. Predict the number of passes until that pattern disappears.
Inspect a loop
Set a breakpoint at shrink. Continue to it and record t0 and t1. Repeat until t0 reaches zero. Mark the longest original run in the full 32-bit sample. How many times did the counter advance? Why do two runs that start separated never become a single run?
Replace the sample with zero, a word with only bit 31 set, then all ones. Assemble and load again after each edit. Hand in the three counts and a short trace of the supplied word. A logical right shift fills from the left with zero. Explain how an arithmetic right shift would affect termination for the all-ones input.
Adapted from FPGAcademy Computer Organization 24.1 · Lab 2, I. Original LabsLand assembly and worksheet. MIT
