Numbers and Boolean Algebra N
Numbers and Boolean Algebra N
Numbers and Boolean Algebra N
By
Dr. M. Khamis
Mrs. Dua’a Al Sinari
Computer Organization
The course is aimed at designing the different computer
components (circuits) and connecting these components
in a way to achieve the goals of a specific architectures.
Computer (hardware) consists of processor, memory and I/O
units.
Processor itself consists of Arithmetic Logic Unit (ALU) and
Control unit.
All the above units are designed using primitive logic circuits.
Course Objectives
Understanding the basic Laws of Boolean algebra.
Designing and using the basic logic devices.
Understanding the operation of the main computer
units and their design.
Interconnecting the various computer units to achieve
the specific architecture.
Presenting the attributes of the different architectures.
Programming specific architecture using its instruction
set (machine instruction).
Explaining the Interaction between Computer hardware
and the operating system.
Course outline
The course will consist of two parts:
The first part is Logic design: in which
the primitive
components, by which the different devices are designed, are
presented.
The second part is intended for interconnecting the
components presented in first part in a way to build a logical
system (computer organization).
Part 1: Logic Design
Introduction to number systems and arithmetic
operations in binary system.
Combinational circuits:
Logic Gates (AND, OR, NOT, NOR, NAND and XOR), in this
regards we will give the truth tables and symbols for each .
Laws of Boolean algebra, deriving logical expression and
simplification.
Karnaugh maps and its use for simplification .
half and full adders and binary coded decimal adders
Part 1: Logic Design
devices include:
Decoder.
Encoder.
Multiplexers/ De-multiplexer.
Comparator.
Sequential circuits include :
Flip/Flops and counter
Design Mealy and MOORE machines.
Part 2: Computer Organization
chapter 3: computer system
chapter 7: Input/output
chapter 8: Operating System Support.
chapter 9: Computer Arithmetic
chapter 10: Instruction Sets.
chapter 11: :Instruction Sets: Addressing Modes and
Format.
chapter 12: CPU structure
chapter 16 : Control Unit
chapter 17: Micro Programmed Control Unit.
NUMBERS AND BOOLEAN
ALGEBRA
10
DECIMAL REVIEW
11
CONVERTING BINARY TO DECIMAL
13
So, 162.37510 = 10100010.0112
WHY DOES THIS WORK?
14
0.375 x 10 = 3.750
0.750 x 10 = 7.500
0.500 x 10 = 5.000
BASE 16 IS USEFUL TOO
20
BOOLEAN OPERATIONS
21
BOOLEAN VALUES
f(x,y,z) = (x + y’)z + x’
f(x,y,z) = (x + y’)z + x’
x y z f(x,y,z)
0 0 0 1
0 0 1 1
f(0,0,0) = (0 + 1)0 + 1 =1
0 1 0 1
f(0,0,1) = (0 + 1)1 + 1 =1
f(0,1,0) = (0 + 0)0 + 1 =1 0 1 1 1
f(0,1,1) = (0 + 0)1 + 1 =1 1 0 0 0
f(1,0,0) = (1 + 1)0 + 0 =0 1 0 1 1
f(1,0,1) = (1 + 1)1 + 0 =1 1 1 0 0 26
f(1,1,0) = (1 + 0)0 + 0 =0 1 1 1 1
f(1,1,1) = (1 + 0)1 + 0 =1
PRIMITIVE LOGIC GATES
Logic gate:
27
EXPRESSIONS AND CIRCUITS
28
CIRCUIT ANALYSIS SUMMARY
Find a Boolean
Find a truth table
expression
for the circuit
for the circuit
29
BOOLEAN OPERATIONS SUMMARY
Next, we’ll look at how Boolean algebra can help simplify expressions,
which in turn will lead to simpler circuits.
30
BOOLEAN ALGEBRA
(x + y’)z + x’
31
EXPRESSION SIMPLIFICATION
32
FORMAL DEFINITION OF BOOLEAN ALGEBRA
1. x+0=x 2. x1=x
3. x+1=1 4. x0=0
5. x+x=x 6. xx=x
7. x + x’ = 1 8. x x’ = 0
9. (x’)’ = x
10. x+y=y+x 11. xy = yx Commutative
12. x + (y + z) = (x + y) + z 13. x(yz) = (xy)z Associative
14. x(y + z) = xy + xz 15. x + yz = (x + y)(x + z) Distributive
16. (x + y)’ = x’y’ 17. (xy)’ = x’ + y’ DeMorgan’s 33
COMMENTS ON THE AXIOMS
1. x+0=x 2. x1=x
3. x+1=1 4. x0=0
5. x+x=x 6. xx=x
7. x + x’ = 1 8. x x’ = 0
9. (x’)’ = x
10. x+y=y+x 11. xy = yx Commutative
12. x + (y + z) = (x + y) + z 13. x(yz) = (xy)z Associative
14. x(y + z) = xy + xz 15. x + yz = (x + y)(x + z) Distributive
34
16. (x + y)’ = x’y’ 17. (xy)’ = x’ + y’ DeMorgan’s
ARE THESE AXIOMS FOR REAL?
The first 11 axioms are easy to see from these truth tables alone. For
example, x + x’ = 1 because of the middle two lines below (where y = x’)
x y x+y
0 0 0
0 1 1
1 0 1 35
1 1 1
PROVING THE REST OF THE AXIOMS
In each table, the columns on the left (x and y) are the inputs. The columns
on the right are outputs.
In this case, we only care about the columns in blue. The other “outputs”
are just to help us find the blue columns.
Since both of the columns in blue are the same, this shows that (x + y)’ and 36
x’y’ are equivalent
SIMPLIFICATION WITH AXIOMS
38
SOME MORE LAWS
x y z f(x,y,z) x y z f’(x,y,z)
0 0 0 1 0 0 0 0
0 0 1 1 0 0 1 0
0 1 0 1 0 1 0 0
0 1 1 1 0 1 1 0
1 0 0 0 1 0 0 1
1 0 1 0 1 0 1 1
1 1 0 1 1 1 0 0
1 1 1 0 1 1 1 1 40
COMPLEMENTING A FUNCTION
ALGEBRAICALLY
You can also take the dual of the function, and then complement each
literal
If f(x,y,z) = x(y’z’ + yz)…
… the dual of f is x + (y’ + z’)(y + z)…
… then complementing each literal gives x’ + (y + z)(y’ + z’)…
… so f’(x,y,z) = x’ + (y + z)(y’ + z’)
41
SUMMARY SO FAR
Next:
Introducing some standard forms and terminology
An alternative simplification method
We’ll start using all this stuff to build and analyze bigger, more useful,
circuits
42
Parity Checking
Parity checking is used to check the correctness or
erroneous of data.
Circuit used to raise 1 on its output when its input data
contain even number of 1’s is called even parity circuit,
otherwise it called odd parity circuit.
Parity checking is used with memory to ensure the read
data is exactly as written one or otherwise, it interrupts
the main processor. Also, it is used within the modem to
ensure the correct arrival of the received data.
Parity Checking with the Main Memory
Parity RAM
Data RAM
Parity cct
To interrut processor
Parity cct
How is parity circuits detect the error?
0 0 1 0
0 0 0 1
How to add binary numbers
Consider adding two 1-bit binary numbers x and y
0+0 = 0
0+1 = 1 x y Carry Sum
1+0 = 1
1+1 = 10
0 0 0 0
0 1 0 1
1 0 0 1
Carry is x AND y 1 1 1 0
Sum is x XOR y
The circuit to compute this is called a half-adder
The half-adder
Sum = x XOR y
Carry = x AND y
x x
y y Sum
Sum
Carry
Carry
Using half adders
We can then use a half-adder to compute the sum of
two Boolean numbers
1 0 0
1 1 0 0
+1 1 1 0
? 0 1 0
How to fix this
We need to create an adder that can take a carry bit as an
additional input
Inputs: x, y, carry in x y c carry sum
Outputs: sum, carry out
1 1 1 1 1
This is called a full adder
Will add x and y with a half-adder 1 1 0 1 0
Will add the sum of that to the
1 0 1 1 0
carry in
What about the carry out? 1 0 0 0 1
It’s 1 if either (or both): 0 1 1 1 0
x+y = 10
x+y = 01 and carry in = 1 0 1 0 0 1
0 0 1 0 1
0 0 0 0 0
The full adder
The “HA” boxes are half-adders
cc X
X HA
HA S
S
s
Y
Y C
C
xx X
X HA
HA S
S
c
yy
Y
Y C
C
The full adder
The full circuitry of the full adder
c
s
x
y
c
Adding bigger binary numbers (4 bits parallel
binary adder)
This design is available with IC 7483
x0 X HA S
s0
y0 Y C
x1
C
X
FA S
s1
y1 Y C
x2
C
X
FA S
s2
y2 Y C
x3
C
X
FA S
s3
y3 Y C
c
Seven Segment
Example
Seven-segment display used to display binary values visually
To do so it needs a driver to convert from 4 bit binary to 7-segments
output.
d’ output of the driver (decoder to 7 segment)
Simplified expression of “d”
Karnaugh Map Method
Don’t cares simplify the expression a lot
Using decoder to 7-segment to display the
output of the 4-bits adder on 7-segment
All output of the decoder to 7-segments is calculated in
similar way (IC 7447 performing the function of the
decoder to 7-segments).
Adding bigger binary numbers
A half adder has 4 logic gates
A full adder has two half adders plus a OR gate
Total of 9 logic gates
To add n bit binary numbers, you need 1 HA and n-1 FAs
To add 32 bit binary numbers, you need 1 HA and 31 FAs
Total of 4+9*31 = 283 logic gates
To add 64 bit binary numbers, you need 1 HA and 63 FAs
Total of 4+9*63 = 571 logic gates
More about logic gates
To implement a logic gate in hardware, you use a
transistor
Transistors are all enclosed in an “IC”, or integrated
circuit
The current Intel Pentium IV processors have 55 million
transistors!
Summary: Digital Logic Basics
Hardware consists of a few simple building blocks
These are called logic gates
AND, OR, NOT, …
transistors
Basic Concepts
Simple gates
AND
OR
NOT
Functionality can be
expressed by a truth table
A truth table lists output
for each possible input
combination
Precedence
NOT > AND > OR
F=AB+AB
= (A (B)) + ((A) B)
Basic Concepts (cont.)
Additional useful gates
NAND
NOR
XOR
NAND = AND + NOT
NOR = OR + NOT
XOR implements exclusive-
OR function
NAND and NOR gates
require only 2 transistors
AND and OR need 3
transistors!
Basic Concepts (cont.)
Basic building block:
Transistor
{OR, NOT}
{NAND}
{NOR}
Example:
Majority function
Output is 1 whenever majority of inputs is 1
We use 3-input majority function
Logic Functions (cont.)
3-input majority function Logical expression form
A B C F F=AB+BC+AC
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
Logical Equivalence
All three circuits implement F = A B function
Logical Equivalence (cont.)
Proving logical equivalence of two circuits
Derive the logical expression for the output of each
circuit
Show that these two expressions are equivalent
Two ways:
You can use the truth table method
For every combination of inputs, if both expressions yield the
same output, they are equivalent
Good for logical expressions with small number of variables
A B F1 = A B F3 = (A + B) (A + B) (A + B)
0 0 0 0
0 1 0 0
1 0 0 0
1 1 1 1
Logic Circuit Design Process
A simple logic design process involves
Problem specification
Truth table derivation
Derivation of logical expression
Simplification of logical expression
Implementation
Deriving Logical Expressions
Derivation of logical expressions from truth tables
sum-of-products (SOP) form
product-of-sums (POS) form
SOP form
Writean AND term for each input combination that
produces a 1 output
Write the variable if its value is 1; complement
otherwise
OR the AND terms to get the final expression
POS form
Dual of the SOP form
Deriving Logical Expressions (cont.)
3-input majority function SOP logical expression
A B C F Four product terms
Because there are 4 rows
0 0 0 0 with a 1 output
0 0 1 0
0 1 0 0
0 1 1 1 F=ABC+ABC+
1 0 0 0 ABC+ABC
1 0 1 1
1 1 0 1
1 1 1 1
Deriving Logical Expressions (cont.)
3-input majority function POS logical expression
A B C F Four sum terms
Because there are 4 rows
0 0 0 0 with a 0 output
0 0 1 0
0 1 0 0
0 1 1 1 F = (A + B + C) (A + B + C)
1 0 0 0 (A + B + C) (A + B + C)
1 0 1 1
1 1 0 1
1 1 1 1
Logical Expression Simplification
Two basic methods
Algebraic manipulation
Use Boolean laws to simplify the expression
Difficult to use
BC+AC+AB
AB+CD=AB+CD
Using de Morgan’s law
AB+CD=AB.CD
Can be generalized
Majority function
A B + B C + AC = A B . BC . AC
Selection input
determines the
input that should
be connected to
the output
Multiplexers (cont.)
4-data input MUX implementation
Multiplexers (cont.)
MUX implementations
Multiplexers (cont.)
Example chip: 8-to-1 MUX
Multiplexers (cont.)
Efficient implementation: Majority function
Demultiplexers (DeMUX)
Demultiplexer
a single input
n selection inputs
2n outputs
Decoders
Decoder selects one-out-of-N inputs
Decoders (cont.)
Logic function implementation
Comparator
Used to implement comparison operators (= , > , < , , )
A=B: Ox = Ix (x=A<B, A=B, & A>B)
Comparator (cont.)
4-bit magnitude comparator chip
Comparator (cont.)
Serial construction of an 8-bit comparator
1-bit Comparator
x>y
CMP x=y
x<y
x y
Full-adder
Adds three 1-bit values
Simple technique
Connect Cout of one adder to Cin of the next
These are called ripple-carry adders
Adders (cont.)
Adders (cont.)
A 16-bit ripple-carry adder
Adders (cont.)
Ripple-carry adders can be slow
Delay proportional to number of bits
Carry lookahead adders
Eliminate the delay of ripple-carry adders
Carry-ins are generated independently
C0 = A0 B0
C = A B A + A B B + A B
1 0 0 1 0 0 1 1 1
...
Requires complex circuits
Usually, a combination carry lookahead and
ripple-carry techniques are used
Programmable Logic Arrays
PLAs
Implement sum-of-product expressions
Internally uses
An AND array
Each AND gate receives 2N inputs
N inputs and their complements
An OR array
Programmable Logic Arrays (cont.)
A blank PLA with 2 inputs and 2 outputs
Programmable Logic Arrays (cont.)
Implementation examples
Programmable Logic Arrays (cont.)
Simplified notation
1-bit Arithmetic and Logic Unit
Preliminary ALU design
2’s complement
Required 1 is added via Cin
1-bit Arithmetic and Logic Unit (cont.)
Final design
Arithmetic and Logic Unit (cont.)
16-bit ALU
Arithmetic and Logic Unit (cont’d)
4-bit ALU
Introduction to Sequential Circuits
Output depends on current as well as past inputs
Depends on the history
Have “memory” property
Feedback circuit
Start of a cycle
End of a cycle
changes levels
Timing information
Propagation delay
Time required for the output to react to changes in the
inputs
Clock Signal (cont.)
Latches
Can remember a bit
Level-sensitive (not edge-sensitive)