Skip to content

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).

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).