0% found this document useful (0 votes)
3 views

Chapter3-Boolean Algebra and Digital Logic

Chapter 3 discusses the principles of Boolean algebra and its application in digital logic design, emphasizing the relationship between Boolean logic and computer circuits. It covers the basics of Boolean functions, operators, and laws, as well as the design and simplification of logic circuits using truth tables and canonical forms. The chapter also introduces various logic gates, including AND, OR, NOT, NAND, NOR, and XOR, and their roles in creating combinational and sequential logic circuits.

Uploaded by

sumitghoshw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter3-Boolean Algebra and Digital Logic

Chapter 3 discusses the principles of Boolean algebra and its application in digital logic design, emphasizing the relationship between Boolean logic and computer circuits. It covers the basics of Boolean functions, operators, and laws, as well as the design and simplification of logic circuits using truth tables and canonical forms. The chapter also introduces various logic gates, including AND, OR, NOT, NAND, NOR, and XOR, and their roles in creating combinational and sequential logic circuits.

Uploaded by

sumitghoshw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 96

Chapter 3 – Boolean Algebra

and Digital Logic

CS 271 Computer Architecture


Purdue University Fort Wayne
1
Objectives
 Understand the relationship between Boolean
logic and digital computer circuits.
 Learn how to design simple logic circuits.
 Understand how digital circuits work together to
form complex computer systems.

2
Introduction
 In the latter 19th century, George Boole suggested
that logical thought could be represented through
mathematical equations.
 Boolean algebra is everywhere
 https://www.google.com/doodles/george-booles-
200th-birthday

3
Application of Boolean Algebra

 Digital circuit
 Google search
 Database (SQL)
 Programming
 ……

4
An Example on Programming
while (((A && B) || (A && !B)) || !A)
{
// do something
}

5
3.2 Boolean Algebra
 Boolean algebra is a mathematical system for
manipulating variables that can have one of two
values.
 In formal logic, these values are “true” and
“false”
 In digital systems, these values are
“on”/“off,” “high”/“low,” or “1”/”0”.
 So, it is perfect for binary number systems
 Boolean expressions are created to operate
Boolean variables.
 Common Boolean operators include AND, OR,
and NOT.
6
Boolean Algebra
 The function of Boolean operator
can be completely described
using a Truth Table.
 The truth tables of the Boolean
operators AND and OR are
shown on the right.
 The AND operator is also known
as the Boolean product “.”. The
OR operator is the Boolean sum
“+”.
7
Boolean NOT
 The truth table of the
Boolean NOT operator is
shown on the right.
 The NOT operation is
most often designated by
an overbar “‾”.
 Some books use the prime
mark (‘) or the “elbow” (),
for instead.

8
Boolean Function
 A Boolean function has:
• At least one Boolean variable,
• At least one Boolean operator, and
• At least one input from the set of {0,1}.
 It produces an output that is a member of the
set {0,1} – Either 0 or 1.

Now you know why the binary numbering system


is so handy for digital systems.

9
Boolean Algebra
 Let’s look at a truth table
for the following Boolean
function shown on the
right. :

 To valuate the Boolean


function easier, the truth
table contains a extra
columns (shaded) to hold
the evaluations of partial
function.
10
Rules Of Precedence
 Arithmetic has its rules of
precedence
 Like arithmetic, Boolean
operations follow the rules
of precedence (priority):
 NOT operator > AND
operator > OR operator .
 This explains why we
chose the shaded partial
function in that order in
the table. Rules Of Precedence

11
Use Boolean Algebra in Circuit
Design
 Digital circuit designer always like achieve the following
goals:
 Cheaper to produce
 Consume less power
 run faster
 How to do it? -- We know that:
 Computers contain circuits that implement Boolean functions 
Boolean functions can express circuits
 If we can simplify a Boolean function, that express a circuit, we can
archive the above goals
 We always can reduce a Boolean function to its
simplest form by using a number of Boolean laws
can help us do so. 12
Boolean Algebra Laws
 Most Boolean algebra laws have either an AND
(product) form or an OR (sum) form. We give the
laws with both forms.
 Since the laws are always true, so X (and Y) could be
either 0 or 1

13
Boolean Algebra Laws (‘Cont)
 The second group of Boolean laws should be
familiar to you from your study of algebra:

14
Boolean Algebra Laws (‘Cont)
 The last group of Boolean laws are perhaps the
most useful.
 If you have studied set theory or formal logic, these laws
