You are on page 1of 11

1

3.1 Logic
Gates

Zain Merchant
2

Zain Merchant
3

Zain Merchant
4

Electronic processing
Data processing
You have learned that a computer processes data to make information. The data is
held inside the computer in the form of electronic signals. The data is processed by
changing the electronic signals.
This happens inside a part of the computer called the processor. The processor is
at the centre of the computer system. It is an electronic device. It transforms data
into information by changing the electronic signals in regular and organised ways.
In this chapter you will learn how the processor works.

Electronic devices
Many devices are electrical (they put electrical energy to work), for example an
electric heater or a washing machine. Some devices are electronic. This means
electrical energy in one circuit directly controls the flow of electricity in another
circuit.
A digital electronic device has on/off switches inside it. When on, electricity
can flow through a switch; when off, it cannot. An electronic switch is itself
controlled by electricity. Electricity flowing in a switch’s control (input) circuit may
switch off its controlled (output) circuit, or the other way round. The output of one
switch can control the input of any number of other switches. This means switches
can be interconnected to vary the electrical flow in a complex way. That is how
digital devices such as computers carry out their work.

On/off switches
When we describe the operations of the processor, we need to talk about on/off
switches, and their effect on an electric circuit. We can use the terms:
● on and off, meaning the switch allows or does not allow current to flow in an
electric circuit
● high and low, meaning the switch connects a point in an electric circuit to a
relatively high potential (e.g. 3 volts) and low potential (e.g. 0 volts)
● 1 and 0
● True and False.
These are all ways of describing the state of the on/off switches inside a computer.
When a switch is on, a current can flow through it; when off, no current can flow. A
circuit can detect the difference, and use it to denote
1 versus 0, or True versus False.

Logic gates
On/off switches are combined to make electrical circuits. These circuits are called
logic gates. Electrical signals pass into logic gates, and electrical signals pass out.
Every logic gate has input and output:
● The input to a logic gate is the electrical signal that goes into the gate. For
example, a potential of 3 volts might mean 1 or True, while 0 volts means 0 or
False. Some logic gates have one input, some have two inputs.

Zain Merchant
5
● The output from a logic gate is the electrical signal that comes out of the
gate.
Each input to a logic gate can be 1 or 0 (True or False). Each output is also
1 or 0 (or True or False). There are no other states for input or output. This means
that a logic gate’s inputs and output are binary digital values: each has only two
possible states.
A logic gate uses the electrical signals at its inputs to decide whether its switch
should be on or off. The switch setting determines what the output signal will be, 1
or 0 (or True or False). There are different types of logic gate. Each type decides its
switch setting in a different way.

Logic circuits
Logic gates can be connected together into a logic circuit. The output of a gate
can be connected to the input of other gates. Each gate transforms the signal in
some useful way. Logic gates can be joined together in different ways to create
many different circuits. Each circuit will transform its binary input signals in a
different way.

Zain Merchant
6

The NOT gate


The NOT gate is a simple logic gate. It changes every binary signal into its
opposite. If the signal is 1, it makes it 0. If the signal is 0, it makes it 1. In logical
terms, it changes True into False.
This gate works like the word “not” in everyday speech. If we put “not” into a
sentence it changes the meaning to the opposite. For example, “I am not tired”
means the opposite of “I am tired”.
The word “not” reverses the meaning of a sentence. The NOT gate inverts a binary
signal.

Symbol
Each type of logic gate has a different symbol. This is the symbol for a NOT gate.

The line coming into the gate from the left is the input. The line coming out on the
right is the output. A NOT gate has one input and one output.

Input and output


Logic gates are predictable and logical. If we know the input to a gate, we know
what the output will be.
Only one signal goes into a NOT gate. This signal can be 1 or 0:
● If the signal going in is 1, then the signal coming out is 0.
● If the signal going in is 0, then the signal coming out is 1.

Possible states
The NOT gate can be in two possible states. They are shown in these diagrams.
There are no other possible states for the NOT gate.

Truth table
A truth table is a way of showing all the possible states of a logic
gate. Each state is shown on a different row of the table. The truth
table for the NOT gate is very simple. It only has two rows.
The first row shows input 0, output 1. The second row shows input 1,
output 0. Those are the only possibilities.

Zain Merchant
7

The AND gate


