Plot a line at the right framebuffer address
Online version: https://fpga.labsland.com/altera/computer-organization/lab-08/part-01/
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
A graphics program draws six test shapes using integer coordinates. The red line should be on row 16, yet the starter draws it elsewhere. Fix the address calculation, then use the other five shapes to check that the repair works across the image.
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).

Six test shapes in the CPUlator framebuffer. The white diagonal reaches the lower-right corner.
Find the row pitch
A pixel holds one 16-bit RGB565 value. Each row has 320 visible pixels, but the next row begins 1,024 bytes later. Calculate the addresses of (0,1), (13,16) and (319,239) relative to the front-buffer address at 0xFF203020. Look at clear_frame and put. Which distance does each use to reach the next row?
Check more than one slope
In the VGA pixel buffer panel, locate the red horizontal line, green vertical line, blue steep line, yellow shallow line, white lower-right diagonal and isolated magenta pixel. In the Zoom menu enlarge the image to inspect endpoints. With the incorrect row pitch, where does the magenta point at (179,101) appear? Convert its faulty halfword offset back into a physical row and column.
| Shape | First and last pixel | How many pixels including endpoints? |
|---|---|---|
| Red horizontal | ||
| Green vertical | ||
| Blue steep | ||
| White corner diagonal |
Repair put and compare the panel with your predictions. Trace two iterations of line on paper. Explain why keeping an integer error allows a vertical line and a single point to use the same function.
Original LabsLand activity following FPGAcademy Computer Organization Lab 8, Part I. FPGAcademy PDF · MIT