should be familiar to you.

15
DeMorgan’s law
 DeMorgan’s law provides an easy way of finding the
negation (complement) of a Boolean function.
 DeMorgan’s law states:

 Example More Examples?


 I will come to school tomorrow if
 (A) my car is working, and
 (B) it won’t be snowing

=  I won’t come to school tomorrow if


 (A) my car is not working, or
16
 (B) it will snowing
DeMorgan’s Law
 DeMorgan’s law can be extended to any number
of variables.
 Replace each variable by its negation (complement)
 Change all ANDs to ORs and all ORs to ANDs.
 Let’s say F (X, Y, Z) is the following, what is 𝐹ത ?

17
Simplify Boolean function
 Let’s use Boolean laws to simplify:

as follows:

18
Logic simplification steps

 Apply De Morgan’s theorems


 Expanding out parenthesis
 Find the common factors
 Popular rules used:
X+XY=X X+X=X, XX=X
XY+XY=X X+0=X, X+1=1
X+XY=X+Y X0=0 X1=X
19
Example (1)
 Apply De Morgan’s theorem
WXYZ W+X+Y+Z

(A+B+C)D

AB+CD+EF

20
Example (2)

 (AB(C+BD)+AB)C

21
Example (3)

 ABC+ABC+ABC+ABC+ABC

22
Example (4)

 (AB+AC)+ABC

23
Example (5)

 AC+ABC+ABCD+ABD

24
Example (6)
 (A+B+C)(B+C)(A+B)

25
An Example on Programming
while (((A && B) || (A && !B)) || !A)
{
// do something
}
=
while (1)
{
// do something
} 26
Boolean Algebra
 Through our exercises in simplifying Boolean
expressions, we see that there are 1+ ways of
stating the same Boolean expression.
 These “synonymous” forms are logically equivalent.
 Logically equivalent expressions could produce
confusions
=XZ
 In order to eliminate the confusion, designers
express Boolean express in unified and
standardized form, called canonical form.
27
Boolean Algebra
 There are two canonical forms for Boolean expressions:
sum-of-products and product-of-sums.
 Boolean product (x) AND logical
conjunction operator
 Boolean sum (+)  OR logical conjunction
operator
 In the sum-of-products form, ANDed variables are
ORed together.
 For example:
 In the product-of-sums form, ORed variables are
ANDed together:
 For example:
28
Minterm and Maxterm
 Some books uses sum-of-minterms form and
product-of-maxterms form
 A minterm is a logical expression of n
variables that employs only the complement
operator and the product operator.
 For example, abc, ab'c and abc' are 3 minterms
for a Boolean function of the three variables a, b,
and c.
 A maxterm is a logical expression of n
variables that employs only the complement
operator and the sum operator.
29
Create Canonical Form Via
Truth Table
 It is easy to convert a function
to sum-of-products form from
its truth table.
 We only interested in the
production of the inputs which
yields TRUE (=1).
 We first highlight the lines that
result in 1.
 Then, we group them together
with OR.

30
Create Canonical Form Via Truth
Table (‘Cont)
 Look at this example:

 It may not the simplest


form. But, it is the standard
sum-of-products canonical
form
31
Exercise
 Convert ABC+A'BC+AB'C+A'B'C+ABC'
to its simplest form

32
Exercise
 Convert AB + C to the sum-of-products
form

AB+C

33
3.3 Logic Gates
 We’ve seen Boolean functions in abstract terms.
 You may still ask:
 How could Boolean function be used in
computer?
 In reality, Boolean functions are implemented as digital
circuits, which called Logic Gates.
 A logic gate is an electronic device that produces a
result based on input values.
 A logic gate may contain multiple transistors, but, we
think them as one integrated unit.
 Integrated circuits (IC) contain collections of gates,
for a particular purpose.
34
AND, OR, and NOT Gates
 Three simplest gates are the AND, OR, and NOT
gates. “inversion
bubble”

 Their symbol and their truth tables are listed above.

35
NAND and NOR Gates
 NAND and NOR
are two additional
gates.
 Their symbols and
truth tables are
shown on the
right.
 NAND = NOT
AND
 NOR = NOT OR

36
The Application of NAND and
NOR Gates
 NAND and NOR are
known as universal
gates! – gates of all
gates
 They are inexpensive
to produce
 More important: Any
Boolean function can
be constructed using
only NAND or only
NOR gates.
37
Multiple Inputs and Outputs of
Gates
 The gates could have multiple inputs and/or multiple
