Breadboarding With Diode Logic

A circuit with diode logic

I was thinking recently about OR gates. We normally do these with TTL logic chips but I wondered whether it would be possible to do the same thing with diodes. A quick Google showed that this was not merely a workable idea but something which has a name – ‘diode logic‘ – and which has been used in commercial products. And it can also be used to create AND gates.

So, why would I want to build logic circuits with diodes instead of ‘proper’ logic ICs? My answer to that is simply one of space. Building processors and computers on breadboards requires a lot of gates which means a lot of chips. And using a lot of chips takes up a lot of space. Sometimes I need just a single gate but when doing this with chips I have to add a whole chip. Sometimes adding an extra chip would mean a module expanding onto an extra breadboard.

And, I’m not going to lie, doing something in a different and unusual way is always fun.

Diode OR Gates

Let’s take a look at how diode logic works starting with the easiest to understand – a diode OR gate.

A TTL OR gate
Figure 1: A TTL OR gate

Consider how we use a standard OR gate. A and B are outputs from some arbitrary TTL ICs. Z is an input to an arbitrary TTL IC. If A or B (or both) is high then the output at Z will be high.

Figure 2

We might naively assume that the OR gate itself is unnecessary. If A is high then surely Z will be high? Except, of course, that if B is low then the current from A will ‘sink’ into B as our logic chip dies in a puff of smoke.

Figure 3

But what if there a way to stop the current flowing back into B? We can easily do that with a diode. Now when A is high the only place it can flow to is into Z.

Figure 4

And to fix the identical issue with current from B flowing back into A we’ll also add a diode to A’s output. So now, when A is high current flows into Z. When B is high current flows into Z. When they’e both high current flows into Z.

But what happens when neither is high? We might innocently assume that when both A and B are low (i.e. at zero volts) then Z will also be at zero volts. In reality Z is actually floating and, as with any floating input, we can’t determine what the input value is.

Why is this? Well, we tend to think of TTL outputs as being … outputs. In reality when they are high they output, but when they are low they’re actually inputs connected to ground. Any stray voltages ‘hanging around’ their outputs will, like a black hole, get sucked in resulting in the zero volt ‘low’ output.

But the diodes here prevent any current flowing into the outputs and Z floats.

In the 74LS logic that I’m usually using for breadboarding inputs normally float high. Although that’s not guaranteed and we’d be foolish to depend on it.

Diode logic OR gate
Figure 5: Diode logic OR gate

What we need to do here is use a resistor to tie the output low. Now when A or B is high current flows though one or other diode and Z becomes high. When both A and B are low the resistor pulls Z low.

And we have our final working circuit. The only question left is what value of resistor to use. And at this point I have to admit that I’m not an electrical engineer and Google is not helping me to find a formula.

But since 10k is a good general purpose value for a a tie up/tie down resistor for 5V TTL then that’s where I’ve started and in most cases it works fine. This value didn’t work reliably for my 8-input OR gate in the ALU of my Bentium Pro computer and I dropped down to a 3.3k instead. So, for a hobbyist use, I’d say start at 10k and tweak if it doesn’t work reliably.

8 input diode logic OR gate
Figure 6: 8 input diode logic OR gate

And, since I mentioned an 8-input OR gate here’s a circuit diagram for one. You can extend to as many inputs as you want by extending the circuit.

Diode AND Gates

Talking about pull up/pull down resistors gives us a good starting point to talk about diode AND gates.

Figure 7

This circuit shows a circuit using a pull-up resistor. The resistor ensures that the circuit ‘defaults’ to 5V if the output from A is floating. Of course it never will be and it’s utterly pointless in this circuit…

Figure 8

…but when we add a diode it almost starts to find a purpose. Now when A is high current can’t flow through the diode. Input Z would be floating, except that the resistor keeps it high. When A is low the current from Z flows through the diode and Z goes low.

Diode AND gate
Figure 9: Diode AND gate

And with a second output we can turn this into an actual, useful circuit. If A is high current can’t flow through it’s diode to Z. If B is high current can’t flow through it’s diode to Z. In both cases Z floats and is pulled high by the resistor.

But if A is low then current can sink from Z through it’s diode and Z get’s pulled low. If B is low then current can sink through it’s diode and Z gets pulled low. In other words, if either A or B (or both) is low then Z is low. The only time when Z is high is when both A and B are high. Drawing that up as a truth table gives us:

A    B    Z    Comments
low  high low  Current flows into A and pulls Z low.
high low  low  Current flows into B and pulls Z low.
low  low  low  Current flows into both A and B and pulls Z low.
high high high Current can't flow from either A or B to Z.
               Z is pulled high by the resistor.

The rest of this article has probably given away what was going to happen, but look carefully and you’ll see this is the truth table for an AND gate!

Diode AND gate
Figure 9 again: Diode AND gate

Our diode AND gate is again taking advantage of the fact that a logic low is an input sucking in current. Look at Figure 9 again. Z ‘defaults’ to 5V because of the pull-up resistor but if A goes low it ‘sucks’ current through the diode to take Z low. Similarly with B going low. If both A and B are high then the diodes mean current can’t flow out of them to Z and Z stays pulled up.

8 input diode logic AND gate
Figure 10: 8 input diode logic AND gate

As with the OR gate we can extend this to any number of outputs. This may actually help you to understand things. If ALL the outputs are high, then nothing flows through the diodes (in either direction) and Z is pulled high by the resistor. If ANY of the outputs goes low then current flows through the corresponding diode and Z goes low. I.e. Z will only be high when A and B and C and D and E and F and G and H are high.

Combining Diode Logic Gates

Diode logic A and (B or C)
Figure 11: Diode logic A and (B or C)

As with TTL logic you can combine diode logic into more advanced circuits. This gives us Z = A and (B or C).

Diode logic (A and B) or C or D
Figure 12: Diode logic (A and B) or C or D

And here we have Z = (A and B) or C or D.

I’ll leave you to examine how these work in detail!

The limit to how far you can take such combinations is the voltage drop over the diodes which, over a few gates, will cause the voltages to fall outside the levels needed to accurately trigger the TTL inputs. There’s probably also a limit to how much you can actually understand such circuits.

For me, when breadboarding computers, I’ll probably stick to single gates largely due to the voltage drops that happen on breadboards already and which could affect the reliability of any circuits.

Limitations of Diode Logic

While all this is fun there is a major limitation to diode logic: you can’t use it to invert signals. And without inverters you can’t create NAND, NOR or exclusive OR gates which depend on them.

The flags circuitry of the Bentium Pro
The circuitry to evaluate the flags on my Bentium Pro computer. Much of this is hard to see under the wiring but above the leftmost IC are the diodes for an OR gate testing for non-zero. The diodes around the next chip to the right are a four input AND gate selecting a carry output value.

If you want to see some diode logic in action then the ALU of my Bentium Pro breadboard computer makes a fair bit of use of them for evaluating the flags.