A small 8-bit 6502 computer in VHDL for the Colorlight i9+ (XC7A50T)
  • VHDL 80.3%
  • Assembly 5.6%
  • Python 5.4%
  • C 3.6%
  • Tcl 3%
  • Other 2.1%
Find a file
vratk0529-arch-desktop 14fab375d3 Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado
rtl/rom_loader.vhd listens on the RX pin alongside the CPU's UART. On an
8-byte magic sequence it holds the machine in reset, takes a 16 KB image,
writes it into the ROM (now a block RAM with a write port, still
initialised from rom_data), replies with a CRC-16/CCITT and reboots.
A stalled host times out after 250 ms. Wired into both the 6502 and the
8080 computers and all four build scripts.

sw/romload.py is the host side (stdlib termios, no pyserial); "make load"
in sw/ and sw8080/ builds and pushes. The image lasts until the FPGA is
reconfigured.

sim/tb_loader.vhd checks no false triggers, the overlap case, a full load
with the CRC matching Python's crc_hqx, and timeout recovery. Existing
testbenches still pass; frame.png and frame8080.png render identically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:33:58 +01:00
rtl Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
sim Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
sw Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
sw8080 Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
syn Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
.gitignore 8080: HDMI output, now the default build 2026-11-13 22:22:21 +01:00
LICENSE Add MIT license, clean up repo for publishing 2026-11-11 12:46:23 +01:00
README.md Serial ROM loader: replace the boot ROM in ~1.5 s without Vivado 2026-11-13 23:33:58 +01:00
THIRD_PARTY_NOTICES.md Add Intel 8080 version of the machine 2026-11-11 16:59:48 +01:00

n6502

A small 8-bit computer in VHDL for the Colorlight i9+ v6.1 (Xilinx XC7A50T): a 6502 at 5 MHz, 16 KB of RAM, 16 KB of ROM, a 40×25 colour text display on VGA with a redefinable character set, a PS/2 keyboard, a 115200 serial port, four channels of sound, and a hardware random generator.

Note: this was mostly vibecoded, as an experiment in how far an AI coding assistant can take an FPGA project. The hardware testing was done by hand, but treat the code and the claims in this README accordingly.

Running on real hardware. Video, keyboard, serial and sound are all confirmed working on the board. The only part that has never worked is the HDMI output — see Known issues.

Everything is also verified in simulation, and the testbenches are the point: each one measures what the hardware actually does rather than checking that a register reads back what was written. The CPU passes the full Klaus Dormann 6502 functional test suite, the UART is checked against an independent 115200 bit generator, the sound chip's pitches are timed and converted back to hertz, and the random generator is compared against a model written in Python.

the demo firmware, rendered out of the simulator

There is also an Intel 8080 version: the same machine with an 8080 core in place of the 6502, programmed in assembly. See 8080 version.


Quick start

cd sw  && make                                  # build the firmware
cd ../sim && make                               # run the fast testbenches
cd ..  && vivado -mode batch -source syn/build.tcl
sudo openFPGALoader -c ch347_jtag -m build/soc_top.bit

-m loads to SRAM, so the board reverts to whatever is in flash on power cycle. Drop it to write flash instead.

On power-up you should get a blue-bordered screen with a coloured banner, a C-E-G arpeggio followed by a noise blip in the first second, the LED blinking once a second, and n6502 ready. on the serial port. Typing echoes to both the screen and serial, and plays a note.

Use Vivado, not openXC7. The board documentation recommends openXC7, which is Yosys-based, and Yosys will not read VHDL without the GHDL plugin. The XC7A50T is covered by the free Vivado WebPACK licence.


Memory map

Range Size Contents
$0000-$00FF 256 B zero page
$0100-$01FF 256 B 6502 stack (fixed by the CPU)
$0200-$2FFF 11.5 KB your RAM: .data, .bss, heap
$3000-$3FFF 4 KB cc65 expression stack
$4000-$43E7 1000 B character plane, 40×25
$4800-$4BE7 1000 B colour plane, bg<<4 | fg
$8000-$87FF 2 KB font RAM, 256 glyphs × 8 rows, writable
$C000-$FFFF 16 KB ROM, vectors at $FFFA/$FFFC/$FFFE

I/O sits at $4400-$44FF rather than the traditional $Dxxx because a 16 KB ROM occupies the whole top quarter of the address space.

