## Revise Now

### GCE Subjects

Physics Chemistry CS Accounting

### Coding Lessons

Learn HTML Learn SEO

## More

### What do you want to do? # Logic Gates & Truth Tables & Logic Circuits

Logic circuits are made from logic gates

## Logic gates

These manipulate the bits entered to the gate and output a bit depending on the type of the gate used

We usually use a truth table to show the different combinations of bits which can be entered to the logic gate and their corresponding outputs. A bit can be either 0 or 1

You will need to know some of these gates and how to draw them and draw their truth table:

• NOT Gate
• This only has a single input, so this leads to 21 possibilities.

So the gate outputs the value opposite from which was entered. For example if a 0 was entered, it then outputs 1 (vice versa)

Truth Table
Input Output
1 0
0 1

• AND Gate
• There can have two or more inputs

In this both the inputs must be true for the output to be true.

Truth Table
A B Output
0 0 0
0 1 0
1 0 0
1 1 1

It is very important to note down that if we have 2 inputs this gives us 22 possibilties and so we have 4 combinations.

Also it better if you memorise the pattern of the input values as it is very useful.

So the first column is half 00 and half 11

The next column we have 0101

• OR Gate
• This also can have two or more input values.

In this gate either one of the input values must be true for the output to be true.

Truth Table
A B Output
0 0 0
0 1 1
1 0 1
1 1 1

• NAND Gate
• It is the opposite of the AND gate. This is done by using a NOT gate after the AND gate.

The output is TRUE only when both Inputs are not TRUE which means only when inputs are both true the output is false. If one input is true and the other one is not then the output is still true

In simpler terms the output is true when neither A or B are both true

Truth Table
A B Output
0 0 1
0 1 1
1 0 1
1 1 0

If you do forget how to draw the table just draw the opposite of the AND truth table.

• NOR Gate
• It can have 2 or more inputs

The Output is only TRUE if the neither the input values are TRUE.

So if one of the input values are true the output values is false.

Truth Table
A B Output
0 0 1
0 1 0
1 0 0
1 1 0

• XOR
• It only can have 2 inputs

The output is TRUE when the input values are different (not same).

Truth Table
A B Output
0 0 0
0 1 1
1 0 1
1 1 0

## 3 Inputs

Most questions usually have 3 inputs (A B C) and so this leads to 23 possibilities = 8 combinations

So now there are 8 rows and 3 inputs. So we also need to remember this pattern

Truth Table
A B C
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

We need to Memorise this form of inputs

The 1st column is half 0000 and half is 1111

The 2nd column is 00110011

The 3rd column is 01010101

We create the truth table based on the number of input values the ciruit begins with and not with the intermediate values

## Logic expressions and Problem statements

The definitions are not required to be remembered but the understanding is important.

Usually questions gives us problem statement as the example below:

The systems reorders if the inventory level is below 10 units or if the user makes a large order

A logic proposition is the statement which can be either TRUE or FALSE. Ex - the user makes a large order can be true or false.

This must be converted to a logic expression which then we replace the the logic proposition with simple variables such as:

System reorder(output) - X

Inventory below 10 units - A

Large order - B

This is like a normal simple logic gate but usually most examples contains 3 inputs.

X = A OR B

There are somethings you need to remember. By default we name the variable of a logic proposition with a variable A - this when the value of the variable is 1.However, if we want to represent the variable which has a value of 0 (FALSE). We must use NOT A

Lets see an example - the system sends an alarm if the chemical process is not working - 0 or if the user has switched off the system - 1

X = NOT C OR S

The reason why we define it this way is that we expect the output X to be 1 and usually they state this in logic expressions

## Truth Table for logic circuits

After finding the Logic expression we must draw the logic circuits and there is a simple way to do this

This is an example

#### X = (NOT A AND NOT B) AND C

Usually the brackets will be given but sometimes they don't give brackets such as the below example:

#### X = NOT A AND NOT B AND C

In this way we read from the left to the right when drawing the logic ciruits so this means we draw NOT A AND NOT B first then we Add the AND C. Note that I didn't make an intermediate variable for NOT A OR NOT B as they are very easy to do.

So when we draw the truth tables for these its best to get the intermediate values

#### D = (NOT A OR NOT B)

We name a new variable for the intermediate steps. Then the D AND C are compared

#### X = D AND C

Usually logic cirucits are not that easy and sometimes there could be many intermediate variables. Also you need to remember as 3 inputs are used there should be 8 possibilites.

If we want we could make intermediate variables for NOT A - E and NOT B - F Truth Table
A B C E(NOT A) F(NOT B) D X
0 0 0 1 1 1 0
0 0 1 1 1 1 1
0 1 0 1 0 0 0
0 1 1 1 0 0 0
1 0 0 0 1 0 0
1 0 1 0 1 0 0
1 1 0 0 0 0 0
1 1 1 0 0 0 0