I understand logic gates and their truth tables, but when it comes to the circuits of the gates, I have trouble understanding them. Could someone please explain how this BJT circuit works like the NAND logic gate?

enter image description here

(Original image source Basic Logic Gates and Buffers)

  • 1
    \$\begingroup\$ It is worth noting that if you invert both inputs of an OR gate, you get a NAND gate. And if you invert the output of an AND gate, that is another way to get a NAND gate. \$\endgroup\$ Commented Nov 9, 2019 at 19:41
  • \$\begingroup\$ DeMorgan's Theory \$\endgroup\$ Commented Nov 9, 2019 at 21:43

3 Answers 3


The best way to do this is to analyze each case separately. This gate has two input signals, so only four combinations to analyze. For each case write down the inputs and the resulting output. After the four cases, you have a truth table, which you say you already understand.

Here is the case with both inputs 0:

Both transistors are obviously off, so the pullup drives the output high.

Now do the (1,0) inputs case:

The bottom transistor is obviously off, so again the outut can only be high.

Case (0,1):

Case (1,1):

From these four cases you get the truth table:

  In1  In2  Out
  ---  ---  ---
    0    0    1
    1    0    1
    0    1    1
    1    1    0

which is the NAND function.


When either of the transistors are off (ie, inputs A or B are LOW) the connection between output and ground is open. In that case the output is HIGH. You can better picture this case by removing the transistors from the circuit.

To change that one must turn on both inputs (change both transistor bases signals to HIGH) so that the output gets connected to ground (LOW). You can picture this case by shorting emitter-collector of each transistor, or replacing the connections by a wire.

That's exactly the truth table of a NAND: output is only LOW when both inputs A and B are HIGH.

You don't need to memorise every possible combination of transistors to answer questions like these. To solve problems like the one presented, and this other one linked in a comment below, you should reason like I'm doing here.

You need to understand how a transistor works (as a switch in this case). Then you can then tell whether the transistor is conducting or not. If it is conducting, you can simplify the circuit by replacing the collector-emitter connection with a short (ie., a wire). If it is not conducting, you can replace the connection with an open circuit. Then you solve the resulting circuits.

Of course, I'm oversimplifying things, but only for didactical purposes. Transistors have may other properties that we abstracted here, but that should be considered in real life as it will affect the outcomes of such circuits.

  • \$\begingroup\$ I understand that, I now the gates and stuff. However, for example this is my mock question vvcap.net/db/RgyRxKKMIY3FcAJIQd4e.htp. How am I able to identify what this is -.- \$\endgroup\$ Commented Jan 15, 2014 at 11:06
  • \$\begingroup\$ As the mock question does not state which voltage level corresponds to which logical value, it cannot be answered (but only guessed) without further information. \$\endgroup\$
    – user16324
    Commented Jan 15, 2014 at 11:14
  • \$\begingroup\$ So, it's about memorising the diagram rather than using information or knowledge to figure it out. If so, wow, that's dumb... \$\endgroup\$ Commented Jan 15, 2014 at 12:11
  • \$\begingroup\$ @Ricardo When any of the transistors are off, the output will be left floating. How can the output be deduced as HIGH until and unless there is a pull-up at the output? \$\endgroup\$
    – Avin
    Commented Jan 15, 2014 at 12:12
  • 1
    \$\begingroup\$ Link to mock question is dead. \$\endgroup\$
    – PStechPaul
    Commented Dec 9, 2022 at 19:41

Input A and Input B are both connected to say +5 volts. The top resistor is also connected to +5 volts. Let us say all the resistor values are 1K. If both A and B are not on, the current from the top resistor can not reach the bottom ground. This means the current will be sent to the output path. This top resistor is called a pull-up resistor in that case.

When both A and B are on all the current will flow to the bottom ground. This is because the transistors will allow up to 100 times more current to flow from the top resistor to the bottom ground than is flowing from the inputs into the ground by going into the base of the transistor. When the current is flowing to the bottom ground the voltage drop across the top resistor will be very high, close to 5 Volts. This means there is basically no voltage at the output point of the circuit when inputs A and B are both on.

AND and NAND logic gates can be confusing because they can both be built with two transistors. However to send an output further down the circuit the AND gate needs three transistors. So it is fair to be confused by these logic gates at first. I recently made a video explaining how to build all the different types of logic gates. Including how to build an NAND gate and 7 ways to implement an AND gate. https://youtu.be/nB6724G3b3E


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.