Archive: Apr 2017

Bringing it all together

Before building the control logic, we want to connect all of the modules to a shared bus and test things out. The modularity of the design makes it easier to test each module by itself so we won’t ever get to a point where we put it all together and nothing works.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
810kΩ resistor
8470Ω resistor
8Red LED

Output register

The output register is similar to any other register (like the A and B registers) except rather than displaying its contents in binary on 8 LEDs, it displays its contents in decimal on a 7-segment display. Doing that requires some complex logic; luckily there’s an easier way:

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
2Breadboard
11kΩ resistor
1100kΩ resistor
20.01µF capacitor
1555 timer IC
174LS08 (Quad AND gate)
174LS76 (Dual JK flip-flop)
174LS139 (Dual 2-line to 4-line decoder)
174LS273 (Octal D flip-flop)
128C16 EEPROM
4Common cathode 7-segment display

Additionally, I used an Arduino Nano, two 74HC595 shift registers, and one more breadboard to build a simple EEPROM programmer to program the 28C16 EEPROMs.

Program counter

The program counter (PC) counts in binary to keep track of which instruction the computer is currently executing. Most of the videos below explain how counting in binary works.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
1Breadboard
174LS161 (4-bit synchronous binary counter)
174LS245 (Octal bus transceiver)
4Green LED

Random access memory (RAM) module

The random access memory (RAM) stores the program the computer is executing as well as any data the program needs. Our breadboard computer uses 4-bit addresses which means it will only have 16 bytes of RAM, limiting the size and complexity of programs it can run. This is by far its biggest limitation.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
3Breadboard
31kΩ resistor
10.01µF capacitor
174LS00 (Quad NAND gate)
274LS04 (Hex inverter)
474LS157 (Quad 2-to-1 line data selector)
174LS173 (4-bit D-type register)
274LS189 (64-bit random access memory)
174LS245 (Octal bus transceiver)
1Double-throw toggle switch
1Momentary 6mm tact switch
18-position DIP switch
14-position DIP switch
9Red LED
4Yellow LED
1Green LED

Arithmetic logic unit (ALU)

The arithmetic logic unit (ALU) part of a CPU is usually capable of performing various arithmetic, bitwise, and comparison operations on binary numbers. In our simple breadboard CPU, the ALU is just able to add and subtract. It’s connected to the A and B registers and outputs either the sum of A+B or the difference of A-B.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
1Breadboard
274LS86 (Quad XOR gate)
174LS245 (Octal bus transceiver)
274LS283 (4-bit binary full adder)
8Red LED

Registers

Most CPUs have a number of registers which store small amounts of data that the CPU is processing. In our simple breadboard CPU, we’ll build three 8-bit registers: A, B, and IR. The A and B registers are general-purpose registers. IR (the instruction register) works similarly, but we’ll only use it for storing the current instruction that’s being executed.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
3Breadboard
674LS173 (4-bit D-type register)
374LS245 (Octal bus transceiver)
16Red LED
4Yellow LED
4Blue LED

Clock module

The computer’s clock is used to synchronize all operations. The clock we’re building is based on the popular 555 timer IC. The videos go into some detail on the operation of the 555 and use it in three different ways.

Our clock is adjustable-speed (from less than 1Hz to a few hundred Hz). The clock can also be put into a manual mode where you push a button to advance each clock cycle. This will be a really useful feature for debugging the computer later on.

Videos

Schematic

(coming soon!)

Parts list

QuantityDescription
1Breadboard
51kΩ resistor
1100kΩ resistor
11MΩ resistor
11MΩ potentiometer
30.01µF capacitor
20.1µF capacitor
11µF capacitor
3555 timer IC
174LS04 (Hex inverter)
174LS08 (Quad AND gate)
174LS32 (Quad OR gate)
2Double-throw toggle switch
2Momentary 6mm tact switch
1Blue LED

Build an 8-bit computer from scratch

I built a programmable 8-bit computer from scratch on breadboards using only simple logic gates. I documented the whole project in a series of YouTube videos and on this web site. For an introduction:

Background

If you’re interested in seeing the computer in action to get a sense of what it can do, check out these videos:

If you want to dive into the details of how the computer works and understand it from first principles, but are a little unsure of how transistors and logic gates work (or just want a refresher), here’s a few videos to serve as an introduction:

Computer modules

The computer is composed of several modules, each of which performs just a few basic functions. Check out these posts for more detailed information on building each module:

Complete parts list

Here’s a complete parts list of everything I used to build the breadboard computer. The total cost works out to roughly $150-$200 USD depending on what breadboards you use and how much you end up paying for shipping.

