Logic Gates
Logic Gates
Within a processor, logic gates are combined t o form logic circuits. These can perform
more complex operations like binary addition.
Each of the six required logic gates has an internationally recognised s ymbol which
you should learn. The symbols have inputs on the left and outputs on the right.
Truth Tables
A truth table shows every possible combination of inputs and the corresponding output
for a logic gate or logic circuit. The inputs are labelled alphabetically starting with A and
the output is usually labelled Q.
NOT
The NOT gate has one input a
nd one output. The gate’s output is always the opposite of
its input. If the input to the gate is a 1,it will output 0 and vice versa.
A Q
0 1
1 0
The truth table for the NOT gate has just two columns, the input A and the output Q.
0
There are just two possible inputs, 1 and .
Q = A
3
AND
The AND gate has two inputs, labelled A and B in the truth table below, and outputs
the product of the two inputs.
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Q = A × B
) when both inputs are TRUE
The AND gate only outputs TRUE(1 , otherwise it outputs
FALSE.
OR
dds them together. Therefore, the
In the same way that AND multiplies its inputs, OR a
OR gate is said to output the sum of its inputs.
A B Q
0 0 0
0 1 1
1 0 1
1 1 1
Q = A + B
OR only outputs FALSE when both inputs are FALSE
. When one or more of the gate’s
inputs are TRUE
, the logic gate outputs TRUE.
4
XOR
The XOR gate’s full name is exclusively or and it outputs TRUE when
strictly one of its
inputs is TRUE . The gate’s truth table is the same as the OR gate with the exception of
the last line in which FALSE is output with two TRUEinputs.
A B Q
0 0 0
0 1 1
1 0 1
1 1 0
Q = A ⊕ B
NAND
NAND is short for NOT AND. The NAND gate is actually a combination of two gates
which we’ve already covered, the NOT gate and the AND gate.
The NAND gate’s truth table is the same as the AND gate’s truth table, but the output
is reversed.
A B Q
0 0 1
0 1 1
1 0 1
1 1 0
Q = A×B
5
NOR
NOR, short for NOT OR is a combination of the two logic gates NOT and OR.
OR NOT NOR
Therefore, the NOR gate’s truth table is the same as the OR gate’s table, just with the
output reversed.
A B Q
0 0 1
0 1 0
1 0 0
1 1 0
Q = A + B
6
Combining Logic Gates
Logic gates can be combined to form more complex circuits. You may be asked to draw
or interpret a logic circuit involving multiple logic gates.
The logic circuit above combines four logic gates and can be represented using the
logical expression b elow.
Q = C ⊕ ((B×C) + A )
In order to create a truth table for this circuit, we first need to fill in all the possible
permutations of inputs like so:
1 0 0
1 0 1
1 1 0
1 1 1
7
Next, we add columns for each of the elements that make up the logical expression
such as B × C and A . This will make it easier for us to combine them to form the final
expression.
A B C B×C A (B × C) + A C ⊕ ((B × C) + A)
0 0 0 0 1 1 1
0 0 1 0 1 1 0
0 1 0 0 1 1 1
0 1 1 1 1 1 0
1 0 0 0 0 0 0
1 0 1 0 0 0 1
1 1 0 0 0 0 0
1 1 1 1 0 1 0
Once the column in the truth table for the finished expression is complete, the
columns used for working c an be removed and the final column renamed Q .
A B C Q
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 0
8
Adders
An adder is a logic circuit t hat can be used to add Boolean values together. There are two
types of adder that you need to be aware of: half adders and full adders.
Half adders
A half adder is a logic circuit with t wo inputs, two outputs and two logic gates. The circuit
can be used to add two Boolean values.
The two inputs are labelled A and B and the outputs are labelled S and C. Short for
sum and carry.
A B S C
0 0 0 0 0 + 0 = 0
0 1 1 0 0 + 1 = 1
1 0 1 0 1 + 0 = 1
1 1 0 1 1 + 1 = 0 carry 1
9
Full adders
A full adder has three inputs and two outputs, enabling it to input two Boolean values
and a carry bit from a previous, less significant operation.
The three inputs are labelled A, B and Cin for carry in. The two outputs are labelled S for
sum and Cout for carry out.
A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
10
Edge-triggered D-type flip-flop
An edge-triggered D-type flip-flop is a logic circuit which can be used as a memory unit
for storing the value of a single bit.
An edge-triggered D-type flip-flop has two inputs, one for data and another for a c lock
signal. There is one output, which always holds the value of the stored bit.
The clock signal can also be used to synchronise numerous flip-flops when they form part
of a larger system such as a shift register.
11