Address Access Meaning
$4400 W output port, bit 0 → LED
$4401 R video status, bit 7 = vertical blanking
$4402 R frame counter
$4410 R keyboard character — reading pops the FIFO
$4411 R b7 key ready, b6 shift, b5 ctrl, b4 caps lock
$4412 W b7 = raise IRQ when a key is ready
$4420 R/W UART receive byte (pops) / byte to transmit
$4421 R b7 rx ready, b6 tx room, b5 overrun, b4 framing error
$4422 W b7 = raise IRQ when a byte arrives
$4430 R/W random byte (advances) / seed byte
$4440-$444F W sound, four bytes per voice

Every region decodes as one comparison on the top address bits.

Block RAM use is about 36 KB of the 337 KB on the XC7A50T, so any of these can grow substantially.


Pinout

All verified on hardware.

Signal Pin Signal Pin
clk25 K4 ps2_clk V17
led A18 ps2_dat P17
vga_hs M3 uart_tx R16
vga_vs R4 uart_rx N17
vga_r[0] T5 audio P15
vga_g[0] V4
vga_b[0] R3

VGA is one bit per channel through a ~270 Ω series resistor into the monitor's 75 Ω input. COLOR_BITS on soc_top selects how many of the internal four bits per channel reach pins; see Colour.

Serial is 3.3 V logic. A USB-serial adapter set to 3.3 V connects directly; a real RS-232 port at ±12 V needs a transceiver. uart_tx goes to the adapter's RX.

Audio needs a filter to turn the 1-bit stream into sound:

P15 ---[ 1k ]---+---[ 10uF ]--- jack tip
                |
             [ 10nF ]
                |
               GND               sleeve to GND

The RC pair rolls off around 16 kHz to remove the carrier; the capacitor blocks the DC offset the unipolar mixer leaves behind. Feed a powered speaker or a line input rather than headphones directly.


Video

640×480 @ 60 Hz, 40×25 characters of 8×8 pixels doubled to 16×16, giving a 640×400 active area centred in the frame.

The board's 25 MHz crystal is the pixel clock (spec is 25.175 MHz; 0.7% low, and every monitor accepts it), so the VGA build needs no MMCM, no clocking wizard and no vendor IP at all.

Two planes with the same geometry: $4000 holds a full 8-bit character code so all 256 glyphs are reachable, and $4800 holds background in the high nibble and foreground in the low nibble. They are separate block RAMs read at the same address, so the colour fetch happens in parallel with the character fetch and costs no extra pipeline slot.

Inverse video is a colour swap rather than a character code, which is what freed bit 7 for the second 128 glyphs. The colour plane powers up as $0F, so a freshly configured FPGA shows white on black before the CPU writes anything.

Colour

16 colours, 4 bits per channel internally, using the CGA palette. That is not nostalgia: it survives truncation to one bit per channel unusually well. On the 3-wire build only dark grey collapses to black and brown lands on red; the other fourteen keep their hue. sim/frame_1bit.png is rendered exactly as the 1-bit build displays it, next to the full sim/frame.png.

To move to four bits per channel, change the COLOR_BITS default in rtl/soc_top.vhd and the -generic in syn/build.tcl, then swap the commented colour block in syn/i9plus.xdc. Change both: synth_design -generic only applies to the non-project flow, and a GUI run silently uses the VHDL default.

Glyphs

$00-$7F is ASCII. Above that:

Range Contents
$80-$8A single line box drawing
$90-$9A double line box drawing
$A0-$AA heavy line box drawing
$B0-$B7 shading and half blocks
$B8-$BF horizontal bar levels, ⅛ cell each
$C0-$C7 vertical bar levels, ⅛ cell each
$D0-$E3 arrows, triangles, discs, diamond, heart, check, star, face
$F0-$FF empty, scratch space

n6502.h has a CH_* name for each. The bar levels give meters eight times the resolution of whole cells — hbar() uses them.

Redefinable character set

The font is RAM, mapped at $8000-$87FF. FONT[ch * 8 + row] is one row, MSB leftmost. Redefining glyphs turns the character display into a tile engine: 40×25 cells of 8×8 pixels is a 320×200 field with 256 unique tiles, each cell picking a tile plus a foreground and background colour — structurally what the 8-bit machines did for graphics.

