Electricity/Diodes/A ROM made of diodes

A ROM made of diodes

A diode cannot amplify anything, but it can decide. With nothing but diodes and resistors you can build an OR gate, an AND gate, and a read-only memory whose contents are literally which crossings someone soldered a part into.

Everything so far has treated a diode as a part that protects something. It is also the cheapest decision-making element in electronics, and the two circuits on this page are worth building once because they make "stored data" and "logic" into things you can see with the lights on.

A gate made of three diodes and a resistor

Logic with no transistor: OR
out = 0.00 V
Inputs0 0 0
Output
0.00 V
Reads as
0
Into the LED
nothing
Every input low, every diode blocked. Nothing pushes the node up, the 330 Ω holds it at ground, and the LED is dark. That is an OR gate, in three parts and no silicon that can amplify anything.

Switch between the two tabs and the only thing that changes is which way the diodes point.

  • OR. Anodes at the inputs, cathodes tied together. Take any input high and its diode conducts and pulls the shared node up with it. All inputs low, all diodes blocked, and the resistor holds the output at ground.
  • AND. The diodes point the other way, and the output is pulled up to the rail by a resistor. Any input that is low gives its diode somewhere to conduct, and the node is dragged down to a diode drop above ground. Only when every input is high is there nowhere for that current to go, and the output floats up.

Both are real gates, and neither is how anything is actually built. Two reasons, and the figure shows both of them.

Every gate costs 0.7 V and gives back no drive. An OR output is one diode drop below its input, so feeding it into another gate hands the next stage 3.6 V instead of 5, and the stage after that 2.9 V. There is no gain anywhere in the circuit to restore what was lost — and an AND gate holding its output high through 10 kΩ can source a fraction of a milliamp.

A transistor fixes exactly that: a small current in controls a big one out, so every stage starts again from a full rail. That is the next chapter, and it is why diode logic is something you meet in a book rather than in a chip.

Diode gates are still fitted in real circuits, just not in rows. Two diodes OR-ing two supplies into one rail is the same AND-OR idea doing a job no logic chip is needed for.

A memory with nothing in it but wiring

Here is the circuit that makes the point. Four columns, each pulled up to 6 V through 1 kΩ and each ending in an LED. Ten rows, each with a key that connects it to ground. At every crossing there is either a diode or nothing at all.

Hold a key.

Ten numbers, stored as 25 diodes
reads 1111 · 15
Hold a keynone
The lamps read
1 1 1 1
Which is
nothing valid
Diodes conducting
0
No key held, so nothing is diverting anything, and all four lamps light. 1111 is not a stored number — it is the display's idle state. Every column is sitting at 2.0 V through its 1 kΩ, drawing about 4.0 mA.

Press 6 and the two diodes on row 6 pull their columns down to about 0.7 V. That is well below the 2 V an LED needs before it conducts, so those two lamps go dark and the other two stay lit: 0110. Press 9 and you get 1001.

The number came out of the wiring. Nothing in this circuit stores anything — there is no charge held anywhere, no state, nothing that changes when the power goes off and comes back. A diode fitted at a crossing is a 0 and an empty crossing is a 1, and the pattern of twenty-five diodes across forty crossings is the data.

The two things it does that nobody designed

Press nothing and every lamp lights. 1111 is not one of the ten numbers stored here; it is what the display does when no row is grounded and nothing is diverting any current. Real memory has a select line for the same reason your keyboard has a scan: something must say "this row, now".

Press two keys at once and you get the bitwise AND. A lamp goes out if any diode on any held row pulls its column down, so a bit survives only where every held row has a 1. Hold 5 and 6 — 0101 and 0110 — and the display reads 0100. Hold 3 and 5 and you get 0001. Try it in the figure above.

That is not a feature and it is not a bug. It is the direct consequence of wiring several sources onto one node through diodes, and it is the same behaviour that lets two supplies share a rail without feeding each other.

What it costs

Each lit lamp draws (6 − 2) ÷ 1000 ≈ 4 mA. Each conducting diode carries (6 − 0.7) ÷ 1000 ≈ 5.3 mA to ground instead, through the key, for as long as you hold it. Nothing here is fast, either: a diode that has been conducting takes a moment to stop, which is the reverse-recovery time on its datasheet, and it is the reason the book this circuit comes from warns you not to use power rectifiers for switching.

It is a lovely thing to build on a breadboard, and it will teach a programmer more about what "read-only memory" means than any amount of reading.

Edit this page — content/fundamentals/electricity/a-rom-made-of-diodes.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Fundamentals on the forum