Skip to the content
2 layers237.5 × 102.9 mmAlu, the printed circuit board in 3D

A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

Size
237.5 × 102.9 mm
Copper layers
2
Thickness
1.6 mm
Parts
91
Nets
198
Pads
591
Tracks, vias
1,764, 237
Pours
2
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
18 Jan 2021
Updated
8 Dec 2023

Overview

Alu is an open-source printed circuit board by jes, from the jes/scamp-cpu repository on GitHub, published under the Unlicense licence. It is a 2-layer board of 237.5 × 102.9 mm with 91 parts on 198 nets, routed with 1,764 tracks and 237 vias.

It is built around the 74LS86, 74LS377PC and 74LS157PC, with the 74LS32SC and 74LS02PC among its other parts. Its parts include 26 resistors, 23 capacitors, 23 ICs and 7 connectors.

Main components

5

README

README.md

SCAMP CPU

SCAMP is my homebrew 16-bit CPU. It stands for something like "Simple Computing and Arithmetic Microcoded Processor".

The CPU is very primitive. It doesn't support interrupts, and has no MMU, and no concept of privilege levels. It currently runs at 1 MHz, above that the CompactFlash interface falls over. It runs a homebrew operating system, with a homebrew programming language and compiler, and can self-host the kernel and all of the system utilities. The environment tastes a bit like an early Unix, but works like CP/M. I used the computer to complete almost all of Advent of Code 2021.

My Advent of Code solutions are here: https://github.com/jes/aoc2021

I have some blog posts here: https://incoherency.co.uk/blog/tags/cpu.html and a web-based emulator available here: https://incoherency.co.uk/scamp/

Here are some pictures:

And here's a video with some explanation and an example session on real hardware:

Architecture

It is a 16-bit CPU. The bus is 16-bit, registers are 16-bit, addresses are 16-bit, and memory contents are 16-bit. The upper 8 bits of an instruction select the opcode, and the lower 8 bits are available for small immediate values. There is no support for: cache, interrupts, virtual memory, DMA, privilege rings, floating point, and ~anything else that is not strictly necessary.

Here is a diagram of the architecture:

For more information, see doc/UCODE.md and doc/ISA.md.

Try it out

The easiest way to try it out is to use the web-based emulator at https://incoherency.co.uk/scamp/

If you want to run it locally, first you'll need to build everything. Try make -j in the root directory of this repository. It probably won't work on the first attempt because it works with multiple different Makefiles that have annoying dependencies. Just run make -j twice or three times. If that doesn't do the trick, run make in sys/ first, and then run it in .. Once you get to the point that it is only complaining about emcc, you're done, unless you also want to build the web-based emulator.

Having built everything, you can go into kernel/ and start it in the emulator with ./run:

text
~/scamp-cpu/kernel $ ./run
make: 'os.disk' is up to date.
SCAMP boot...
.......................................................OK
starting kernel...
loading init...
      ____   ____    _    __  __ ____   __
     / ___| / ___|  / \  |  \/  |  _ \ / /__  ___
     \___ \| |     / _ \ | |\/| | |_) / / _ \/ __|
      ___) | |___ / ___ \| |  | |  __/ / (_) \__ \
     |____/ \____/_/   \_\_|  |_|_| /_/ \___/|___/

$

If you know how to use Unix you'll probably understand how to use it. If you know how to use CP/M you'll probably understand how it works.

If you want, you can write SLANG programs using kilo and compile them with slc. You've probably never written SLANG before. You can learn how to use it by reading programs under /src (or sys/ in the repo). It's mostly like C but with fewer features and less safety.

How it's made