define_glyph() waits for vertical blanking before writing, because rewriting a glyph while it is being scanned out tears it.


Keyboard

PS/2, receive only. Everything awkward about the protocol is handled in hardware, so the CPU never sees a raw scan code: the $F0 break prefix and $E0 extended prefix are absorbed, shift and ctrl are tracked as modifier state, caps lock toggles and applies to letters only, and the result is translated to ASCII and pushed into a 16-byte FIFO.

        lda KBD_STATUS
        bpl no_key
        lda KBD_DATA        ; reading pops the FIFO

About seven cycles to poll, or set bit 7 of $4412 and the ready flag drives IRQ. Arrow keys arrive as $80-$83; ctrl+letter gives the usual control code.

Because it is receive-only the keyboard is never initialised — not needed, they power up in scan code set 2 and start sending — and the caps lock LED cannot be lit.

Two details in ps2_rx.vhd that matter on real hardware: the clock line is open-collector and its edges are dirty, so a 16-sample filter rejects glitches that would otherwise be counted as extra bits; and a glitch that got through would strand the bit counter mid-frame and corrupt every key after it, so a watchdog resets it after ~2 ms of silence.


Serial

115200 8N1, 16-byte FIFOs each way, no flow control.

The baud rate needs no special clocking: 25 MHz / 115200 = 217.01, so an integer divisor of 217 gives 115207 baud. That is 0.006% off against the ~2% of total drift 8N1 tolerates across a frame.

Receive uses half-bit alignment — on the falling edge of the start bit, wait half a bit time and re-check, so a glitch that no longer reads low is rejected as a false start rather than latched as a byte. Each following bit is sampled at its centre, which is why the baud error is irrelevant: the sampling point can drift nearly half a bit before anything breaks.


Sound

Three square wave voices plus one noise channel, modelled on the SN76489 with the register layout rearranged to suit C.

Four bytes per voice at $4440: period low, period high (4 bits), volume (4 bits), control. Voices 0-2 are squares; voice 3 is noise, and bit 0 of its control byte selects the short periodic loop instead of white hiss.

A prescaler divides the 25 MHz clock by 64 to give a 390625 Hz tick, so

frequency = 390625 / (2 * period)

covering 47.7 Hz to 195 kHz from a 12-bit period. Volume is logarithmic at 2 dB per step, because a linear ramp spends most of its range sounding equally loud and then collapses at the bottom.

notes.h tabulates every octave rather than shifting one, since the period is an integer and halving it compounds rounding. Tuning stays under 3 cents through octave 5, reaching about 15 cents in octave 7 where the period gets coarse — a good ear will catch that on a held note. Shifting a single table would have been 23 cents. If the top octave matters, halve PRESCALE in psg.vhd and double the table.

Output is first-order sigma-delta at the full 25 MHz, not PWM. Straight 10-bit PWM would put its carrier at 24.4 kHz — right at the edge of hearing and barely touched by a simple RC filter. Sigma-delta pushes the quantisation noise into the hundreds of kHz where the filter removes it completely.

There is no envelope generator, so psg_tick() walks a per-voice decay once per frame. Notes that stop dead are what make short effects sound like effects rather than beeps.


Random

$4430 is a 32-bit maximal-length Galois LFSR (taps 32, 31, 29, 1). Reading advances it eight steps, so every byte is entirely fresh bits rather than a sliding window. Four writes set the whole 32-bit seed, and an all-zero seed — the one state that would lock any LFSR up — is rejected.

The sequence is deterministic for a given seed, which is what you want in a game: levels reproduce, bugs reproduce, replays work. randomize() mixes in the frame counter so each run differs.


Firmware

cd sw && make          # C firmware (default)
cd sw && make asm      # the original assembly firmware instead
cd sw && make font     # regenerate the character set

Both paths end at rtl/rom_data.vhd. make prints ROM usage; the demo takes about 5.3 KB of 16 KB.

Loading firmware without rebuilding the bitstream

cd sw && make load                    # build, then push over serial
cd sw && make load PORT=/dev/ttyACM0  # another adapter
cd sw && make asm load                # the assembly firmware
cd sw8080 && make load                # 8080 build, same loader

