Lab 10

C · Linux + remote VGA

Put a bitmap on a remote VGA screen

Physical DE1-SoCYour computer

Embedded Systems · Framebuffer layout. A lighthouse has a red stripe, a yellow sun above it and the sea below. Your C program sends it to the screen upside down, with the stripe blue. Correct the framebuffer, then use a switch on a physical DE1-SoC to show what you changed.

A physical VGA capture shows the lighthouse upside down with a blue stripe and the sun below it.

This capture came from the VGA output of a University of Washington board on LabsLand. You will make the pixels in C on your own Linux computer. The LabsLand Online Editor then builds a Verilog design that displays those pixels on the remote board. You need a C compiler and Python 3 for the local steps, and access to a DE1-SoC Verilog lab with VGA for the board step.

Find the two faults

Open resources/beacon.bmp in an image viewer. A 24-bit BMP stores blue, green and red bytes for each pixel. This file starts with the bottom row. The display expects the top row first, with one little-endian 32-bit word per pixel. Its word layout is 0x00RRGGBB.

Predict the four bytes in memory for a pure red pixel, starting at its lowest address. Where should file row zero land in a display with 480 rows?

cc -std=c11 -O2 -Wall -Wextra -Werror starter/display.c -o display
truncate -s 1228800 before.xrgb
./display resources/beacon.bmp before.xrgb
python3 resources/view_frame.py before.xrgb before.bmp

Open before.bmp. Compare it with the original and the remote capture. Which error could turn a red stripe blue while leaving it in the same position?

Repair one thing at a time

In starter/display.c, change pixel_word to put each channel in its specified set of bits. Recompile. Use a new destination so you can keep the baseline.

truncate -s 1228800 yours.xrgb
./display resources/beacon.bmp yours.xrgb
python3 resources/view_frame.py yours.xrgb yours.bmp

Inspect the result, then fix display_row. A positive BMP height means its rows run bottom-up. A negative height means the file already starts at the top. Recompile and regenerate the second frame. Record the stripe color and the sun position for your original, color-only and final versions. Explain why 640 × 480 pixels occupy 1,228,800 bytes in the framebuffer.

Compare your frames on the physical board

On Windows with the Python launcher, use py -3 wherever a command starts with python3.

python3 resources/vga_tiles.py before.xrgb yours.xrgb frame_beacon.v

Open your institution’s DE1-SoC Verilog Online Editor. In the interface chooser, select the Media group and the interface with VGA and audio, then apply it. Choose New, enter the name frame_beacon, paste the generated Verilog into the new file, select it as the top level and choose Synthesize. When the build succeeds, choose Upload to FPGA and enter the board session. LabsLand DE1-SoC laboratory

  1. Set SW0 down. Wait until the lighthouse appears in the VGA pane. Color bars can briefly appear while the capture locks onto the signal.
  2. Set SW0 up. Record what happens to the stripe and the sun. The board is now showing the bytes your edited C program produced.
  3. Return SW0 down. Verify that both faults return. Save the two VGA observations with the board identifier and switch position.

The Verilog exporter preserves every pixel of this teaching image. It stores one color per 8 × 8 tile, using a palette of up to 16 colors across both frames. The C program still packs every pixel individually. Submit your two C edits, the red-pixel byte prediction and your observed switch comparison. If you did only the local steps, identify the two BMP previews as local output.

FPGAcademy exercise · Exercise notice · LabsLand source license