The SAM-80 Homegrown Computer

Reinventing the Wheel

What is the most simple computer? The idea was to learn electronic circuit design by building a minimalist computer using a classic 8-bit microprocessor. For those of us who started computing with the Sinclair ZX Spectrum 48k and its hundreds of clones, what processor could be more suitable for this task than the legendary Zilog Z80? This design is inspired by Steve Rayner’s Z80 build, Ben Eater’s 6502 computer, the original ZX schematics, and a box of components I have got on Amazon.

SAM stands for the Slowest Assembly Machine or a Simple Assembly Machine (or maybe Smooth As Molasses.) The Z80A CPU clock is provided by the 74HC214 Schmitt Trigger with an RC circuit, which is a simple oscillator. Its frequency is given by f = 0.8/RC, so the computer runs at 0.8 Hz and can turbo to a whopping 80 kHz and beyond if you change capacitors. The clock can be stopped with a switch, giving the ability to pause execution, which is handy for debugging purposes.

An array of eight DIP switches is used as the input directly into the data bus of the processor, and LEDs as the output. The first test implementation had no RAM, so simply locking the input to, say, all zeroes, executes a series of assembly “no operation” instructions (NOPs), or 11000011 (equals to C3h) for a series of unconditional jumps (JP) to the same address, because the opcode for the JP instruction is C3h. This was the first 3-byte “program” I’ve got running on SAM-0 with zero memory:

JP C3C3h

The reset circuit has a time delay implemented via 100 µF capacitor and 100 kΩ resistor, suspending the CPU in reset state for a brief moment of time after the power-on and when the Reset switch is pressed.

Adding Memory

Where does an abacus end and computer begins? Anything programmable I would consider a computer, so it really needs memory. The SAM-80 design features two 4-bit 5114 Static RAM chips that do not require clock input or refreshing like DRAM chips, keeping things simple. Because of the 8-bit address bus, only 256 bytes are addressable, but this can be expanded.

The 74LS245 chip serves as a bus transceiver when CPU needs to address the RAM. It is enabled by the Memory Request signal of the CPU. When enabled, the CPU can transmit the requested memory address via the address bus to memory chips to read or write stuff. By default the 74HC14 inverting trigger generates a clean “read” signal to the RAM at all times, unless CPU intends to write to RAM or an operator pushes the Memory Commit button to write to memory manually. The RAM chips are always powered on and selected, so even if the Reset button is pressed, memory contents remain intact and the processor begins execution from address 0.

That’s about it – a simple programmable machine, fully capable of executing Z80 Assembler, perhaps very similar to a Kenbak-1. The SAM-1 name was taken by some Norwegian Defence Research Establishment in the 60s, so this one proudly displays the number 80.

The First Program

The very first program executed from memory was the read-write test:

LD A, 111110b
LD (111110b), A
HALT

This program occupies 6 bytes of memory. It loads the number 111110b (binary) into CPU register A and then loads the content of register A to the memory address indexed by the same binary number, and then halts execution.

This video shows SAM-80 with this program punched in memory executing it:

So, what happens here?

  • The initial state is just a series of NOPs cycling.
  • I reset the RAM contents at cell 111110b to zeroes with the big red Commit button.
  • I push Reset, so execution will start from memory cell 0.
  • The program runs, writes A to RAM (red LED cycle).
  • The processor is halted – it continues to loop through NOPs.
  • The output is the contents of memory at cell 111110b – as expected.

To convert Assembler to the machine code I use the ASM80 Online Assembler by Martin Malý, but the original Zilog Z80 Manual also conveniently provides opcodes and description in binary format.

Technical Specifications

Diseño: Zilog Z80 inside – MSXBlog
  • Zilog Z80A 8-bit CPU
  • Running at 0.8 Hz with 80 kHz turbo mode
  • 256 bytes of addressable SRAM
  • Pause Execution switch
  • 8-bit memory address and data bus I/O LED indicators
  • CPU M1 Cycle, Read, Write and Memory Request LED indicators.
  • 2x DIP switches for memory addressing and programming
  • Big red Memory Commit button.

The circuit is powered from a +5 V DC source.

Circuit Diagram

The computer is very simple to build. With just two breadboards things get a little crowded. The turbo button can be implemented by replacing the original C1 capacitor with a smaller one (100 pF for 80 kHz), and adding the original 10 µF back with a switch. By default all resistors are 1 kΩ unless specified otherwise. I use bussed SIP-9 A102J resistor arrays to hook up LEDs and DIP switches – it looks much cleaner on the board.

Components

  • 2-3x breadboards
  • Z80-family CPU (I have Goldstar Z8400A PS, but any other will do the job)
  • 2x 2114, 5114 or similar 5 V 4-bit SRAM chips (e.g. Philips PCD5114)
  • 74HC14 Hex Schmitt-Trigger Inverter
  • 74LS245 Bus Transceiver
  • 2x 8-position DIP switches
  • 20x LEDs
  • Resistors: 1 kΩ, 100 kΩ (or A102J resistor arrays)
  • Capacitors: 100 pF for turbo mode, 10 µF for normal operation, 100 µF for reset circuit
  • 3x button switches
  • 5 V DC power supply

I would strongly encourage to follow other’s advice and invest into quality breadboards, e.g. BusBoard Prototype Systems BB830T to avoid connectivity problems common with generic Chinese breadboards, like the ones I have for the RAM and the I/O. This will preserve your time and nerves. I have also got used 5114 chips off the eBay with corroded pins – took some cleaning effort to get proper signals out of them.

Further Thoughts

SAM-80 may not be the simplest of all computers, but it is definitely one of the most simple. It is basically a CPU with a little bit of memory and direct data bus I/O. It is a fun exercise in attempting to understand how computers work.

Some ideas for the next project (SAM-800):

  • Display with characters (and maybe even graphics)
  • 4 MHz crystal clock
  • 16-bit memory bus with 64 KB RAM (with maybe some address space gone to ROM)
  • More convenient method of input

If anyone finds this useful or will decide to build something similar, I would really love to hear your feedback.