Once a bitstream with the serial loader is on the board, a firmware change no longer needs Vivado at all. sw/romload.py sends the 16 KB image down the ordinary serial port in about 1.5 s; the board holds itself in reset, rewrites the ROM, sends back a CRC for the host to check, and reboots into the new code. It needs only Python's standard library, no pyserial.

The loaded image is in block RAM, so it lasts until the FPGA is reconfigured. Power-cycling brings back whatever was built into the bitstream. Do the Vivado build when you want a change to survive power-off.

The loader (rtl/rom_loader.vhd) listens on the RX pin in parallel with the CPU's UART and waits for an 8-byte magic sequence (A5 5A "n6ROM" C3), which neither typing nor normal program output will produce by accident. The protocol: magic → ACK 06h → 16384 image bytes → CRC-16/CCITT back. If the host stops partway, the loader gives up after 250 ms and releases the machine; the ROM is then part old, part new, and you just load again.

File
n6502.h hardware definitions, colour and glyph names
console.c text output, scrolling, boxes, bars, cursor
uart.c serial helpers
psg.c sound driver with per-voice decay
notes.h / notes.c equal temperament period tables
main.c the demo
crt0.s C startup: soft stack, bss, data, constructors

The ROM image is compiled into VHDL by sw/mkrom.py, not read from a file at elaboration. An earlier version used textio to load rom.hex, which resolves relative to the directory the tool was launched from; when that lookup failed the ROM filled with $EA (NOP), the reset vector read as $EAEA, and the CPU executed NOPs forever — a blank screen with a perfectly good border, which looks exactly like a broken character generator.


Simulation

GHDL. The Makefile defaults to ghdl-llvm, which compiles to native code and is roughly 3× faster than the mcode backend — that matters for the CPU suite. Override with make GHDL=ghdl.

Target What it proves Time
make ps2 shift, caps, ctrl, break codes, extended keys, bad parity, watchdog recovery seconds
make uart real 115200 bit timing, false starts, framing errors, overrun seconds
make loader serial ROM loader: no false triggers, full load, CRC against Python's, timeout recovery seconds
make lfsr matches an independently written Python model, bit balance seconds
make psg measured output frequencies, volume curve, mixing, noise seconds
make tmds DVI 8b/10b round trip, transition count, disparity bound seconds
make frame renders a full video frame to frame.png seconds
make klaus the complete 6502 functional test suite ~6 min
make boot bus trace of the firmware's first writes seconds

The CPU result is *** PASS: Klaus functional test completed after 112,398,787 cycles — every legal opcode, every addressing mode, all flag behaviour, and the exhaustive decimal-mode ADC/SBC tests.

Two of these deserve a note on method. make uart drives the RX pin from an independent generator at exactly 115200 rather than using loopback, because loopback passes even when the baud rate is wrong — both ends being wrong together. make psg times the actual output and converts back to hertz rather than trusting the register values; A4 comes out at 440 Hz within 0.02%.

make lfsr compares against values computed in Python, so it is a genuine cross-check rather than the design agreeing with itself.

Note that rtl/tmds_serializer.vhd, dvi_out.vhd and soc_top_hdmi.vhd are deliberately not analysed by the simulation Makefile: they instantiate Xilinx primitives that need the unisim library, which only Vivado provides.


8080 version

The same machine with an Intel 8080 in place of the 6502: same video, font, keyboard, serial, sound and random generator, programmed in assembly. It is a separate top level, so the 6502 build is untouched.

Status: verified in simulation (below) and built with Vivado 2025.1, where it meets timing with 23 ns of slack on the 40 ns clock and uses about 1,400 LUTs and 9.5 block RAMs. Runs on the board (VGA and HDMI).

cd sw8080 && make                               # assemble the firmware
cd ../sim && make cpu8080 boot8080 frame8080    # quick checks
cd ..     && vivado -mode batch -source syn/build8080.tcl
sudo openFPGALoader -c ch347_jtag -m build8080/soc_top8080_hdmi.bit

The default build outputs HDMI and VGA at the same time (see HDMI). syn/build8080_vga.tcl builds VGA only, into build8080_vga/soc_top8080.bit.

Same pins and the same syn/i9plus.xdc, and the same demo as the 6502 build: banner, palette, uptime clock and meter, the runtime sprite, typing with echo and a note per key, the power-up arpeggio, and n8080 ready. on serial.

the 8080 demo, rendered out of the simulator

HDMI