outputs.
 The second output can be provided as the
complement of the first output.
 We’ll see more integrated circuits, which have
multiple inputs/outputs.

39
XOR Gates
 Another very useful gate is the Exclusive OR (XOR)
gate.
 The output of the XOR operation is true (1) only when
the values of inputs are different.

 The symbol for XOR is 


40
Parity generator / checker
 Electrical noise in the transmission of
binary information can cause errors
 Parity can detect these types of
errors
 Parity systems
 Odd parity
 Even parity
 Add a bit to the binary information

41
Even parity check
 Even parity check
 Example: input: A(7…0), Output:
even_parity bit
 If there are even numbers of 1 in A,
even_parity = ‘0’,
 If there are odd numbers of 1 in A,
even_parity = ‘1’
e.g., A = “10100001”,
even_parity = ‘1’
A = “10100011”,
even_parity = ‘0’
42
Odd parity check
 Odd parity check
 Example: input: A(7…0), Output:
odd_parity bit
 If there are odd numbers of 1 in A,
odd_parity = ‘0’,
 If there are even numbers of 1 in A,
odd_parity = ‘1’
e.g., A = “10100001”,
odd_parity = ‘0’
A = “10100011”,
43
odd_parity = ‘1’
Odd-parity generator/checker
system

44
Error detection
 Transmitting end: The parity generator
creates the parity bit.
 Receiving end: The parity checker
determines if the parity is correct.
 e.g., odd-parity check of 8-bit data
 Data send: 10111101 + 1
 Data received: 101011011
odd-parity check: The number of 1 is even →
error
45
Discussion point
 What are disadvantages of even parity
(or odd parity) check to detect
transmission errors? Consider the
following case:
 Protocol: 8-bit plus one even parity bit
 Information sent: 11011100 + 1
 Information received: 10010100 + 1
 The parity generator/checker system
detects only errors that occur to 1 bit.
46
Parity check using XOR
 N-1 XOR gates can be cascaded to form a
circuit with N inputs and a single output
– even-parity circuit.
 Example: N=8, Inputs=10111101, even-parity
output
=((10)(11))((11)(01))=0
 Odd-parity check circuit: even-parity check
circuit Inverted Odd-parity check
 Example: N=8, Inputs=10111101, odd-parity
output
=NOT(((10)(11))((11)(01)))=1 47
Binary comparators
 A one-bit comparator is the same as the XOR
4-bit comparator

1-bit comparator

 A n-bit comparator determines if two n-bit signal vectors


are equal:
EQ(X[1:n],Y[1:n])=(X1=Y1)(X2=Y2)….(Xn=Yn)
48
Two Types of Logic Circuits
 Combinational Logic Circuit (CLC)
 Good at designing computational
components in the CPU, such as ALU
 Sequential Logic Circuit (SLC)
 Good at designing memory components,
such as registers and memory

49
Logic Gates
 We use the combination of gates to implement
Boolean functions.
 The circuit below implements the Boolean function:

50
3.5 Combinational
Circuits
 The circuit implements the Boolean function:

 The major characteristics of this kind of circuits:


 The circuit produces an output almost immediately
after the inputs are given.
 This kind of circuits are called combinational
logic circuit (CLC).
 In a later section, we will explore circuits
where this is not the case.

51
Simplify CLC via Boolean
Algebra
 As I have mentioned previously:
 The simpler that we can express a Boolean function,
the smaller the circuit will be constructed.
 Simpler circuits are cheaper  consume less
power  run faster than complex circuits.
 We always want to reduce a Boolean function to its
simplest form.
 It is important to simplify combinational logic circuit
via Boolean algebra laws

52
Simplify CLC via Boolean
Can we simplify
Algebra this circuit? If
yes, then how?

 Look at this example

=
=

53
Steps to Simplify a Complex
Circuit
 From this example, we know that the
basic steps to simplify a complex
circuit is the following:
 Step1: Express a logical circuit into a
Boolean expression
 Step2: Simplify the Boolean expression
as much as possible
 Step3: Re-express the simplified
expression back to a circuit.

54
Example of Simplify a Logical
Circuit
 Simplify the following circuit

55
Example of Simplify a Logical
Circuit
 Step1: Express a logical circuit into a
Boolean expression

56
Example of Simplify a Logical
Circuit
 Step2: Simplify the Boolean expression
as much as possible

