Last year I built Ben Eater’s 8-bit breadboard computer, which taught me a lot about how processors work. But with only 16 bytes of memory it’s not really usable for any kind of real world tasks.
As soon as I’d finished it I knew I wanted to make some upgrades. And when I looked at what upgrades I wanted I realised that my next project would be pretty much a completely new build.
I find the phrase ‘Ben Eater’s 8-bit breadboard computer’ rather long-winded so I’ve taken to referring to his machine as the ‘Bentium’. (Ben-tium/Pentium? Get it?) and I’m calling my upgraded version the ‘Bentium Pro’.
I have so far built the program counter, memory, registers, ALU and control logic, and I’m using Ben’s original clock module as is.
What Can It Do?
This is my first post about the project and I’m going to start off by giving an overview of the ALU. I may have got a little bit carried away with features as this little box of tricks can now perform twenty different operations…
- Add with carry
- Subtract with carry
- Increment (add 1)
- Decrement (subtract 1)
- Exclusive or
- Rotate left
- Rotate left through carry
- Shift left
- Shift left with 1 input (to bit 0)
- Rotate right
- Rotate right through carry
- Shift right
- Shift right logical (preserve sign bit)
- Zero carry flag
- Set carry flag
- Complement carry flag
…not including the fact that it can act as a temporary register.
It also has a flags register containing four flags:
- Overflow (for twos complement arithmetic)
- Non-zero (I wanted a zero flag but didn’t have space to invert it!)
- Sign (again for twos complement arithmetic.
And in addition to all the TTL chippery involved I’ve been playing with diode logic which helps save some board space but, if I’m honest, it just gives me some cool new tricks to play with.
So, What Are All These Chips Doing?
Lets have a quick run through of what you’re seeing in the photos. I’ll run through from the top-most breadboard to the bottom-most looking at each chip from left to right.
But firstly it will be helpful to discuss the colour schemes for wires and LEDs. For the LEDs:
- Red = data.
- Yellow = outputting to the bus.
- Green = reading (usually from the bus) into (usually) a latch or register.
- Orange = other control signals and internal state.
And for the wires (for the module itself, the Arduino board uses a slightly different colour scheme! And the Dupont jumper wires are mostly there for the tester and using whatever I had that was long enough)
- Blue = data bus.
- Green = data internal to the module.
- Purple = control signal (positive logic), as opposed to…
- Pink = inverted logic control signal.
- Brown = other stuff internal to the module.
- Red & Black = if you need these explaining you clicked on the wrong thing but congratulations for making it this far.
- Rainbow ribbon cable = data bus.
Board 0: Arduino Tester
In case your getting worried, no, my ALU does not use an Arduino. This is just attached temporarily for testing. And, trust me, this thing takes a fair bit of testing. My current test quite runs through over 3,000 tests across all the different operations. And I don’t fancy doing that by moving Dupont wires around!
But, since you’re going to ask anyway, in addition to the Arduino Nano there’s a 74LS245 bus transceiver for writing to and reading from the bus and a pair of 74HC595 shift registers for sending input and control signals.
for sending input and control signals.
Pin A0 is used for sending the clock signal and pins A1 to A4 are used to read the flags register.
Board 1: Flags and Adder Pre-input
On the left we have a 74LS245 (I’m using 74LS logic throughout so I’ll shorten stuff from now on…) which is buffering the bus to a set of diodes which are calculating the non-zero flag.
Next is a ’32 OR gate which selects one of four sources to use to set the carry flag value. The possible sources are left shift/rotate, right shift/rotate, adder, and the carry input being sent to the adder (which allows it to do the zero/set/complement carry functions). An OR gate is used because the control signals are inverted (pink wires) meaning it is equivalent to an AND gate. This then uses a diode logic AND gate which is equivalent to a positive logic OR gate. Not complicated at all then!
Then we have the ‘173 flags register itself.
Beyond the indicator LED’s is a ’00 NAND gate which selects a carry signal to input to (mainly) the adder. The possible inputs here are: use the carry flag; input a zero; input a one. This (along with the subtract signal) is what makes all those different maths operations possible.
The final chip is a ’86 XOR gate. The top half is calculating the overflow flag (with the help of a diode AND gate using the resistor and a pair of diodes mostly hidden under wiring). The bottom half inverts the carry both into and out of the adders when we’re doing a subtract operation. The output of the input side also feeds back as a possible input to the carry flag for those zero/set/complement carry operations.
Board 2: The Adder
The LED on the far right displays the subtract control signal and the orange one to it’s left indicates the carry input to the adders.
Board 3: The Registers
I realise you’re probably getting bored by now so I’ll speed through this board. A pair of registers (called W and Z) equivalent to Ben’s A and B registers except that these are exclusively for use as inputs to the ALU. Each register using a pair of ‘173s.
Note that these are input only but the W register can also be used as a temporary register when needed by the control logic (it’s not available for direct use by the programmer). This will be needed by the CALL subroutine opcode. (Did I mention the Bentium Pro will have a stack and the ability to use subroutines?).
The Z register has it’s own clear signal (hence the orange LED). This is needed for the increment and decrement operations. These work by zeroing the Z register and manipulating the carry input to get the +1 or -1.
(I genuinely intended to speed though this but there was more to talk about than I realised. Sorry).
Board 4, 5 and 6 Left Hand Side: Logic
The three leftmost chips on each board are doing, from top to bottom, AND, OR and XOR operations. There’s a ‘245 transceiver for output and a pair of ’08, ’32 and ’86s for each of the operations.
Notice on the left of each board is another diode attached to the enable inputs of the ‘245 transceivers. This is yet more diode logic. Another AND gate (which is actually an inverted logic OR gate) to select a carry output.
This means each of these operations will clear the carry flag (with the correct carry and subtract input signals). I’ll also be using one of these operations to do the zero/set/complement carry opcodes which saves a control signal and saves me having to have a fifth selector for the carry flag output.
Board 4,5 and 6 Right Hand Side: Shift and Rotate
Boards 5 and 6 here are left and right shift/rotate respectively. This is very simple with the data wires being directly connected to a ‘245 transceiver but one pin to the left or right of where they began.
The spare pin at the end is fed in from board 4. The chip here is a ‘153 twin 4 to 1 multiplexer. This allows the ALU to select one of four possible inputs for each of those spare shift/rotate input pins.
The control signals for this, by the way, are shared with those for the carry selection inputs because my control logic is running very short of control lines!
Wow, You Made It To the End
If you made it through that lot I congratulate you. I’ve tried to keep this fairly shortish which means I’ve had to gloss over a fair bit of how everything works. I’m planning some follow-up posts with more detail but if there’s anything you’re especially interested in then I’d love to hear your feedback.
You can also comment if you’d rather I moved on to the rest of the computer design (so far), or if you want to see me plug the ALU into the control logic to see if it does, actually work.
Or, to be honest, since this blog is brand new, any kind of feedback to let me know this is of interest to anybody would be great. Until next time…