The default 8080 build (syn/build8080.tcl, top soc_top8080_hdmi) drives DVI over the ext-board HDMI connector and keeps VGA driven as well. Verified on the board. Extra pins are in syn/i9plus_hdmi_se.xdc.

The connector pins (W7 Y8 AB7 Y7 AB6 AA5 AB5 AA4, labelled D2± D1± D0± CK±) are not differential pairs of the FPGA, so TMDS_33 can't be used; this is why the 6502 HDMI build fails. Following the i9plus-gpu project, rtl/hdmi_pins.vhd drives each pin single-ended (LVCMOS33, 16 mA, fast slew) from its own ODDR at 5x the pixel clock, and the "−" pin carries the inverted stream. The connector is wired as labelled with no lane inverted. -tclargs scan builds a version that steps through all 16 lane polarities (5 s each, index shown by LED blinks and on screen), for other boards.

Memory and I/O

The 8080 resets to 0000h and its RST vectors sit at 0000h-0038h, so the ROM moves to the bottom and RAM to the top, where the stack grows down from FFFFh. The screen and font keep their 6502 addresses.

Range Size Contents
0000h-3FFFh 16 KB ROM; RST n calls 8n, the interrupt lands on 0038h
4000h-43E7h 1000 B character plane, 40×25
4800h-4BE7h 1000 B colour plane, bg<<4 | fg
8000h-87FFh 2 KB font RAM, writable
C000h-FFFFh 16 KB RAM and stack

The peripherals move into the 8080's own I/O space and are reached with IN and OUT. Each port number is the low byte of the 6502 address, so $4411 becomes port 11h and the register table applies unchanged.

        IN      11h             ; keyboard status
        ORA     A
        JP      no_key          ; bit 7 clear
        IN      10h             ; reading pops the FIFO

OUT only takes a constant port. The firmware reaches a computed one (a sound voice chosen at run time) through a three-byte OUT nn / RET stub in RAM whose port byte it patches first. sw8080/n8080.inc has every port, colour and glyph name.

Interrupts. The keyboard and UART sources are ORed onto INT. The acknowledge cycle reads FFh from the bus, which is RST 7, so a taken interrupt calls 0038h. End a handler with EI / RET: EI takes effect one instruction late, exactly so that the RET gets out before the next interrupt.

Assembler

sw8080/asm8080.py is a small two-pass assembler in Python, so the 8080 side needs nothing but python3. It takes Intel mnemonics, EQU, ORG, DB, DW, DS, INCLUDE, expressions with HIGH()/LOW(), and .local labels scoped to the previous ordinary label. make writes a listing to sw8080/boot.lst.

The CPU

Does: all 244 documented opcodes, plus the undocumented aliases (the extra NOPs, JMP at CBh, RET at D9h, CALL at DDh/EDh/FDh) as the real chip runs them. Flags are exact, including the 8080's odd auxiliary carry on subtraction and ANA. HLT, EI/DI with the one-instruction EI delay, and an interrupt acknowledge cycle that executes whatever RST the system supplies.

Doesn't: cycle accuracy. Each state is one bus cycle, so instructions take 2 to 6 states rather than 4 to 18 T-states, which makes this core roughly twice as fast as a real 8080 at the same clock. Multi-byte instructions in the acknowledge cycle (a CALL from an 8259) are not supported, only RST.

The memory timing contract is the 6502 core's, so CPU_DIV must again be at least 2.

Verification

The standard 8080 diagnostics are CP/M programs. sim/cpm8080.asm supplies just enough CP/M for them: a BDOS entry at 0005h that prints through an I/O port, and a warm boot at 0000h that the testbench treats as the exit. sim/get_8080tests.sh downloads them.

Target What it proves Time
make cpu8080 TST8080 and 8080PRE, plus int8080.asm: EI delay, DI, HLT wake-up, vectors, return address seconds
make cputest8080 SuperSoft Diagnostics II CPU test, in GHDL ~15 min (mcode)
make exm8080 all four diagnostics including 8080EXM ~50 min
make boot8080 firmware sound, serial, LED and keyboard against a scripted I/O model seconds
make frame8080 renders the 8080 demo to frame8080.png, and decodes the serial pin ~1 min

The results: TST8080 prints CPU IS OPERATIONAL, CPUTEST CPU TESTS OK, and 8080EXM passes all 25 of its tests, every CRC matching the real chip, after 9,349,430,322 cycles.

