Home |
Projects | SoftVGA
SoftVGA - AVR based Software-only VGA Display Generator
Project Basics
Project Status
Hardware Description
Code Download
Auxillary Documents
Photos of the Project
Other Websites of Interest
Project Basics
This project is aimed at generating an VGA monitor (basically 31.5kHz
horizontal, 70Hz with400of450lines or 60Hz with 480of525lines vertical)
compatible video signal, without using any specialised hardware VLSI video
generator chips (hardwired limited, not available any more), nor 100s of
TTL chips (lots of space and soldering), nor an CPLD or FPGA chip (awfull
software tools, no bitfile docs for making usable ones). Only hardware is
an VGA HD15 connector, behind it 3*2 resistors which together with the
75ohm input resistance of the monitor RGB signals make 3 2bit DACs, for
converting 6 bits of PIO port 5V digital TTL output into 3 0.7V analog
video signals for the VGA monitor. Their 6 signals, plus 2 bits of PIO for
the sync signals, are taken from an 8bit PIO port. All the rest is done in
software, running as vertical "microcode" on an single Atmel AVR
microcontroller chip (currently ATmega32, 16MHz, 32k Flash, 2k SRAM, 40pin,
32IOs).
Target is to make an pixture that is good enough for an late 1970s or early
1980s style home computer or game console. That requires at least 32x24
(TMS9918, MSX) and preferably 40x24or25 (Apple II, Atari 800, Commodore PET
or C64) text output, suitable for an machine code monitor or Basic
interpreter, and at least low resolution colour graphics (bitmap, or 2x2
blockgraphics, or soft font character cell) suitable for standard genre
defining games such as Pong, Breakout, Space Invaders, Pacman, Frogger, and
similar classics.
For more info on this project read the README file.
For some questions people have asked or may ask read the FAQ
list.
Project Status
For the full details of done/doing/todo of the project best read the
Logfile. A short excerpt from it is here:
Done are:
Current (= development, = may be fantastic, may be broken):
- Built an STK200 compatible PC parallel port flashing device
- Build an 3-wire RS232 based extension to above, for debugging
- Built an generic 40pin analog pinout AVR prototyping board
- Built an PIO to VGA adaptor, including 3 2bit DACs
- Wrote m32def.inc to define ATmega32 resources, ports and bits
- Wrote blink_test.asm, blinks TxD on RS232 extension
- Wrote vga_static.asm, static pattern test picture generator
- Evolved software until it can generate 40x25 characrter text
- Evolved software further so it can update picture while drawing
- Wrote various demos to show off that it is dynamically generated
- Switched to indirect thread drawing, font as indexes, save Flash
- Switched to using font indexes in SRAM, allows soft font
Todo are:
- Port to larger and faster AVR for more soft font and resolution
- Offer selectable choices of resolution or more colours
- Write terminal style RS232 to frame buffer processing
- Add counterpart SoftPS2 for keyboard input, together SoftTERM
Hardware Description
Unfortunately there exists no real hardware documentation. But as the
hardware is trivial, I have here collected the best info that exists, in 3
photos and 1 description:
- Schematic sketches and wiring of
prototyping board and port to VGA adapter. These are really sketchy,
but for the moment better than nothing. Left is AVR wiring schematic
for an generic STK200 and STK500 compatible prototyping board. Middle
is the board layout and partial AVR wiring diagram as viewed from
below. Right is AVR port to VGA adaptor also viewed from below.
- The actual VGA adaptor components and signalling and programming are
fairly simple. This is documented in textual form at the top of the
Assembler source file, just
after the AVR fuse settings. AVR ports are wired each to 5x2=10 pin
connectors, Pins1..8 = Port0..7, Pin9 = 0V, Pin10 = 5V. VGA adaptor is
Pin1 = red to Bit5+4, Pin2 = green to Bit3+2, Pin3 = blue zu Bit1+0,
Pin4+5 unused, Pin6+7+8+9+10 to 0V, Pin11+12 unused, Pin13 = H-Sync to
Bit6, Pin14 = V-Sync to Bit7, Pin15 unused. The 3 Pins1+2+3 go via each
2 resistors of 680ohm and 1k5ohm to Bits54+32+10, which on the AVR
connector are on the first 3 of the 5 pairs.
- Hardware I have produced: Top left
standing on the laptop VGA connector is a LPT port tester running.
Below middle are AVR programming adaptor and 10pin cable. Right
slightly above are RS232 MAX232 adaptor and 10pin cable. Below right is
the VGA adaptor. Bottom middle is the AVR prototyping board.
- That hardware while running: Bottom
left AVR with VGA adaptor to VGA connector. Bottom middle MAX232
adaptor with above RS232 tester and nullmodem and cable. Right of that
AVR programming adaptor with above LPT tester and cable. Also visible
left up top is that the laptop stands on an docking station which has
LPT and COM ports.
- For the ATmega644 I wanted an better prototyping board. So I at long
last documented the wiring of the existing one, for later expanding.
This is in form of an wiring list.
It has wirings for the main 40pin AVR prototyping board, plus an PC LPT
Parport programming device, plus an UART to RS232 converter, plus the
VGA adaptor auxillary board, plus an DIP switches auxillary board.
Code Download
Current (= development, = may be fantastic, may be broken):
-
Installation Guide
- entire project:
SoftVGA.tar.gz (without large Photo files)
- single files:
-
Makefile, control processing
-
avr_registers.inc, define my AVR register usage and naming
-
m32def.inc, define ATmega32 resources, memories, ports, bits
-
blink_test/, AVR test program, blink RS232 TxD, debug IF LED
-
vga_static/, static pattern test picture generator
-
vga_text_static/, static text screen generator
-
vga_threaded/, threaded text screen generator
-
vga_indirect/, space saving table indirect font jumping
Auxillary Documents
These are files I made while investigating various aspects of VGA:
- Older font with 3x5 pixel
characters (no underlines), fits in 4x8 character cells. Base for
selecting 8 linepairs of 4 pixels display format.
- Newer font with 3x6
pixel characters (3x7 with underlines), fits in 4x8 character
cells. Base for selecting 8 linepairs of 4 pixels display format. In
meantime improved by feedback from seeing them running in part of this
project.
- Signals and timing data for various
video standards. Also what various types of monitor will require.
Base for selecting RGB and VGA as target monitor.
- What sort of abilities an
controller needs to fullfill, for this project to work on it.
- Looked at a selection of
various microcontrollers, features, speed, pinouts, etc. Base for
selecting the AVR family for this.
- Colour range
generateable by various bit-sizes and types of DACs. Base for
selecting 6bit (3 times 2bit) DAC for 64 colours. In meantime improved
with detailed 8bit, RGB 3+3+2bit (awfull grays) and 3*3 G+B merged LSB
(more colours and no downside), of which I could switch to the later,
but decided against it.
- Detailed analysis of VGA
timing, and various algorithms for drawing text fast enough, while
fitting in AVR Flash and SRAM memory.
- VCFe 10
(2009) lecture script. Theme of this VCFe was computer
architectures. I presented SoftVGA (and generally using AVRs for
emulation) as architecture for implementing small and cheap own design
systems, as fourth alternative to lots of TTL logic or expensive ASICes
or difficult FPGAs. (in german)
- VCFe 20
(2019) lecture script. Theme of this VCFe was programming at the
limit. I presented SoftVGA as case of such programming, with cycle
precise runtime allocation and explicitely corecting interrupt latency.
(in german)
Photos of the Project
These are photos (and some videos) I made while working on the project:
- The first vga_static display. Near
correct, but colours green/cyan/red/magenta are wrong. This was due to
solder bridge between red bit 0 and green bit 0.
- The first fully correct vga_static
display. After solder bridge was removed.
- The second revision vga_static
display. After adding second drawing routine (SHLINE) was added,
which uses all 64 possible colours.
- The first run vga_text_static
display. Shows 25 rows of 10 times repeat of 4 characters, 1
shifted, but only lines 0,1,2,4,6 of 0..7 drawn, and horizontal timing
trouble.
- The second run vga_text_static
display. Missing lines control flow, and horizontal timing
fixed.
- The third run vga_text_static
display. Entire line-in-row algorithm replaced, no unroll, all 16
lines.
- The fourth run vga_text_static
display. At long last entirely correct timing, no frayed out
lines.
- Reworked vga_text_static display.
New loop subroutines, sync timing problem and orange "comb".
- Extended vga_text_static display.
Added support for row specific colours, here cyan to white.
- Extended vga_text_static font.
Added support for old style TTY 64 ASCII chars 32 to 95.
- More extended vga_text_static font.
Added support for rest of ASCII chars 96 to 126, with 127 as abort
pseudo character.
- X/Y based vga_text_static display.
Misscomputation of +XYCOL, overwrites abort pseudo-chars.
- X/Y based vga_text_static display.
Allowing far more expressive demo, real text and colours.
- Colour exchanges vga_text_static
display. Allowing even more expressive demo with effects.
- 2x2pixel block graphics vga_threaded
display. Allowing low-res bitmaps, such as an SoftVGA logo.
- state machine graphics vga_threaded
display. Misscomputation of row/segment/line counting.
- running with timer and blank second
lines. Shows what effect of interrupt jitter looks like.
- video, animated vga_threaded
display. Has colour rotate, video snail, lissajou ASCII+block
graphics ball.
- video, animated vga_threaded
display. Has colour rotate, video snail, lissajou ASCII+block with
hollow ball, cursor in announce.
- scrambled YH:YL vga_indirect
display. Changed XH:XL and ,X+ to YH:YL and ,Y+ but specials still
used ,X+.
- first non-scrambled vga_indirect
display. Font mess, all characters shifted by one character.
- working indirect jumped vga_indirect
display. Only 30char/row because lpm needs 3*(3+1)clocks/char.
- graphic char demo vga_indirect
display. Frame-round ball, frame-square frame, block cursor (text
uC)
- SRAM indirect vga_indirect display.
Frame buffer and demo reduced to 36x23char screen size.
- SRAM indirect vga_indirect display.
Reverse/underline at mid-space, 3 foregr and 2 backgr colours.
- video, animated vga_indirect
display. Has colour rotate, video snail, framed round linedraw
ball, announce cursor.
- video, animated vga_indirect
display. Has colour rotate, video snail, real circle ball, cursor,
square font digits.
Other Websites of Interest
These sites all contributed some input to this project:
- Two Rickard Gunee
projects, including
PIC B&W NTSC video and
SX colour NTSC video. Original inspiration for this entire
project.
- The
xgamestation, an commercial system similar to Gunees SX NTSC.
- Minimal PIC12 B&W
8pin for Pong, similar to Gunees PIC B&W, even with Paddles, not
joysticks.
-
Robert Greene attempts PIC VGA video, with its difficult fast
timing, also has space problems because using bitmap representation,
gets only 64x44x4bpp.
- B&W NTSC video
used for the Replica-1 Apple 1 clone, done inefficiently.
-
B&W NTSC or PAL video used for the A-ONE 1 clone, done better.
- The VCFe (Vintage Computer Festival
europe), where I got the final push to start this project in
earnest.
-
AVR-ChipBasic2 AVR SCART RGB video, text mode 30x23 cells, and
Basic interpreter. The project at VCFe that gave me that final
push.
-
Atmel AVR Chips, model overview and data sheets.
-
Atmel AVR instruction set documentation.
-
AVR Assembler User Guide.
-
STK200 Parallel Port Starter Kit User Guide.
-
STK500 Serial Port Starter Kit User Guide.
-
STK500 Serial Port Starter Kit Hardware.
- STK200
compatible parport programming adaptor, one of various
descriptions (in german), used 74LS367 version from it.
- STK200 compatible
parport programming adaptor, a slightly differing description
(in german), used suggestion of BAT46 instead of 1N4148 from it.
-
R.G. Keen electronic building technique without etching boards.
Home |
Projects | SoftVGA
This page is by Neil Franklin, last modification 2019.06.03