We begin this session with an example to understand the impact of 0s and 1s in our lives.
Suppose you are handed with a will of 1000 dollars.
The money increases if we increase zeroes on the right.
However, if we swap the one to right, the values decreases drastically.
This is numerical significance whereas in smart devices, it has a logical significance.
The values are decisions which can have a high value or logic 1
and a low value or logic 0.
The decision-making elements are called logic gates.
The decisions are termed as output which are binary variables 0 or 1.
It has a single output.
The input to logic gate can be single or multiple.
The output changes for every input combination and it depends upon two things -
Type of logic gate and nature of input variables.
There are numerous gates available, each for a specific decision.
Each of these have a specific symbol and clearly defined behaviour.
There are two major classifications- Basic gates and derived gates.
We will discuss each of them in detail later.
For now, let’s concentrate upon the nature of binary input variables.
To study this, let’s understand the truth table.
It maps the input-output relationship.
The left hand side, lists all possible combinations of input binary variables
and RHS maps the output to each.
Consider a logic gate with a single input A.
It can take values 0 or 1.
There are 2 input combinations for 1 input variable.
Another system has two inputs,
A and B and a single output Y.
It may happen that A has the value 0 and B takes values
0 or 1.
When A is at logic 1, B may have values 0 or 1.
Thus there are 4 input combinations for 2 input variables.
Therefore, n input variables will have 2^n input combinations.
There is a trick to fill the truth table.
We start filling with the leftmost input and will go column by column.
Since we know it will have four input combinations,
2 zeroes are followed by 2 ones.
Next column with have one zero followed by one one.
If there are 3 inputs A, B, and C,
there will be 2^3 = 8 combinations.
Left most column will have 4 zeroes, 4 ones.
Next column will have 2 zeroes, 2 ones
which will repeat.
Last column will have a series of 0 and 1.
But how do we decide the output for each input?
The type of logic gate decides the output.
Let us study the basic logic gates.
Basic logic gates are the fundamental logical operations
from which all other functions
no matter how complex can be derived.
These functions are named as AND, OR and NOT.
The first basic gate is an AND gate.
This is the symbol for AND Gate.
A and B are two inputs resulting in a single output Y.
The Boolean expression is read as Y = A and B..
A Boolean expression relates output with the inputs of the logic system
For a 3 input AND gate, the boolean expression is Y=A and B and C.
This way the boolean expression can be written for a multiple input AND gate.
Let’s construct the truth table. When both
When both the inputs A and B are low,
the output Y is low.
The output of AND Gate is low when either
of the inputs are low.
Both the inputs A, B need to be at logic 1
for the output to be 1
You can imagine it as 2 switches in series.
When the circuit is complete, the bulb will glow.
When both the switches are at logic 1, the path is complete and current
flows. AND Gate finds applications in security systems such as burglar’s alarm.
Suppose you have to leave the house and keep the house secure.
You turn on the alarm switch.
This turns first input of AND gate as high.
If a burglar tries to enter the house,
the person sensor detects a logic 1.
This goes to second input of AND gate.
When both the inputs are
high, the output of AND gate is high which sets the alarm ON.
Second type of basic gate is an OR gate.
For two inputs A and B, the Boolean expression
is A OR B.
For multiple input, It is simply this way.
Let us see the truth table.
For two input OR gate
when both the inputs are low the output is low
otherwise the output
is high for remaining 3 input combinations.
It is similar to 2 switches in parallel.
The circuit is complete when either of the inputs is at logic 1 or both at logic 1 which makes the bulb glow.
When a house has a front door and a back door, guests can arrive at any door
In the event, when either the front door or the back door bell is pressed, the
bell rings indicating that the guest has arrived.
The last basic gate is a NOT gate. This gate can only have one input.
Let us consider the input as A
As the name suggests, the output is always NOT the input i.e., complement of input.
A complement is denoted by a bar over the variable. The boolean expression for input, A is A bar.
When the input is 0, output is 1 and vice versa