# Realizing logic gates with transistors: AND and OR gate in parallel, trying to understand different behaviours

I am trying to understand and finally realize a logic gate by using transitors. In order to build a "simple" one-bit adder, my first step was to design a circuit that puts an AND-gate and an OR-gate in parallel (as can be seen below in circuit 1). The desired behaviour is as follows:

Remark: This is NOT supposed to be the final 1-bit-adder. I am trying to figure out as much as possible on my own, so I kindly ask not to spoiler on how to proceed with the entire 1-bit-adder.

1.) Upper switch closed, lower switch opened: Left LED off, right LED on.

2.) Upper switch open, lower switch closed: Left LED off, right LED on.

3.) Upper switch closed, lower switch closed: Both LEDs on.

With the circuit shown above this behaviour could be achieved, which is good. However, this is the result that I came up with after several iterations of trial and error. One of my first attempts can be seen below in circuit 2. This one is not working and I am trying to understand why this is. Please check out my "first-attempt-circuit" first:

The major difference between the two designs is that the two 20k resitors (per switch) that where set up in parallel in circuit 1 were substituted by just ONE 10k resistor (per switch) just in front of the switches. So the total resistance in the 5V-control-circuit should be the same in both cases, right? However, the behavious is completely different and I do not understand why this is. The behaviour shown by circuit 2 is as follows:

1.) Upper switch closed, lower switch opened: Left LED off, right LED on. (OK!)

2.) Upper switch open, lower switch closed: Both LEDs off. (Bad!!!)

3.) Upper switch closed, lower switch closed: Left LED on (damped, I = 3.25 mA), right LED on (bright, I = 23.48 mA). (Bad!!!)

I assume that in case 2 the lower transistor of the AND-gate opens, allowing base-current to flow back to GND. Further I assume that this leads to a drop in voltage, not leaving enough power to open the lower transistor of the OR-gate. However, I do not understand why this is different in circuit 1, where the voltage between the AND-gate's base and the OR-gate's base should be the same too, just with a higher resistance, right? I would love to see someone bringing some clarification to this one ;-)

• Hint: Voltage doesn't just drop across semiconductors. Commented Aug 20, 2013 at 8:36
• I'm not 100% sure about what this hint shall point me, too. Would you mind to specify, please. Commented Aug 20, 2013 at 8:44
• The voltage drops across the resistor as well. Commented Aug 20, 2013 at 8:46
• I believe that the "desired behavior" doesn't match what you get with Circuit 1 - when just one of the switches is closed it is the right LED which will be ON Commented Aug 20, 2013 at 9:50
• @Vasiliy Zukanov, you are totally right. Thanks, I messed that up in the first place. I corrected it in the text above! Commented Aug 20, 2013 at 10:43

## 1 Answer

In your second circuit you have the Base-Emitter diodes of the lower two transistors in parallel. The division of the current between both will heavily depend on small variations between the two transistors. This might not show up in your simulation, but it is not a good situation.

The situation with the top two transistors is even worse. The right one will take almost all of the current, because the emitter of the left transistor is at a slightly higher voltage than the emitter of the right one.

That second circuit would work OK with MOSFET transistors, it is in fact the way ports were commonly made in the NMOS days (before CMOS became dominant). MOSFETS are voltage-controlled transistors, hence the problem of how the base current is split between the two transistors does not arise. Bipolar transistors are (base-) current-controlled, hence they each need at separate base resistor.

A potential problem with your first circuit can arise when you use its output to drive subsequent gates. When the output is not pulled down all the way below the Vbe of a transistor (which can happen in the NAND because two Vce's are in series) a subsequent transistor might still receive some base current. Two solutions:

• add (for each transistor) a resistor from base to ground of ~ 100k. this would also make the circuit faster.

• avoid the two-transistors-in-series circuit, use only the NOR gate as building block (you can still get an AND gate at the cost of two extra transistors by inverting the two inputs).

• Hi @Wouter, thank you for your response. I understand most of what you said above and it already helps a lot. However, I have a problem understanding your statement "he situation with the top two transistors is even worse. The right one will take almost all of the current, because the emitter of the left transistor is at a slightly higher voltage than the emitter of the right one." - Can you explain why this is? I would appreciate that! Commented Aug 20, 2013 at 10:46
• @TheStoepsel: The voltage will only go as high as it needs to in order to operate the circuit, and for the right transistor that's Vbe, whereas for the left transistor it's Vbe+Vce (since the two transistors are in series). It's for that reason that the left transistor can't possibly saturate. Commented Aug 20, 2013 at 11:01
• I tried the MOSFETs you described above and it works beautifully! However, I would love to realize my circuit with "traditional" transistors (just for the purpose of learning). As far as I understand your answer above, EVERY transistor needs a properly dimensioned resisitor in front of its base when installed parallel to each other, such that the influence of real-world-minor-differences between the transistors themselves has less impact. Did I get that correct? Commented Aug 20, 2013 at 13:11
• That is the reason the lower transistors need an individual base resistor. For the upper transistors the is the additional reason that the emitter of the left one is at a higher potential than the right one. Commented Aug 20, 2013 at 13:16
• Yours is a good basis, assuming you don't need it to be fast, and each output drives only a few (let's say 10) transistor inputs. But once you understand how a logical port works, it is much easier to think and build in terms of ports, not in individual transistors. Such abstraction steps are the essence of the progress towards more complex circuits. Commented Aug 20, 2013 at 15:19