I did these tasks, but working on several steps at a time (i.e. I didn't wait until after I had built the entire computer before thinking about microcode or the operating system):

  1. Create the CPU in Verilog, with a testbench for each part.
  2. Replace the raw Verilog with Verilog that only uses 74xx-compatible primitives (e.g. https://github.com/TimRudy/ice-chips-verilog), but still passes the testbenches.
  3. Convert the 74xx-Verilog into KiCad schematics (by hand).
  4. Order the PCBs and components, solder up the PCBs, build a card cage, build a wooden case.
  5. Settle on the instruction set and write the microcode (see doc/table.html, available online at https://incoherency.co.uk/interest/table.html).
  6. Write a bootloader, kernel, shell, text editor, compiler, and various system utilities.

Next steps

I suspect the computer will never be "finished", but some things I still want to work on are:

Hardware
  • build a hardware multiplication card (and maybe division?)
  • build a hardware RNG
Low-level software
  • make library blob self-hosting (compile within SCAMP/os)
  • write an strace-like debugging tool
  • write a DDT-like debugging tool
  • better facility for memory profiling (mainly to stop kilo and asm from running out of memory on large inputs)
  • atexit()
  • static initialisation of globals from constants (e.g. var x = 5 at global scope should not take any code to initialise)
  • "const" variables (e.g. const x = 5 should lead to x being replaced with the constant value 5 where possible)
Other software
  • write a big-fixed-point arithmetic library
  • fixed-point mathematics: pow,tan,asin,acos,atan,atan2
  • write a FORTH implementation (should it run on bare metal or under SCAMP/os?)
  • write a Z-machine interpreter and port some text adventures
  • write some games (pong? breakout? tetris?)

If you happen to want to work on any of the above, I'd be happy to help you!

Resources

I thoroughly recommend the Nand2Tetris course. https://nand2tetris.org/

If you want to do the exercises from Nand2Tetris without learning what a hardware-description language is, and without going through all the lectures, you can play https://nandgame.com/

Ben Eater's videos on 8-bit CPU design are excellent and heavily influenced the design of my CPU.

I found the YouTube playlist for Nicolas Laurent's compiler class quite helpful in writing the parser for the compiler.

The Build Your Own Text Editor is a fantastic tutorial that walks you through implementing antirez's kilo editor.

Balazs Markus's 8250 UART example is helpful.

Daniel Tufvesson has a post that is a good starting point for understanding the 8-bit CompactFlash interface.

PickledDog has a description of an improvement to the RC2014 CompactFlash card that might be helpful. Also Bill Shen's comment on the RC2014 mailing list.

Michał Cierniak has a good blog post about CompactFlash + 8255 interface card with lots of detail on how his CompactFlash interface works.

James Sharman is building an interesting 8-bit pipelined CPU, and has good videos with lots of explanation on how it works.

SCAMP is featured on the Homebrew CPU ring which also features many other interesting homebrew CPU designs.

Contact

You can email me on james@incoherency.co.uk or read my blog: [https://incoherency.co.uk/].

Parts

91
QtyValueFootprintReferences
26RResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2, R10, R11, R12, R13, R14, R15, R16, R17, R19, R20, R21, R22, R23, R24 +10
23CCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P2.50mmC1, C2, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23 +7
8SolderJumper_3_Bridged12Jumper:SolderJumper-3_P2.0mm_Open_TrianglePad1.0x1.5mmJP1, JP2, JP3, JP4, JP5, JP6, JP7, JP8
674LS08Package_DIP:DIP-14_W7.62mm_SocketU7, U8, U9, U16, U17, U20
674LS86Package_DIP:DIP-14_W7.62mm_SocketU13, U14, U15, U18, U19, U23
374LS377Package_DIP:DIP-20_W7.62mm_SocketU1, U2, U4
3Conn_01x09_MaleConnector_PinHeader_2.54mm:PinHeader_1x09_P2.54mm_VerticalJ2, J3, J4
274LS157Package_DIP:DIP-16_W7.62mm_SocketU12, U22
274LS283Package_DIP:DIP-16_W7.62mm_SocketU11, U21
274LS32Package_DIP:DIP-14_W7.62mm_SocketU5, U10
2Conn_01x03_MaleConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ5, J6
174LS02Package_DIP:DIP-14_W7.62mm_SocketU6
174LS244Package_DIP:DIP-20_W7.62mm_SocketU3
1Conn_01x02_MaleConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ7
1Conn_02x30_Counter_ClockwiseConnector_PinSocket_2.54mm:PinSocket_2x30_P2.54mm_HorizontalJ1

The 87 most common of 91 parts.

More from jes/scamp-cpu

5
  • 2 layers237.5 × 102.9 mmInstruction, the printed circuit board in 3D

    Instruction

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    112 parts301Unlicense
  • 2 layers237.5 × 102.9 mmSerial, the printed circuit board in 3D

    Serial

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    72 parts301Unlicense
  • 2 layers237.5 × 102.9 mmMemory, the printed circuit board in 3D

    Memory

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    55 parts301Unlicense
  • 2 layers237.5 × 102.9 mmStorage, the printed circuit board in 3D

    Storage

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    25 parts301Unlicense
  • 2 layers295 × 102.8 mmBackplane, the printed circuit board in 3D

    Backplane

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    24 parts301Unlicense

Similar boards

  • 2 layersEDiCPoster, the printed circuit board in 3D

    EDiCPoster

    Nik-Sch/EDiC

    Developement, Simulation and Emulation of an 8 bit CPU including a Software Framework for my Masters Thesis

    176 parts1
  • 2 layers370.8 × 298.5 mm8 Bit Computer, the printed circuit board in 3D

    8 Bit Computer

    The-Invent0r/8-bit-Computer-PCB

    These are the KiCAD files for my 8-Bit Computer.

    323 parts142
  • 2 layers236.8 × 169.8 mmTK2000, the printed circuit board in 3D

    TK2000

    clemarfolly/Microdigital-TK2000

    Reprodução da PCB do TK-2000 da Microdigital, clone do Micro-Professor MPF-II

    212 parts17
  • 2 layersNewBrain Original, the printed circuit board in 3D

    NewBrain Original

    flypie/NewBrain

    Newbury/Grundy NewBrain schematics

    209 parts5GPL-3.0
  • 2 layers244 × 244 mm6809PC-6U, the printed circuit board in 3D

    6809PC-6U

    danwerner21/6809PC

    6809 PC

    167 parts2
  • 4 layers304.5 × 217.2 mmLatest Full Backplane, the printed circuit board in 3D

    Latest Full Backplane

    Trilobyte-CPU/8-bit-computer

    A DIY 8-bit computer built mostly with discrete logic chips

    478 parts2
  • 2 layers300 × 300 mmSAP Extended, the printed circuit board in 3D

    SAP Extended

    cyrillvalentini/SAP-Extended

    Extended Simple-As-Possible Computer based on Ben Eaters video series

    440 parts1
  • 2 layers486 × 306.3 mmMonacoGP, the printed circuit board in 3D

    MonacoGP

    stonedDiscord/MonacoGP

    Sega MonacoGP TTL Boards

    257 parts1

Questions

How big is the Alu PCB?

It measures 237.5 × 102.9 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Alu use?

91 parts, built around the 74LS86, 74LS377PC, 74LS157PC and 74LS32SC. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Alu KiCad files?

From the jes/scamp-cpu repository on GitHub, at the commit this page was made from: the board is kicad/alu/alu.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Alu design in my own project?

Its repository publishes it under the Unlicense licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).