
This project draws a small ball on a 640x480 VGA-style display. The top-level clock drives the VGA timing generator, SPI receiver, command decoder, and physics engine.
Commands are sent over SPI using one byte per command. The upper two bits select the command and the lower six bits hold the data:
00: set X position01: set Y position10: set X velocity11: set Y velocityPosition values are shifted left by three before being stored. Velocity values are interpreted as signed 6-bit numbers and clamped to the range -10 to 10. The ball position updates every six video frames and rebounds by inverting the X or Y velocity when it reaches the screen edges.
Run the cocotb testbench from the test directory:
cd test
make clean
make
The tests send SPI commands to set position and velocity, then check movement, velocity clamping, reset behavior, and edge rebound behavior. The gate-level test uses a smaller top-level pin smoke test because internal RTL signal names are not preserved after synthesis.
The design is intended for a TinyVGA-style PMOD connection on the output pins and SPI command input on the bidirectional pins.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | VGA red[0] | SPI chip select | |
| 1 | VGA green[1] | SPI MOSI | |
| 2 | VGA blue[1] | ||
| 3 | VGA vsync | SPI clock | |
| 4 | VGA red[1] | ||
| 5 | VGA green[0] | ||
| 6 | VGA blue[0] | ||
| 7 | VGA hsync |