8080EXM runs every instruction over millions of operand combinations and compares a CRC of the results and flags against real silicon. It is billions of cycles, about a day in GHDL. make exm8080 has GHDL synthesise cpu8080.vhd to Verilog and compiles that with Verilator (needs verilator installed), so it still tests the same RTL, and proves it synthesises. That takes about 50 minutes on one core. The run is serial, so a faster core helps and more cores do not.

The interrupt test was checked by mutation: with the EI delay removed from the core it fails at check 1.


Design notes

One clock, no PLL

The VGA build has exactly one clock domain. The CPU runs from the 25 MHz pixel clock via a clock enable pulsing every 5 clocks. Slowing a CPU with a clock enable rather than a divided clock keeps everything synchronous and keeps static timing analysis meaningful.

The memory timing contract

Worth understanding before changing the core, because it caused two of the nastier bugs here:

Each state presents an address on addr_o and consumes the returned data on din_i at the end of that same state.

With block RAM this works because addr_o is held stable across the whole clock-enable window, so the RAM's one cycle of latency hides inside it. It follows that CPU_DIV must be at least 2 — tying the clock enable high will fetch stale data. The testbenches run the CPU at full speed and therefore use combinational memory.

CPU_DIV = 2 would give 12.5 MHz, though the core's critical path has not been timed that hard. Check build/timing.rpt before trusting it.

Dual-ported memory

Real 8-bit machines fought over one memory bus — the C64 stole cycles, the Apple II interleaved on clock phases. FPGA block RAM is genuinely dual-ported, so the CPU gets port A and the video scanner port B and they never collide. No arbitration, no wait states, no snow.

What the CPU does and doesn't do

Does: all 151 documented opcodes, all 13 addressing modes, decimal-mode ADC/SBC with NMOS flag behaviour, the JMP ($xxFF) page-wrap bug, and IRQ, NMI and BRK with correct vector and B-flag handling.

Doesn't: cycle accuracy. Each FSM state is one bus cycle and instructions take roughly one to two cycles more than the real chip. There are no dummy reads on page-crossing indexed addressing, no read-modify-write double write, and interrupts are sampled at instruction boundaries rather than on the penultimate cycle. Undocumented opcodes decode as one-byte NOPs.

Fine for running your own code. Not fine for running C64 or NES software, which depends on all of the above.


Known issues