57
Example of Simplify a Logical
Circuit
 Step3: Re-express the simplified
expression back to a circuit

Obviously, the simplified circuit is much


simpler than the original one
58
Combinational Circuits: Half
Adder
 Combinational logic circuits
can be used to create many
useful devices.
 Half Adder: Compute the
sum of two bits.
 Let’s gain some insight of
how to construct a half
adder by looking at its truth
table on the right.

59
Combinational Circuits: Half
Adder (‘Cont)
 It consists two gates:
 a XOR gate -- the sum bit
 a AND gate -- the carry bit

60
Combinational Circuits: Full
Adder
 We can extend the half
adder to a full adder,
which includes an
additional carry bit
(Carry In)
 The truth table for a full
adder is shown on the
right.

61
Half Adder  Full Adder ?
 How can we extend the
half adder to a full
adder?

 Hint: First calculate X + Y by a half adder,


then the sum adds the carry in bit, then…… 62
The Full Adder

63
Ripple-carry Adder
 Just as we combined half adders to construct a
full adder, full adders can be connected in series.
 The carry bit “ripples” from one adder to the next.
This configuration is called a ripple-carry adder.

 This is the full adder for two 16 bits!

64
Decoder
 Decoder is another important combinational circuit.
 It is used to select a memory location according a
address in binary form
 Application: given a memory address  Obtain its
memory content.
 Address decoder with n inputs can select one out
of 2n locations.

Address Memory
Lines
65
Decoder

66
A 2-to-4 Decoder
 This is a 2-to-4 decoder :
Memory
0
0

1 0

Address:
01
1

Only this piece of


memory will be 67
chosen/accessed
68
74138 as a memory address decoder
Multiplexer
 A multiplexer works just the

Memory
opposite to a decoder.
 It selects a single value
from multiple inputs.
 The chosen input for output
is determined by the value
of the multiplexer’s control
1 0 Address
lines.
 To select from n inputs,
log2n control lines are
required.
69
A four-line multiplexer

What is the logic equation for


the output Y =?
70
Combinational Circuits
 This is a 4-to-1 multiplexer.

which input is transferred to the output? 71


A Simple Two-Bit ALU
3.6 Sequential Logic Circuits (SLC)
 Combinational logic circuits are perfect for those
applications when a Boolean function be immediately
evaluated, given the current inputs.
 Examples: multiplexer, ripple-carry adder, shifter, etc

 However, sometimes, we need a kind of circuits that


change value by considering the current inputs and its
current state.
 Memory is such an example that requires to remember
the current state
 The circuits need to “remember” their states.

 Sequential logic circuits (SLC) provide this functionality.


75
How to “remember”?
 Think about the states in your own
life-time
 1 years old, blabla…
 2 years old, blabla…
 3 years old, blabla…

Time
76
Essential Component of Sequential
Circuits: Clocks
 As the name implies, sequential logic circuits require a
means by which events can be sequenced.
 The change of states is triggered by the clock.
 The “clock” is a special circuit that sends
electrical pulses to a sequential logic circuit.
 Clocks produce electrical waveforms constantly, such
as the one shown below.

77
When Change Its State?
 State changes occur in sequential circuits, only
when the clock ticks.
 A sequential logic circuits could changes it state
 Either, at the rising/falling edge of the clock pulse ,
 Or, when the clock pulse reaches its highest/lowest level.

78
Edge-triggered Or Level-triggered?
 SLC that changes its state at the rising edge, or the
falling edge of the clock pulse is called Edge-
triggered SLC.
 SLC that changes its state when the clock voltage
reaches to its highest or lowest level are called
Level-triggered SLC.
Level-triggered SLC
Edge-triggered SLC

79
Latch And Flip-flop
 latch and flip-flop are two kinds of SLCs,
which are used to construct memory
 A latch is level-triggered
 A flip-flop is edge-triggered
 Which one depends on the length of the clock
pulse?
 Latch, or
 flip-flop?

80
Essential Component Of
Sequential Circuits: Feedback
 The most important design mechanism of SLC is
Feedback
 Feedback can retain the state of sequential circuits
 Feedback in digital circuits occurs when an
output is looped back as an input.
 A simple example of this concept is shown
below.
 If Q is 0 it will always be 0, if it is 1, it will
always be 1. --- The motivation of Memory!

81
SR Flip-flop
 You can see how feedback works by examining
