What are logic gates and truth tables?

167 views

This is a topic I’ve been struggling with and I need help understanding what different logic gates do and how to make truth tables for each.

In: 2

7 Answers

Anonymous 0 Comments

If you’re an electrical engineer or a physics person, wires are messy and complicated. You can measure a wire’s potential (volts), current (amps), or resistance (ohms), and these can be any number: You might measure 1 volt or 2 volts or 10 volts or 4.7125 volts. Wires store charge (capacitance) and create magnetic fields (inductance).

Computer people don’t like thinking about all that complicated stuff. Instead, computer people think about a simple imaginary cartoon world where wires can only be “on” or “off”. Sometimes “on” is called “1” or “true”. Sometimes “off” is called “0” or “false”.

A logic gate is simply a “box” that has some input wires (usually 2 inputs) and output wires (usually 1 output).

A truth table is a “specification” or “manual” for a logic gate. To make a truth table, first, you put each possible combination of 0’s and 1’s somebody might put on the input wires into a row in the truth table. For example:

– If you have a logic gate with one input wire labeled A, there will be 2 rows in the truth table, corresponding to {A=0}, {A=1}.
– If you have a logic gate with two input wires labeled A,B, there will be 4 rows in the truth table, corresponding to {A=0,B=0}, {A=0,B=1}, {A=1,B=0}, {A=1,B=1}.
– If you have a logic gate with three input wires labeled A, B, C, there will be 8 rows in the truth table, corresponding to {A=0,B=0,C=0}, {A=0,B=0,C=1}, {A=0,B=1,C=0}, {A=0,B=1,C=1}, {A=1,B=0,C=0}, {A=1,B=0,C=1}, {A=1,B=1,C=0}, {A=1,B=1,C=1}.

There are four common, important logic gates: AND, OR, XOR, NOT [1] [2]. You just have to memorize these names, the corresponding truth tables, and the corresponding circuit diagram symbols.

Logic gates are mostly useful as building blocks for more complicated circuits. There are many, many resources about this. See [this Sebastian Lague video](https://www.youtube.com/watch?v=QZwneRb-zqA) for an example of building an addition circuit from logic gates.

[1] Some textbooks / courses might say there are six. The other two are called NAND, NOR.

[2] NOT has 1 input wire and 1 output wire. All the others have 2 input wires and 1 output wire.

You are viewing 1 out of 7 answers, click here to view all answers.