https://github.com/szym-mie/vga3
Redesign of 'vga_src' video card architcture using proper FIFOs
https://github.com/szym-mie/vga3
clean-architecture fifo ise kicad memory-controller rewrite spartan6 verilog vga video-card
Last synced: 4 months ago
JSON representation
Redesign of 'vga_src' video card architcture using proper FIFOs
- Host: GitHub
- URL: https://github.com/szym-mie/vga3
- Owner: szym-mie
- License: bsd-3-clause
- Created: 2024-05-06T19:25:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T08:41:14.000Z (about 1 year ago)
- Last Synced: 2025-06-06T03:40:45.816Z (about 1 year ago)
- Topics: clean-architecture, fifo, ise, kicad, memory-controller, rewrite, spartan6, verilog, vga, video-card
- Language: Verilog
- Homepage:
- Size: 3.56 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VGA FPGA Video Card implementation


## Display
This module works in standard VGA mode of 640x480 at 60Hz monitor refresh rate. The picture itself was scaled down to 160x120, but can be reverted to be true 640x480.
Full specification:
```
pixel clock: 25MHz
-0.7% deviation from ideal 25.175MHz
pixel mode: RGB222 6bpp
max analog color output voltage: 0.6V
sync signal level: 3.3V
```
## Hardware
### CAUTION
SPI connection requires 3.3V voltage level for safe operation
---
Apart from standard VGA connector, there is a SPI connection:
```
[ GND ]--(1)
< CSEL ]--(2)
< MOSI ]--(3)
< SCLK ]--(4)
```
FPGA:
```
MIMAS SPARTAN6 MODULE
```
Memory:
```
IS61LV5128AL 512K x 8 HIGH-SPEED CMOS STATIC RAM
access max time: 10, 12ns
full read/write max time: <20ns
```
## Video memory
The video memory access is handled by module `vmmu.v`, which coordinates read access by VGA display unit and write access by SPI interface.
The basic working mechanism is the use of FIFOs to queue request addresses and read/write data.
Then the module can alternate between executing read and write requests, or if only one source has an active request, only that source is being processed.
The usage of FIFOs also make the system memory independent of other video circutry in terms of clock domains, further making the design more flexible.
## Schematics
As of recent update I've recovered KiCAD schematics and PCB design that contained system memory, SPI input and VGA connector. Those can be found under `kicad` directory.

## Modules
- spi.v - 8-bit SPI sampling receiver
- vbuf.v - video output buffer, also able to read 3 packed bytes to 4 pixels
- vcmd2v.v - video command processor, interacts with received data from SPI
- vctl.v - video output counter unit, sends signals related to video signal blanking and issues pixel read requests
- vsig.v - generates HSync and VSync VGA signals, along with global blank signal
- fifo.v - First-In-First-Out, asynchronous queue, with Full/Empty signals
- seqfifo.v - Generates sequences of addresses from staring address behaving as regular FIFO
- vmmu.v - video memory managment unit, time-slots reads and writes, controls memory chip
- vga.v - top-level module
## Bugs
#### 160x120 picture resolution (unresolved)
This was a hardware fault that prevented me from using a full 640x480. It turned out that one of the address lines was busted and it basically could corrupt the whole lower half of the screen. In theory I such issue could be remedied remap that region to an area that didn't use that address line.
#### PCB design mistake (fixed)
Due to confusing and just plain wrong schematic of pin headers that was published on Mimas site, one of data lines ended up connected to chip ground. This required an ad hoc jumper wire to be connected to a new location on a pin header, and a previous trace to be cut.
#### Dummy byte write needed after cursor move (unresolved)
An annoying issue, this results from tricky synchronization problems when the command to change cursor location is received. I was unable to fix it due to time constraint, instead a software workadround was devised, by writing a dummy byte just after `vga_set_xy`. This solution is not perfect and can cause flickering, depending on SPI data rate.
## Example driver code
A simple test driver code for ATMega88 (and its derivitives) can be found in `test_driver` directory. This test includes a simple color pallette pattern and animated analog speedometer.
The other example is included as a submodule [`vga_snake`](https://github.com/szym-mie/vga_snake) and it's a snake game demo written in C.