Logic gates, Truth tables and Boolean logic.

What are logic gates? How do you record the results? And what is Boolean logic?

all-logic-gates
All types of logic gates.

The NOT gate

not-gate
A NOT gate

The NOT gate is the most simple, only requiring one input for it to work.

Truth Tables

The results from a gate are represented in a Truth table:

A Q
0 1
1 0

A NOT gate produces the opposite outcome when applied. So when A is 0, the outcome (Q) is 1 and vice versa.

The AND gate

and-gate
An AND gate

The AND gate is the second most simple gate.

A B Q
0 0 0
0 1 0
1 0 0
1 1 1

For an AND gate to produce an outcome of 1, both A AND B must be 1.

The NAND gate

nand-gate
A NAND gate

The NAND gate is the opposite of an AND gate.

A B Q
0 0 1
0 1 1
1 0 1
1 1 0

Each output will be the opposite of the AND gate.

The OR gate

or-gate
An OR gate

The OR gate will produce an output of 1 if A OR B is 1.

A B Q
0 0 0
0 1 1
1 0 1
1 1 1

The output is 0 only when A AND B  are 0.

The NOR gate

nor-gate
A NOR gate

The NOR gate is the opposite of the OR gate.

A B Q
0 0 1
0 1 0
1 0 0
1 1 0

The only output to be 1 is when A AND B are 0.

The XOR gate

xnor-gate
An XOR gate

XOR means ‘Exclusive OR’.

A B Q
0 0 0
0 1 1
1 0 1
1 1 0

The XOR will only produce an output of 1 when A OR B are 1 NOT when A AND B are 1.

The XNOR gate

xnor-gate
A XNOR gate

The XNOR gate is the opposite of the XOR gate.

A B Q
0 0 1
0 1 0
1 0 0
1 1 1

The XNOR gate has similar results to an AND gate except for when A AND B are 0 the output is 1.

Boolean Logic

Boolean logic is practically binary; with two results: True or False.

Some examples:

Is ABC an integer?

The answer would be False.

Is 123 an integer?

The answer would be True.

A more practical use for this can be seen in programming codes like python:

simple-python
A simple python code to count to 10

Basically this is asking a simple question: Is a <= 10?

If yes, then print the value of a and add 1

If no, then end the code.

This is using a simple True and False scheme. So while a is smaller than 10, the result is ‘True’ and when a is larger than 10 the result is ‘False’

 

 

 

 

If you want to test any logic gates simply go to logic.ly and use their software! I’d recommend using this if you get confused by all the truth tables!

Leave a comment