# How to build logic gates?

I'm thinking of ideas for a school project and one of the better ones was to build a calculator from scratch using only wire and basic electrical components. I've seen very many marble, Lego, domino, etc calculators that involve AND, OR, NOT, etc logic gates, but I wanted to make one purely electrically. I've seen some say that this is a very difficult project, but I have a couple months and I'm intermediately experienced in electrical engineering and have 6 or 7 EE projects under my belt. My problem is that I can't find diagrams anywhere for basic logic gates, only transistors, which feels like cheating. Any and all help is appreciated. Thank you!

• What do you mean by "diagrams for basic logic gates, only transistors"? Do you mean you can find schematic diagrams of logic gates using transistors, or that you're looking for such diagrams and not finding them? Certainly, building a calculator using gates built up from discrete transistor circuits will be a challenge and a half -- you'll end up with something big and clunky, but hopefully educational. Commented Dec 30, 2018 at 20:37
• There are a bunch of ways, from relays and switches through to diodes and transistors. A good text on logic design should cover this. Commented Dec 30, 2018 at 20:44
• What would you define as "basic electrical components"? Do transistors count? Relays? Basic logic ICs?
– user39382
Commented Dec 30, 2018 at 20:45
• You'll need to use the edit button to more clearly restate your goal or this is likely to fairly soon end up closed. Doing actual computation with hand built gates will be hard and is not something you should attempt without an understanding of clocked design, and a plan that you have validated by one means of simulation or another. Commented Dec 30, 2018 at 20:46
• As a rough estimate a 4-banger calculator might take 100 MSI chips (gates, latches and such like). It might take a few thousand transistors and diodes. Or one \$2 Arduino Nano clone. Commented Dec 30, 2018 at 20:52

Build a serial-adder. That can become a multiplier. Or a subtractor. Given a subtractor, you can build a divider.

Here is a discrete resistor-transistor logic NOR, such as used in the Lunar Lander Radar; that used ONLY this circuit, even for latches.

simulate this circuit – Schematic created using CircuitLab

Note this will be rather slow, about 5MHz clock rate, maybe. For each 1-bit serial-add. For 32-bit add, you need about 6 microSeconds (160,000 per second). For 32-bit multiply (that will produce 64-bit lossless result) you need 64 * 6 = over 3,000 microSeconds, or about 300 multiplies per second.

But who is in a hurry?

If you want to build this, at 3mA per logic NOR, assuming each latch is at least 4 NOR, and 500 bit storage, you need 4 * 500 = 2,000 NOR gates at 3mA each. Thus at least 6 amperes of 3.3 volt power. Just for the latches.

• Are you saying the Lunar Lander Radar is made entirely 3 input NOR gates, and that each one required a transistor and 4 resistors?
– K H
Commented Dec 30, 2018 at 22:51
• I'm not trying to be rude, just want to be clear because whooooa! Crazy little factoid!
– K H
Commented Dec 30, 2018 at 22:55
• Indeed. Twas the Fairchild uL 923 integrated circuit. These were some of the early Integrated Circuits (I've a couple, somewhere), with 6 or 8 gold plated leads that stick down from an epoxy package. Commented Dec 30, 2018 at 23:02
• Ah. OK. That would still really add up, but I saw the "2n3904" in your drawing and started thinking of big old FR boards with hundreds of resistors and 3904s on them =).
– K H
Commented Dec 30, 2018 at 23:10
• See here for a history of the lunar lander radar: hq.nasa.gov/alsj/ApolloLMRadarTND6849.pdf Commented Dec 30, 2018 at 23:11

Internally, logic gates are made of transistors, diodes, and resistors. This is true for all logic families, both bipolar and CMOS. Of course, the components vary among the families; that is why they have different operating characteristics. Most basic gate (AND, OR, etc.) datasheets have an internal schematic of one gate so you can see how it works. Growing gates from discrete components following these schematics isn't cheating; in some courses it is required lab work.

Be warned, it takes a LOT of gates to make a simple 4-function calculator, and that's just for the calculation part. Growing the display system from scratch is even more work.

• There are no diodes or resistors that are designed components in CMOS gates. There may be parasitic devices, but your statement is misleading. Furthermore, AND and OR are not the "basic gates" in CMOS...NAND and NOR are the simplest primitive gates. Commented Dec 30, 2018 at 21:40
• As I said, the components vary among the logic families. Spelling out which components are used in each of the dozen major logic families seemed like a waste of effort at this level of the discussion. For the same reason, I did not list all six of the basic gate types. Commented Dec 30, 2018 at 22:27
• Also, there are (non-parasitic) resistors and diodes in most CMOS logic families. Granted, these are for input protection rather than the logic function, but they are in there. Again, this is a level of detail that I thought would be more confusing than enlightening given the experience level of the OP. Commented Dec 30, 2018 at 22:30
• Having done lots of CMOS designs, I can state the DIODES and the Resistors are indeed "designed", even using special implants to improve the diodes (especially for ESD purposes) and allowing the resistors (the gate poly) to be placed atop thick oxide for minimal capacitance and thus best bandwidth and also minimal substrate-trash injection. Lots of subtle ADC errors go away, when using the right resistors. Commented Dec 30, 2018 at 23:11
• @analogsystemsrf Yes, resistors and diodes are designed as part of ESD protection and for analog circuits...but they are not designed components for CMOS gates and this question is about gates. Commented Dec 30, 2018 at 23:21

The idea of using a 3-input NOR gate as the basis for your logic is a good one. However, I personally have a nearly-full reel of NMOS transistors, so instead of using @analogsystemsrf's RTL gate, I would go with an NMOS gate:

simulate this circuit – Schematic created using CircuitLab

As far as physical construction goes, I've been toying with the idea of having a small PCB made that incorporates two such gates in a 10-pin SIP package. (See these UNI-SIP breadboards for an example of this.)

Note that it takes six 3-input gates to build a full master-slave D flip-flop, which would be three such modules.

These SIPs would plug into a wire-wrap breadboard, which would then hold the application-specific wiring. A large panel (of the type shown below) could hold a couple hundred such modules, which would be enough for a general-purpose CPU (e.g., PDP-8 or 8008).