Professional Documents
Culture Documents
Week 2 - Lectures PDF
Week 2 - Lectures PDF
1 COMBINATIONAL CIRCUITS
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
2 .1
1. Combinational circuits
Digital circuits that implement one or several switching functions, in such a way that, at
any time, the output signal values only depend on the input signal values at the same
time.
time
Combinational
… circuit …
2
temp onoff
0 ON
This is NOT the definition of a
combinational circuit 1 ON
… …
18 ON
19 ON
20 DON’TT CHANGE
DON
21 OFF
22 OFF
… …
49 OFF
50 OFF
3
2 .1
1. Combinational circuits
Adder of two 4-bit numbers (4-bit adder)
4-bit adder
s <= X + Y + carryIN;
if s > 1111 then Z(3 downto 0) <= s - 10000; carryOUT <= 1;
else Z(3 downto 0) <= s; carryOUT <= 0;
end if;
4
2 .1
2.1 Synthesis
y from a table: ROM
Adder of two 4-bit numbers (4-bit adder)
4-bit adder
5
….
TRUTH TABLE
….
29w
words (512),, 5 bits per w
word ROM
6
2.1 Synthesis
y from a table: ROM
CC with n inputs and m outputs → ROM with 2n words, m bits per word
Combinational
… … circuit …
…
BUT generally inefficient !
7
2 .1
(quizz))
(q
Minimum size (number of words, number of bits per word of a ROM that implements
an 8-input,
p , 16-output
p combinational circuit?
1. 8 16-bit words
2
2. 23 16-bit
16 bit words
d
3. 28 16-bit words
4. 16 8-bit words
5. 24 8-bit words
6. 216 8-bit words
8
2 .1
2.2 Synthesis
y from a table: logic
g Gates
4-bit adder
2-level hierarchy
9
2 .1
2.2 Synthesis
y from a table: logic
g Gates
x x
z z x z
y y
x y z x y z
0 0 0 0
0 1 0 1
1 0 1 0 INV
1 1 1 1
AND OR
10
2 .1
2.2 Synthesis
y from a table: logic
g Gates
c0 = 1 iff
((x y ci = 011)) OR ((x y ci = 101)) OR ((x y ci = 110)) OR ((x y ci = 111))
x y ci = 011 iff
(x = 0) AND (y = 1) AND (ci = 1)
x = 0 iff INV(x) = 1
11
2 .1
2.2 Synthesis
y from a table: logic
g Gates
c0 = 1 iff
(x y ci = 011) OR (x y ci = 101) OR (x y ci = 110) OR (x y ci = 111)
x y ci = 011 iff
(x = 0) AND (y = 1) AND (ci = 1) (x y ci = 011)
x = 0 iff INV(x) = 1
(x y ci = 101)
(x y ci = 110)
(x y ci = 111) 12
2 .1
2.2 Synthesis
y from a table: logic
g Gates
c0 = 1 iff
(x y ci = 011) OR (x y ci = 101) OR (x y ci = 110) OR (x y ci = 111)
q
equivalent to
c0 = 1 iff
(x y ci = 011) OR (x y ci = 101) OR (x y = 11)
13
2 .1
BOOLEAN ALGEBRA
14
2 .1
((Exercise)) Synthesize the function z with
logic gates.
15
2 .1
((solution)) Synthesize the function z with
logic gates.
z = 1 iff
(x y ci = 001) OR (x y ci = 010) OR (x y ci = 100) OR (x y ci = 111)
(x y ci = 001)
(x y ci = 010)
(x y ci = 100)
(x y ci = 111)
16
2 .1
SUMMARY
Combinational circuits.
ROM (table) implementation.
A first approach to logic gate implementation.
17
2 .1
18
2 .2 BOOLEAN ALGEBRA
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
2 .2
1. Boolean algebra
g
A Boolean algebra B is a finite set over which two binary operations + (sum) and · (product) and
satisfy five postulates.
20
2 .2
1. Boolean algebra
g
P 1 - Operations + and · are internal: ∀a , b ∈ B , a + b ∈ B y a ⋅ b ∈ B
21
2 .2
1. Boolean algebra
g
The set {0, 1} is a Boolean algebra if the operations are defined as follows:
ab a·b a+b ⎯a
00 0 0 1
01 0 1 1
10 0 1 0
11 1 1 0
22
1. Boolean algebra
g
23
1. Boolean algebra
g
Comment:
|||
24
1. Boolean algebra
g
The set of n-variable switching functions
{0 1}n → {0,
F: {0, {0 1}
is also a Boolean algebra. Given two switching functions f and g, then f + g, f · g and⎯f are
defined as follows:
(f + g)(x0, x1, ··· , xn-1) = f(x0, x1, ··· , xn-1) + g(x0, x1, ··· , xn-1),
(f · g)(x0, x1, ··· , xn-1) = f(x0, x1, ··· , xn-1) · g(x0, x1, ··· , xn-1),
25
2 .2
2. Some useful properties
p p
1 – Neutral element properties: 0 = 1, 1 = 0
2 – Idempotence:
p a + a = a, a ⋅ a = a
a = a + 0 = a + (a ·⎯a)
a) = (a + a)
a)·(a
(a ++⎯a)
a) = P1 - ∀a, b ∈ B, a + b ∈ B y a ⋅ b ∈ B
(a + a)·1 = a + a
P2 - ∀a ∈ B, a + 0 = a, a ⋅1 = a
P3 - ∀a ∈ B, ∃ a ∈ B | a + a = 1, a ⋅ a = 0
P4 - a + b = b + a, a ⋅ b = b ⋅ a
P5 - a ⋅ (b + c) = a ⋅ b + a ⋅ c, a + b ⋅ c = (a + b) ⋅ (a + c)
26
2 .2
(Exercise)
Demonstrate that a ⋅ a = a
Hint: Use the second part of P2
P2, P3 and P5
P5.
P1 - ∀a, b ∈ B, a + b ∈ B y a ⋅ b ∈ B
P2 - ∀a ∈ B, a + 0 = a, a ⋅1 = a
P3 - ∀a ∈ B, ∃ a ∈ B | a + a = 1, a ⋅ a = 0
P4 - a + b = b + a, a ⋅ b = b ⋅ a
P5 - a ⋅ (b + c) = a ⋅ b + a ⋅ c, a + b ⋅ c = (a + b) ⋅ (a + c)
27
2 .2
(Solution)
Demonstrate that a ⋅ a = a
Hint: Use the second part of P2
P2, P3 and P5
P5.
a = a · 1 = a · (a ++⎯a)
a) = (a · a) + (a ·⎯a)
a) = P1 - ∀a, b ∈ B, a + b ∈ B y a ⋅ b ∈ B
(a · a) + 0 = a · a
P2 - ∀a ∈ B, a + 0 = a, a ⋅1 = a
P3 - ∀a ∈ B, ∃ a ∈ B | a + a = 1, a ⋅ a = 0
a = a + 0 = a + ((a ·⎯a)) = ((a + a)·(a
) ( +⎯a)) =
(a + a)·1 = a + a P4 - a + b = b + a, a ⋅ b = b ⋅ a
P5 - a ⋅ (b + c) = a ⋅ b + a ⋅ c, a + b ⋅ c = (a + b) ⋅ (a + c)
28
2 .2
2. Some useful properties
p p
1 – Neutral element properties: 0 = 1, 1 = 0
2 – Idempotence:
p a + a = a, a ⋅ a = a
3 – Involution: a = a
4 – Asociativity: a + (b + c) = (a + b) + c, a·(b·c) = (a·b)·c
5 – Absortion law: a + a·b = a, a ⋅ (a + b) = a
6 - (nameless): a + a·b = a + b, a ⋅ ( a + b ) = a·b
8 – generalized de Morgan law: (a1 + a2 + ... + a n ) = a1·a2 ·...·an , a1·a2 ·...·an = a1 + a2 + ... + an
29
2 .2
(quizz)
What Boolean expression is equivalent to the following : a ⋅ (b + cd ) + a.b ?
Hint: Use postulates and properties
1. a.b + b.c + d
2. a.b
3. a.b + b.c + d
4. a.b + b.c + b.d
30
2 .2
3. Boolean functions and truth tables
a) Any Boolean function can be explicitely defined by a truth table
31
2 .2
3. Boolean functions and truth tables
b) Given a truth table can we find an equivalent Boolean function?...
Answer is YES
LITERAL
n-variable MINTERM
A product of n literals such that each variable appears only once. Example: if n=3, there
are eight minterms.
1. a.b.c.d
2. a.b.c
3. a.b.c.d
4. a.b.c.d
34
2 .2
3. Boolean functions and truth tables
MINTERMS of an n-variable Boolean function f ?
= minterms that correspond to the 1s of f.
a b c f(a,b,c)
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0
35
2 .2
3. Boolean functions and truth tables
Canonical sum of products representation of an n-variable Boolean function.
a b c f(a,b,c)
0 0 0 0
0 0 1 0 f ( a, b, c ) = a.b.c + a.b.c + a.b.c =
0 1 0 1
= a.b( c + c ) + b.c.( a + a ) = a.b + b.c
0 1 1 1
1 0 0 0
f ( a, b, c ) = Σ( m2 , m3 , m6 )
1 0 1 0
f ( a, b, c ) = a.b.c + a.b.c + a.b.c
1 1 0 1
1 1 1 0
37
4. Example: 4 bit-adder
2 .2
4-bit adder
38
4. Example: 4 bit-adder
2 .2
39
4. Example: 4 bit-adder
2 .2
40
SUMMARY
Boolean algebra. Postulates and properties.
Tabular representation of Boolean functions.
Minterms and canonical sum of products expression.
Circuit generation from a functional description:
(functional description → truth table → Boolean function(s) → circuit)
41
42
2 .3 NAND, NOR, XOR, XNOR, TRI-STATE
Jean-Pierre Deschamps
University Rovira i Virgili, Tarragona, Spain
1. NAND, NOR
2 .3
≡
≡
ab NAND(a,b)
NAND(a b) NOR(a,b)
NOR(a b)
00 1 1 Algebraic symbols:
01 1 0 NAND(a, b) = a ↑ b,
10 1 0
11 0 0 O ( b) = a ↓ b.
NOR(a, b
44
1. NAND, NOR
2 .3
NAND and NOR gates are universal modules. For example, with NAND gates:
NAND(a b
NAND(a, b, c) = 0 iff a = b = c = 1
NAND(a, b, c, d) = 0 iff a = b = c = d = 1
··············
NOR(a, b, c) = 0 iff (a = 1) OR (b = 1) OR (c = 1)
NOR(a, b, c, d) = 0 iff (a = 1) OR (b = 1) OR (c = 1) OR (d = 1)
46
1. NAND, NOR
2 .3
NOR(0 0,
NOR(0, 0 0) = 1 NOR(NOR(0 0)
NOR(NOR(0, 0), 0) = NOR (1
(1, 0) = 0
47
2 .3
(quiz)
Which of the following circuits implements the AND function z = a·b ?
48
2 .3
(Exercise)
Implement the same function with NAND gates.
49
2 .3
(solution)
Implement the same function with NAND gates.
50
1. NAND, NOR
2 .3
Why do we use NAND gates ( or NOR gates) instead of AND and OR gates?
=> Within an IC (Integrated Circuit) NAND and NOR are “cheaper” than AND and OR.
51
2 .3
2. XOR,, XNOR
ab XOR(a,b) XNOR(a,b)
00 0 1
01 1 0
10 1 0
11 0 1
Algebraic symbols:
XOR (= eXclusive OR): XOR(a, b) = 1 if a ≠ b;
XOR(a, b) = a ⊕ b,
XNOR ((= eXclusive NOR): XNOR(a, b) = 1 if a = b.
( O ( b) = a ≡ b)
(XNOR(a,
52
2 .3
2. XOR,, XNOR
Equivalent definition:
XOR(a, b) = (a + b) mod 2 = a ⊕ b,
XNOR(a, b) = INV(a ⊕ b).
=> 3-input, 4-input, ··· XOR and XNOR gates can be defined:
XOR( b,
XOR(a, b c)) = (a d 2 = a ⊕ b ⊕ c, XNOR(a,
( + b + c)) mod XNOR( b, INV( ⊕ b ⊕ c),
b c)) = INV(a )
XOR(a, b, c, d) = (a + b + c + d) mod 2 = a ⊕ b ⊕ c ⊕ d, XNOR(a, b, c, d) = INV(a ⊕ b ⊕ c ⊕ d),
···
XOR is an associative operation =>
≡ ≡
53
2 .3
2. XOR,, XNOR
XOR y NXOR are not universal modules,
useful functions.
First example: magnitud comparator. Given two 4-input vectors a = a3 a2 a1 a0 and b = b3 b2 b1 b0,
generate comp = 1 iff a = b.
Algorithm
if (a
( 3 ≠ b3) or (a
( 2 ≠ b2) or (a
( 1 ≠ b1) or (a
( 0 ≠ b0)
then comp <= 0;
else comp <= 1;
end if;;
54
2 .3
2. XOR,, XNOR
Observation:
Second example: parity bit generation. a vector ak-1 ak-2 ··· a0 has an even
Given an n-input vector
number of 1’s
1 s iff
a = an-1 an-2 ··· a1 a0 (ak-1 + ak-2 + ··· + a0) mod 2 = 0,
its parity bit is and additional bit an such that the and
extended vector
ak-1 ⊕ ak-2 ⊕ ··· ⊕ a0 = 0.
aext = an an-1 an-2 ··· a1 a0
Algorithm – Parity bit generation
has an even number of 1’s. It is used for a(n) <= a(n-1) xor a(n-2) xor ··· xor a(0);
error detection purpose:
Algorithm – Parity check
error <=
<
a(n) xor a(n-1) xor a(n-2) xor ··· xor a(0);
55
2 .3
2. XOR,, XNOR
56
2 .3
2. XOR,, XNOR
The main application of XOR gates is Arithmetic:
57
2 .3
2. XOR,, XNOR
Thus
s = x ⊕ y ⊕ carryIN.
58
2 .3
2. XOR,, XNOR
59
2 .3
3. BUFFER TRI-STATE,, INVERSOR TRI-STATE
cx y
00 High impedance (Z)
01 High impedance (Z)
10 0
11 1
cx y
00 High impedance (Z)
01 High impedance (Z)
10 1
11 0
60
2 .3
3. BUFFER TRI-STATE,, INVERSOR TRI-STATE
cx y
00 0
01 1
10 High impedance (Z)
11 High
g impedance
p (Z)
cx y
00 1
01 0
10 High impedance (Z)
11 High impedance (Z)
61
2 .3
3. BUFFER TRI-STATE,, INVERSOR TRI-STATE
62
nombre símbolo función 2 .3
AND
OR
INV
NAND
NOR
XOR
XNOR
Tri-state
63
2 .3
SUMMARY
NAND, NOR. Universal module concept.
XOR, XNOR
Tri-state buffers. Bus.
64