P32W¶
P32W: a 32-bit homebrew computer and its operating system. Discrete 74-series logic, GALs, SRAM and flash on 9U × 340 mm cards with three 96-pin bus connectors, on a 10-slot backplane, with the ALU in an FPGA module (a Tang Nano 20K in sockets: every part is through-hole). A custom minimal load/store ISA with traps, interrupts and virtual memory, and P32W Unix, a multi-user V6-style Unix in C, with a native C compiler, assembler and linker, MicroPython, Lua, SQL, BASIC and networking.
The cards: CPU, MMU / data, memory (1–4 × 16 MiB), disk (2 CompactFlash + 2 IDE), I/O (4 serial ports, timer, clock, 2 USB, Ethernet and Wi-Fi), video (VGA text and graphics, PS/2 keyboard and mouse) and debug. They meet on a synchronous system bus that carries physical memory cycles; the CPU and the MMU / data card have a private local link besides.
Start here: docs/architecture.md (the machine, the cards, the address map) and docs/programmers-guide.md (how to program it).
- Design decisions: docs/decisions.md
- The operating system: docs/os-design.md; using P32W Unix: docs/unix.md
- Working from a web browser, in a GitHub codespace: .devcontainer/README.md
- The debugger, in a browser tab (the screen, the console, the code, the CPU's insides): tools/p32dbg/README.md
- The backlog: docs/backlog.md
- Instruction set: docs/isa-v0.md; traps, privilege, interrupts, timer and virtual memory (stages A–C): docs/isa-system.md; every instruction in one table: docs/instruction-reference.md (generated)
- Microarchitecture: docs/microarch.md; the CPU card: docs/cpu-card.md; the MMU / data card: docs/mmu-card.md; the memory card: docs/mem-card.md; the I/O card: docs/io-card.md; the disk card: docs/disk-card.md; the video card: docs/video-card-acrtc.md (revision 2, an HD63484 ACRTC; revision 0, never built: docs/video-card.md); the debug card: docs/debug-card.md; each card's theory of operation beside it (
*-card-theory.md); how it boots: docs/boot.md; the kernel: docs/kernel.md; the filesystem: docs/filesystem.md.python3 tools/mkpdf.pymakes them PDF books (docs/pdf). The GALs' fuse files and how to program every chip (TL866II+ / T48): hardware/gal/README.md - ISA additions measured for the new datapath: docs/isa-measurements.md
- The backplane bus: docs/bus.md (generated by
generators/p32bus.py); the backplane itself: docs/backplane.md; the power budget: docs/power-budget.md; timing: docs/timing.md - The emulators: docs/emulators.md
The cards¶
The card netlists come next, the CPU card first (docs/architecture.md, the
order of work). Until then the cards exist as the emulators' models
(emulator/p32io.h, emulator/p32uemu.c) and the architecture document.
Layout¶
| Directory | Contents |
|---|---|
microcode/ |
p32isa.py — the opcode table, single source of truth for the ISA; p32ucode.py — the microcode generator |
generators/ |
p32bus.py — the bus (pinnet(), busnet()); p32net.py — device library, netlist helpers, electrical checks; p32cards.py — the card list; p32gal.py — GAL equations, exhaustive checks, a logic minimiser; p32sim.py — netlist-level simulator; p32schem.py — schematic PDFs; p32kicad_sch.py — KiCad schematic projects; p32kicad_pcb.py + build_board.sh + kicad_tools.py — place, autoroute (Freerouting 2.5) and finish boards; gen_footprints.py — the project's footprints (hardware/lib); gen_p32opc.py, gen_isaref.py — the emulator header and the instruction reference |
assembler/ |
p32asm.py — two-pass assembler, linker, archiver |
cc/ |
p32cc.py — the C compiler |
emulator/ |
p32emu.c — instruction-level reference emulator; p32uemu.c — microcode-level emulator, cross-checked against it; p32io.h — the devices, shared by both; tests in test/ |
kernel/ |
P32W Unix |
software/ |
the boot ROM monitor, libc, the commands, MicroPython, Lua, SQL, the tests (software/README.md) |
fpga/alu/ |
the ALU in Verilog, its testbench and vector generator |
hardware/lib/ |
the project's KiCad footprints (generated); the cards will go beside it |
docs/ |
design documents |
Build and test¶
cd generators && npm install # once: elkjs, for the wired KiCad schematic sheets
cd emulator && make test # everything: emulators, microcode, P32W Unix
Assemble and run a program:
python3 assembler/p32asm.py prog.asm -o prog.bin -l prog.lst
emulator/p32emu [-t] [-l N] [-d disk.img] prog.bin
Tools used: Python 3, a C compiler, KiCad 10 (schematics and boards),
Freerouting 2.5 on Java 25 (~/freerouting/), Icarus Verilog (the ALU test).