Download Gates and Boolean Algebra

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Flexible electronics wikipedia , lookup

Flip-flop (electronics) wikipedia , lookup

Integrated circuit wikipedia , lookup

Transcript
Introduction
Gates & Boolean Algebra
• Boolean algebra: named after mathematician
George Boole (1815 – 1864). A 2-valued
algebra.
• A digital circuit can have one of 2 values.
Signal between 0 and 1 volt = 0, between 4
and 5 volts = 1.
• Gates calculate various functions of 2 values
(like AND).
Computers are made up of gates.
Gates are made of connected transistors
(which are digital circuits).
CS 160
Ward 1
CS 160
Ward 2
Combinational Logic
Boolean Operators
• Translates a set of n input variables (0 or
1) by a mapping function (using Boolean
operations) to produce a set of m output
variables (0 or 1).
i0
i1
in-1
CS 160
– NOT
– AND
– OR
• Other useful operators
f0 = F0(i0,i1, …, in-1)
F
• Basic operators
– NAND
– NOR
– XOR
– XNOR
f1 = F1(i0,i1, …, in-1)
fm-1 = Fm-1(i0,i1, …, in-1)
Ward 3
CS 160
Ward 4
NOT (inverter) Operator [1]
NOT Operator [2]
1 goes in, 0 comes out and vice versa
• NOT truth table
Simplified Circuit:
When input (base) Vin is low, transistor
turns off (infinite resistance) which means
output is Vcc (typically 5 volts) (0 in = 1 out)
+5 volts
resistor
When Vin is high, transistor acts like a
wire to ground making output 0 volts
(1 in = 0 out)
Time to make output change values is
a few nanoseconds
A
X
0
1
1
0
X=A
• NOT gate symbol
A
X
0 volts
Inversion bubble
CS 160
Ward 5
CS 160
Ward 6
AND Operator
• AND truth table
NAND Operator [1]
• NAND truth table
(not and)
X=AB
A B X
0 0 0
A
0
0
1
1
• AND gate symbol
0 1 0
1 0 0
1 1 1
B
0
1
0
1
X
1
1
1
0
X=AB
• NAND gate symbol
Circuit: NOT connected to a NAND (next 2 slides)
CS 160
Ward 7
CS 160
Ward 8
NAND Operator [2]
OR Operator
Simplified Circuit:
If V1 and V2 are both high, both
transistors will conduct and
send the electricity to ground
and Vout will be low
If either V1 or V2 (or both) are
low, the corresponding
transistor resists, not allowing
electricity to ground and
output is high
• OR truth table
X=A+B
A B X
0 0 0
• OR gate symbol
0 1 1
1 0 1
1 1 1
Circuit: NOT connected to NOR (next 2 slides)
CS 160
Ward 9
CS 160
NOR Operator [1]
• NOR truth table
(not or)
A B X
0 0 1
NOR Operator [2]
X=A+B
• NOR gate symbol
0 1 0
1 0 0
1 1 0
CS 160
Ward 10
Ward 11
Simplified Circuit:
If either input V1 or V2 is
high then transistor
will conduct electricity
to ground and output
will be low
If both inputs are low
then both transistors
resist, making output
high
CS 160
Ward 12
NOR Operator [3]
XOR Operator
Actual Circuit:
•
Exclusive-OR example
–
Truth table
_
_
XOR = A ⊕ B = A B + A B
6 transistors, 5 resistors, & 3 diodes
CS 160
Symbol:
Ward 13
CS 160
XNOR Operator
•
Exclusive-NOR example
–
Truth table
Gate Manufacturing Technology
• Bipolar
XNO
R
– TTL (Transistor-Transistor Logic) workhorse of digital
electronics
– ECL (Emitter-Coupled Logic) very fast
1
0
0
• MOS (Metal Oxide Semiconductor) slower than
bipolar but needs less power and takes up less
space so can put a lot on one chip
1
_ _
– PMOS
– NMOS
– CMOS (most modern CPU’s and memories)
XNOR = A ⊕ B = A B + A B
Symbol:
CS 160
Ward 14
Ward 15
CS 160
Ward 16
Boolean Functions
Majority Function Truth Table
• A combination of Boolean operators
• A majority function for 3 inputs (0 if most inputs
are 0, 1 if most inputs are 1)
F1(A,B,C) = A + BC
A B C
F2(A,B,C) = ABC + ABC + ABC + ABC
M ( A, B, C)
= C (by minimizing techniques shown later)
Recall: + operator means OR & no operator
(A B C ) means AND
CS 160
Ward 17
0 0 0
0
0 0 1
0
0 1 0
0
0 1 1
1
1 0 0
0
1 0 1
1
1 1 0
1
1 1 1
1
CS 160
Ward 18
Majority Boolean Function
Majority Function Circuit
ABC ABC
M
___
• A Boolean algebra function for the
majority function:
A dash (A) means
(not A)
__
Dots are connections
__
__
M=ABC+ABC+ABC+ABC
How was this formula (and circuit on
previous slide) derived?
CS 160
Ward 19
CS 160
Ward 20
Boolean Function from Truth Table [1]
• A Boolean algebra function can be derived from
any truth table
• For each 1 in result, AND the row values (use NOT
to make row values 1) then OR those together
• Example:
A B X
0 0 1
0 1 0
1 0 1
1 1 0
Boolean Function from Truth Table [2]
• Draw circuit for function:
X=AB+AB
_ _
_
AB
AB
_ _
_
then OR them: A B + A B
AND these rows:
X=AB+AB
sum-of-product (sop) form for function
CS 160
Ward 21
CS 160
Circuits from SOP Functions [1]
•
Circuits from SOP Functions [2]
• Why simplification?
Steps to implement a circuit:
– NAND and NOR gates are simpler (faster, smaller)
than NOT AND and NOT OR
– Simpler, faster (?) to use small number of gate
types
– Ultimately, want to implement circuit using a small
complete set of operators (discussed later)
1. Write down truth table
2. Provide inverters (NOTs) to generate complement
of each input
3. Draw an AND gate for each term with 1 as result
4. Wire the AND gates to inputs
5. Feed outputs of all AND gates to an OR gate
6. Simplify circuit, e.g:
• NAND and NOR are both complete because any Boolean
function can be implemented with either
– Faster to use small number of inputs to a gate
(fan-in) and small number of gate inputs from a
gate output (fan-out)
1. Replace NOT AND with NAND, NOT OR with NOR (for
efficiency)
2. Replace large-number-of-input (say ≥ 10) gates with
many smaller-number-of-input (<10) input gates (for
efficiency and timing)
CS 160
Ward 22
• Typically, fan-in and fan-out limited to < 10
Ward 23
CS 160
Ward 24
Cascading to Reduce Inputs
Basic Laws of Boolean Algebra
• Boolean algebra follows many algebra rules
which can be used to make simpler circuits
Example: AB + AC = A( B + C ) (3 gates vs 2 gates)
CS 160
Ward 25
Equivalent Gates/Symbols
AND
CS 160
Ward 26
Functionally Complete Sets of Gates
From these Boolean laws (identities), alternative symbols
(implementations) for some gates can be derived:
NAND
CS 160
NOR
• Not all gate types are typically implemented in
circuit design. Simpler if only 1 or 2 types of
gates are used.
• A functionally complete set of gates means that
any Boolean function can be implemented using
only the gates in the set.
• Examples of functionally complete set
–
–
–
–
–
OR
Ward 27
CS 160
AND, OR, NOT
AND, NOT
OR, NOT
NAND
NOR
Ward 28
NAND & NOR Completeness
Implement XOR with NANDs [1]
•
Exclusive-OR example
–
Truth table (step 1)
–
First circuit from truth
table (steps 2 – 5)
_
Making (a) NOT, (b) AND, (c) OR with NAND or NOR
CS 160
_
XOR = A ⊕ B = A B + A B
Ward 29
CS 160
Implement XOR with NANDs [2]
Ward 30
Implement XOR with NANDs [3]
– Using Boolean algebra rules
Circuits implementing XOR (in addition to the one
given from sop on slide 29):
Last formula is 3 NAND gates (see next slide)
CS 160
Ward 31
CS 160
Ward 32
Other Examples
Simplification
• Boolean functions (and therefore circuits) can
frequently be manipulated using Boolean laws
into simpler functions (circuits), e.g.,
ABC + AC + AB
= A(BC + BC)
= (A + B)A + (A + B)B
(A + B) (A + B)
= A(BC + B + C)
=A1 = A
= AA + AB + AB + BB
(A + B) (A + B) (BC + B + C)
= A(1 + B + B) + 0
= A(1 + 1)
= A(1)
=A
CS 160
Ward 33
(previous slide)
(above)
= A
Ward 34
XOR Operations [2]
_
Recall XOR = A ⊕ B = A B + A B ( 1 if A≠B; 0 otherwise )
A ⊕ 0 = A⋅0 + A⋅1 = A
_
_
XOR = A ⊕ B = A B + A B
A ⊕ B ⊕ C = (A ⊕ B) ⊕ C
A ⊕ 1 = A⋅1 + A⋅0 = A
= (A ⊕ B)C + (A ⊕ B)C
A ⊕ A = A⋅A + A⋅A = 0
= (AB + AB)C + (AB + AB)C
A ⊕ A = A⋅A + A⋅A = 1
A ⊕ B = A⋅B + A⋅B = A ⊕ B
Verify on your own
A ⊕ B = A⋅B + A⋅B = A ⊕ B
Hint: start with the
definition of XNOR
CS 160
1
CS 160
XOR Operations [1]
_
A
Ward 35
= ABC + ABC + ABC + ABC
(sop form)
CS 160
Ward 36
A ⊕ B ⊕ C Truth Table
A
0
0
0
0
1
1
1
1
CS 160
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
A⊕B⊕C
0
1
1
0
1
0
0
1
Thus, output TRUE iff
odd-number of Boolean
variables are TRUE.
Used for memory check.
Ward 37