Animate connected squares with two framebuffers
Online version: https://fpga.labsland.com/altera/computer-organization/lab-08/part-03/
Debugger setup
CPUlator simulatorC · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
main.c - Open the simulatorOpen CPUlator
Four colored squares move along diagonals. A white line joins each neighboring pair. Even the starter can look convincing for several frames. Use the controller registers to decide whether it actually draws each new frame off screen.
In CPUlator choose C, use File → Open to load main.c, then Compile and Load (F5). Open the VGA pixel buffer device and use Continue (F3).

Four squares from one CPUlator frame. The white lines connect adjacent squares.
Inspect the buffer swap
Set a breakpoint on the first instruction of move. Each stop follows a completed presentation. In Memory, enter 0xff203020. The first two 32-bit words contain the front and back buffer addresses. Capture four successive pairs. In VGA pixel buffer follow the red square as it touches the top edge and then the left edge.
| Frame | Front | Back | Red square top-left (x,y) |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 |
Repair the drawing order
Trace next between present and move. Make the program alternate between the two frame arrays. Find when the program waits for the controller to finish swapping. Confirm that after the first frame the previous front buffer becomes the back buffer on every swap. Compare the addresses and the red square's positions before and after the repair. Calculate how far apart the two buffers are in bytes using their allocated height and row pitch.
Original LabsLand activity following FPGAcademy Computer Organization Lab 8, Part III. FPGAcademy PDF · MIT
