Notes Logic
Notes Logic
901220
By: Dr. Wael Al Qassas
Al Albayt university
2
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Web sites.
Www.geocities.com/wael_it2003
www.aabu.edu.jo/it/~wael
http://web2.aabu.edu.jo:8080
http://web2.aabu.edu.jo:8080/tool/course_file/
901220_lectures.pdf
www.aabu.edu.jo/~wael
3
/AABU
Syllabus
Syllabus review & Introduction :1 hour
Simple logic Circuits and manufacturing technology :1 hours
Truth table and symbolic representation :1 hour
Fundamental properties for Boolean algebra :1 hours
Implementing Circuits form Truth table , practice : 2 hours
XOR gate, Demorgans Law : 1 hour
Logical expression simplification using Fundamental properties,
Demorgan , Practice : 1 hours.
Karnaugh map ( 3 input, 4 input), SOP,POS, practice: 3 hour
Tabulation method : 2 hours.
Numbering systems, Binary numbers, Hexadecimal,, real number
implementation,: 3 hours
First exam., Question solving & evaluation : 1 hour.
4
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Transistor: Building Block of Computers
Microprocessors contain millions of transistors
Intel Pentium II: 7 million
Compaq Alpha 21264: 15 million
Intel Pentium III: 28 million
5
/AABU
Switch closed:
Short circuit across switch
Current flows
Light is on
Vout is 0V
PDF created with pdfFactory trial version www.pdffactory.com
LOGICAL AND:
7
/AABU
Gate = 0
Terminal #2 must be
connected to GND (0V).
8
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
P-type MOS Transistor
P-type is complementary to N-type
when Gate has positive voltage,
open circuit between #1 and #2
(switch open)
when Gate has zero voltage,
short circuit between #1 and #2
(switch closed)
Gate = 1
Gate = 0
Terminal #1 must be
connected to +2.9V.
9
/AABU
Logic Gates
Use switch behavior of MOS transistors
to implement logical functions: AND, OR, NOT.
Digital symbols:
recall that we assign a range of analog voltages to each
digital (logic) symbol
10
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Inverter (NOT Gate)
Truth table
In Out In Out
0 V 2.9 V 0 1
2.9 V 0V 1 0
11
/AABU
NOR Gate
A B C
0 0 1
0 1 0
1 0 0
1 1 0
Note: Serial structure on top, parallel on bottom. 12
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
OR Gate
A B C
0 0 0
0 1 1
1 0 1
1 1 1
13
/AABU
A B C
0 0 1
0 1 1
1 0 1
1 1 0
Note: Parallel structure on top, serial on bottom. 14
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
AND Gate
A B C
0 0 0
0 1 0
1 0 0
1 1 1
15
/AABU
16
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Fundamental Properties of boolean algebra:
Commutative:
X+Y=Y+X
X.Y= Y.X
Associative:
( X + Y) + Z = X + (Y + Z)
( X . Y) . Z = X . (Y . Z)
Identity:
X + 0 = X
X . 1 = X
Complement:
X +(X) = 1
X . (X) = 0
Distributive:
X . (Y + Z) = (X . Y) + (X . Z)
X + (Y . Z) = (X + Y) . (X + Z)
Absorption
X + X.Y = X
17
/AABU
X.X = X
X+X = X
X + 1= 1
X.0=0
18
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
X.(Y+Z)=(X.Y)+(X.Z)
19
/AABU
X+(Y.Z)=(X+Y).(X+Z)
20
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
More than 2 Inputs?
AND/OR can take any number of inputs.
AND = 1 if all inputs are 1.
OR = 1 if any input is 1.
Similar for NAND/NOR.
21
/AABU
Practice
Implement a 3-input NOR gate with CMOS.
22
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Logical Completeness
Can implement ANY truth table with AND, OR, NOT.
A B C D
0 0 0 0
0 0 1 0 1. AND combinations
that yield a "1" in the
0 1 0 1
truth table.
0 1 1 0
1 0 0 0
1 0 1 1 2. OR the results
1 1 0 0 of the AND gates.
1 1 1 0
23
/AABU
Practice
Implement the following truth table.
A B C
0 0 0 A
0 1 1
B C
1 0 1
1 1 0
24
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Another example:
We want to build a circuit that has 3 binary inputs.
This CKT is On if the inputs are XYZ or XYZ .
Build the Truth table, then Draw the Ckt
X Y Z Output
0 0 0 0
0 0 1 1 X
0 1 0 1 Y
Z Output
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0
25
/AABU
XOR gate:
A XOR B= A.B+A.B
A+B
A B A+B
A A+B 0 0 0
B
0 1 1
1 0 1
1 1 0
A
B
A.B+A.B
26
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
DeMorgan's Law
Converting AND to OR (with some help from NOT)
Consider the following gate:
To convert AND to OR
A B A B A B A B (or vice versa),
0 0 1 1 1 0 invert inputs and output.
0 1 1 0 0 1
1 0 0 1 0 1
1 1 0 0 0 1
Same as A+B!
27
/AABU
DeMorgan Law:
A B A B A.B (A.B) OR
A+B= (A . B) Truth
0 0 1 1 1 0
table
0 1 1 0 0 1
1 0 0 1 0 1
1 1 0 0 0 1
A.B=(A+B)
A B A B A+B (A+B)
0 0 1 1 1 0 AND
Truth
0 1 1 0 1 0
table
1 0 0 1 1 0
1 1 0 0 0 1
28
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Build the following logical expression using AND, Not
Gates only:
F=X.Y+Z
=((X.Y).Z)
=((X.Y).Z)
Another example:
F= XYZ+YZ+XZ
= ( (XYZ).(YZ).(XZ) )
29
/AABU
30
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Simplification using boolean algebra:
We have the following truth table for a logical circuit and we want to
implement this using the minimum number of gates:
SOP
A B C F
F=ABC+ABC+ABC+ABC+ABC
0 0 0 0
= ABC+ABC+AB(C+C)+ABC
0 0 1 1
0 1 0 0 = AC(B+B) +AB +ABC
0 1 1 1 = AC+AB+AC(B+B) ;we can reuse ABC
1 0 0 1 =AC+AB+AC
1 0 1 1
1 1 0 1
1 1 1 0
31
/AABU
Another example:
A B C F
F=ABC+ABC+ABC+ABC+ABC
0 0 0 0
= AC(B+B)+ABC+ABC+ABC
0 0 1 1
0 1 0 0 = AC + AC(B+B) +ABC
0 1 1 1 = AC+AC+ AB(C+C)
1 0 0 0 =AC+AC+AB
1 0 1 1
= C(A+A)+AB
1 1 0 1
= C+AB
1 1 1 1
32
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Karnaugh Maps
Karnaugh map : is a representation for the truth table in a graphical
way, which makes the simplification of any boolean function easier.
BC
00 01 11 10
ABC ABC ABC ABC
0 000 001 011 010
A ABC ABC ABC ABC
1 100 101 111 110
As we can see, each cell represent one raw of the truth table
Next step is to fill the map using the truth table output.
33
/AABU
A B C F BC
00 01 11 10
0 0 0 0 0 1 1 0
0
0 0 1 1 A
0 1 0 0 1 1 0 1
1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1 F=AC+AC +BC
1 1 1 0
34
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Resolve the same example in another way:
BC
00 01 11 10
0 1 1 0
0
1 1 0 1
1
F=AC+AB+AC
35
/AABU
Another example
00 01 11 10
0 1 1 0
0
1 1 1 1
1
36
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Convert from logical expression to minterms
What are the minterms that represent the
following expression assuming that we have 3
inputs A,B, and C
F=A+AC
F=
37
/AABU
38
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
39
/AABU
00 1 1
01 1 1
11 1 1
10 1 1
40
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Minterms & Maxterms
To understand the relation between Minterms and Maxterms let is see the
following example:
F=(1,3,5,6,7) A B C F F
F=ABC+ABC+ABC+ABC+ABC 0 0 0 0 1
F=ABC+ABC+ABC 0 0 1 1 0
We know that F=F 0 1 0 0 1
F=F=(ABC+ABC+ABC) 0 1 1 1 0
41
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
5 variables Karnaugh map
CDE
000 001 011 010 110 111 101 100
00
01
AB
11
10
43
/AABU
Tabulation method
Last lecture we noticed the difficulty of
simplifying 5 variable equations using
karnaugh Map.
PDF created with pdfFactory trial version www.pdffactory.com
Determining Prime implicants
Example 1 : F(w,x,y,z)=(0,1,2,8,10,11,14,15)
First we list the minterms in groups depending on the number of ones
in each minterm
0 0000
~~~~~~~~~~
1 0001
2 0010
8 1000
~~~~~~~~~
10 1010
~~~~~~~~~
11 1011
14 1110
~~~~~~~~~
15 1111 45
/AABU
Then look for any two minterms that differ on one variable
only , between any adjacent groups
0,1 000- 0,2,8,10 -0-0
0 0000
0,2 00-0 0,8,2,10 -0-0
1 0001
0,8 -000 10,11,14,15 1-1-
2 0010
2,10 -010 10,14,11,15 1-1-
8 1000
8,10 10-0
10 1010
10,11 101-
11 1011
10,14 1-10
14 1110 11,15 1-11
15 1111 14,15 111-
The prime implicants are : wxy , xz , wy
Next step is to select needed prime implicants.
46
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
0 1 2 8 10 11 14 15
WXY V V
XZ V V V V
WY V V V V
47
/AABU
Example 2
Simplify the following SOP using tabulation method.
F(W,X,Y,Z)=(1,4,6,7,8,9,10,11,15)
48
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Determining the prime implicants
1 0001 1,9 -001 8,9,10,11 10- -
4 0100 4,6 01-0 8,10,9,11 10- -
8 1000 8,9 100- ~~~~~~~~~~~~
~~~~~~ 8,10 10-0
6 0110 ~~~~~~~~
9 1001 6,7 011-
10 1010 9,11 10-1
~~~~~~ 10,11 101-
7 0111 ~~~~~~~~~
11 1011 7,15 -111
~~~~~~~ 11,15 1-11
15 1111
XYZ, WXZ, WXY, XYZ, WYZ, WX 49
/AABU
XYZ V V
WXZ V V
WXY V V
XYZ V V
WYZ V V
WX V V V V
50
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
ICs characteristics ( From Ch 1):
Fan-out: the number of standard loads that the
output of a gate can drive without impairing its
normal operation ( 20 to 50 gates)
51
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Binary numbers
53
/AABU
Also
5 = 00000101
-5= 10000101
54
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Negative numbers (1s Complement)
q1s comp is another method used to represent negative
numbers.
qIn this method we invert every bit in the positive number
in order to represent its negative.
qEx.:
9 = 01001
-9= 10110
55
/AABU
56
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
-22
22 = 010110
In 1s= 101001
In 2s= 101010 -22 in 2s comp
57
/AABU
011010000 011010000
100101111 (1s comp) (flip) (copy)
+ 1
100110000 100110000
58
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Operations: Arithmetic and Logical
Recall:
a data type includes representation and operations.
We now have a good representation for signed integers,
so lets look at some arithmetic operations:
Addition
Subtraction
Sign Extension
Well also look at overflow conditions for addition.
Multiplication, division, etc., can be built from these
basic operations.
Logical operations are also useful:
AND
OR
NOT
59
/AABU
Addition
As weve discussed, 2s comp. addition is just
binary addition.
assume all integers have the same number of bits
ignore carry out
for now, assume that sum fits in n-bit 2s comp. representation
60
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Subtraction
Negate subtrahend (2nd no.) and add.
assume all integers have the same number of bits
ignore carry out
for now, assume that difference fits in n-bit 2s comp.
representation
61
/AABU
Sign Extension
To add two numbers, we must represent them
with the same number of bits.
If we just pad with zeroes on the left:
4-bit 8-bit
0100 (4) 00000100 (still 4)
1100 (-4) 00001100 (12, not -4)
62
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Overflow
If operands are too big, then sum cannot be represented
as an n-bit 2s comp number.
63
/AABU
Sa Sb Ss Overflow
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
64
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Real numbers ( outside the text book)
qAll what we discussed before was about integers.
qWhat about real numbers (ex.: 6.125)
qTo represent real numbers we take first the integer part
and convert is as we learned before, and then take the
fraction part and convert it using the following algorithm
q 1- multiply fraction by 2
q 2- take the integer of the result
q 3- Repeat 1 and 2 until the fraction is zero, or until u reach get
enough digits.
qEx. : 6.125
6= 110
0.125x2 = 0.25
0.25x2 = 0.5
0.5x2 = 1.0
6.125= 110.001
65
/AABU
Another example:
Convert 9.2 to binary.
9=1001
0.2x2 = 0.4
0.4x2 = 0.8
0.8x2 = 1.6 ; take the fraction only
0.6x2 = 1.2
0.2x2 = 0.4 ; let us stop here, 5 digits after the point
66
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Convert from binary
Again let us take the previous results
22 21 20 2-1 2-2 2-3
11 0.0 0 1
= 4+2+.125=6.125
Ex. 2:
23 22 21 20 2-1 2-2 2-3 2-4 2-5
1 0 0 1. 0 0 1 1 0
= 8+1+ .125+.0625 = 9.1875
Why not 9.2 !??
67
/AABU
Floating numbers
Nowadays numbers with decimal point are represended in
the computer using IEEE 754 float number format.
This format has to subtypes :
Float: 32 bit number can represent up to 1035 .
Double: 64 bit number can represent up to 10350 with more
number of digits after the point.
68
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Hexadecimal
qAs we noticed to read a long binary number is confusing
qSo another numbering system was invented ( base 16)
qWe know base 10 ,base 2, and now base 16
qNumbers in (base 16) are : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
qThere is a direct relation between base 2 and base 16,
24=16 , so the conversion from binary to hexadecimal is
quite easy.
qEach 4 binary digits are converted to one hexadecimal
digit.
69
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Examples on Hexadecimal
01010001=51h, 0x51,$51, 5116
1110010 =$72
10101110=$AE
71
/AABU
Binary Codes
Binary coding is different from binary conversion
Excess-3 code
In Excess-3 0 = 0011, 1=0100, 2=0101 , , 9=1100
This means that we add 3 to the number then convert it to binary
We mainly use this to avoid having zeros in transmission lines.
Other coding methods ( See Page 17).
72
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Error detection :
Many techniques are used in order to detect if an error has occurred
in the data transmitted or stored, one of these is the parity check.
The idea of the parity check is to add an extra bit to the binary
number, the value of this bit depends on the number of ones in the
binary number.
A parity check involves appending a bit that makes the total number
of binary 1 digits in a character or word , either odd (for odd parity) or
even (for even parity).
Examples:
Even parity 0000 0, 0001 1, 1111 0
Alphanumeric Codes
To represent numbers and letters we need some coding
method.
First we need to know the number of symbols (letters,
numbers, or other symbols)
PDF created with pdfFactory trial version www.pdffactory.com
EBCDIC: Extended BCD Interchange, is an 8 bit coding
Ex: A= 1100 0001
1= 1111 0001
space= 0100 0000
75
/AABU
Summary
MOS transistors are used as switches to implement
logic functions.
N-type: connect to GND, turn on (with 1) to pull down to 0
P-type: connect to +2.9V, turn on (with 0) to pull up to 1
76
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
77
/AABU
78
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Building Functions from Logic Gates
We've already seen how to implement truth tables
using AND, OR, and NOT -- an example of
combinational logic.
79
/AABU
Chapter 4.
Combinational Circuits
A combinational circuit consists of :
1- Input variables.
2- Logic gates
3- Output variables
Combinational
n inputs Logic m outputs
Circuit
80
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Design Procedure
To design a combinational circuit, the following steps are
used:
1. The problems in stated
2. The number of inputs and outputs are determined
3. Assigning letter symbols to each input and output
4. Building the Truth table, which defines the relationship
between inputs and outputs, ( and the dont care
conditions).
5. Simplifying the truth table.
6. Drawing the logic diagram.
81
/AABU
Adders
Let us implement what we learned in the previous slide
and build a combinational circuit that adds two binary
numbers.
1. State the problem: Build a circuit that can add two
binary numbers ( HALF ADDER)
0+0= 0
0+1=1
1+0=1
1+1=10
2. Number of inputs is two , Number of outputs derived is
also two.
3. Let us name the inputs as X, Y, and the outputs as S for
Sum, and C for Carry_out.
82
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
4. Truth table
x y C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
5. Simplification:
C = x.y ( No more simplification)
S = x.y + xy
=x+y
83
/AABU
X
C
Y
S
84
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Full ADDER: Build a circuit that can Add three binary
numbers.
85
/AABU
Subtractors
Half Subtractor
86
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Full Subtractor
X- Y Z BD
000 = 00
00-1 = 11
011= 10
1-1-0 = 00
1 -1 1 = 11
87
/AABU
Code Conversion
We studied before different coding techniques for
numbers or alphanumarics, such as BCD, Excess_3 ,
88
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Truth table
Decimal BCD Ex_3
We also have dont care conditions
_______ ABCD wxyz
in this example, 1010,
0 0000 0011
1011,1100,1101, 1110,1111 are
1 0001 0100
not accepted codes in BCD, which
2 0010 0101
so can be considers as dont care.
3 0011 0110
4 0100 0111 d(A,B,C,D)=(10,11,12,13,14,15)
5 0101 1000 for all outputs.
6 0110 1001
7 0111 1010
8 1000 1011
9 1001 1100
89
/AABU
w x
y z 90
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Ex-3 to BCD
91
/AABU
92
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Example
93
/AABU
94
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Q 4.14
BCD to 7 segment display.
1. Build the truth table for each segment
2. Minimize the function of each segment, ( use the dont
care conditions)
95
/AABU
96
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Four-bit Adder
97
/AABU
98
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Building a BCD ADDER
The BCD adder should have 9 inputs, and 5 outputs.
Trying to build a truth table for this is not a good idea
(number of possible states for inputs is 29 =512.
We also will have many dont care states.
The other solution is to use 4bit full adders with a small
combinational circuit
Things to take into consideration
1. If the sum of the 2 BCD numbers is <= 9 , no problem in
the result
2. If the sum was greater than 9, it will not be in the BCD
format, we need to correct the result
99
/AABU
0101 0101
0100 0111
1001=9 1100 = 12 ,
but we write 12 in BCD as 0001 0010
Another case ( worst one)
1001
1001
10010 =18
Again , in BCD 18 is 0001 1000
100
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
The solution:
If the resulting sum is >9 we need to correct the sum by
adding 6= 0110
We have two cases
1) The answer between 1010 and 1111 , with carry =0
2) The carry out is 1 , which means that the sum is > 15
101
/AABU
102
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Decoder
n inputs, 2n outputs
exactly one output is 1 for each possible input pattern
2-bit
decoder
103
/AABU
Decoder
n inputs, 2n outputs
Y0 1
100 A
Y1 1
Y2 1
00
1 B
Y3 1
104
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
3x8 Decoder
Implement combinational circuits using a decoder , OR
gates
Ex. Full adder, using 3x8 decoder
105
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Decoder with Enable
If E=1 , else
all outputs
are zeros
107
/AABU
Y0
A
Y1
2x4
Y2
B
Y3
X
Y0
Y A
Y1
2x4
Y2
Z B
Y3
3x8 108
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
4x16 Decoder using 2x4 decoders
y0
A
B
C
D
y15
109
/AABU
3x8 D0-D7
D0- D15
3x8 D8-D15
110
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Demultiplexer
D0
A 2x4 decoder D0
D1 input 1x4 D1
B With Enable D2
D3
demultiplexer D2
D3
E S1 S0
111
/AABU
Encoder
An Encoder is a digital function that produces a reverse
operation for that of a decoder.
2n x n encoder , has 2n inputs and n outputs
112
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Multiplexer (MUX)
n-bit selector and 2n inputs, one output
output equals one of the inputs, depending on selector
4-to-1 MUX
113
/AABU
Multiplexer (MUX)
n-bit selector and 2n inputs, one output
0
1 I0
1 I1
1 I2
0 I3
S1 S0
0
0 1
114
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
115
/AABU
A0 A1 A2 A3 B0 B1 B2 B3
116
S /AABU
PDF created with pdfFactory trial version www.pdffactory.com
MUX to implement boolean functions.
We saw before how to implement a boolean function using
decoders.
We can also implement this using a mux
1. If we have a function with n variables we need a MUX
with n-1 selection lines ( 2n-1 MUX)
2. Find the implementation table, then draw the circuit
Ex. for F(x,y,z)=(1,3,5,6)
I0 I1 I2 I3
X 0 1 2 3
X 4 5 6 7
0 1 X X
117
/AABU
0 I0
1 I1 4x1 Output
X I2 MUX
X I3
S1 S0
Y Z
118
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Implement the boolean function
F(w,x,y,z)=(0,1,3,4,8,9,15) using Multiplexer
119
/AABU
ROM
Types:
ROM
PROM
EPROM
EEPROM
120
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
HOW ROM works
It consists of a decoder and OR gates.
In general Memory has address and Data lines.
We call a ROM with n address lines and m data lines 2nxm
memory
This memory has 2n words, each word is m bits
m outputs
n inputs 2nxm
ROM
121
/AABU
8 x 4 bit Memory
0 0010
1 0101
3 2 0000
Decoder
3 1111
001
4 0010
5 0101
6 1011
7 0011
D3 D2 D1 D0 122
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
From the previous discussion its clear that each output of
the ROM represents a SOP
Ex.
D0= (1,3,5,6,7)
D1= (0,3,4,6,7)
D2=
D3=
123
/AABU
Another example
Assume we want to build the Following Ckt that has two
inputs and three outputs
F0 (A1,A0) =(1,3)
F1 (A1,A0) = (0,3)
F2 (A1,A0) = (0,1,2)
We can build this Ckt using a 4x3 ROM = 22 x 3 bit ROM
This ROM is built from a decoder, OR gates
A1
2x4 4x3
Decoder ROM
A0
124
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Q. What is the Data stored in this ROM?
125
/AABU
126
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Combinational vs. Sequential
Combinational Circuit
always gives the same output for a given set of inputs
ex: adder always generates sum and carry,
regardless of previous inputs
Sequential Circuit
stores information
output depends on stored information (state) plus input
so a given input might produce different outputs,
depending on the stored information
example: ticket counter
advances when you push the button
output depends on previous state
useful for building memory elements and state machines
127
/AABU
Sequential Logic
Synchronous sequential circuits:
A system whose behavior can be defined form the
knowledge of its signals at discrete instants of time.
128
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
129
/AABU
130
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Flip Flops
131
/AABU
132
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
133
/AABU
134
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
R-S Latch: Simple Storage Element
R is used to reset or clear the element set it to zero.
S is used to set the element set it to one.
1 1
0 1 1 0
1
1 0 0 1
0
1 1
1 0
0
1 Output changes to zero.
1
1 0
1
0 1
0
0
PDF created with pdfFactory trial version www.pdffactory.com
Setting the R-S Latch
Suppose we start with output = 0, then change S to zero.
1
1 0
0 1
1 Output changes to one.
0
0 1
1 0
1
R=S=0
both outputs equal one
final state determined by electrical properties of gates
Dont do it!
138
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Gated D-Latch
Two inputs: D (data) and WE (write enable)
when WE = 1, latch is set to value of D
S = NOT(D), R = D
when WE = 0, latch holds previous value
S = R = 1
139
/AABU
Characteristic equations
Remember that the output
depends on the inputs and the
current state.
PDF created with pdfFactory trial version www.pdffactory.com
Characteristic equation for D flip flop
Qt D Qt+1 0 1
0 0 0
0 1 1 0 1
1 0 0
1 1 1 Q(t+1)=D
141
/AABU
J K flip flop
Its a refinement of RS flip flop , that defined the
indeterminate states in RS.
In RS flip flop the state 11 is not allowed ,
In JK flip flop the state 11 makes the flip flop changes
(switches) its output.
142
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
S3S2S1S0
1010
S1S0
1011
0 0 0 0
1100
1101 0 0 0 0
1110
1111 S3S2 1 1 1 1
0 0 1 1
S>=9 : Cout+S3S2+S3S1
143
/AABU
144
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Characteristic table and Equation
Qt J K Qt+1
0 0 0 0
JK
0 0 1 0
0 0 1 1
0 1 0 1
Q 1 0 0 1
0 1 1 1
1 0 0 1
1 0 1 0 Q(t+1)=JQ+KQ
1 1 0 1
1 1 1 0
145
/AABU
T flip flop
Its a single input version of the JK Flip flop
T flip Flop has the same
Problem of JK when T=1
Qt T Qt+1
0 1
0 0 0
0 1 1 1 0
1 0 1
1 1 0 Q(t+1)=TQ+TQ
146
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
147
/AABU
148
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
149
/AABU
S S S Q
Master Slave
R R R Q
CP
150
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
1
151
/AABU
152
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
IF D=0 Gate1=0,Gate4=1,Gate2=1,Gate3=1;
and CLK goes to 1
Gate 4=1, Gate 3=0, Gate1=0;Gate 2=1;
After the CLK being 1, if D changed to 1, this will not affect
on Gate 4 , nor any other gates.
153
/AABU
IF D=1 Gate1=1,Gate4=0,Gate2=1,Gate3=1;
and CLK goes to 1
Gate 4=0, Gate 3=1, Gate1=1;Gate 2=0;
After the CLK being 1, if D changed to 0, Gate 4 =1 , other
gates will not affect by this change.
154
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
155
/AABU
156
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
157
/AABU
158
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Example CP
X
A B
R Q
A S Q
B
Y
B R Q A
S Q
A
B
A
159
/AABU
State Table
AB AB AB Y Y
00 00 01 0 0
01 11 01 0 0
10 10 00 0 1
11 10 11 0 0
160
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
State diagram
The state table can be represented graphically using the state diagram.
Transition from a state to state is shown as arrow labeled with two
values (Input/output)
00
01
10
11
161
/AABU
State equation
State equation (or application equation) is an expression
that shows the relation for the next state of each flip flop
as a function of the present state and the inputs,
Method 1: using the characteristic equation of the flip flop
A(t+1) =S+RQ
= X.B+ (X.B)A
= X.B+(X+B).A
= XB+X.A+A.B
B(t+1) = S+RQ
= X.A+(XA).B
= X.A+X.B+A.B
162
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
State equation
Method 2:
From the state table.
A(t+1) = (AB+AB+AB).X + ABX
=ABX+ABX+ABX +ABX
=BX+AX+AB
163
/AABU
164
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
The following formulas for JK flip flop inputs will help us
Qt Qt+1
0 to 0 J=0, K=X ( dont care)
0 to 1 J=1, K=X
1 to 0 J=X, K=1
1 to 1 J=X, K=0
165
/AABU
Qt Qt+1 D Qt Qt+1 T
0 0 0 0 0 0
0 1 1 0 1 1
1 0 0 1 0 1
1 1 1 1 1 0
D T
166
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Example 1
Design a circuit that works as a counter from 0 to 3 if the
input x is 1 and stay in the same state if x is 0
0
00
1 1
0
01 11
0
1 1
10
0 167
/AABU
Example 0
Design a counter that counts from 3 down to 0 one step
on each clock
168
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
State table
X=0 X=1
AB AB AB
00 00 01
01 01 10
10 10 11
11 11 00
169
/AABU
Excitation table
Next state flip flop inputs
ABX AB JA KA JB KB
00 0 00 0 X 0 X
00 1 01 0 X 1 X
01 0 01 0 X X 0
01 1 10 1 X X 1
10 0 10 X 0 0 X
10 1 11 X 0 1 X
11 0 11 X 0 X 0
11 1 00 X 1 X 1
PDF created with pdfFactory trial version www.pdffactory.com
0 0 1 0 x x x X
x x x X 0 0 1 0
JA=Bx KA=Bx
0 1 x X x x 1 0
0 1 x x x x 1 0
JB=x KB=x
171
/AABU
Example 2
Design a circuit that works as a down counter from 3
down to 0 if the input x is 1 and stay in the same state if
x is 0
172
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Example 3
Design a sequential Ckt that generate the following
sequence 000, 001, 010,100 , using JK flip flops
01 11
1 1
10
173
/AABU
Example 4
Repeat example 1 using RS flip flop
1) How RS Flip flop works
0 to 0 S=0, R=X ( dont care)
0 to 1 S=1, R=0
1 to 0 S=0, R=1
1 to 1 S=X, R=0
174
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Excitation table
Next state flip flop inputs
ABX AB SA RA SB RB
00 0 00 0 X 0 X
00 1 01 0 X 1 0
01 0 01 0 X X 0
01 1 10 1 0 0 1
10 0 10 X 0 0 X
10 1 11 X 0 1 0
11 0 11 X 0 X 0
11 1 00 0 1 0 1
0 0 1 0 X X 0 X
X X 0 X 0 0 1 0
SA= RA=
0 1 0 X x 0 1 0
0 1 0 X x 0 1 0
SB= RB=
176
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Example 5
Design an up_down counter that counts from 0 to 6,
depending on the input value, if x=0 it counts down, if 1 it
counts up
000
110
001
101
010
100
011
177
/AABU
010
100
011 178
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Non-Standard Counters
179
/AABU
180
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
181
/AABU
182
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Complete Example
A blinking traffic sign
No lights on
1 & 2 on
1, 2, 3, & 4 on 3
4
1, 2, 3, 4, & 5 on 1
5
(repeat as long as switch
2
is turned on)
When the input is 0 , No lights on
DANGER
MOVE
RIGHT
183
/AABU
Switch on
Switch off
State bit S1
State bit S0
Outputs
PDF created with pdfFactory trial version www.pdffactory.com
State Output
X Combinational Ckt
Sequential Ckt
185
/AABU
Lights 3 and 4 In S1 S0 S1 S0
Light 5
0 X X 0 0
S1 S0 Z Y X 1 0 0 0 1
0 0 0 0 0 1 0 1 1 0
0 1 1 0 0 1 1 0 1 1
1 0 1 1 0 1 1 1 0 0
1 1 1 1 1
Whenever In=0, next state is 00.
186
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
2 input Sequential Ckts
Q. Build a counter that counts from 0 to 3, this counter
has two inputs X,Y,
XY
00 Reset the counter ( go to state 00)
01 Count forward
10 Counts backward
11 No change
187
/AABU
00
01 11
10
188
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
State table
Next state
Present state XY=00 XY=01 XY=10 XY=11
AB AB AB AB AB
00
01
10
11
189
/AABU
Excitation table
XYAB AB TA TB
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
190
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Chapter 7
Gated D-Latch
Two inputs: D (data) and WE (write enable)
when WE = 1, latch is set to value of D
S = NOT(D), R = D
when WE = 0, latch holds previous value
S = R = 1
192
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Register
A register stores a multi-bit value.
We use a collection of D-latches, all controlled by a common WE.
When WE=1, n-bit value D is written to register.
193
/AABU
4 bit register
A3 A2 A1 A0
Q Q Q Q
D D D D
Clock
I3 I2 I1 I0
194
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Register with
parallel load
195
/AABU
196
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Serial
Transfer
197
/AABU
198
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Serial Adder
199
/AABU
200
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Ripple
counter
201
/AABU
1 Q J 1 Q J 1 Q J 1
Q J
Clk Clk Clk Clk
K 1 K 1 K 1 K 1
202
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Decimal counter
203
/AABU
BCD Ripple
counter
204
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
In BCD counter the first digit flips with the clock,
The second digit flips depending on the first digit a clock
if the number is less than 8, since J is connected to Q8
When Q8 becomes 1, J will be 0, this will clear Q2.
BUT this will take effect only after Q0 goes from 1 to 0.
What about J8
205
/AABU
Load Clear
I0 A0
I1 A1
I2 A2
I3 A3
Clock
206
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Using an MSI Binary counter , Build a BCD counter
As you know, BCD counter goes to 0 after 9.
All what we want to do is to load 0 if the counter value is 9
Load
I0 A0
I1 A1
I2 A2
I3 A3
0
Clock
207
/AABU
208
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Build a counter that counts from 5 to 13
209
/AABU
Johnson counter
Self read.
Required for the exam.
210
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
Memory Unit
A memory unit stores binary information in groups called
words. Each is n bits.
Memory size is the number of locations (words) that a
memory have.
A memory word ( which contains binary numbers) is used
to represent an Instruction, Number, Character,
MAR
Read
MDR
Write
M
A Memory
R
MDR
211
/AABU
input Output
BC
Read/Write
R
S Q
212
/AABU
PDF created with pdfFactory trial version www.pdffactory.com
213
/AABU
PDF created with pdfFactory trial version www.pdffactory.com