RHDL includes a comprehensive Apple II emulation system — a complete computer built from HDL components, featuring the MOS 6502 CPU, video generator, keyboard, speaker, Disk II controller, and an interactive terminal interface.

System Architecture

┌──────────────────────────────────────────────────────────┐
│                     Apple II System                       │
├──────────────────────────────────────────────────────────┤
│  ┌──────────┐  ┌──────────┐  ┌────────────────────────┐ │
│  │ MOS 6502 │  │ Timing   │  │   Video Generator      │ │
│  │   CPU    │◄─│ Generator│─▶│  Text (40x24)          │ │
│  │  1 MHz   │  │  14 MHz  │  │  Lo-res (40x48)        │ │
│  └────┬─────┘  └──────────┘  │  Hi-res (280x192)      │ │
│       │                       └────────────────────────┘ │
│  ┌────┴──────────────────────────────────────────────┐   │
│  │              Address / Data Bus                     │   │
│  └────┬─────────┬──────────┬──────────┬──────────────┘   │
│  ┌────┴────┐┌───┴────┐┌───┴────┐┌────┴─────┐            │
│  │  48KB   ││  12KB  ││  I/O   ││ Disk II  │            │
│  │  RAM    ││  ROM   ││ $C000  ││ Slot 6   │            │
│  └─────────┘└────────┘└────────┘└──────────┘            │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐                 │
│  │ Keyboard │ │ Speaker  │ │ Gameport │                 │
│  └──────────┘ └──────────┘ └──────────┘                 │
└──────────────────────────────────────────────────────────┘

Running the Emulator

# Full Apple II with ROM
rhdl apple2 --appleiigo
 
# Demo mode (no ROM required)
rhdl apple2 --demo
 
# Karateka with hi-res graphics
rhdl apple2 --karateka --hires --color
 
# Load a disk image
rhdl apple2 --appleiigo --disk game.dsk
 
# Fast simulation
rhdl apple2 --karateka --sim compile --sub-cycles 2

Memory Map

AddressSizeDescription
00FF256BZero Page
01FF256BStack
07FF1KBText Page 1 (40x24)
3FFF8KBHi-Res Page 1 (280x192)
5FFF8KBHi-Res Page 2
C0FF256BI/O Page (soft switches)
FFFF12KBROM

I/O Soft Switches

Keyboard

AddressFunction
$C000Read key data (bit 7 = strobe)
$C010Clear keyboard strobe

Video Modes

AddressEffect
$C050Graphics mode
$C051Text mode
$C052Full screen
$C053Mixed mode (4 lines text)
$C054Display page 1
$C055Display page 2
$C056Lo-res graphics
$C057Hi-res graphics

Speaker

AddressEffect
$C030Toggle speaker click

Video Modes

Text Mode (40x24)

Standard 40-column display. Character encoding: inverse (3F), flashing (7F), normal (FF).

Lo-Res Graphics (40x48)

16-color graphics. Each byte encodes two vertically stacked pixels (low nibble = top, high nibble = bottom).

Hi-Res Graphics (280x192)

High-resolution monochrome/color. 7 pixels per byte with 1 color palette bit. Non-linear memory layout.

Disk II Controller

Full emulation of the Disk II floppy drive controller in slot 6. Supports DOS 3.3 .dsk disk images (143,360 bytes = 35 tracks x 16 sectors x 256 bytes).

HDL Components

ComponentDescription
Apple2Top-level system integration
CPU6502MOS 6502 with bus interface
VideoGeneratorText, lo-res, hi-res output
TimingGenerator14.318 MHz timing and sync
KeyboardPS/2 keyboard interface
DiskIIDisk controller
CharacterROMCharacter generator
RAM48KB main memory
AudioPWMPWM audio output

Simulation Backends

# Ruby HDL (most accurate)
rhdl apple2 --mode ruby --appleiigo
 
# IR with JIT (fast)
rhdl apple2 --mode ir --sim jit --appleiigo
 
# Verilator (fastest)
rhdl apple2 --mode verilog --appleiigo
 
# CIRCT/MLIR
rhdl apple2 --mode circt --appleiigo

Display Renderers

The terminal emulator supports multiple rendering modes:

  • ASCII — basic text output
  • ANSI color — 16-color terminal rendering
  • Braille — Unicode Braille characters for hi-res display
rhdl apple2 --karateka --hires --color --hires-width 280

Next Steps