# memory for the simplest possible computer (Pi0K)

I'd like to build the simplest possible computer. I don't care about speed or storage, indeed having slow speed and low storage is a huge advantage as I want to build it out of transistors (ideally relays!) and I want an LED for each state. It'll be programmed via a Raspberry Pi which will host a camera so that you can see each clock cycle executing (yes, it's going to run at Hz not GHz). It'll be an open design with the intention that schools can buy the parts, understand and improve on the design. So the total budget must be well under £400, preferably about £100.

I have researched this over many years and have good ideas for the CPU (minimal registers, microcode in DIP switches and bit serial logic/arithmetic operations to reduce the transistor count). What I can't figure out is how to get the memory, I'd like 1024 to 8096 bits.

The best I can come up with is two 6 bit one-of-n decoders giving access to 64 x 64 grid of capacitors. Either they have a charge in them or they don't, and reading would reinforce that state. There would be no LEDs on the capacitors as the refresh of this 'DRAM' would be in the order or minutes (which is a shame as this would be the only part not to show state).

Other ideas include some form of tape drive (compact cassette mechanism: great storage, too complex, no seek), drum memory (tape around a bean can: too hard to get the mechanics working), mechanical memory (bike wheel and ball bearings: too many bit errors), core memory (large hard ferrite cores: still very tricky to get right at the scale required), tape/card (can we still buy the tape readers), rotating disk with punched holes in binary order and some magnetic memory for storage (too complex to build).

Ultimately the aim is to publish a design that can be build in a school year where all parts of a CPU and memory are 'visible' and so you can see the instruction fetch, decode to microcode, and address decoding/register access/logic all happening over the course of minutes.

If anyone has ideas for really cheap memory (<<£100) where it's clear exactly how it works then please do let me know.

Tony

P.S. current state of play is at http://www.blinkingcomputer.org/

• Just google around for people who already did this and similar things, the designs are there, you can make a BOM and find that you likely need a bit more money and time. – PlasmaHH Jan 7 '16 at 20:14
• I would suggest that going to the transistor level might be a bit much for a school project. I would think CMOS small and medium-scale integration would be much more do-able and probably more understandable (gates, registers, buffers, decoders, etc.). You could include something that demonstrates how gates are made from transistors, flip-flops are made from gates, etc.). – Tut Jan 7 '16 at 20:36
• Just an idea: You should make the (program) memory easily modifiable by hand, so people can "program" manually with their hands :-). – oyvind Jan 7 '16 at 21:12
• First decide what you want the computer to be able to do. That will determine how much memory you need and what the instruction set should be. – Tony Ennis Jan 7 '16 at 23:46
• Thanks all. PlasmaHH: Yes, it's a huge challenge to do this in money and time constraints, that's why nobody else has done it yet. Tut: I really want to be able to see each signal. People will then see how logic gates are built from transistors. oywind: Yes, it'll be programmable via a Raspberry Pi with a web interface that you can write your own code and see it running with a web cam. Tony Ennis: I want to build the simplest computer that shows every signal - this will demonstrate all aspects and necessitate non-standard architectures, such a bit-serial ALU. – Tony Robinson Jan 8 '16 at 4:50

There are many people who have built computers out of discrete transistors, ICs, relays, and even vacuum tubes. They range from 4-bit machines all the way up to 32-bit. The 4-bitters of course will be the simplest you can build and do anything. The very first microprocessor was Intel's 4-bit 4004.

I would start by searching Google for "home-brew 4-bit computers" (without the quotes).

Here's a board from a transistorized 4-bit computer:

As far as memory goes, some of these projects which otherwise are using discrete transistors "cheat" and use SRAM chips. They are incredibly cheap for moderate amounts of memory, 32KB is $3.28 and requires no clocks and no refresh. Even if the rest of your computer uses relays, using them for memory will be prohibitively expensive. If you can get by with 1K bits, you could build one with transistorized flip-flops; 2048 2N3904's will cost 3¢ apiece ($60 altogether, plus the other components which will be even cheaper -- resisters for 1/2 a cent etc). You can get PCB's made for $10 apiece, then hire a kid to stuff them. Relay computers date all the way back to the late 1930's, and one of the first was the Harvard Mark I. It's where the name Harvard architecture comes from (separate program space and data, compared to von Neumann architecture that combines the two). The most famous home-brew relay computer is one built by Harry Porter. Check out the videos of the computer running. Reminds me of an old electromechanical telephone exchange. Here's a portion of another home-brew relay computer called Zusie: Lots of blinking lights. And finally, here's a link to a video of a 4-bit adder, made up of 24 relays. Adders like this are the heart of the ALU (arithmetic logic unit) in a computer. • Sorry, the "I have researched this over many years" was buried in the second paragraph. I've edited the title of the post to clearly state it's the memory I care about.If you can get by with 1K bits, you could build one with transistorized flip-flops; 2048 2N3904's will cost 3¢ apiece ($60 altogether, plus the other components which will be even cheaper -- resisters for 1/2 a cent etc). You can get PCB's made for $10 apiece, then hire a kid to stuff them. – Tony Robinson Jan 8 '16 at 4:07 • ctd... this is closer than I'd guestimated, but you do need the address decoding and I'd put in more transistors per memory cell. Maybe a one transistor one capacitor 'DRAM' memory cell is also possible within budget. – Tony Robinson Jan 8 '16 at 4:17 • @TonyRobinson I did try to address the memory isuse (as you acknowledged) but I was also trying to provide information re your desire to make a computer out of discrete transistors and/or relays, and to illustrate that several have been successful at this. Good luck in your endeavors. – tcrosley Jan 8 '16 at 6:13 If you want simple memory, then look no farther than a flip-flop. With two transistors and four resistors, you can have a whole bit of memory. You can also make a flip-flop with two cross-coupled NOR gates, or just buy an IC with a bunch of flip-flops in it already. In fact, the very fast CPU cache is basically a bunch of flip-flops, integrated into the CPU. • DRAM is more power consuming as it needs to be constantly refreshed whereas SRAM uses only a small quiescent current when idle. The reason for using capacitors is because it only requires one transistor per bit, so allows much higher memory densities. – Tom Carpenter Jan 7 '16 at 22:16 • You're right -- I had in mind simple RTL flip-flops. I'll edit to clarify. – Phil Frost Jan 8 '16 at 3:05 • ICs are out - they hide what's really happening. I want every signal to be exposed as far as possible. I really don't care about power - I can't see power being a problem, it'll be wired to a Raspberry Pi so power is available. One transistor DRAM may be a much better way to go than my array of capacitors ideas as the earlier post suggested - I'll have to work out what transistors are needed for that to keep the charge leakage low enough (I need refresh times in the order of minutes). Else, yes, flip flops look like the next best idea. – Tony Robinson Jan 8 '16 at 4:22 • @TonyRobinson "It'll be wired to a Raspberry Pi so power is available." - ...maybe. Depends on the maximum power available through a Raspberry Pi, and which logic family you plan to use. (I'd expect that an average bench PSU would be able to supply quite a bit more power, though) – user253751 Jan 8 '16 at 8:44 I agree that it would be pretty cool to have a complete computer system with an LED for every bit of state, visible to the human eye. The TIM 8 relay computer uses 8 capacitors, 2 diodes, and one SPDT relay per byte in its 12 bytes of RAM main memory (data memory). (The TIM 8 has 16 bytes of variable memory if you include registers). The TIM 8 relay computer uses punch tape for its program memory. Is it possible to replace those diodes with LEDs, so there's a brief pulse showing the data going in or out of a byte of RAM? Perhaps if the system does DRAM refresh rapidly enough, scanning though every byte of RAM, then every bit of state would appear to be visible at those LEDs (although technically only one byte of LEDs would be activated at any one instant). (Those would have to be pretty high-current LEDs if we want to LOAD and STORE data from those capacitors to relay-based registers). Is it possible to put a resistor and a LED across each bit-storage capacitor, truly simultaneously showing every bit of state? (Those would have to be pretty low-current LEDs and physically large capacitors if we want the capacitor to hold the data long enough for a reasonable refresh rate. Some LEDs can be easily seen with only 1 mA of current. With a 1 second refresh cycle and (guesstimating) capacitors initially charged to 12 V even though (guesstimating) a charge of 7 V on the capacitor is enough to charge the downstream hardware, then the capacitor needs a rating of C ~= i*t/V = 1 mA * 1 s / (12 V - 7 V) = 200 uF. ). This will, of course, be vastly larger and take more human labor to assemble than pretty much any integrated-circuit-based main memory. Why don't you just use a simple 8 bit CPU (e.g. 6502) & a very small amount of memory (CPU registers, IC RAM, & a very small amount of external storage (e.g.: FD, HD, or flash disk, etc.) & then just explain with slides the following: 1. The hardware components, sub-components, & their functions 2. The operating system, system programs, & user programs 3. Load & execution of a simple program to add 2 numbers together, store the result in each type of memory & display it on a video display. If you want to keep the device as simple & inexpensive as possible, use a micro controller development system as your base system or even an Arduino is simple & inexpensive enough. None of the students are going to build a simple relay or vacuum-tube computer--nor should anyone really want them to do so. They should start out with a good book & an Arduino for basic understanding of programming. Then later, if they want to get into reading/controlling external devices, they can delve into specific programming or into engineering. Here's a good project for you to consider for ideas: http://www.instructables.com/id/How-to-Build-an-8-Bit-Computer/?ALLSTEPS • Although nowadays we call it the "W65C02S" – Ignacio Vazquez-Abrams Jan 7 '16 at 20:56 • Thanks, I come from 6502 days (BBC micro but also I worked on the ZX80). I agree that there's a lot to learn at that level, indeed I was just rereading the BBC Microcomputer Advanced User Guide. I really want to be a level below that, you see a 5-bit instruction come in, it jumps through a small set of microcode that set a few bit registers and bus lines and calls a bit serial ALU so that you can see all logic happening bit by bit. That's why it'll be the slowest ever. – Tony Robinson Jan 8 '16 at 4:36 • Yeah--that will be slower. Did you look through the detail at this url: instructables.com/id/How-to-Build-an-8-Bit-Computer/?ALLSTEPS It's actually quite good & allows for some unique customization for your system. – DIYser Jan 8 '16 at 9:06 I agree that it would be pretty cool to have a complete computer system with an LED for every bit of state, visible to the human eye, rather than hidden inside a mysterious black box. You might consider using a more-or-less standard bit-parallel memory bus -- perhaps something like the STEbus (IEEE-1000 bus). You might consider using a bunch of ICs like 74HC273 or 74LS373 or 74HC564 to store the data so the current state of the data inside the chip is always visible on LEDs connected to the parallel-output pins. Then use octal 3-state buffers (such as the 74HC241 or 74LS245) or muxes, also connected to those parallel output pins, to funnel the data into the bus. You end up with a few one-of-N decoder chips and 2 chips per 8 bits of storage. "This allows you... to view what data is actually stored in each byte of RAM." -- Pong Guy's SAP-1 Simple as Possible Computer with Discrete Component RAM. The same arrangement is used for the registers in Jaromir's Fourbit CPU or the registers in Kyle's 8 bit spaghetti CPU. Current (2016) prices from Mouser.com are about$0.11/bit in qty 10 for such an arrangement (one octal storage latch plus one octal 3-state buffer per 8 bits), and $0.05/bit for new LEDs in qty 500. For 2^9 bytes = 512 bytes = 2^12 bits = 4096 bits, that's (very roughly) •$205 in LEDs
• $450 in storage and buffer chips •$??? the 1-of-N decoder chips to select the appropriate storage or buffer chip; the cost of boards, wire, labor, and etc.

Perhaps you could build (very roughly) 64 bytes of data memory (the same amount of data memory as an Atmel ATTINY13 or a Microchip PIC16F570) for roughly $90 ( which may fit within your$150 ~= £100 budget).

You can see why it's tempting to replace all those storage and buffer chips and most of the decoder chips with an off-the-shelf 32Kx8 parallel SRAM chip giving you far more storage for less than \$10. (Alliance AS6C1008-55PCN, Cypress CY7C199CN-15PXC, etc.)

This may be why most home-brew CPUs, from the tiny Nibbler 4 Bit CPU to the impressive RC-3 Relay Computer http://www.computerculture.org/2012/09/rc-3-relay-computer/ http://www.computerculture.org/projects/rc3/ , are hooked up to a black-box SRAM chip for main memory.

With something like a standard memory bus, perhaps you could have several different memory boards connected to the CPU at the same time:

• A few bytes of completely visible variable storage, and a few bytes of completely visible hard-wired program ROM, which should be enough for some interesting demo programs.
• A SRAM chip that can be occasionally plugged in for holding programs or data or both when you haven't yet built enough completely visible memory to store them.

Here's another suggestion for a similar project that might be worthwhile - build a Turing Machine.It's about the simplest computing machine possible