The AND gate is a circuit that takes two binary signals and turns them into one
signal. The inputs can be 1 or 0:
● If both inputs are 1, the output is 1.
● In all other cases, the output is 0.
We can express this using True and False:
● If both inputs are True, the output is True.
● In all other cases, the output is False.
The AND gate is like the word “and” in a sentence. We use “and” to say that two
things are both true. For example, “I like sport AND books”, or “I am tired AND
hungry”. The sentence is only true if both parts are true. The AND gate works like
this. The output is only True if both inputs are True.

Symbol
The symbol for the AND gate looks like this.

There are two inputs to the AND gate. We can label the two inputs as A and B. A
and B are independent of each other: they don’t affect each other.

Possible states
You learned that the NOT gate can be in two possible states (input 1 or 0,
independent of the other). The AND gate is more complicated because it
has two inputs, and each input can be 1 or 0. That gives four possible
states altogether:
● A is 0, B is 0
● A is 0, B is 1
● A is 1, B is 0
● A is 1, B is 1.
The AND gate will only output 1 if both the inputs are 1.

Truth table
We use truth tables to set out all possible states for a logic gate. The four possible
states are shown like this.

Zain Merchant
8
We can put those four inputs into a truth table. Each input is shown on a different
row of the table.

Now the output is filled in for each case.

The output is always 0, except on the bottom row of the table. When both A and B
are 1, the output is 1.

Zain Merchant
9

The OR and XOR gates


The OR gate
The OR gate takes two binary input signals and turns them into one output signal.
Each input can be 1 or 0, True or False. The OR gate will output 1 if at least one of
the inputs is 1. It works like this:
● If both inputs are 1, the output is 1.
● If one input is 1, and one is 0, the output is 1.
● If both inputs are 0, the output is 0.
The OR gate works like the word “or” in a sentence. We use “or” to say that at least
one thing is true, for example “I will eat some cake or bread”. The sentence is true if
either part is true, or if both parts are true.
The OR gate works in the same way. The output is on if at least one of the inputs is
on.

Symbol
The symbol for the OR gate looks like this.

There are two inputs to the OR gate. In this diagram we have labelled the inputs A
and B. Like the AND gates, these inputs are independent of each other.

Truth table
The truth table for the OR gate shows the four possible states of the OR gate. It
shows the output in each state.
Columns A and B are the same as the truth table for the AND gate. The final
column, which shows the output, is different. This is because the OR gate has a
different effect.

Zain Merchant
10
The XOR gate
XOR stands for “Exclusive OR”. It can be pronounced “ex-or” or “zor”. This gate is
sometimes called EOR. That is pronounced “ee-or”. XOR and EOR mean the same
thing.
The XOR gate only outputs 1 if one of the inputs is 1 and the other is 0. These rules
apply:
● If both inputs are 1, the output is 0.
● If only one input is 1, the output is 1.
● If both inputs are 0, the output is 0.
In a sentence, the word “or” is sometimes used with this meaning. For example, the
sentence “I can go to a party or go to sleep” means that I can do just one of those
things, not both.

Symbol
The symbol for the XOR gate is like an OR gate, with a curved line in front of it.

Truth table
The truth table for the XOR gate is given below. The A and B columns are the same
as the other truth tables we have looked at. Any logic gate with two inputs has the
same logic table. The only difference is the final (“Output”) column.

The XOR gate has a different effect from the other gates you have learned about,
so the content of the “Output” column is different.

Zain Merchant
11

The NAND and NOR gates


The NAND gate
The NAND gate is a logic gate. NAND stands for “NOT” plus “AND”. The NAND
gate works the same as a NOT and an AND gate joined together. The symbol is an
AND gate with a small circle attached to it.

The NAND gate always outputs 1, unless both inputs are 1. It works like this:
● If both inputs are 0, the output is 1.
● If one input is 0, and one input is 1, the output is 1.
● If both inputs are 1, the output is 0.
The NAND gate is the opposite of an AND gate. Here is the truth table for the
NAND gate.

NOR gate
The NOR gate is a logic gate. NOR stands for “NOT” plus “OR”. The NOR gate
works the same as a NOT and an OR gate joined together. The symbol is an OR
gate with a small circle attached to it.

The NOR gate outputs 0 unless both inputs are 0. This is how it works:
● If both inputs are 0, the output is 1.
● If one or both inputs are 1, the output is 0.
The NOR gate is the opposite of the OR gate. Here is the truth table for this gate.

Zain Merchant

You might also like