Combining Logic Gates Combining Logic Gates A note on Precedence

advertisement
Combining Logic Gates
► By
combining the logic gates we have already
looked at, we can create circuits to implement
all the arithmetic and logical operations a CPU
performs
CS10110: Logic Circuits
What a chip is made of
► The
logic gate is at the heart of the computer;
without it, we wouldn't have computers.
Laurence Tyler
lgt@aber.ac.uk
November 2012
November 2012
Combining Logic Gates
Y = (A●B)+C
Note: Although AND (•) takes
precedence over OR (+), we
often use brackets anyway to
avoid confusion.
November 2012
2
A note on Precedence
A
B
C
(A●B)+C
0
0
0
0
0
0
1
1
0
1
0
0
0
1
1
1
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
1
CS10110 - Logic Circuits
CS10110 - Logic Circuits
► In
●
mathematics we have operator precedence:
xy (powers) » ×,÷ » +,−
► Similarly,
●
NOT » AND » OR
► So
●
we have precedence in digital logic:
A•B+C should be interpreted as:
((NOT A)•B)+C
► To
avoid ambiguity, we would normally in any
case write ((A•B)+C)
3
November 2012
CS10110 - Logic Circuits
4
De Morgan's Theorem
De Morgan's Theorem
Consider the following circuit:
Y = A∙B
A
B
Y
0
0
0
0
1
1
1
0
1
1
1
1
A∙B = A+B
A+B = A∙B
► This
is a very useful rule to remember when
trying to simplify a complex logic circuit
► We
don't need an OR gate, because we can
construct one using NAND and NOT gates
► We
don't need an AND gate, because we can
construct one using NOR and NOT gates
What do you notice?
November 2012
CS10110 - Logic Circuits
5
November 2012
Doing away with Gates
6
NAND and NOR
► We
know we don't need an OR or an AND gate,
because we can construct them from NOR,
NAND and NOT gates
► But
CS10110 - Logic Circuits
► So
all we really need is NAND and NOR
► But,
if we can construct an OR from NAND
gates, we can construct a NOR too
what about this:
●
simply by inverting the output
► Similarly,
November 2012
A
Y
A
Y
CS10110 - Logic Circuits
if we can construct an AND from NOR
gates, we can construct a NAND as well
A
Y
0
1
► So
1
0
► We
we only need ONE type of gate: either a
NAND or a NOR gate
can then construct any logic circuit we
want!
7
November 2012
CS10110 - Logic Circuits
8
Why use only one or two gates?
NAND is simpler than AND
► There
is a good reason why we should only want
to use one or two types of gate - we don't just
do this to make logic hard to learn!
A 2-input NAND gate
implemented in TTL
logic
Image courtesy of
Wikipedia
► It
is easier and cheaper to manufacture chips
with only one or two types of gate on them
●
●
Arrays of identical circuit elements
Function actually determined by interconnection
layer(s) - the metal "wiring" between gates
NB: you are not expected
to learn this circuit! For
information only.
► Automated
design systems can help with doing
the required logic transformations to use a
standard gate type
November 2012
CS10110 - Logic Circuits
Because of the way TTL (transistor-transistor logic)
works, a NAND gate only needs two transistors. To
make an AND gate we actually have to add another
transistor to invert the output.
9
November 2012
Other Simplifications
CS10110 - Logic Circuits
10
More complex circuits
This is called
Boolean Algebra
1) (A•B)+B = B
2) (A+B)•B = B
3) (A•B)+B = A+B
4) (A+B)•B = A•B
5) (A•B)+(A•C) = A•(B+C)
6) (A+B)•(A+C) = A+(B•C)
Also note that, as in maths:
Note: sometimes the •
(AND) symbol is omitted,
so AB means the same as
A•B
Note: the dot means the lines connect here. If there is
not a dot, the lines do not connect but pass over each
other.
A•B = B•A
A+B = B+A
Doesn't matter which way round the inputs
are (commutative rule)
A•(B•C) = (A•B)•C
A+(B+C) = (A+B)+C
Doesn't matter how you group the brackets if it's the same function (associative rule)
November 2012
CS10110 - Logic Circuits
11
Q: Work out expressions for Y0 ... Y4
November 2012
CS10110 - Logic Circuits
12
Complex circuit simplified
►
Y0 = A•B ; Y1 = B+C
►
Y2 = Y0+B
The final circuit!
A
= (A•B)+B
= A+B
►
Y4 = A•B
B
Y3 = Y1•B
= (B+C)•B
= B•C
►
(rule 3)
C
(rule 4)
Y4 = Y2+Y3
= (A+B) + (B•C)
= (A+B) • (B•C)
= (A•B) • (B+C)
(De Morgan's)
(De Morgan's)
= A•(B•(B+C))
(associative rule)
= A•B
(rule 2)
November 2012
CS10110 - Logic Circuits
As you can see, it's much simpler than
what we started with - and we've shown
that input C is completely redundant!
13
What next?
► If
you can work your way through the values of
Y0 to Y3 on the previous slides and write out
expressions for them - without looking at the
answers - and also understand the working for
Y4, then you've conquered logic circuits, at least
as far as this module is concerned!
► Find
●
●
●
a logic simulator and try out some circuits:
http://smartsim.org.uk/
(free, Win/Linux/Mac)
http://sourceforge.net/projects/cedarlogic/ (free, Win)
http://logic.ly/
(pay, but has online flash demo)
► If
you're really keen, get a breadboard & some
chips and make some real circuits...
November 2012
CS10110 - Logic Circuits
15
November 2012
CS10110 - Logic Circuits
14
Download