There’s no right way to do this project. There are tons of substitutions and other approaches which will work just as well (or better), so if you want to build something similar and can’t find all the parts, try to figure out what the missing part does and find a different way of doing it. It might not work the first time, but you’ll learn a ton from trying to figure out why.

(If you click through any of the Amazon links, I get a tiny cut, though it won’t cost you any more. I’m a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.)

QuantityDescriptionApprox. cost eachApprox. total costSourcesModules
14Breadboard$3 - $8$36 - $96AmazonAll
122 AWG Solid Tinned-Copper Hook-Up Wire$18.00$18.00Amazon JamecoAll
91kΩ resistor$0.04$0.36Digikey AmazonCLK, RAM, OUT
810kΩ resistor$0.04$0.32Digikey AmazonBUS
2100kΩ resistor$0.04$0.08Digikey AmazonCLK, OUT
8470Ω resistor$0.04$0.32Digikey AmazonBUS
11MΩ resistor$0.04$0.04Digikey AmazonCLK
11MΩ potentiometer$2.50$2.50Digikey AmazonCLK
60.01µF capacitor$0.15$0.90Digikey AmazonCLK, RAM, OUT
20.1µF capacitor$0.18$0.36Digikey AmazonCLK
11µF capacitor$0.71$0.71Digikey AmazonCLK
4555 timer IC$0.41$1.64Digikey EbayCLK, OUT
174LS00 (Quad NAND gate)$0.50$0.50Digikey EbayRAM
574LS04 (Hex inverter)$0.50$2.50Digikey EbayCLK, RAM, CONT
274LS08 (Quad AND gate)$0.50$1.00Digikey EbayCLK, OUT
174LS32 (Quad OR gate)$0.50$0.50Digikey EbayCLK
174LS76 (Dual JK flip-flop)$2.00$2.00EbayOUT
274LS86 (Quad XOR gate)$0.50$1.00Digikey EbayALU
174LS138 (3-to-8 line decoder)$0.50$0.50EbayCONT
174LS139 (Dual 2-line to 4-line decoder)$0.50$0.50EbayOUT
474LS157 (Quad 2-to-1 line data selector)$0.50$2.00EbayRAM
474LS161 (4-bit synchronous binary counter)$0.50$2.00EbayPC, CONT
774LS173 (4-bit D-type register)$1.00$7.00EbayREG, RAM
274LS189 (64-bit random access memory)$1.50$3.00EbayRAM
674LS245 (Octal bus transceiver)$0.50$3.00EbayREG, ALU, RAM, PC
174LS273 (Octal D flip-flop)$0.50$0.50EbayOUT
274LS283 (4-bit binary full adder)$2.00$4.00EbayALU
428C16 EEPROM$6.00$24.00EbayOUT, CONT
2Double-throw toggle switch$3.80$7.60AmazonCLK, RAM
2Momentary 6mm tact switch$2.50$5.00AmazonCLK, RAM
18-position DIP switch$0.50$0.50Amazon EbayRAM
14-position DIP switch$0.50$0.50Amazon EbayRAM
41Red LED$0.05$2.05Amazon EbayBUS, REG, ALU, RAM
20Yellow LED$0.05$1.00Amazon EbayREG, RAM, CONT
11Green LED$0.05$0.55Amazon EbayRAM, PC, CONT
22Blue LED$0.05$1.10Amazon EbayCLK, REG, CONT
4Common cathode 7-segment display$0.75$3.00Amazon EbayOUT

Additionally, I used an Arduino Nano and two 74HC595 shift registers to build a simple EEPROM programmer to program the 28C16 EEPROMs used in the output module and control logic.

Breadboards

A note on breadboards: You can get them from lots of places for different prices. The best quality I’ve found is the BB830 by BusBoard Prototype Systems. I get them on Amazon, but they’re not cheap. (If you’re paying less than $7-8 USD each, you’re probably getting a fake.)

Lower quality, cheaper breadboards will probably work just fine (and save a bunch of money if you’re buying ~12 of them). The biggest differences include inadequate funneling on each hole, making it harder to properly insert components (this can vary a lot, from not a big deal to useless); inconsistent coloring (i.e., several breadboards, even ordered at the same time, are different shades of white); confusing labeling (e.g., numbers not lining up with holes); and warping (i.e., the breadboard doesn’t sit completely flat). Most of those aren’t deal-breakers, and if something doesn’t work right, look on the bright side: you get to troubleshoot it and learn more 🙂

Discuss this on Hacker News: https://news.ycombinator.com/item?id=14883776