the most basic sequential logic components, the
SR flip-flop.
 The “SR” stands for set/reset.
 The internals of an SR flip-flop are shown below,
along with its block diagram. Clock Driven

82
C
Behavior Of An SR Flip-flop
 The behavior of an SR flip-flop is illustrated in the
following truth table.
 Let’s denote Q(t) as the value of the output at time t, and
 Denote Q(t+1) is the value of Q at time t+1.

C 83
Retain its Change its
original value value

SR Flip-flop Truth Table


 We consider Q(t), its
current output, as the
third input for SR flip-
flop, besides S and R.
Q(t+1)
 The truth table for this =Q(t)
circuit, as shown on the
0
right.
 When both S and R are 1
1, the SR flip-flop is in
forbidden state

forbidden state 84
Clocked SR Flip-flop

85
JK Flip-flop
 One limitation of SR flip-flop is that, when S and
R are both 1, the output is undefined.
 This is not nice because it wastes a state
 Therefore, SR flip-flop can be modified to provide
a stable state when both S and R inputs are 1.

• This modified flip-flop is


called a JK flip-flop,
shown on the right.
- The “JK” is in honor of
Jack Kilby.

86
3.6 Sequential Circuits
 On the right, we see
how an SR flip-flop can
be modified to create a
JK flip-flop.
 The truth table
indicates that the flip-
flop is stable for all
inputs.
 When J and K are
both 1, Q(t+1) = ¬Q(t)
87
An Example
 Let’s say a JK flip-flop is rising-edge triggered
 At t0, Q(t) = 0. What will be the changes of the value of
Q over time?
Time
• Any time other than
the rising edge won’t
trigger this JK flip-flop
to change its state

88
D Flip-flop
 Another modification of the SR flip-flop is the D
flip-flop, shown below with its truth table.
 You will notice that the output of the flip-flop
remains the same during subsequent clock
pulses. The output changes only when the value
of D changes.

89
D Flip-flop
 The D flip-flop is the fundamental circuit of
computer memory.
 D flip-flop and its truth table are
illustrated as below.

90
3.6 Sequential Circuits
 Sequential circuits are used anytime that we
need to design a “stateful” application.
 A stateful application is one where the next state of the
machine depends on the current state of the machine
and the input.
 A stateful application requires both combinational
and sequential logic.
 The following slides provide several examples of
circuits that fall into this category.
Can you think of
others? 91
3.6 Sequential Circuits
 This illustration shows a
4-bit register consisting
of D flip-flops. You will
usually see its block
diagram (below) instead.

A larger memory configuration


is shown on the next slide.
92
3.6 4X3 Memory

Read the
content
Write from the
the memory
content
into the
memory
(0,0); (0,1); (1,0); (1,1);
Choose a word, Wordi 93
(0<=i<=3)
3.6 Sequential Circuits
 A binary counter is
another example of a
sequential circuit.
 The low-order bit is
complemented at
each clock pulse.
 Whenever it changes
from 0 to 1, the next
bit is complemented,
and so on through the
other flip-flops.

94
Synchronous MOD-16 counter
3.7 Designing Circuits
 Digital designers rely on specialized software
to create efficient circuits.
 Thus, software is an enabler for the
construction of better hardware.
 Of course, software is in reality a collection of
algorithms that could just as well be
implemented in hardware.
 Recall the Principle of Equivalence of
Hardware and Software.

95
Designing Circuits
 When we need to implement a simple, specialized
algorithm and its execution speed must be as fast
as possible, a hardware solution is often preferred.
 This is the idea behind embedded systems, which
are small special-purpose computers that we find in
many everyday things.
 Embedded systems require special programming
that demands an understanding of the operation of
digital circuits, the basics of which you have
learned in this chapter.
96
Chapter 3 Conclusion
 Computers are implementations of Boolean
logic.
 Boolean functions are completely described by
truth tables.
 Logic gates are small circuits that implement
Boolean operators.
 The basic gates are AND, OR, and NOT.
 The XOR gate is very useful in parity
checkers and adders.
 The “universal gates” are NOR and NAND.
97
Chapter 3 Conclusion
 Computer circuits consist of combinational logic
circuits and sequential logic circuits.
 Combinational circuits produce outputs almost
immediately when their inputs change.
 Sequential circuits require clocks to control
their changes of state.
 The basic sequential circuit unit is the flip-flop:
The behaviors of the SR, JK, and D flip-flops
are the most important to know.

98
End of Chapter 3

99

You might also like