You are on page 1of 64

2 .

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

ROM 2n m-bit words

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

We need a tool that helps us to minimize the number of gates:

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

P 2 – To each operation corresponds a neutral element: ∀a ∈ B , a + 0 = a, a ⋅1 = a

P 3 – To each element corresponds an inverse element: ∀a ∈ B , ∃ a ∈ B | a + a = 1, a ⋅ a = 0

P 4 – Operations + and · are conmutative: a + b = b + a, a ⋅ b = b ⋅ a

P 5 –Operations + and · are distributive: a ⋅ (b + c ) = a ⋅ b + a ⋅ c, a + b ⋅ c = ( a + b) ⋅ ( a + c )

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

Example: check that a·(b+c) = a·b + a·c

abc b+c a·(b+c) a·b a·c a·b+ a·c


ab a·b a+b ⎯a 000 0 0 0 0 0
00 0 0 1 001 1 0 0 0 0
01 0 1 1 010 1 0 0 0 0
011 1 0 0 0 0
10 0 1 0
100 0 0 0 0 0
11 1 1 0 101 1 1 0 1 1
110 1 1 1 0 1
111 1 1 1 1 1

23
1. Boolean algebra
g

Comment:

a·(b+c) = a·b + a·c =>

|||

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),

The neutral elements are the constant functions 0 and 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

7 - de Morgan law: ( a + b ) = a·b, 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

f ( a , b, c ) = b.c + a.b abc ⎯c b ·⎯c ⎯a ⎯a · b f


000 1 0 1 0 0
001 0 0 1 0 0
010 1 1 1 1 1
011 0 0 1 1 1
100 1 0 0 0 0
101 0 0 0 0 0
110 1 1 0 0 1
111 0 0 0 0 0

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

A variable or an inverted variable : a, a, b, b, c, c, ...

n-variable MINTERM

A product of n literals such that each variable appears only once. Example: if n=3, there
are eight minterms.

a.b.c, a.b.c , a.b .c, a.b .c , a .b.c, a .b.c , a .b .c, a .b .c


32
2 .2
3. Boolean functions and truth tables
Given a MINTERM m, there is one, an only one, set of variable values such that m = 1.
With n = 3:
a b c
a.b.c = 1 ⇔ 0 0 0 → m0 = a.b.c
a.b.c = 1 ⇔ 0 0 1 → m1 = a.b.c
a.b.c = 1 ⇔ 0 1 0 → m2 = a.b.c
a.b.c = 1 ⇔ 0 1 1 → m3 = a.b.c
a.b.c = 1 ⇔ 1 0 0 → m4 = a.b.c
a.b.c = 1 ⇔ 1 0 1 → m5 = a.b.c
a.b.c = 1 ⇔ 1 1 0 → m6 = a.b.c
a.b.c = 1 ⇔ 1 1 1 → m7 = a.b.c
33
(quiz)
What expression corresponds to minterm-5 (m5 ) of n = 4 variables?

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.

Any Boolean function can be represented by a b c f(a,b,c)


the sum of its minterm.
0 0 0 0
0 0 1 0
0 1 0 1 → m2 = a.b.c
f ( a, b, c ) = Σ( m2 , m3 , m6 )
0 1 1 1 → m3 = a.b.c
f ( a, b, c ) = a.b.c + a.b.c + a.b.c
1 0 0 0
1 0 1 0
1 1 0 1 → m6 = a.b.c
1 1 1 0
36
2 .2
3. Boolean functions and truth tables
if ((a=1 and b=1 and c=0) or (a=0 and b=1)) then f=1;
else f=0;
end if;

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:

Exercise: the same for NOR gates 45


1. NAND, NOR
2 .3

3-input, 4-input, ··· NAND and NOR gates can be defined:

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

BUT NAND and NOR are not associative operations. In particular:

NAND(1, 1, 1) = 0 NAND(NAND(1 1),


NAND(NAND(1, 1) 1) = NAND(0,
NAND(0 1) = 1

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?

 Iff we use “of


“ f the
h shelf”
h lf” components (laboratory)
(l b ) we only
l need
d one type off gate.
 In CMOS technology
- an AND ggate is implemented
p with a NAND and an INV,,

- an OR gate is implemented with a NOR and an INV.

=> 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:

1-bit adder is the basic component of practically all arithmetic circuits;

It computes two functions:


 carryOUT = 1 iff x + y + carryIN ≥ 2;
2
 s = (x + y + carryIN) mod 2 = x ⊕ y ⊕ carryIN.

57
2 .3
2. XOR,, XNOR

Condition x + y + carryIN ≥ 2 is equivalent to

((x = 1) and (y = 1))


or ((carryIN = 1) and (x ≠ y));

Thus

carryOUT = x·y + carryIN ·(x ⊕ y),

s = x ⊕ y ⊕ carryIN.

58
2 .3
2. XOR,, XNOR

4-bit adder (new version):

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

Main application: BUS

Example: 4-bit bus

cA = 1 and cB = 0: circuit A → circuit C;


cA = 0 and cB = 1: circuit B → circuit C;

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

You might also like