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

A logic gate represents boolean logical operators. Those operators take one or more boolean inputs (either a 1/TRUE or a 0/FALSE) and evaluate them to generate an output. A Truth Table is just all possible inputs and outputs.

For example, you have the AND operator. It returns 1/TRUE if both inputs are TRUE. If the inputs are 1 and 1 then it gives you 1. If the inputs are 0 and 0 then it gives you 0. If the inputs are 1 and 0 then it gives you 0, because the inputs are not matched.

So the table would look like this:

Input1 Input 2 = Output

0 AND 0 = 0

1 AND 0 = 0

0 AND 1 = 0

1 AND 1 = 1

The most useless useful logic gate is “YES” which is a straight pass through. 1 outputs 1, 0 outputs 0. “Not” is also pretty helpful, it inverts the input. 1 -> 0 and 0 -> 1.

Then you have AND where if the two inputs are matched it outputs 1 and OR where if *any* input is 1 it outputs 1.

It gets a little more complicated with XOR, named “exclusive OR.” XOR requires exactly one input to be 1 in order to output 1. 1 OR 1 = 1 while 1 XOR 1 = 0.

Then there’s the “not” operators, which are just a combination of NOT and another operator, but they’re useful enough that they get their own names.

NAND is “NOT AND” so anything that gives you a TRUE with AND will give you a FALSE instead and vice versa. 1 NAND 1 = 0 while 0 NAND 0 = 1 and 0 NAND 1 also = 1.

Take the output of the operator and put it through a NOT gate and that’s the N version of the operator. NAND, NOR, XNOR

When you do “traditional” math, you have operations such as addition, subtraction, multiplication, etc. This math works using the numbers we know.

Logic gates are a different kind of math (Boolean algebra). Instead of using every number, you only use 1 and 0, which can be interpreted as True and False. This type of math uses other type of operations, mainly AND, OR and NOT (and derivations of them).

Truth tables are like multiplication tables, in the sense of “this numbers combined using this operation give this result”. You can interpret them from everyday speech, for instance, when you say “this is not true” is like saying “this is false”. Thus, the NOT gate is an operation when a 1 becomes a 0 and vice versa.

Not an explanation, but potentially helpful for independent learning:

I am not an EE, but basic classical (true/false) logic is the same regardless of discipline. If you are still struggling with logic gates, it may help to learn them in a different way. In mathematics, logic is often taught fully in the abstract, so if you think that intuitive language-based examples will help you understand better, then you might consider looking at a philosophical logic textbook. Philosophy students learn basic classical logic “sententially,” meaning that the logical statements are treated as though they roughly approximate English language sentences. Students begin with problem sets that ask them to “translate” sentences into logical propositions, and learn the fundamental operators that way. Worth noting is that logic is usually taught to mathematics and linguistics students using set theory. You will not learn set theory in an introductory philosophical logic textbook, so keep that in mind if it applies to your situation.

Classical Logic and its Rabbit Holes by Nelson Lande is an excellent and accessible book that will teach you sentential logic. Unlike many other logic textbooks, it is inexpensive and it focuses specifically on fluency in sentential logic for about the first half, before introducing first-order logic and the axioms via synthesis (however, do EEs use first-order logic?). You could also look up philosophical logic tutorials on YouTube.

As I mentioned, the book was written for philosophy undergraduates, so it does not use the same symbols or terminology as electrical engineering, but it is fundamentally the same. You may also think about taking a logic class in your university’s philosophy department. You may find that you enjoy philosophy too! Good luck with your studies!

Here’s the boolean operations that you represent with single logic gates.

AND has two inputs, and outputs true only if both inputs are true. On diagrams, these gates look like a half circle on the output side and a square on the input side.

OR has two inputs, and outputs true only if either input is true. On diagrams, these gates look like curves bowing outward and meeting at a point on the output side, and bowing inward on the input side.

XOR has two inputs, and outputs true only if the two inputs are different. It looks like an OR gate, but with an extra curve on the input side.

NOT gates have only one input, and output the opposite of the input. Alone, it looks like a triangle pointing to the output, with a little circle on the point.

Sometimes the little circle symbol is combined with the other three gates to make NAND, NOR, XNOR gates. It’s the same as those first ones, but the output is the opposite. So a NAND outputs false only when both inputs are true.

You can also use the triangle part of the not gate without the little circle. It’s just a passthrough, so for logic purposes, it doesn’t really matter.

To draw a truth table, make a table such that there’s a column for every input and output, and a row for every combination of inputs. Then fill in the output column with the output that’s produced by the input listed in that row.

For these logic gates, they’ll be pretty small. Two rows for the NOT gate, and four for the others. You can combine logic gates in your design to implement more complicated logic though, and if you have more inputs, you’ll need a bigger table.

A logic gate, in electrical engineering, takes some number of inputs binary inputs and produces a binary output. The binary inputs are basically just TRUE or FALSE, but you also might see them represented as 1 or 0, or ON and OFF.

I’ll walk through an OR gate because that’s a simple one. An OR gate has two inputs and produces one output. If any of the inputs are true, the output will be true, and the output will be false if both inputs are false. To give a real world example, let’s say you were designing a toll road. You want to let the drivers through if they have either paid the toll or have a pass, so you can take an OR gate and one of the inputs is “has pass” and the other is “paid toll” and you can use the output of that to decide to open the gate.

A truth table is just a list of all the inputs and what output you’d get. For an OR gate, it would look like this

False, False: False

False, True: True

True, False: True

True, True: True