Chapter 4 Machine Structure 2024
Chapter 4 Machine Structure 2024
Basic Elements
Chapter 4:
Boolean Algebra
2024-2025
A
Circuit F(A,B)
B
2
Machine Structure Course, 1st-year Computer Science Engineer
Introduction (continued)
• To design and build this circuit, we need a
mathematical model of the function
performed by the circuit.
• This model must take into account the binary
system.
• The mathematical model used is that of Boole
(or Boole’s) .
3
Machine Structure Course, 1st-year Computer Science Engineer
Overview
• George Boole was an English mathematician (1815-1864).
• He produced works in which functions (expressions) are made up of
variables that can take the values 'YES' or 'NO'.
• This work has been used to study systems with two mutually exclusive
states:
- The system can only be in two states E1 and E2 such that E1 is the
opposite of E2.
- The system cannot be in state E1 and E2 at the same time.
- This work is well suited to the Binary System (0 and 1).
• Nowadays, Boolean algebra is used in digital electronics for:
- Analysis: a formal tool for describing the operation of digital circuits.
- Design: Starting from the function of a circuit, Boolean algebra enables
us to arrive at a simplified realization (implementation) of this circuit.
4
Machine Structure Course, 1st-year Computer Science Engineer
Example of two-state systems
• A switch is open or not open (closed )
• A lamp is on or off ( off )
• A door is open or not open (closed )
Remarque :
The following conventions can be used :
• YES →TRUE
• NO → FALSE
• YES → 1 ( High Level )
• NO → 0 ( Low Level )
5
Machine Structure Course, 1st-year Computer Science Engineer
Definitions and conventions
• Logic level: When studying a logic system, it's important
to specify the level of the work.
Level Positive Logic Negative Logic
H ( Hight ) 1 0
L ( Low ) 0 1
• Example:
▪ Positive logic: Lamp on=1
Lamp off=0
▪ Negative logic: Lamp on=0
Lamp off=1
6
Machine Structure Course, 1st-year Computer Science Engineer
Logical variable (Boolean)
• A logical variable (Boolean) is a variable that can take
either the value 0 or 1 .
• Generally, it is expressed by a single alphabetic
character in uppercase ( A , B, S , ...).
• Exemple :
▪ A lamp is : On L = 1
Off L = 0
▪ First switch is Open : I1 =1
Closed : I1 =0
▪ 2nd switch is Open : I2=1
Closed : I2=0
7
Machine Structure Course, 1st-year Computer Science Engineer
Logic function
• It's a function that links N logical variables with a set of basic logical
operators.
• In Boolean algebra, there are three basic operators: NOT, AND, and
OR .
• The value of a logic function is equal to 1 or 0, depending on the
values of the logic variables.
• If a logic function has N logic variables 2n combinaisons
the function has 2n values.
A B C F
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 0
1 1 1 1
9
Machine Structure Course, 1st-year Computer Science Engineer
Basic logical operators
NOT (Negation )
NOT: is a unary operator (a single variable) whose role is to invert the
value of a variable.
A
0 1
1 0
10
Machine Structure Course, 1st-year Computer Science Engineer
AND operator
• The AND is a binary operator (two variables), whose role is to
produce a logical product between two Boolean variables.
• AND is the conjunction between two variables.
• AND is defined by : F(A,B)= A . B
• It returns 1 if A and B are 1, otherwise it returns 0
• Both variables must be true together, otherwise the AND is false.
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1
11
Machine Structure Course, 1st-year Computer Science Engineer
OR opearator
• The OR is a binary operator (two variables) whose role is to perform
the logical sum between two logical variables.
• The OR makes the disjunction between two variables.
• The OR is defined by F(A,B)= A + B (not to be confused with the
arithmetic sum).
• It returns 1 if A or B is 1, otherwise returns 0.
• At least one of the two variables is true, otherwise the OR is false.
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
12
Machine Structure Course, 1st-year Computer Science Engineer
Precedence of operators (operator
priority)
To evaluate a logical expression (logical function) :
▪ first, evaluate the sub-expressions between the parentheses or
brackets.
▪ then the complement (NOT),
▪ then the logical product (AND)
▪ then the logical sum (OR)
• Example:
– F(A, B, C) = ( A . B ) . ( C + B) + A .B .C
– First, we calculate the negation, then the logical product (and)
and finally the logical sum (or).
13
Machine Structure Course, 1st-year Computer Science Engineer
Fundamental laws of Boolean algebra
◆ Involution : a=a
◆ Idempotency : a+a=a a.a=a
◆ Complementarity : a .a=0 a+a=1
◆ Neutral elements : a=a .1=1.a=a
a+0=0+a=a
◆ Absorbents : a+1=1 a.0=0
14
Machine Structure Course, 1st-year Computer Science Engineer
Basic properties
➢ Associativite
: (a.b) .c=a.(b.c)
(a+b)+c=a+(b+c)
➢ Distributivite : a.(b+c)=a.b+a.c
a+(b.c)=(a+b).(a+c)
➢ De Morgan's rules : a+b=a . b
a.b=a+b
➢ Optimisations : a+a b=a+b
a+bc=(a+b)(a+c)
15
Machine Structure Course, 1st-year Computer Science Engineer
Summary of the basic properties of Boolean
Algebra
Theorem Logic sum format Logic product format
Absorbent element A+1=1 A.0=0
Neutral element A+0=A A.1=A
– –
Complementation A+ A= 1 A.A =0
Idempotence A+A=A A.A=A
Associativite (A+B)+C = A+(B+C) = A+B+C (A.B).C = A.(B.C) = A.B.C
Commutativite A+B = B+A A.B = B.A
Distributivite A.(B+C) = A.B + A.C A+(B.C) = (A+B).(A+C)
Absorption A+A.B = A A.(A+B) = A
– –
Simplification A+ A B=A+B A.( A + B ) = A.B
=
Involution A =A
–––– – – ––– – –
De Morgan‘s rules A+B = A.B A.B = A + B
Machine Structure Course, 1st-year Computer Science Engineer 16
Generalization of the DE-MORGANE’s
Theorem to N variables
• Reminder of De Morgane's theorem:
- The logical complemented sum of two variables is equal to the
product of the complements of the two variables.
–––– – –
A+B = A.B
17
Machine Structure Course, 1st-year Computer Science Engineer
Other logical operators Exclusive OR (XOR), Not
AND (NAND), and Not OR (NOR)
XOR
F (A , B ) = A B = A .B + A .B
F(A, B) = A . B
F ( A, B) = A B
Not OR (NOR)
F(A, B) = A + B
F ( A, B) = A B
18
Machine Structure Course, 1st-year Computer Science Engineer
NAND and NOR: universal operators
• Using NANDs and NORs, you can express any logical expression
(function).
• Simply express the basic operators (NOT, AND, OR) with NAND
and NOR.
• A =A+A =AA
• A + B = A + B = A B = (A B) (A B)
• A.B= A.B= A + B = A B = (A A) (B B)
19
Machine Structure Course, 1st-year Computer Science Engineer
Properties of the NAND and NOR
operators
A0=1 A0= A
A1= A A1=0
AB= B A
AB= B A
( A B) C A (B C)
( A B) C A (B C)
20
Machine Structure Course, 1st-year Computer Science Engineer
Logic Gates
Non A S S = !A
A S 0 1
! S =A
1 0
A A
30
21
Machine Structure Course, 1st-year Computer Science Engineer
AND and OR gates
Symbol Graphism Truth table Equation
ou A A B S T S =A+ B
S 0 0 0 1
+ B
0 1 1 0
1 0 1 0
A 1 1 1 0 T=A+ B
Nor T
B
A B S T S =A. B
A 0 0 0 1
And S
B 0 1 0 1
1 0 0 1
Nand A 1 1 1 0 T=A. B
T
B
22
XOR gate
Xor A A B S T S=AB
S 0 0 0 1
B =A.B + A.B
0 1 1 0
1 0 1 0
A 1 1 0 1 T = (A = = B)
== T
B
23
Machine Structure Course, 1st-year Computer Science Engineer
Logic circuit diagram (Logigram)
• Example 1:
24
Machine Structure Course, 1st-year Computer Science Engineer
Example 2
F(A,B, C, D) = (A + B ) . ( B + C + D ) .A
25
Application exercises
Exercise 1:
26
Machine Structure Course, 1st-year Computer Science Engineer
Application exercises (continued)
Exercise 2:
Give the equation or expression for F?
27
Machine Structure Course, 1st-year Computer Science Engineer
Steps in designing and building a digital
circuit
To design and build a circuit, follow these steps:
1. Understand how the system works.
2. Define the input variables.
3. Define the output variables.
4. Establish the truth table.
5. Write the algebraic output equations (from the truth table).
6. Perform simplifications (algebraic or using the Karnaugh
map).
7. Draw the schematic with a minimum number of logic
gates.
28
Machine Structure Course, 1st-year Computer Science Engineer
Text definition of a logic function
Question: What is the circuit diagram that controls the opening of the lock?
29
Machine Structure Course, 1st-year Computer Science Engineer
Application exercise (continued)
Let's take the example of the lock:
o The system has three inputs:
▪ Each input represents a key.
▪ Each key is assigned to a logical variable: key 1 to A, key 2 to B, key 3 to C.
✓ If key 1 is used then variable A=1 otherwise A =0
✓ If key 2 is used then variable B=1 otherwise B =0
✓ If key 3 is used then variable C=1 otherwise C =0
The system has a single output corresponding to the lock status (open or
closed).
We will assign a variable S to designate the output:
• S=1 if the lock is open ,
• S=0 if closed
A
▪ S=F(A,B,C) B F
C Circuit
▪ F(A,B,C)= 1 if at least two keys are entered
▪ F(A,B,C)=0 if not.
30
Machine Structure Course, 1st-year Computer Science Engineer
Application exercise: Truth table
NB: It's also important to specify the logic level you're working with
(positive or negative logic).
A B C S
0 0 0 0 F=A+B+C Maxterm
0 0 1 0 F=A+B+C Maxterm
0 1 0 0 F=A+B+C Maxterm
0 1 1 1 F=A B C Minterm
1 0 0 0 F=A+B+C Maxterm
1 0 1 1 F=A B C Minterm
1 1 0 1 F=A B C Minterm
1 1 1 1 F=A B C Minterm
31
Machine Structure Course, 1st-year Computer Science Engineer
Extracting the logic function from the
truth table
F ( A, B, C ) = A . B . C + A . B . C + A . B . C + A . B . C
F(A, B, C) = ( A + B + C) (A + B + C)(A + B + C) (A + B + C)
32
Machine Structure Course, 1st-year Computer Science Engineer
Canonical forms of a function
33
Computer Architecture 1 Course, 1st year Computer Science Engineer
First canonical form
For a 3-variables function a, b and c, we have :
◆ Minterms : abc,abc,abc,abc,...
◆ Maxterms :
• a+b+c ,a+b+c,a+b+c ,a+b+c ,...
Example :
• F(A,B,C)= ( A+B+C) (A+B+C)(A+B+C)(A+B+C)
35
Machine Structure Course, 1st-year Computer Science Engineer
Important note
36
Machine Structure Course, 1st-year Computer Science Engineer
Transition to canonical forms
37
Machine Structure Course, 1st-year Computer Science Engineer
Example of transition to the first canonical form
a b c | b | c | ab | bc | ac | f(a,b,c)
-------+---+---+----+----+----+---------
0 0 0 | 1 | 1 | 0 | 0 | 0 | 0
0 0 1 | 1 | 0 | 0 | 1 | 0 | 1
0 1 0 | 0 | 1 | 0 | 0 | 0 | 0
0 1 1 | 0 | 0 | 0 | 0 | 0 | 0
1 0 0 | 1 | 1 | 0 | 0 | 1 | 1
1 0 1 | 1 | 0 | 0 | 1 | 0 | 1
1 1 0 | 0 | 1 | 1 | 0 | 1 | 1
1 1 1 | 0 | 0 | 1 | 0 | 0 | 1 40
Transition from the truth table to the logic
function
41
Machine Structure Course, 1st-year Computer Science Engineer
Transition from the truth table to the logic
function
45
Machine Structure Course, 1st-year Computer Science Engineer
The aim of simplifying logic functions
47
Machine Structure Course, 1st-year Computer Science Engineer
Simplification rules
• Rule 1:
Group terms using the previous rules.
Example: ABC + AB C = AB(C+C)=AB
49
Machine Structure Course, 1st-year Computer Science Engineer
Simplification using the
Karnaugh map
50
Machine Structure Course, 1st-year Computer Science Engineer
Adjacent terms
• Let's consider the following expression :
A.B+A.B
• Both terms have the same variables. The only difference
is the state of variable B, which changes.
• If we apply the simplification rules, we get :
AB + AB = A ( B + B ) = A
• These terms are adjacents.
51
Machine Structure Course, 1st-year Computer Science Engineer
Example of adjacents termes
52
Machine Structure Course, 1st-year Computer Science Engineer
Description of the Karnaugh map
• Karnaugh's method is based on the previous rule.
• The method consists in graphically highlighting all
adjacent terms (which differ only in the state of a
single variable).
• The method can be applied to logic functions of 2, 3,
4, 5 and 6 variables.
• A Karnaugh map has 2n cells (n is the number of
variables).
53
Machine Structure Course, 1st-year Computer Science Engineer
Karnaugh maps with 2, 3 and 4
variables
54
Machine Structure Course, 1st-year Computer Science Engineer
Description of the Karnaugh map
(with 5 variables)
AB AB
CD 00 01 11 10 CD 00 01 11 10
00 00
01 01
11 11
10 10
U=0 U= 1
55
Machine Structure Course, 1st-year Computer Science Engineer
Examples of adjacent cells
AB
AB
C 00 01 11 10 CD 00 01 11 10
0 00
01
1
11
10
56
Machine Structure Course, 1st-year Computer Science Engineer
Transition from the truth table to the
Karnaugh map
• For each combination that represents a minterm, a cell in
the map must be set to 1.
• For each combination that represents a maxterm, a cell
in the map must be set to 0.
• When filling in the table, you must: either take the
minterms or the maxterms.
57
Machine Structure Course, 1st-year Computer Science Engineer
Example
AB
C 00 01 11 10
0 1
1 1 1 1
58
Machine Structure Course, 1st-year Computer Science Engineer
Change from the canonical form
to the Karnaugh map
• If the logic function is given in the first
canonical form (disjunctive), then its
representation is direct: for each term, it has a
single square/cell that must be set to 1.
59
Machine Structure Course, 1st-year Computer Science Engineer
Examples
y
0 1 ƒ (𝑥, 𝑦) = 𝑥. 𝑦 + 𝑥. 𝑦
x
1 ƒ (𝑥, 𝑦) = (𝑥 +𝑦) (𝑥+ 𝑦)
0 0
1 0 1
y
0 1
x
ƒ (𝑥, 𝑦) = 𝑥. 𝑦 + 𝑥. 𝑦 + 𝑥. 𝑦
1
0 1
ƒ (𝑥, 𝑦) = 𝑥 + 𝑦
1 0 1
60
Machine Structure Course, 1st-year Computer Science Engineer
Simplification method: Example with
3 variables
• The basic idea is to try to group (make groupings/clusters) adjacent
cells that contain 1 (group of adjacent terms).
AB
C
00 01 11 10
0 ABC + ABC =AB
1
1
1 1 1
61
Machine Structure Course, 1st-year Computer Science Engineer
Simplification method: Example with
3 variables (continued)
• Since there are still cells outside a grouping, we repeat the same
procedure: forming groupings.
AB
C
00 01 11 10
0
1 ABC + ABC =AB
1
1 1 1 ABC + ABC = AC
62
Machine Structure Course, 1st-year Computer Science Engineer
Simplification method: Example with
3 variables (continued)
• We stop when there are no more 1's outside the groupings.
ABC + ABC = BC
F ( A, B, C) = AB + AC + BC
63
Machine Structure Course, 1st-year Computer Science Engineer
Simplification steps with the
Karnaugh map
So, to simplify a function using the Karnaugh map, follow these
steps:
1. Fill in the map using the truth table or the canonical form.
2. Make groupings: groupings of 16,8,4,2,1 cells (the same terms
can take part in several groupings).
3. In a grouping :
▪ Containing a single term: no variables can be eliminated.
▪ Contains two terms: one variable (the one that changes state)
can be eliminated.
▪ Containing 4 terms: 2 variables can be eliminated. Containing
8 terms: 3 variables can be eliminated.
▪ Containing 16 terms: 4 variables can be eliminated.
ƒ ( 𝑥, 𝑦, 𝑧) = 𝑥. 𝑦. 𝑧 + 𝑥. 𝑦. 𝑧 + 𝑥. 𝑦. 𝑧 + 𝑥. 𝑦. 𝑧
ƒ (𝑥, 𝑦, 𝑧) = 𝑥. 𝑧 + 𝑥. 𝑦 + 𝑦. 𝑧
AB
C
C 00 01 11 10
0 1 F ( A, B, C) = C + AB
1 1 1 1 1
65
Machine Structure Course, 1st-year Computer Science Engineer
Examples of simplification
AB AB
C
U=0 U= 1
67
Machine Structure Course, 1st-year Computer Science Engineer
Other examples
Y a b
00 01 11 10
00 1 0 0 1
01 1 0 0 1
cd Y = 𝑏̅
11 1 0 0 1
10 1 0 0 1
Y a b
00 01 11 10
00 1 0 0 1
01 0 0 0 0
cd
𝑌 = 𝑏̅ 𝑑̅
11 0 0 0 0
10 1 0 0 1
68
Machine Structure Course, 1st-year Computer Science Engineer
The case of a function not totally
defined
Consider the following example:
• A security lock is opened by four keys A, B, C and D.
• The operation of the lock is defined as follows: S(A,B,C,D)= 1 if at
least two keys are used; S(A,B,C,D)= 0 otherwise
• Keys A and D cannot be used at the same time.
• Note that if keys A and D are used at the same time, the state of the
system is not determined.
• These cases are called impossible or forbidden cases. So, the question
is how to represent these cases in the truth table?
Answer:
• For impossible or forbidden cases, put an X in the Truth Table.
• Impossible cases are also represented by Xs in the Karnaugh map.
69
Machine Structure Course, 1st-year Computer Science Engineer
Truth table+ Karnaugh map
• Let's give the associated truth table and Karnaugh map:
A B C D S
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0 AB
0 0 1 1 1 00 01 11 10
CD
0 1 0 0 0
0 1 0 1 1 00
0 1 1 0 1
01
0 1 1 1 1
1 0 0 0 0 11
1 0 0 1 X
10
1 0 1 0 1
1 0 1 1 X
1 1 0 0 1
1 1 0 1 X
1 1 1 0 1
1 1 1 1 X
70
Machine Structure Course, 1st-year Computer Science Engineer
Simplification using the Karnaugh
map (indeterminate cells)
• Xs can be used in groupings:
▪ Either take them as 1s
▪ Or as 0s
• You must not form groupings containing only Xs.
AB
CD 11
00 01 10
00 1
01 X X
1
1 X X
11 1
1 1 1
10
F= AB + CD + BD + AC + BC
71
Machine Structure Course, 1st-year Computer Science Engineer
Application exercise
Find the simplified logic function from the following Karnaugh map :
AB
CD 00 01 11 10
00
01
11
10
72
Machine Structure Course, 1st-year Computer Science Engineer