HDMI does not work. syn/build_hdmi.tcl builds and the pin map is correct (recovered from the package database with syn/pairs.tcl after the board's own net labels turned out to be shuffled), but the board produces no signal on any pair — including the clock, which carries a fixed pattern with no dependency on video. That points at the serialisers never leaving reset, most likely the MMCM failing to lock. Probe locked in soc_top_hdmi.vhd first.

The TMDS encoder itself is verified in simulation; the serialiser and MMCM are the untested part, since they need unisim.


Extending it

  • A blitter. The CPU touches memory once every 5 clocks, so a blitter sharing port A gets the other 4 for free. A full-screen fill would drop from ~3 ms to ~40 µs with no impact on the CPU.
  • A vblank IRQ. Five lines, and the IRQ path is already tested. Gives a proper 60 Hz game loop where the CPU sleeps until the frame boundary.
  • Hardware multiply. The 6502 has none and a software 8×8 multiply is ~100 cycles. As a peripheral it would be ready long before the CPU came back for the result.
  • 80×30 text. Bump the character and colour planes to 2 KB each and use an 8×16 font with no pixel doubling.
  • Cycle accuracy. A rewrite of the sequencer around a T-state counter, not a patch.

Files

rtl/cpu6502.vhd        6502 core, all 151 legal opcodes, decimal mode
rtl/computer.vhd       CPU + memories + peripherals, display agnostic
rtl/soc_top.vhd        VGA top level
rtl/soc_top_hdmi.vhd   HDMI top level: MMCM + computer + dvi_out
rtl/soc_top8080_hdmi.vhd 8080 HDMI + VGA top level
rtl/hdmi_pins.vhd      single-ended DVI serialiser with pin crossbar
rtl/vga_timing.vhd     640x480 @ 60 Hz counters and syncs
rtl/video_text.vhd     character generator and pixel shifter
rtl/font_ram.vhd       writable character set   (GENERATED - sw/mkfont.py)
rtl/dpram.vhd          dual-port RAM for the character and colour planes
rtl/ram.vhd            main RAM
rtl/rom.vhd            boot ROM (writable by the loader)
rtl/rom_loader.vhd     serial ROM loader, see sw/romload.py
rtl/rom_data.vhd       boot ROM image           (GENERATED - sw/mkrom.py)
rtl/ps2_rx.vhd         PS/2 frame receiver, filtered, with watchdog
rtl/ps2_keyboard.vhd   scan codes -> ASCII, modifiers, FIFO
rtl/ps2_map.vhd        scan code tables         (GENERATED - sw/mkps2map.py)
rtl/uart.vhd           115200 8N1 with FIFOs both ways
rtl/psg.vhd            3 square voices + noise, sigma-delta output
rtl/lfsr.vhd           32-bit maximal-length random generator
rtl/tmds_encoder.vhd   DVI 8b/10b encoder
rtl/tmds_serializer.vhd 10:1 OSERDESE2 serialiser + OBUFDS
rtl/dvi_out.vhd        three TMDS channels plus the clock channel

sim/tb_klaus.vhd       6502 functional test suite
sim/tb_soc.vhd         renders one video frame
sim/tb_boot.vhd        bus trace of the firmware
sim/tb_ps2.vhd         keyboard decoding
sim/tb_uart.vhd        UART against true 115200 timing
sim/tb_loader.vhd      serial ROM loader
sim/tb_psg.vhd         sound: measured frequencies and levels
sim/tb_lfsr.vhd        random generator vs a Python model
sim/tb_tmds.vhd        TMDS encoder vs the DVI spec

rtl/cpu8080.vhd        8080 core, all opcodes, exact flags
rtl/computer8080.vhd   the 8080 machine: same devices, 8080 bus and map
rtl/soc_top8080.vhd    8080 VGA top level, same ports as soc_top
rtl/rom8080.vhd        8080 boot ROM
rtl/rom8080_data.vhd   8080 ROM image           (GENERATED - sw8080/mkrom.py)

sw8080/asm8080.py      8080 assembler, Python, no dependencies
sw8080/boot.asm        8080 demo firmware
sw8080/n8080.inc       8080 ports, colours, glyphs

sim/tb_cpu8080.vhd     runs a CP/M 8080 diagnostic
sim/tb_cpu8080.cpp     the same under Verilator, for 8080EXM
sim/cpm8080.asm        the minimal CP/M those diagnostics need
sim/tb_int8080.vhd     8080 interrupts, driven by int8080.asm
sim/tb_boot8080.vhd    8080 firmware vs a scripted I/O model
sim/tb_soc8080.vhd     8080 frame render and serial decode

syn/i9plus.xdc         VGA pin constraints
syn/build.tcl          Vivado flow, VGA
syn/i9plus_hdmi.xdc    HDMI pin constraints
syn/build_hdmi.tcl     Vivado flow, HDMI
syn/i9plus_hdmi_se.xdc single-ended HDMI pin constraints
syn/build8080.tcl      Vivado flow, 8080 HDMI + VGA (default)
syn/build8080_vga.tcl  Vivado flow, 8080 VGA only
syn/pairs.tcl          prints true differential pair partners from the package

Credits

The 8×8 font, box drawing and block glyphs are dhepper/font8x8 (public domain, derived from the IBM VGA fonts); the game symbols are drawn by hand in sw/mkfont.py. The CPU test suite is Klaus Dormann's 6502_65C02_functional_tests, downloaded by sim/get_klaus.sh rather than included here. The 8080 diagnostics are TST8080 (Microcosm Associates), CPUTEST (SuperSoft Associates), and 8080PRE and 8080EXM (Ian Bartholomew's 8080 adaptation of Frank Cringle's Z80 exerciser), downloaded by sim/get_8080tests.sh from the copies in superzazu/8080. The sound chip follows the SN76489. Built with GHDL, cc65, Verilator and Vivado.

Board photos, pinout and datasheets for the Colorlight i9+ v6.1 are collected in wuxx/Colorlight-FPGA-Projects (see its doc/ folder and colorlight_i9plus_v6.1.md).


License

MIT, see LICENSE. Third-party material is listed in THIRD_PARTY_NOTICES.md.