Digital Electronics 1
Digital Electronics 1
(Theory)
GATE & ESE
Disclaimer: The content provided herein is created and owned by a third-party service
provider and licensed to the Company. The Company disclaims all rights and liabilities
in relation to the content. The author of the content shall be solely responsible towards,
without limitation, any liabilities, damages, or suits which may arise with respect to the
same. The content contained herein is copyright protected and any unauthorised use or
distribution is not allowed.
2
Contents
Chapter 1 Number Systems 07 - 26
Chapter 2 Boolean Algebra and Logic Gates 27 - 67
Chapter 3 Combinational Logic Circuits 69 - 109
Chapter 4 Sequential Logic Circuit 111 - 148
Chapter 5 Data Converters 149 - 159
Chapter 6 IC Logic Families 161 - 185
Chapter 7 Semiconductor Memories 187 - 193
Chapter 8 Microprocessors 195 - 264
3
4
Syllabus EE
Combinational and sequential logic circuits, multiplexer, demultiplexer, schmitt trigger,
sample and hold circuits, A/D and D/A converters, 8085 microprocessor: architecture,
programming and interfacing.
Syllabus ECE
• Number systems; binary integers and floating point numbers
• Combinatorial circuits: Boolean algebra, minimization of functions using Boolean
identities and Karnaugh map, logic gates and their static CMOS implementations,
arithmetic circuits, code converters, multiplexers, decoders and PLAs
• Sequential circuits: latches and flip-flops, counters, shift-registers and finite state
machine, propagation delay, setup and hold time, critical path delay
• Data converters: sample and hold circuits, ADCs and DACs
• Semiconductor memories: ROM, SRAM, DRAM
5
6
Number Systems
Introduction
In science, technology and business and many other fields of endeavor we constantly
deal with quantities. These quantities are measured, manipulated and recorded using
physical systems. There are basically two systems to represent numerical value of a
quantity which are analog and digital. In analog representation a quantity is measured
by voltage, Current or meter movement which is proportional to the quantity under
measurement. Some examples of analog representation are auto speedometer, mercury
thermometer etc.
In digital representation, quantities are not represented by proportional values but
rather by symbols or digits. Some examples of digital representation are 10 decimal
digits, 26 alphabets, 52 playing cards etc. The most frequently used number systems in
the applications of digital computers are binary number system, octal number system,
decimal number system and hexadecimal number system.
7
Number Systems
(ii) The base decides the total number of digits available in the number system. For
example, if base is 2, we have 2-digits (0 and 1), if base is 10, we have 10-digits
(0 to 9) and so on. Therefore, the total number of digits available in the number
system is equal to the base of the number system
(iii) First digit in the number system is always zero (0) and the last digit in the number
system is always base −1. As an example, in the decimal system, the last digit is 9,
i.e., (10 − 1 = 9)
The radix of binary number system = 2 i.e., it uses two different symbols 0 and 1 to write
the number sequence.
The radix of octal number system = 8 i.e., it uses eight different symbols 0, 1, 2, 3, 4, 5, 6
and 7 to write number sequences.
The radix of the decimal number system = 10 i.e., it uses ten different symbols 0, 1, 2, 3,
4, 5, 6, 7, 8 and 9 to write number sequences.
The radix of hexadecimal number system = 16 i.e., it uses sixteen different symbols 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F to write the number sequence.
The radix of ternary number system = 3 i.e., it uses three different symbols 0, 1 and 2 to
write the number sequence.
To distinguish one number system from the other, the radix of the number system is
used as a suffix to that number.
8
Number Systems
1 Binary 2
2 Octal 8
3 Decimal 10
4 Hexadecimal 16
5 Ternary 3
Example: 102 binary number; 108 octal number; 1010 decimal number; 1016 hexadecimal
number
9
Number Systems
Solved Examples
Problem:
Convert the following decimal number 3710 into binary equivalent.
Solution: r = 2
Quotient Remainder
37/2 18 + 1
18/2 9+0
9/2 4 + 1
4/2 2+0
2/2 1+0
½ 0 + 1
1 0 0 1 0 1 ∴ 3710 = 1001012
10
Number Systems
Solved Examples
Problem:
Convert the following decimal number 0.687510 into binary equivalent.
Solution: r = 2
0.6875 × 2 = 1.3750 1
0.3750 × 2 = 0.7500 0
Go from top
to Bottom
0.7500 × 2 = 1.5000 1
0.5000 × 2 = 1.0000 1
∴ (0.6875)10 = 0.10112
Problem:
Convert the following decimal number (37.6875)10 to its binary equivalent.
Solution: r = 2
(37.6875)10 = x2
3710 = 1001012 0.687510 = 0.1011
Hence (37.6875)10 = 100101.10112
Note:
(A) Convert the integral part of decimal to binary equivalent
(1) Divide the decimal number by 2 and store remainders in an array
(2) Divide the quotient by 2
(3) Repeat step 2 until we get the quotient equal to zero
(4) Equivalent binary number would be the reverse of all remainders of step 1
11
Number Systems
Problem:
Convert the following decimal number 15310 to its octal equivalent.
Solution: r = 8
153/8 = 19 +1
Go from
19/8 =2 +3 bottom
to top
2/8 =0 +2
∴ 15310 = 2318.
Problem:
Convert the following decimal number (0.513)10 to its octal equivalent.
Solution: r = 8
0.513 × 8 = 4.104 4
0.104 × 8 = 0.832 0
0.248 × 8 = 1.984 1
(0.513)10 = (0.406517…)8
Problem:
Convert the following decimal number 25310 to its hexadecimal equivalent.
Solution: r = 16
253/16 = 15 + (13 = D)
15/16 = 0 + (15 = F) 4 25310 = FD16.
12
Number Systems
Solved Examples
Problem:
Convert the binary number 1011012 to its decimal equivalent.
Solution: 101101 = 25 × 1 + 0 × 24 + 1 × 23 + 0 × 21 + 1 × 20 = 32 + 8 + 4 + 1 = 45
(101101)2 = 4510
Problem:
Convert the octal number 2578 to its decimal equivalent.
Problem:
Convert the hexadecimal number 1AF.23 to decimal.
Decimal (Base = 10) Binary (Base = 2) Octal (Base = 8) Hexadecimal (Base = 16)
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
13
Number Systems
Solved Examples
Problem:
Convert the following hexadecimal number (2C6B.F2)16 into its binary equivalent.
Problem:
Convert the following hexadecimal number (3A.E5)16 into its octal equivalent.
Solution: (3A.E5)16 = (0011 1010.1110 0101)2 = (111 010.111 001 010)2 = (72.712)8
Summary of Conversion
• When converting from radix-r to decimal use the method of taking the weighted sum
of each digit position
• When converting from decimal to radix-r, use the method of repeatedly dividing by
‘r’ and collecting remainders
• When converting from binary to octal (or hex), group the bits in a group of 3 (or 4)
bits and represent each such combination by equivalent octal or hexadecimal value
• When converting from octal (or hex) to binary, represent each digit by a group of
3(or 4) bits
• When converting octal to hex (or vice versa), first convert to binary and then convert
to desired number system
14
Number Systems
Binary Codes
BCD (Binary Coded Decimal): In this each digit of the decimal number is represented by
its four bit binary equivalent. It is also called natural BCD or 8421 code. It is a weighted
code.
10 out of 16 combinations of 4 bits are used in BCD code and 6 combinations are left
unused. Don’t care values or unused states in BCD code are 1010, 1011, 1100, 1101, 1110,
and 1111.
Excess-3 Code: This is an un-weighted binary code used for decimal digits. Its code
assignment is obtained from the corresponding value of BCD after the addition of 3.
Don’t care values or unused states in excess-3 code are 0000, 0001, 0010, 1101, 1110, 1111.
Gray Code: It is a very useful code called “minimum change codes” in which only one bit
in the code group changes when going from one step to the next.
It is an unweighted code which means different bit positions do not have any specific
weights assigned to them. There are no unused states in this code.
Solved Examples
Problem:
Convert the following decimal number (943)10 into its BCD equivalent.
Solution:
9 -> 1001
4 -> 1000
3 -> 0011
(943)10 -> (100110000011)
Problem:
Convert the following decimal number (137)10 into its binary and BCD equivalent.
Solution:
(137)10 -> (10001001)2
15
Number Systems
Problem:
Convert the following decimal number (48)10 into its equivalent excess-3 code.
Problem:
Convert the following binary number (10011)2 into its equivalent gray code.
Solution:
1 0 0 1 1
1 1 0 1 0
(10011)2 == 🡺 (11010)Gray
Problem:
Convert the following gray code (11010)Gray into its binary equivalent.
Solution:
1 1 0 1 0
1 0 0 1 1
(11010)Gray 🡺 (10011)2
16
Number Systems
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Complements
Complements are used in digital computers to simplify the subtraction operation and
logical manipulation. Two types of complements are defined:
Solved Examples
Problem:
Find 9’s complement of the decimal number (54700)10.
Solution: N = 54700, n = 5, r = 10
9’s complement = (105 − 1) − 54700 = 99999 − 54700 = 45299
17
Number Systems
Problem:
Find 1’s complement of the binary number (10110110)2.
Solution: Complement all the bits i.e. replace all 0’s by 1’s and vice versa.
1’s complement of (10110110)2 = (01001001)2
Problem:
Find 2’s complement of the binary number (10110011)2.
Solved Examples
Problem:
What is the range of signed decimal numbers that can be represented by 6-bit 1’s
complement number?
Solution: Range = −(2n−−1 − 1) to (2n−−1 − 1)
In this case, n = 6
Hence, range = −31 to 31
18
Number Systems
Binary Arithmetic
Binary Arithmetic refers to arithmetic operation on binary numbers like addition,
subtraction and multiplication. Subtraction can be treated as addition of negative
numbers so that addition and subtraction can be looked upon as binary addition of two
numbers.
Rules
(1) When both numbers have same sign (i.e., addition) then we add only magnitudes
and use the sign as MSB,
(2) When both numbers have different sign (i.e., subtraction) then we can perform
addition in two ways:
19
Number Systems
Solved Examples
Problem:
Find the result of binary addition of (3)10 and (4)10.
Solution:
+3 => 0 0 1 1
+4 => 0 1 0 0
+7 => 0 1 1 1
Problem:
−4)10.
Find the result of binary addition of (3)10 and (−
+3 => 0 1 1
-4 => 0 1 1
Always take care of balancing of numbers; it means both
number have equal number of digits or not.
+ 1 1 0
20
Number Systems
Problem:
−4)10 using 2’s complement addition.
Perform binary addition of (3)10 and (−
Solution: Taking 2’s complement of 4 (0100) => (1100)
+3 => 0 0 1 1
-4 => 1 1 0 0
Always take care of balancing of numbers; it means both
number have equal number of digits or not
1 1 1 1
Since, the MSB is 1 the result is negative and we need to take 2’s complement of the
result.
2’s complement of result = (001)2 = 110
So, the result is −110.
BCD Addition
(1) Add the BCD numbers as regular true binary numbers
(2) If the sum is 9(1001) or less, the result is a valid BCD Number
(3) If the sum is greater than 9 or there is a carry out of MSB, the result is an invalid
BCD number
(4) If the result is invalid then 6(0110) is added to the result to make it valid and carry
out of BCD digit is added to the next more significant BCD digit
Solved Examples
Problem:
Perform BCD addition of the following numbers (87)10 and (99)10.
Solution
87 = 1 0 0 0 0 1 1 1
99 = 1 0 0 1 1 0 0 1
1 0 0 0 0
Carry
So, this BCD number is invalid as per Step-3 so 6 (0110) must be added.
21
Number Systems
87 = 1 0 0 0 0 1 1 1
99 = 1 0 0 1 1 0 0 1
1 0 0 0 0
+ 0 1 1 0
1 0 1 1 0
87 = 1 0 0 0 0 1 1 1
99 = 1 0 0 1 1 0 0 1
1 0 0 1 0 0 1 1 0
Carry
So, this BCD digit is also invalid due to carry generated and thus we add 6 (0110) to the
result.
The result thus obtained is (1 1000 0110) = (0001 1000 0110) = (186)10
Floating–Point Number
Basics Concepts
All the numbering systems which have been discussed so far fall in the category of
base r fixed point numbers. Fixed point number means that the fractional number (i.e.,
decimal point) once finalized will remain fixed. The functional point is fixed within each n
bit number word. For example, if the system is 8 bit, and we decided that the fractional
point is after 5th bit then binary format will be as given below.
Floating Point
Here, it will be interesting to note that ones, the number of bits is finalized for a
particular system, we cannot change it abruptly. Hence, for above format, minimum
number we can represent is (0)2 i.e.,
B4 B3 B2 B1 B0. B−1 B−2 B−3 = (00000.000)2 Minimum number that we can present is
B4 B3 B2 B1 B0. B−1 B−2 B−3 = (11111.111)2 i.e., (31.875)10
22
Number Systems
Remedy
The remedy to this problem is the switch over to the scientific notation. In scientific
notation, the number is in the form of N = M × 10E, where M and E are fixed point
numbers called mantissa and exponent respectively.
E is an integer that specifies the number of zeros to be appended to M, to obtain floating
point number N. Here, we may ask one question why the version of scientific number
(notation) is called FLOATING POINT. To understand this, we shall take a simple example.
Let us consider the number (1000.234)10
This number can be represented as under:
1000234 × 10−3
1000234 × 10−2
1000234 × 10−1
1000234 × 10−0
1000234 × 101
10.00234 × 102
1.000234 × 103
0.1000234 × 104
In representation of (1000.234)10, we must have observed that the decimal point is
not fixed as such it can FLOAT from number to number depending upon power of 10.
Normally, in scientific notation, we represent numbers as M × BE. Therefore, depending
upon our requirement, we set E and in M will allow decimal points to float. Therefore, it
is called a floating-point numbering system. In N = ±M × BE,
B = base of floating point number system. We have taken base 10 for the decimal system.
But, for binary number, it will be 2, B = 2
0 1 9 10 31
23
Number Systems
Question:
Consider the following floating point number representation
31 24 23 0
Exponent Mantissa
The exponent is in 2's complement representation and mantissa is in the sign magnitude
of the normalized number in this representation.
Solution:
Given floating point number representation is
31 24 23 0
Exponent Mantissa
⇒ (21 − 1) × 2−1
⇒ 0.5
Maximum value of magnitude of mantissa is,
24
Number Systems
⇒ (223 − 1) × 2−23
⇒ (1 − 2−23)
Thus the range of magnitude of the normalized number is 0.5 to (1 − 2− 23).
Question:
The following is a scheme for floating point number representaion using 16 bits.
Bit position
15 14 9 8 0
S e m
Let S, e, m be the number represented in binary in the sign, exponent and mentissa field
respectively. Then the floating point number represented is,
0 Otherwise
What is the maximum difference between two successive real number representable in
this system?
Solution:
Given floating point number representation using 16-bit is show below
Bit position
15 14 9 8 0
S e m
First Method
According to question, definition of floating point number is,
25
Number Systems
Let us assume to real successive number W1 and N2 mantissa (m − 1) and (m) respectively
So, N1 can be represented in given floating point representation as,
N1 = (−1)s [1 + (m − 1) × 2−g) × 2+ 31
N2 = (−1)s [1 + m × 2−g) × 2+ 31
N2 − N1 = (−1)s × 2−g × 2+ 31
N2 − N1 = (−1)s × 2+ 31
So, N2 − N1 = 222
Thus maximum difference between two successive real number represented under given
system is 222.
Second Method
Maximum value of exponent (e) can be 111110 = 62
i.e., e = 62
So floating point representation is
Now we can chessing two successive real number N1 having decimal value of mantissa is
zero and N2 having decimal value of mantissa is 1, then,
26
Boolean Algebra and Logic Gates
Chapter 2
Boolean Algebra and Logic Gates
Objectives
Upon completion of this chapter you will be able to:
• Form the logic expressions from switching circuits and venn diagrams
Introduction
In the digital age, the cost of digital circuits used to implement the logic becomes a
crucial factor. Hence finding simpler, cheaper but equivalent realization of logic can
result in huge benefits in reducing overall cost of the design.
Advantages of Minimization
• Number of logic gates required to implement the logic is reduced so it leads to a
simpler and cheaper logic
• Speed of circuit increases due to the fact that signal now traverses through a lot
less logic gates so the propagation delay encountered is less
Boolean Algebra
• When no. of variable are less (1, 2, 3)
• It is preferred when output is 0 or 1
27
Boolean Algebra and Logic Gates
Boolean Laws
In this section we will discuss the following Boolean laws:
• Commutative law
• Associative law
• Distributive law
• AND law
• OR law
• INVERSION law
K–Map
• When no. of variables are 2, 3, 4, 5 (up-to 5 variable)
• Output is 0, 1 or x (don’t care)
Tabulation Method
• It is used when numbers of variables are more
Boolean Algebra
Boolean constants and variables are allowed to have only two possible values 0 and 1.
The Boolean 0 and 1 do not represent actual numbers but rather the state of a voltage
variable or what is called as its Logic Level. Boolean algebra is a means of expressing a
relationship between inputs and output of a logic circuit.
Logic 0 Logic 1
False True
Off On
Low High
No Yes
Truth Table
A Truth Table is a means to show how the output logic of the circuit depends on the
input logic level for various combinations of the inputs.
28
Boolean Algebra and Logic Gates
INPUTS OUTPUT
A B Y
0 0 1
0 1 0
1 0 0
1 1 1
A
? Y
B
The figure above shows a logic circuit with two inputs A and B and one output Y. The
truth table shown on the right depicts the logic level of the output for each possible
combination of the input. This is the most basic way of representing the functionality of
a logic circuit.
• NOT (A or A')
0 = 1 A=A
1=0
• AND (.)
0.0 = 0 A.A = A
0.1 = 0 A.1 = A
1.0 = 0 A.0 = 0
1.1 = 1 A.A = 0
• OR (+)
0 + 0 = 0 A+A=A
0 + 1 = 1 A+1=1
1 + 0 = 1 A+0=A
1 + 1 = 1 A+A=1
29
Boolean Algebra and Logic Gates
Solved Examples
Problem:
Simplify AB + AB
Solution: A(B + B) = A ( B + B = 1)
Problem:
Find the min. no. of NAND gate required to implement this function: AB + ABC + AB C
(a) 0 (b) 1 (c) 2 (d) 3
Solution:
AB + ABC + AB C = AB + AB(C + C)( C + C = 1)
AB + ABC + AB C = AB + AB = A(B + B) = A
No NAND gate required
A A
i/p o/p
ABC = A + B + C
A+B+C=A.B.C
30
Boolean Algebra and Logic Gates
Shortcut Method
(a) Three variable
(b) Each variable comes twice
(c) One variable is complemented
Solved Examples
Simplify the following logic expressions:
(a) AB + AB C + AB CD
Solution:
AB C + AB(1 + CD )(1 + λ = 1)
= AB C + AB = A(B + BC) ( B + BB = B + C)
= A(B + C) = AB + AC
(b) (A + B) (A + C)
Solution:
A.A + A.C + AB + BC = A + A(C + B) + BC = A(1 + B + C) + BC = A + BC
Solution:
take A + B = X
= (X + C)(A + B + C)(X + C) = (X + CC)(A + B + C) (By Distribution Theorem)
= X(A + B + C) = (A + B)(A + B +C) = A + B(B + C) = A + BB + BC = A + BC
(d) (A + B)(A + B) (A + B) (A + B)
Solution:
(A + B)(A + B) (A + B) (A + B) = (A + BB)(A + BB) = (A)(A) = 0 (Distribution Theorem)
(e) A + AB
Solution:
(A + A)(A + B) = 1(A + B) = A + B (Distribution Theorem)
31
Boolean Algebra and Logic Gates
(f) A + AB
Solution:
(A + A)(A + B) = 1(A + B) = A + B (Distribution Theorem)
(g) AB + A B + AB
Solution:
A(B + B) + A B = A + A B = (A + A)(A + B) = A + B(Distribution Theorem)
(h) AB + AB + AB
Solution:
B(A + A) + AB = B + AB = (B + A)(B + B) = A + B (Distribution Theorem)
Solution:
ABC + ABC + ABC + ABC ( A + A = A)
= AB(C + C) + (C + A)BC = AB + BC = B(A + C)
Solution:
AB + AC + BC(A + A) = AB + AC + BCA + ABC = AB(1 + C) + AC(1 + B) = AB + AC
(k) AB + BC + AC
Solution:
BC + AC(The term which is complemented is taken)
(l) AB + BC + AC
Solution:
AB + BC
Solution:
(A + B)(A + C) ( (B + C) is redundant term)
32
Boolean Algebra and Logic Gates
(o) A B + AC + B C
Solution:
In this case all the variables are complemented only one is un-complemented then.
= A B + AC(∴ The term which is un-complemented is taken)
(p) A B + BC + A C
Solution:
f[f(x + y, y), z] = f[x + y + y, z] = f[x. y + y, z] = x. y + y + z = x y. y + Z
Minterm
It is a standard product term i.e., a product term which contains all variables of a given
function either in normal form or compliment form. The variables are so arranged that
the product should be 1.
Maxterm
It is a standard sum term i.e., a sum term which contains all the variables of the function
either in normal or compliment form. The variables are so arranged that the sum should
be 0.
F(A, B, C) = min terms F(A, B, C) = max terms
A B C = m0 (0, 0, 0) A + B + C = M7(1, 1, 1)
A B C = m1 (0, 0, 1) A + B + C = M6(1, 1, 0)
A B C = m7 (1, 1, 1) A + B + C = M0(0, 0, 0)
33
Boolean Algebra and Logic Gates
Properties
(1) n – variable function → {2n min terms & 2n max terms}
(2) Mj = mj & mj = Mj
= m =
M ; M m
(3) iD
2n − 1 − i (
iD
) ( )
2n − 1 − i ; D = indicates dual
2n − 1 2n − 1
(4) ∑ mi = 1 ; ∏ Mj = 0
i=0 j=0
Solved Examples
Problem:
For the given truth table, minimum SOP expression.
A B Y
0 0 1
0 1 0
1 0 1
1 1 0
Solution:
In SOP form only 1 taken.
= A B + AB = B(A + A) = B
Y can written as: Y (A, B) = Σ m(0, 2)
34
Boolean Algebra and Logic Gates
Problem:
Simplified the expression for Y (A, B) = Σ m(0, 2, 3)
Problem:
In canonical SOP form, no. of minterm presenting the logical expression: A + AC is___.
Solution:
A + BC = A(B + B)(C + C) + BC(A + A) = (AB +AB)(C + C) + ABC + ABC
: A + BC = ABC + ABC + ABC + ABC + ABC + A BC = ABC + ABC + ABC + ABC + A BC
i.e., 5 terms.
(1) A⋅0 = 0
(2) A⋅1 = A
(3) A⋅A = 0
(4) A + A = 1
(5) A + A = A
(6) A⋅A = A
(7) A + 0 = A
(8) A + 1 = 1
(9) A + BC = (A + B) (A + C)
(10) A + AB = (A + A) (A + B) = A + B
(11) A + AB = A + B
(12) A + A B = A + B
(13) A + A B = A + B
35
Boolean Algebra and Logic Gates
Solved Examples
Problem:
For a given truth table minimize POS expression.
A B Y
0 0 1
0 1 0
1 0 1
1 1 0
Y ( A,B )
And for SOP:= ∑
= m ( 0,2 ) B Y(A,B) = ∑m(0, 2) = B
n
Notes: With n variable maximum possible logical expression are 22
2
Example: for n = 2, logical expression = 22 = 16
Logic Gates
Logic Gates are the most fundamental digital circuits that can be constructed from
diodes, transistors and resistors connected in such a way that the circuit output is the
result of a basic logic operation performed on the inputs. It is a device which accepts
two or more inputs and produces a single output. The function of each logic gate can be
represented by a Boolean expression.
Logic Gates
36
Boolean Algebra and Logic Gates
NOT Gate
Figure shown below shows the symbol for a NOT gate which is more commonly referred
to as inverter. This circuit always has a single input and the output logic level is opposite
to the input.
Truth Table
Input A Output Y
0 1
1 0
A A=Y
A A=Y
Equivalent Circuit
A Y
0 1
1 0
Solved Examples
Problem: Circuit shown in the figure represents:
(a) Buffer
(b) Astable MV
(c) Bi-stable MV
(d) Square wave generator
37
Boolean Algebra and Logic Gates
Problem:
Circuit shown is
3tpd
3tpd
38
Boolean Algebra and Logic Gates
Problem:
In a circuit shown in figure the proportion delay of each not gate is 100p sec. then
frequency of generator square wave.
(a) 10 GHz
(b) 1 GHz
(c) 100 MHz
(d) 10 MHz
Solution:
T = 2Ntpd = 2 × 5 × 100p sec = 1000p sec
1 1
f= = = 109 Hz = 1GHz
T 1000 × 10-12 sec
Problem:
The circuit shown in the fig. the proportion delay of each NOT gate is 2nsec. Then the
time period of the generated square wave is.
(a) 6 ns
(b) 14 ns
(c) 12 ns
(d) 18 ns
X
Y
Solution:
Astable multivibrator, square wave generator.
T = 2Ntpd = 2 × 3 × 2nsec = 12nsec
39
Boolean Algebra and Logic Gates
6nSec
X 6nSec
6nSec
Y
6nSec
Notes:
(1) When even number of inverters (NOT gates) are connected in feedback, then it acts
as bistable multivibrator
(2) When odd number of inverters (NOT gates) are connected in feedback, then it
acts as astable multivibrator or square wave generator or ring oscillator or clock
generator
1
• Output frequency of ring oscillator f0 = = fclock
2nt pd
AND Gate
The output of AND gate is AND product of the inputs. In other words, the output of an
AND gate is high only if all the logic inputs are high and otherwise the output is low.
The output is high(Y = 1) if and only if all the inputs to the AND gate are high (1). The
output is low (0), if any one or more inputs are low (0). AND gate can have two or more
inputs and only one output.
Y = AB
40
Boolean Algebra and Logic Gates
Truth Table
Inputs Output
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
A B
AB =
B A
A A AB
B ABC = B
C ABC
C C
A
0
0
Control(Disable)
A
A
1
Control(Enable)
41
Boolean Algebra and Logic Gates
• In the TTL logic family, if any input is open, and floats then it will act as ‘1’.
• In the ECL logic family, floating input will act as logic ‘0’.
B Y
Unused Inputs
(1) A Vcc
A
B
B
B
1
• In multi pin (input) AND gate unused input can be connected to logic 1 or “pull up”.
• Unused input can be connected to logic ‘0’ or “pull down”.
(2) A A.B.B = AB A
A.A.B = AB
B B
(3) A
B Y=AB (only for TTL)
• If it is TTL logic family, then unused input can be open or floated. (unconnected)
Note:
• Because of unnecessary input attached to B, fan in will be down. (Fan-in is the
maximum number of inputs that a digital logic gate can accept).
B Y=AB
• Best way to connect unused pins (I/P) in AND gate is connecting to logic ‘1’.
42
Boolean Algebra and Logic Gates
B Y=AB
A+B
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
Inputs Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
A B
A+B A+B
B A
43
Boolean Algebra and Logic Gates
A A A+B
B B A+B+C
C A+B+C
C
A
Y=A
Control
0
A
Y=1
Control
Unused I/P’s
(1) In OR gate, unused I/P is connected to logic. ‘0’ “pull down”.
(2) Connect to be one of the used I/P.
(3) If it is ECI then unused I/P can be open or floated.
• In OR gate, Best way of connecting the unused I/P is to connect to logic ‘0’.
A Y=A+B
44
Boolean Algebra and Logic Gates
Solved Examples
Problem:
In the circuit shown in fig. in TTL, AND, OR, INVERTER circuit for the given input, output
is:
(1) 0
(2) 1
(3) AB
(4) AB
A AB
Y
floated 1 + AB = 1 0
1
1
I/P
1
Solution: In TTL, all inputs are float then it is logic ‘1’. Hence option (a) is correct.
Problem:
For ECL AND, OR, INVERTER circuit for the given input, output is :
(1) 0
(2) 1
(3) AB
(4) AB
A AB
Y
float AB AB
0
0 0
Solution: If all inputs are floating in ECL then it is ‘0’ and output Y = AB
45
Boolean Algebra and Logic Gates
NAND Gate
It behaves like an AND gate followed by an inverter. The output of this gate is low if both
inputs are high and otherwise high.
A AB = A + B
A
A+B
B
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
Inputs Output
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
A A
1 A
0 1
46
Boolean Algebra and Logic Gates
• NAND gate follows commutative law but does not follow associative law.
A A AB
B ABC = B
C (AB)C = AB + C
C
• There are only two gates that do not follow associative law i.e. universal gate NAND
or NOR gate.
• Unused input in NAND gate can be connected similar to unused input in AND gate.
B Y
A A
A+B=A.B
Y = A.B
B B
Inputs Output
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
47
Boolean Algebra and Logic Gates
A A
A 0
0 enable 1 disable
• NOR gate follows commutative law but not follows associative law.
i.e. A + B = B + A and A + B + C = A + BC
• Unused I/P in NOR gate can be connected similar to OR gate (i.e. connected to logic
low)
EX-OR or XOR
• Exclusive OR gate. The output of this logic gate is high when the number of 1’s at the
input is odd and low when the number of 1’s at the input is even.
• For two inputs of XOR gate, this condition translates to output being low when both
inputs are equal and high when both inputs are different.
Y=A⊕B
B
Inputs Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
• SOP expression = AB + AB
• POS expression = (A + B) (A + B)
A A
A A
0 Buffer 1 inverter
48
Boolean Algebra and Logic Gates
Note:
A⊕A= 0
A⊕A=1
A⊕0 =A
A⊕1 =A
If A ⊕ B = C then
A⊕C = B
B ⊕C =A
A⊕B ⊕C = 0
B, if n is add
B ⊕ B ⊕ B ⊕ ...........n
0, if n is even
Solved Examples
Problem:
The circuit shown in fig. contains cascading of 20 EXOR gate. If x is the Input then output
is
(a) 0
(b) 1
(c) x
(d) x
x
Y
AB + BA
49
Boolean Algebra and Logic Gates
A B B Y = (A ⊕ B ⊕ C)
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
A
A
B
B Y =
Y
C
C
• The o/p of EXOR gate is 1. When no. of 1’s at the input is odd.
EX-NOR or XNOR
• Exclusive NOR gate. The output of this logic gate is high when the number of 1’s at
the input is even and low when number of 1’s at the input is odd.
• For two input XNOR gates, this condition translates to output being high when both
inputs are equal and low when both inputs are different.
• The word EX-NOR is a short form of exclusive-NOR. Exclusive-NOR means. NOT-
exclusive OR, so EX-NOR gate is equivalent to an EX-OR gate followed by a NOT gate.
AʘB
50
Boolean Algebra and Logic Gates
Inputs Output
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
• SOP expression = A B + AB
• POS expression = (A + B)(A + B)
• Therefore it is called a coincidence logic circuit and also called an equivalent
detector.
A
A A
A
Note:
AΘA=1
AΘA=0
AΘ0=A
AΘ1=A
= 1, if n is add
• B Θ B Θ B Θ ...........n
= 0, if n is even
• EXOR and EXNOR is not always complement, it is complement only when the
number of inputs is even and if the number of inputs is odd then EXOR and EXNOR
are the same.
i.e., A ⊕ B ⊕ C = A ⊕ B ⊕ C ⇒ same
and A ⊕ B ⊕ C ⊕ D = A ⊕ B ⊕ C ⊕ D ⇒ complement
Note: Ex-OR & Ex-NOR Logic gates are also called as special purpose gates.
51
Boolean Algebra and Logic Gates
Question:
Why are NAND & NOR referred to as universal gates?
Solution:
All Boolean functions can be easily realized using the NAND & NOR gate itself hence they
are called as universal gates.
Solved Examples
Problem:
Find expression of A Θ B Θ C
Solution:
A Θ B Θ C = (A B + AB) Θ C = (A B + AB)C + (A B + AB)C
Since,
Problem:
Minimize
A B B Y
0 0 0 1
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 0
52
Boolean Algebra and Logic Gates
• EXNOR gate is an odd number of 1’s detector when the number of inputs are odd.
• Under 3-input only the expression of Ex-OR and Ex-NOR are equal.
Solved Examples
Problem:
Prove A ⊕ A = A Θ B
Solution: Put x = A, y = B
x ⊕ y = XY + XY = AB = A Θ B
Problem:
Simplify A ⊕ B ⊕ AB
Solution:
(AB + AB) ⊕ AB = (AB + AB)AB + (AB + AB)AB = AB(A + B) + AB(A + B) + (AB. AB)AB
(AB + AB) ⊕ AB = AB + AB + [(A + B) (A + B)]AB = AB + AB + AB = A (B + B) + AB = A + AB
(AB + AB) ⊕ AB = (A + A)(A + B) = A + B
Problem:
Find Y
A
B
Solution:
A A⊕B
B =A⊕B
Y= 1
A
=A⊕B
B A⊕B
53
Boolean Algebra and Logic Gates
Symbols
NAND Bubbled or
AND
OR
A
1
A
gate required
(ii) AND
A AB
2
B AB gates required
(iii) OR
A A
3
AB=A+B=A+B gates required
54
Boolean Algebra and Logic Gates
(iv) EXOR
A A.AB
4
Y = A ⊕ B = AB + AB gates required
A AB
B
B B.AB
(v) EXNOR
A
5
EXOR gates required
B 1 Gate
4 Gate
(vi) NOR
A
4
OR gates required
B 1 Gate
3 Gate
(i) NOT
A
1 gate required
A
(ii) AND
A A
3
AB gates required
A B
55
Boolean Algebra and Logic Gates
(iii) OR
A A+B
2
A+B gates required
B
(iv) EXNOR
A
A+A+B=AB
A 4 gates required
A⊕B
B
A+B
B B+A+B=BA
(v) EXOR
A
EXOR 5 gates required
B 1 Gate
4 Gate
(vi) NAND
A
4 gates required
AND
B 1 Gate
3 Gate
XNOR 5 4
56
Boolean Algebra and Logic Gates
Solved Examples
Problem:
To implement xyz the minimum number of two input NAND gate required are?
Solution:
➀
X
Y XYZ
Z ➁
➁
Total no. of NAND gate = 2 + 2 + 1 = 5
Problem:
To implement XY + WZ, the minimum number of 2 input NAND gates required.
Solution:
X 1
2
Y
XY+WZ
W
4
Z 3
Note:
57
Boolean Algebra and Logic Gates
Solved Examples
Problem:
If (A + B)(C + D) then the minimum number of NOR gates required are?
Solution:
A A
B B
=
C C
(A+)(C+D)
D D
Problem:
The given logic gate circuit is shown below, what is the logical expression of Z?
58
Boolean Algebra and Logic Gates
Shifting bubbles towards last NAND gate and rearrange the circuit,
X
X
Y
Z
X
Y
Y
X
X
XY
Y
Y
Z
X
X
XY
Y Bubbled NAND
replace by OR gate
X
X
XY
Y
Z = XY + XY
X
X
XY
Y
Y
So that, Z = XY + XY
Z=X⊕Y
Hence, the output of circuit Z shows EX-OR Logic gate.
Dual Form
+ve logic means higher voltage −ve logic means higher voltage
corresponds to logic '1'. corresponds to logic '0'.
59
Boolean Algebra and Logic Gates
Solved Examples
Problem:
logic 0 → −5v and logic 1 → 0v. Find the logic sign?
Solution:
Higher value of voltage (0v) is for logic 1. Then +ve logic.
Problem:
ECL; logic 0 → −1.7v and Logic 1 → −0.8v
Solution:
−0.8v is larger value than −1.7v then it is +ve logic.
A B Y A B Y
0 0 0 1 1 1
0 1 0 1 0 1
1 0 0 0 1 1
1 1 1 0 0 0
A B Y A B Y
0 0 0 1 1 1
0 1 1 1 0 0
1 0 1 0 1 0
1 1 1 0 0 0
60
Boolean Algebra and Logic Gates
-ve logic
• AND → OR
Dual
-ve logic
• OR → AND
Dual
ANd ↔ OR
. ↔+
Dual
1 ↔ +
Keep variable assist
Solved Examples
Problem:
Find Dual ABC + ABC + ABC
Solution: Dual: (A + B + C) (A + B + C) (A + B + C)
If we find again dual then, ABC + ABC + ABC
Important Points
• For any logical expression, if two times dual is used it results in the same
expression.
• Self Dual:
AB + BC + AC
Dual: = (A + B)(B + C)(A + C) = (B + AC)(A + C) = BA + BC + AC + AC
= AB + BC + AC (Again same expression)
• In some of the logical expressions, not all its dual gives the same expression.
• In self Dual expression, if one time dual is used it results in the same expression.
2 n−1
• If there are n variables then total no. of self dual expression is 2
2 n−1
(i) For n = 1--> 2 = 21 => Then 2 Self dual expressions
A → self dual → A
Total self dual expressions are 2
A → self dual → A
1
(ii) For n = 2, = 22 = 4 Then 4 Self dual expressions.
A → A, B → B and A → A, B → B
61
Boolean Algebra and Logic Gates
Complement
If Y = ABC + ABC + ABC
Complement is Y = (A + B + C) (A + B + C) (A + B + C)
AND ↔ OR
. ↔+
Complement
1 ↔ 0
Complement of each variable.
Venn Diagram
For two variable (A, B)
A B
10 01
AB AB
AB
00
AB
11
Solved Examples
Problem:
For a given Venn diagram, minimize the SOP expression for shaded region.
A B
Solution:
Y = A B + AB + AB = B(A + A) + AB = B + AB = (B + A)(B + B) = A + B
62
Boolean Algebra and Logic Gates
Problem:
SOP expression for shaded region.
A B
Solution:
Y = AB + AB + AB = A(B + B) + AB = (A + A)(A + B) = A + B
Problem:
SOP expression
A B
Solution:
AB + AB + AB + A B = B(A + A) + B(A + A) = B + B = 1
For 3 variables:
ABC
A
B
ABC
ABC
ABC C
63
Current Energy Scenario in India
Problem:
The Boolean Expression for the shaded region in given Venn diagram is shown below,
Solution:
Given Venn diagram is shown below,
A B
Switching Circuit
For Series
Truth Table Y
+
A Y A
0 0 Bulb.
V
1 1
-
For Parallel:
Truth Table
A Y Y
0 1
Bulb.
1 0 V A
64
Boolean Algebra and Logic Gates
• In place of the bulb there is a resistor then the answer remains the same but some
drop.
Truth Table
VCC
A Y
0 1
1 0
Y
Truth Table
A Y VCC
0 1
1 0
Y
AND
A B Y
0 0 0 Y = AB
A B
0 1 0
1 0 0 V
1 1 1
65
Boolean Algebra and Logic Gates
NAND
Y = AB
A B Y
0 0 1
A
0 1 1 V
1 0 1
B
1 1 0
OR
A B Y
A
0 0 0 Y=A+B
0 1 1
V B
1 0 1
1 1 1
NOR
Y=A+B
A B Y
0 0 1
0 1 0 V A B
1 0 0
1 1 0
Solved examples
Problem:
Find the expression of y.
Y
A
C
V
D
66
Boolean Algebra and Logic Gates
Problem:
A logic circuit has 3 input A, B, C and o/p is Y. o/p Y is -1. For the following combination.
(i) B and C are true = BC
(ii) A and C are false = A.B
(iii) A, B and C are true = ABC
(iv) A, B and C are false = A B C
Then minimize the o/p for Y.
Solution:
Output:
Y = 1. (Take minterm = SOP form)
Y = BC + AC + ABC + ABC = BC(1 + A) + A B(1 +B) = BC + A C
If o/p Y = 0, then take max term (POS form)
Problem:
A logic circuit have 3 input A, B, C and output is F = 1. When majority no. of I/p’s are logic 1.
Minimize expression F.
Solution:
A B B Y
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
F = ABC + ABC + ABC + ABC = ABC + ABC + ABC + ABC + ABC + ABC
= BC(A + A) + AC (B + B) + AB (C + C) = AB + BC + CA
67
Boolean Algebra and Logic Gates
68
Combinational Logic Circuits
Chapter 3
Combinational Logic Circuits
Objective
Upon completion of this chapter you will be able to:
• Simplify Boolean expressions using K-map
• Design basic combinational logic circuits
• Implement Boolean expressions using basic combinational circuits as building
blocks
• Analyze combinational circuits for any timing hazards
Introduction
In the last chapter we simplified Boolean expressions and designed logic circuits as a
combination of logic gates. Those circuits are called combinational logic circuits as the
output of those circuits depends on the combination of logic levels of inputs. These
circuits do not have any memory characteristic. In this chapter we will discuss more
about such circuits and present a simple method for logic simplification which is K-map
(Karnaugh Map).
B
A
0 1
0 1 X
1 X 1
K-Map
• It is used when output can be 0, 1 and x (don’t care).
• K – map is graphical representation.
• Each square in a K-map represents one minterm or maxterm.
• In K – map gray code representation is used
• Gray code representation
• K-map is ideally is suitable for designing the combinational logic circuits using either
a SOP method or a POS method.
69
Combinational Logic Circuits
00
10 01
11
LSB
MSB B
A
00 0 01 1
0
10 2 11 3
1
LSB
MSB BC
A
0 00 0 01 1 11 3 10 2
00 4 01 5 11 7 10 6
1
70
Combinational Logic Circuits
LSB
MSB CD 00 01 11 10
AB
00 0 1 3 2
01 4 5 7 6
11 12 13 15 14
10 8 9 11 10
Solved Examples
Minimize:
1 1 1
71
Combinational Logic Circuits
X 1
1
1 X 1
1 1 1
1 1
f(A, B, C) = AC + AB
72
Combinational Logic Circuits
Problem: BC
00 01 11 10
f(A, B, C) = ∑m(0, 1, 2, 5, 7) + ∑d(3, 6) A
0 1 1 X 1
Solution: f(A, B, C) = A + C 1 1 1 1
Problem:
BC
00 01 11 10
f(A, B, C) = ∑m(0, 1, 2, 6, 7) + ∑d(3, 6, 5) A
0 1 1 X
Solution: f(A, B, C) = B + A X
1 X 1 1
Problem:
CD
00 01 11 10
f(A, B, C, D) = ∑m(0, 1, 3, 5, 7, 8, 9, 11, 13, 15) AB
00 1 1 1
Solution: 01 1 1
f(A, B, C) = D + BC
11 1 1
10 1 1 1
Problem: CD
AB 00 01 11 10
f(A, B, C, D) = ∑m(0, 2, 8, 10, 14) + ∑d(5, 15)
00 1 1
11 X 1
10 1 1
73
Combinational Logic Circuits
1 A 0 0
1 A 0 0
1 A 0 0
1 0 4 5 7 0 6
B
A B B B
A 1
A 1 1
74
Combinational Logic Circuits
1 A 0 1 0 X
• The two functions are the same if the position of 1’s and 0’s are the same in k–map
and if the 1’s place 0 are placed and at 0’s place 1’s are placed then the function is
complement to each other.
Implicant
It is the set of all adjacent min terms
Prime Implicant
It is an implicant which is not a subset of another implicant.
Essential PI (EPI)
It is a prime implicant which contains at least one min terms which is not covered by
other prime implicants.
In the figure shown below various implicants can be formed by grouping the minterms in
different order and their classification is as mentioned below:
(1) PI, Non EPI
2 1
(2) PI, EPI
(3) PI, EPI 1
3
(4) PI, EPI 1 1 1
1
5
75
Combinational Logic Circuits
Digital Circuit
No feedback
Feedback
No memory
Memory
Example: Half Adder, Full Adder, Example: Flip Flop, Register, Counter
Multiplexer, Decoder
Input Outputs
A SUM
HA
B CARRY
Block diagram
76
Combinational Logic Circuits
Truth Table
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Logical Expression
SUM = AB + AB = A ⊕ B and CARRY = AB
Implementation
A
SUM
B
CARRY
Important Points
• Logical expression for SUM = A ⊕ B, CARRY = AB
• Min. no. of NAND Gate: 5
• Min no. of NOR Gate: 5
• No. of MUX: 3
• No. of DECODER: 1 2 × 4 Decoder and 1 OR Gate.
AB
A A ⊕ B = SUM
B
AB = CARRY
77
Combinational Logic Circuits
A A+B A B + A B = A ⊕ B = SUM
1
B
A.B
AB = CARRY
Half Subtractor
Half subtractor performs the basic arithmetic operation of subtraction of two bits.
Half subtractor is a combinational circuit with two inputs and two outputs (difference
and borrow).
It produces the difference between the two binary bits at the input and also produces an
output (borrow) to indicate if a1 has been borrowed.
In the subtraction (A-B), A is called a minuend bit and B is called a subtrahend bit.
A Difference
HA
B Borrow
Truth Table
A B Diff Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Logical Expression
Difference = AB + AB and Borrow B = AB
Implementation
A
Difference
B
Borrow
78
Combinational Logic Circuits
A
X=A⊕B
B
Control
Y = AB HA
= AB HS
Important Points
• Number of NAND gate required = 5
• Number of NOR gate required = 5
• Number of MUX required = 3 (2 x 1 MUX)
• Number of Decoder required = 1 (2 × 4) Decoder and 1 OR gate.
A
AB A ⊕ B Difference
B
B
AB Borrow
A
(A + A + B)
AB Borrow
A
A+B
B
A ⊕ B Difference
79
Combinational Logic Circuits
Full Adder
A Full adder is a combinational circuit that forms the arithmetic sum of three bits.
It can add two one-bit numbers A and B, and carry Cin. The full adder is the three input
and two output combinational circuit.
A SUM
B FULL ADDER
C CARRY
Truth Table
A B C SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Logical Expression
SUM = A BC + ABC +ABC + ABC = A ⊕ B ⊕ C = ∑m(1, 2, 4, 7)
CARRY = ABC + ABC + ABC + ABC = AB + BC + AC = ∑m(3, 5, 6, 7)
In full adder if each logic gate has a proportion delay of tpd, then to provide sum or carry
output, it requires to a 2tpd delay.
A B C
tpd
tpd
SUM = 2 tpd
tpd
tpd
tpd
CARRY = 2 tpd
tpd
Now, CARRY = ABC + ABC + ABC + ABC = AB(C + C) + C(AB + AB) = AB +C(A ⊕ B)
80
Combinational Logic Circuits
Implementation
A A⊕B
B AB
A ⊕ B ⊕ C = SUM
C
C
CARRY
= AB + C (A ⊕ B)
A
HA SUM
B
HA
C
CARRY
Important Points
• Logical expression for SUM = A ⊕ B ⊕ C, CARRY = AB + BC +AC
• Number of Half Adder and OR gate required = 2HA, 1 – OR
• Minimum number of NAND gate required = 9
• Minimum number of NOR gate required = 9
• Number of MUX required = 3 (4 × 1) MUX
• Number of DECODER required = (3 × 8) Decoder and 2 OR gate.
A AB A⊕B
B
(A ⊕ B)C
sum
C
carry
81
Combinational Logic Circuits
A A+B
(A ⊕ B)
B
C + (A ⊕ B) SUM
C
C
CARRY
Types of Adders
• There are three types of adders
(1) Serial adder (We design as sequential circuit)
(2) Parallel adder
(3) Carry Look Ahead adder
• In serial adder only one full adder (FA) is used to add a group of bits.
• It is the slowest adder.
Parallel Adder
4 Bit Adder
• 3 full adders and 1 half adder required or 4 full adders are required.
• Parallel adder is used to add groups of bits.
• To add two N bit number it requires (N − 1) full adder and half adder or N full adder
or (2N − 1) half adder and (N − 1) OR gates required.
A3 B3 A2 B2 A1 B1 A0 B0
C0
FA FA FA FA
C4 S3 C3 S2 C2 S1 C1 S0
82
Combinational Logic Circuits
A 3 A 2 A 1 A0
1 1 0 1
1 0 1
1
S3S2S1S0 C4
B3 B2 B1 B0
Sum Carry
Ai
Pi
Bi
Gi Pi
Ci SUM (S)
Ci
CARRY (Cin)
C1 = P0C0 + G0
83
Combinational Logic Circuits
n ( n + 1) 4 × 5
Total number of AND gate inside = 1 + 2 + 3 + 4 = = = 10
2 2
Number of OR Gate = n
Total propagation delay = 2tpd
This is faster than parallel adder.
Full Subtractor
It performs the arithmetic subtraction of three bits.
The full subtractor is a combinational circuit with three inputs A, B and C and two
outputs D and Bo.
A is the minuend, B is the subtractor, C is the Borrow produced by the previous stage, D
is the difference output and Bo is the borrow output.
A Difference
B FS
C Borrow
Truth Table
A B C Diff(A − B − C) BORROW
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
Logic Expression
Difference = A ⊕ B ⊕ C = ∑m(1, 2, 4, 7)
Borrow = AB + AC + BC = ∑m(1, 2, 4, 7)
84
Combinational Logic Circuits
Implementation
A B C
Difference
Borrow
Important Points
• Number of NAND gate required = 9
• Number of NOR gate required = 9
• Logical expression for difference = A ⊕ B ⊕ C
• Logical expression for borrow = AB + AC + BC or AB + C(A B)
• Number of MUX required = 3 (4 × 1) MUX
• Number of decoders required = 1 (3 × 8) decoder and 2 OR gate.
Comparator
A comparator is a combinational circuit which compares two bits and produces three
outputs based on the relative values of the bits.
A A>B=X
A=B=Y
COMPARATOR
B
A<B=Z
Truth Table
A B X Y Z
0 0 0 1 0
0 1 0 0 1
1 0 1 0 0
1 1 0 1 0
x y z
= AB = A Θ B = AB
85
Combinational Logic Circuits
Logic Expression
X = AB, Y = A Θ B = AB + AB, Z = AB
Implementation
A B
A0
B0
A1
B1
1
A2
B2
A3
B3
Summary:
For “n-Bit” Comparator:
(1) Total number of combination = 22n
(2) Number of combination which shows equal expression i.e., A = B is 2n
(3) Number of combination which shows, greater expression i.e. A>B or lower
22n - 2n
expression i.e., A < B is
2
(n = number of bits)
86
Combinational Logic Circuits
Problem:
The output Y of a 2-bit comparator is logic-1 whenever the 2-bit input A is greater than
the 2-bit input B. The number of combinations for which the output is logic-1.
Solution: Let 2-bit input A = A1A0
2-bit input B = B1B0
When A > B → Y Logic-1.
So according to above condition truth table as,
A1 A0 B1 B0 Y=A>B Min-terms
0 0 0 0 0 m0
0 0 0 1 0 m1
0 0 1 0 0 m2
0 0 1 1 0 m3
0 1 0 0 1 m4
0 1 0 1 0 m5
0 1 1 0 0 m6
0 1 1 1 0 m7
1 0 0 0 1 m8
1 0 0 1 1 m9
1 0 1 0 0 m10
1 0 1 1 0 m11
1 1 0 0 1 m12
1 1 0 1 1 m13
1 1 1 0 1 m14
1 1 1 1 0 m15
87
Combinational Logic Circuits
A1 A0 B1 B0 Y Min-terms
m4
0 1 0 0 1
m8
1 0 0 0 1
m9
1 0 0 1 1
m10
1 1 0 0 1
m11
1 1 0 1 1
m12
1 1 1 0 1
Thus, the number of combinations for which the output is logic “1” = 6.
Another Approach
Direct formula based approach,
Given comparator is 2-bit → n = 2
22n − 2n 16 − 4
Number of combination in truth table for which A > B → = =6
2 2
Multiplexer
• Multiple inputs and one output.
• Depending on control or select input, one of the inputs is transferred to the output
line.
• In most of the electronic system, the digital data is available from more than one
source. It is necessary to route this data over a single line.
• A multiplexer is a digital circuit which selects one of the n data inputs and routes
(connects) it to the output. The selection of one of the n inputs is done with the
help of the select inputs.
88
Combinational Logic Circuits
I0
Data
I1 4:1
I/ Y
P I2
MUX O/
I3 P
S1 S0
Control
• It is also called a data selector or many to one circuit or universal logic circuit or
parallel to serial circuit.
m = 2n or n = log2m
Where m = no. of data inputs
n = no. of select inputs (control inputs)
2:1 MUX
It has two inputs and 1 select line.
I0 I0
2:1
Y
MUX Y
I1
I1
S0
Symbol of MUX
I0
Y
I1
S0
89
Combinational Logic Circuits
Truth Table
A B
0 I0
1 I1
Logical Expression
Y = SI0 = SI1
Implementation
I0
I1
4: 1 MUX
It has 4 inputs and 2 select lines.
I0
I1 4:1
Y
I2
MUX
I3
S1 S0
Truth Table
S1 S0 Y
0 0 I0
0 1 I1
1 0 I2
1 1 I3
90
Combinational Logic Circuits
Logical Expression
Y = S1S0I0 + S1S0I1 + S1S0I2 + S1S0I3
Implementation of higher order MUX with lower order MUX
I0
2:1
I1
S0
2:1
Y
I2
2:1 S1
I3
S0
I0
2:1
I1
S0
2:1
I2
2:1 S1
I3
2:1 Y
S0
I4
S1
2:1
I5
S0
2:1
I6
2:1 S1
I7
S0
91
Combinational Logic Circuits
32 + 16 + 8 + 4 + 2 + 1
• 64 × 1 → 63 (2 × 1) MUX
• 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
256 × 1 → 255 (2 × 1) MUX
16 4
Number of MUX = + = 4+ 1=5
4 4
I0
I1
4:1
I2
I3
S1 S0
I4
I5
4:1
I6
I7
S1 S0 4:1 Y
I8 O/
I9 P
4:1 S3 S2
I10
I11
S1 S0
I12
I11
4:1
I12
I13
S1 S0
16 + 4 + 1
• 64 × 1 MUX → 21 (4 × 1) MUX
92
Combinational Logic Circuits
2 : 1 MUX
NOT Gate
1 I0
Y
0 I1
Y = S0I0 + S0I1 = A × 1 + 0 × A = A
• 1 (2:1) MUX is required to implement NOT gate
AND Gate
O I0
Y
B I1
Y = A * 0 + AB = AB
1 (2 : 1) MUX is required to implement AND gate.
OR Gate
B I0
Y
1 I1
S=A
Y = AB + A × 1 = A + B
1 (2 : 1) MUX is required to implement an OR gate.
93
Combinational Logic Circuits
NAND Gate
1 I0
B I1
Y = A × 1 + BA = A + B =AB
For B:
1 I0
B
0 I1
NOR Gate
B I0
0 I1
Y = AB + A * 0 = A + B
2 (2:1) MUX required for NOR gate as 1 MUX is required for B
94
Combinational Logic Circuits
EXOR Gate
B I0
I1
B
Y = AB + AB
2 (2 : 1) MUX required for EXOR gate as 1 MUX is required for B
EXNOR Gate
B I0
B I1
A
Y = A B + AB
2 (2 : 1) MUX required for EXNOR gate as 1 MUX is required for B
Note
• For EXOR number of 2 × 1 MUX required = 2
• For AND gate number of 2 × 1 MUX required = 1
• For half adder number of 2 × 1 MUX required = 3
• For half subtractor number of 2 × 1 MUX required = 3
95
Combinational Logic Circuits
4 : 1 MUX
Any two variable functions are implemented with 4 : 1 MUX.
AND Gate
0
0
4:1 Y
0
1 A B
S1 S0
OR Gate
1
4:1 Y
1
1 A B
S1 S0
EXOR Gate
1
4:1 Y
1
0 A B
S1 S0
EXNOR Gate
1
0
4:1 Y
0
1 A B
S1 S0
96
Combinational Logic Circuits
Solved Examples
Determine minimized output logical expressions
Problem:
I0
C
I1
Y
I2
C
I3
A B
Solution:
Y = ABC + ABC + ABC + ABC = A C(B + B) + AC(B + B) = A C + AC = A Θ C
Problem:
C I0
1 I1 4x1
Y
0 I2 MUX
C I3
A B
Solution:
Y = ABC + AB + AB * 0 + ABC = A BC + AB + ABC = AC + BC
BC
A
BC BC BC BC
A 1 1 1
A 1
97
Combinational Logic Circuits
Problem:
f(A, B, C) = ∑m(0, 1, 4, 6, 7)
Solution:
A B C
0 0 0 → C B A
1 I0
0 0 1 → C B A 0 I1
0 1 0 → C B A 4:1
C I2
0 1 1 → C B A
1 I3 S1 S0
1 0 0 → C B A
1 0 1 → C B A
A B
1 1 0 → C B A
1 1 1 → C B A
AB AB AB AB
I0 I1 I2 I3
C 0 2 4 6
C 1 3 5 7
Problem:
Implement logical expression f(A, B, C) = ∑m(1, 2, 3, 5, 6, 7) with
(i) AB as select line
(ii) AC as select line
(iii) BC
Solution:
(i)
AB AB AB AB
I0 I1 I2 I3
C 0 2 4 6
C 1 3 5 7
98
Combinational Logic Circuits
1
4:1 Y
C
A B
1 – 4 : 1 MUX Required
(ii)
AC AC AC AC
I0 I1 I2 I3
B 0 1 4 5
B 2 3 6 7
B 1 B 1
1
4:1 Y
B
1
A C
(iii) BC Control:
BC BC BC BC
I0 I1 I2 I3
A 0 1 2 3
A 4 5 6 7
0 1 1 1
0
1
4:1 Y
1
1
B C
99
Combinational Logic Circuits
Problem:
Given 4 × 1 multiplexer is shown below; determine the expression of output Q.
1 D3
1 D2 4 x 1
Q
1 D MUX
1
C D0 S1 S
0
A C
Solution:
Given that-
1 D3
1 D2 4x1
Q
D1 MUX
1
C D0 S1 S
0
A B
AB C
C 01 11 10 B
00
00 1 1 1 A
1 1 1 1
01
100
Combinational Logic Circuits
Important Points
Advantages of Multiplexers
(1) It reduces the number of wires, required to be used.
(2) A multiplexer reduces the circuit complexity and cost.
(3) We can implement many combinational circuits using MUX.
(4) It simplifies the logic design.
(5) It does not need the k maps for simplification.
DEMUX (Demultiplexer)
• Single input and multiple outputs.
• A demultiplexer performs the reverse operation of a multiplexer i.e., it receives one
input and distributes it over several CC.
Y0
1x4 Y1
I I 1:4 O/
P
DEMUX Y2
Y3
S1
S0
S1 S0
select
• DEMUX is a combinational circuit which has one input and multiple outputs and
depending on select Input, data input is transferred to any of the outputs.
• Also known as 1 to many circuit or data distributor.
101
Combinational Logic Circuits
Y0
I 1:2 Y0
Y1
Y1
Truth Table
S Y1 Y0
0 0 1
1 1 0
Logical Expression
Y0 = SI and Y0 = SI
Implementation
Y0
1
Y1
S S
1 : 4 DEMUX
I S1 S0
Y0= S1 S0I
S1 S0 Y3
102
Combinational Logic Circuits
3
• 1 × 4 DEMUX ←→ 1 × 2 DEMUX
Y0
7
• 1 × 8 DEMUX ←
→ 1 × 2 DEMUX 1x2
Y1
5
• 1 × 16 DEMUX ←→ 1 × 4 DEMUX I 1x2
21 Y2
• 1 × 64 DEMUX ← → 1 × 4 DEMUX
1x2
9 Y3
• 1 × 64 DEMUX ←
→ 1 × 8 DEMUX
17
• 1 × 256 DEMUX ← → 1 × 16 DEMUX
Decoder
• Decoder is a combinational circuit which has multiple inputs and multiple outputs.
• It is used to convert binary data to other code (binary octal)
Example:
Binary to octal (3 x 8)
BCD to decimal (4 x 10)
Binary to hexadecimal
BCD to seven segments
• 2 to 4 decoders is the minimum possible decoder.
2 × 4 Decoder
E A B
Y0
(MSB)
A Y0
2x4 Y1
Decoder Y2 Y1
B
Y3
Y2
E
Y3
103
Combinational Logic Circuits
Truth Table
E A B y3 y2 y1 y0
0 × × 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
Logical Expression:
Y0 = A B E, Y1 = ABE, Y1 = ABE, Y3 = ABE
• Decoder and DEMUX internal circuit remains same.
Solved Examples
Problem:
Implement half adder using 2 x 4 decoder.
Solution:
AB
(MSB)
A AB
2×4 SUM= A B + A B
AB
B DECODER AB
Carry = A B
E=1
BORROW = A B
(MSB)
A AB
2×4 DIFF = A B + A B
AB
B DECODER
AB
AB
E=1
104
Combinational Logic Circuits
ABC
Y0
ABC
Y1
MSB ABC
A Y2
3×8 ABC
B Y3
DECODER ABC
Y4
C
ABC
Y5
ABC
Y6
ABC Y7
E=1
Solved Examples
Problem
Implement using 3 x 8 decoder make FA.
Solution:
SUM = ∑m(1, 2, 4, 7) = A BC + ABC + AB C + ABC
CARRY = ∑m(3, 5, 6, 7) = AB + BC + CA
0
1
2
MSB
3
A SUM
3×8
B
DECODER
4
C 5
CARRY
6
7
105
Combinational Logic Circuits
4 × 16 ← 5
→2×4
1 × 16 ←→ 1 × 4
5
16 × 1 ←
5
→ 4 × 1 (Since 2 × 4 decoder means 1 × 4 DEMUX using 2 select lines)
C Y0 Y0
MSB
2×4 B
D 3×8
C
MSB D
C C Y7
2×4 2×4 A
D D
Y8
C B
C 3×8
2×4
D
D
Y15
C
2×4
D
Encoder
• Encoder is the combinational circuit which has multiple inputs and multiple outputs.
• Encoder is used to convert other code to binary.
I0
I1
I2
8×3 Y0
I3
OCTAL to Y1
I4 BINARY
Y2
I5
I6
I7
106
Combinational Logic Circuits
• In normal encoder one of the input lines is high and corresponding binary code is
available at the output.
• But this may create a problem when more than one input line is high. So we design
Priority Encoder.
• In priority encoder more than one input is high but binary output corresponds to the
highest priority input.
Truth Table
I7 I6 I5 I4 I3 I2 I1 I0 Y2 Y1 Y0
0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 1 0 0 0 1 0
0 0 0 0 1 0 0 0 0 1 1
0 0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 0 1 0 1
0 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 1 1 1
Logical Expression
Y0 = I1 + I3 + I5 + I7
Y1 = I2 + I3 + I6 + I7
Y2 = I4 + I5 + I6 + I7
I0 I1
I3
I1 Y0
I5
I7
I2
I2
I3 I3
I6 Y1
I4
I7
I5 I4
I5
I6 Y2
I6
I7 I7
107
Combinational Logic Circuits
Hazards
Hazards are unwanted switching transients that may appear at the output of a circuit
due to different paths exhibiting different propagation delays. Hazards occur in
combinational circuits where they may cause a temporary false value at the output.
Hazard
• To avoid static and dynamic hazard redundant terms are added in a combinational
circuit.
• Essential hazard cannot be avoided but feels essentials.
• For the given circuit determine o/p wave form when.
0
1
A
1
X
0
Static '0'
0 0
Y
108
Combinational Logic Circuits
Case 2: If there is propagation delay of 1ns in NOT gate and no delay in AND gate.
0
1
A
1 1ns
X
1 0
1
Static '0' Hazard
0 0
Y
1ns
Case 3: If there is propagation delay of 1ns in NOT gate and 2ns in AND gate
0
1
A
1ns
1
X
0
Y'
2nsec
Similarly, if the output is expected to be static at “Logic 1” but it exhibits a small glitch of
“Logic 0” then it is called as Static-1 Hazard.
109
Combinational Logic Circuits
110
Sequential Logic Circuits
Chapter 4
Sequential Logic Circuits
Objective
Upon completion of this chapter you will be able to:
• Implement basic building blocks of sequential circuits that are flip flops.
• Design basic sequential circuits like registers and counters.
• Implement simple state machines.
Introduction
A sequential circuit is characterized by inputs, outputs and internal states. in
synchronous sequential circuits, change of internal states occurs in response to
synchronized clock pulses. Asynchronous sequential circuits do not use clock pulses
and internal states change whenever inputs change. In sequential circuits, output is a
function of inputs and previous values of outputs so memory elements are employed to
store the past values of outputs.
In the case of a sequential circuit, the timing parameter comes into effect. In fact, the
output of the sequential circuit depends upon the present time input, the previous
output and the sequential in which the inputs are applied.
The basic memory element is Flip Flop whose representation is shown below:
Q
Inputs
FF
Q
Flip-flop has two outputs which are designated as which are often complementary to
Q
each other. The state of flip flop refers to the state of Output Q as when Q = 1, the flip
flop is said to be in set state and when Q = 0, the flip flop is said to be in reset state.
The flip flop can switch between its two states and is also known by other names such
as “Latch” or “Bistable Multi-vibrator”.
The problem with using NOT gate for creating latch is that it has only one input so we
use NAND and NOR gates for implementing latches.
111
Sequential Logic Circuits
S Q
Q
R
Truth Table
S R Q
0 0 Invalid (Q = Q = 1)
0 1 1
1 0 0
1 1 Previous state (no change)
• In SR latch if both gates are enabled then output remains in the previous state and
if both are disabled then output remains in invalid state.
S
Q
Q
R
112
Sequential Logic Circuits
Truth Table
S R Q
0 0 Previous state
0 1 0
1 0 1
1 1 Invalid (Q = Q = 0)
SR Flip Flop
In synchronous circuits, the exact time at which output can change state is determined
by a signal called as a clock. The clock signal is generally a rectangular or a square pulse.
The difference between latches and flip flops is the presence of a clock signal.
Clock
Q
R
113
Sequential Logic Circuits
Truth Table
Clock S R Qn + 1
1 x x Previous state(Qn) S R Qn + 1
1 0 1 Qn 0 0 Qn
1 0 1 0 → reset 0 1 0
1 1 0 1 → set 1 0 1
1 1 1 Invalid → unused 1 1 Invalid
S
Q
Clock
Q
R
Characteristic table
S R Qn Qn + 1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0 S R Qn + 1
1 0 0 1 0 0 Qn
1 0 1 1 0 1 0
1 1 0 x 1 0 1
1 1 1 x 1 1 Invalid
114
Sequential Logic Circuits
Logic expression
R Qn
S R Qn R Qn R Qn R Qn
S 1
S 1 1 X X
Qn + 1 = S + RQ and S.R = 0
• Since S = 1, R = 1 the output is invalid because S.R = 1 does not satisfy the above
condition.
• Excitation Table
Excitation table shows the possible values of input for each combination of present
and next state. It helps in deriving logic expressions for the inputs of Flip-Flops
depending on the value of desired output.
Qn Qn + 1 S R
0 0 0 x
0 1 1 0
1 0 0 1
1 1 x 0
JK Flip Flop
S = JQ
R = KQ
S Q
J
Clock
K
R Q
115
Sequential Logic Circuits
Characteristic Table
Clock J k Qn + 1
0 x x Qn
1 0 0 Qn
1 0 1 0
1 1 0 1
1 1 1 Qn
Truth Table
J k Qn + 1
0 0 Qn Hold
0 1 0 Reset
1 0 1 Set
1 1 Qn Toggle
J
Q
Clock
Q
K
J Q
CLX
K Q
116
Sequential Logic Circuits
Characteristic Table
J K Qn Qn + 1
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
Logical Expression
KQn
J
K Qn K Qn K Qn K Qn
J 1
J 1 1 1
Qn + 1 = JQn + KQn
Excitation Table
Qn Qn + 1 J k
0 0 0 x
0 1 1 x
1 0 x 1
1 1 x 0
• Drawback in JK FF is race around condition which means when J and K are both 1
then output will keep on toggling and output value will be indeterminate.
117
Sequential Logic Circuits
Q
J Q
J
Clock
K Q
K Q
If tpw = 10n sec(Pulse Width), tPFF = 1n sec (Propagation delay of flip flop) then:
10 nsec
Clock:-
O/P:-
Q
• In JK FF RAC occurs when J = K = 1 and tpd FF is less than that of tpd clock and therefore
the output changes several times in a single clock pulse.
J Q J Q
M S
K Q K Q
CLK
118
Sequential Logic Circuits
• Since input of slave is J = Q and K = Qn therefore it is always (1, 0) or (0, 1). But,
race around condition occurs only when the input is (1, 1). So, race conditions are
removed.
Clock
QM
QS
• In Master Slave FF, output changes only when slave output is changing.
• In Master Slave FF, Master and slave is edge triggered.
D–Flip Flop
D J Q D S Q
CLK CLK
K Q R Q
J=D S=D
K=D R=D
Truth Table
CLK D Qn + 1
0 x Qn D Qn + 1
1 0 0 0 0
1 1 1 1 1
Characteristic Table
D Qn Qn + 1
0 0 0
0 1 0
1 0 1
1 1 1
119
Sequential Logic Circuits
Excitation Table
Qn Qn + 1 D
0 0 0
0 1 1
1 0 0
1 1 1
T Flip–Flop (Toggle)
T J Q
CLK J=K=T
K Q
Truth Table
CLK T Qn + 1
0 x Qn T Qn + 1
1 0 Qn 0 Qn
1 1 Qn 1 Qn
Characteristic Table
T Qn Qn + 1
0 0 0
0 1 1
1 0 1
1 1 0
Qn + 1 = TQn + TQn = T ⊕ Qn
120
Sequential Logic Circuits
Excitation Table
Qn Qn + 1 T
0 0 0
0 1 1
1 0 1
1 1 0
• All tables are subsets of JK FF therefore it is also called a universal flip flop.
Qn Qn + 1 S R J K D T
0 0 0 x 0 x 0 0
1 1 1 0 1 x 1 1
0 1 0 1 x 1 0 1
1 0 x 0 x 0 1 0
1 Q f/ Q 1 Q
J J f/ J f/
2 2 2
K Q K Q 1 K Q
J Q J Q f/ D Q
2 f/
f/ 2
2
K Q Q Q
1
S Q
f/
2
R Q
121
Sequential Logic Circuits
Types of Triggering
Trigger
• In the level trigger circuit, the circuit is active based on whether the clock is “logic 1”
or “logic 0”.
• In the level trigger circuit, output may change many times in a single clock.
• in edge trigger circuit, circuit is active on the edge of the clock that is positive edge
(clock goes from “logic 0” to “logic 1”) or negative edge (clock goes from “logic 1” to
“logic 0”)
• In edge triggers, output may change only once on a single pulse.
Differention
Procedure
• Required FF characteristics table.
• Available FF excitation table.
• Write a logical expression for excitation.
D Qn Qn + 1 J K
0 0 0 0 x
0 1 0 x 1
1 0 1 1 x
1 1 1 x 0
122
Sequential Logic Circuits
Qn Qn
D D
D X D X 1
J= K=
D 1 X D X
J=DK=Q
Implementation
D J Q Q
K Q Q
JK FF to SR FF
S R Qn Qn + 1 J K
0 0 0 0 0 x
0 0 1 1 x 0
0 1 0 0 0 x
0 1 1 0 x 1
1 0 0 1 1 x
1 0 1 1 x 0
1 1 0 x x x
1 1 1 x x x
R Qn R Qn
S R Qn R Qn R Qn R Qn S R Qn R Qn R Qn R Qn
S X S X 1 X
J= K=
S 1 X X X S X X X
J = S K=R
123
Sequential Logic Circuits
Implementation
S J Q
CLK
R K Q
JK FF to T FF
T Qn Qn + 1 J K
0 0 0 0 x
0 1 1 x 0
1 0 1 1 x
1 1 0 x 1
Qn Qn
T T Qn
Qn Qn Qn
T X T X
J= K=
T 1 X T X 1
J = T K=T
Implementation
T J Q
K Q
124
Sequential Logic Circuits
SR FF to JK FF
J R Qn Qn + 1 S R
0 0 0 0 0 x
0 0 1 1 x 0
0 1 0 0 0 x
0 1 1 0 0 1
1 0 0 1 1 0
1 0 1 1 x 0
1 1 0 1 1 0
1 1 1 0 0 1
K Qn K Qn
J K Qn K Qn K Qn K Qn J K Qn K Qn K Qn K Qn
J X J X 1 X
S= R=
J 1 X 1 J 1
S = JQn R = KQn
Implementation
S Q
J
Clock
K
R Q
125
Sequential Logic Circuits
SR FF to D FF
D Qn Qn + 1 S R
0 0 0 0 x
0 1 0 0 1
1 0 1 1 0
1 1 1 x 0
Qn Qn
D D
D D X 1
D 1 X D
S=D R=D
Implementation
D
S Q
R Q
SR to T FF
T Qn Qn + 1 S R
0 0 0 0 x
0 1 1 x 0
1 0 1 1 0
1 1 0 0 1
126
Sequential Logic Circuits
Qn Qn
T T
Qn Qn Qn Qn
T X T X
S:- R:-
T 1 T 1
S = TQn R = TQn
Implementation
S Q
T
R Q
D FF to SR FF
S R Qn Qn + 1 D
0 0 0 0 0
0 0 1 1 1
0 1 0 0 0
0 1 1 0 0
1 0 0 1 1
1 0 1 1 1
1 1 0 x x
1 1 1 x x
R Qn
S R Qn R Qn R Qn R Qn
S 1
D=
S 1 1 X X
D = S + RQn
127
Sequential Logic Circuits
Implementation
S D Q
T FF to SR FF
S R Qn Qn + 1 T
0 0 0 0 0
0 0 1 1 0
0 1 0 0 0
0 1 1 0 1
1 0 0 1 1
1 0 1 1 0
1 1 0 x x
1 1 1 x x
R Qn
S R Qn R Qn R Qn R Qn
S 1
T=
S 1 X X
T = RQ + SQ
Implementation
T Q Q
S
Q Q
128
Sequential Logic Circuits
To
From
SR FF JK FF D FF T FF
JK FF J = S, K = R --- J = D, K = D J = T, K = T
D FF D = S + RQ D = JQ + KQ --- D=T⊕Q
T FF T = SQ + RQ T = JQ + KQ T=D⊕Q ---
Setup Time
The minimum time in which the input must be kept at a constant value prior to the
occurrence of the clock edge is called set-up time.
Hold Time
The minimum time in which the input must be kept constant after the occurrence of the
clock edge is called hold time.
Register
• Registers are used to store groups of more than one bit
• To store n–bits, n FFs are cascaded in register
• To increase the storage capacity in terms of number of bits, we have to use a group
of Flip-flop. Such a group of flip-flops is known as a register
129
Sequential Logic Circuits
D3 Q3 D2 Q2 D1 Q1 D0 Q0
I/P O/P
Q3 Q2 Q1 Q0
CLK
Q3 Q2 Q1 Q0 CLK
0 0 0 0 0
1 0 0 0 1
1 1 0 0 2
0 1 1 0 3
1 0 1 1 4
• For serial in register the ‘n’ bit data storage requires ‘n’ clock pulse as each bit is
introduced at successive clock edges.
• SISO register is used to provide n clock pulse delay to Input data as can be seen
from the table that the input ‘1’ applied prior to first clock edge appears at output
after 4 clock cycles.
Delay = nTclk
• To provide n bit data serially out it requires (n − 1) clock pulse.
Q3 Q2 Q1 Q0
Data I/P
Q3 Q2 Q1 Q0
CLK
P3 P2 P1 P0
DATA
CLK
130
Sequential Logic Circuits
• In the SIPO register, to provide ‘n’ bit data serially in, ‘n’ clock pulses are required
and for parallel output it requires 0 clock pulse.
• It is used as a serial to parallel converter.
• SIPO is used to convert temporal code to spatial code.
• Since serial data is slow and parallel data is fast so it is used as a slow to fast
converter.
Solved Examples
Problem:
The circuit shown in the figure is a 4 bit SIPO register which is initially loaded with 1010.
If three clock pulses are applied then the data if the system is:
CLK 1 0 1 0
(a) 1010
(b) 1101
(c) 1111
(d) 0000
Solution: (c)
After 1st Clock Pulse, Data = 1101
After 2nd Clock Pulse, Data = 1110
After 3rd Clock Pulse, Data = 1111
Problem:
Circuit shown in the figure is initially loaded 1011 if clock pulses applied continuously
after how many clock pulse data again become 1011.
1 0 1 1
131
Sequential Logic Circuits
(a) 4
(b) 7
(c) 11
(d) 15
Solution: (b)
Output of 3 variables XOR is 1 if the number of 1’s at th e input is odd.
CLK Q 3 Q 2 Q 1 Q0
1 0 1 0 1
2 0 0 1 0
3 1 0 0 1
4 1 1 0 0
5 1 1 1 0
6 0 1 1 1
7 1 0 1 1
I0 I0 I0
I1 I1 I1
D3 Q3 D2 Q2 D1 Q1 D0 Q0
Q3 Q2 Q1 Q0
Clock
Control
132
Sequential Logic Circuits
D3 Q3 D2 Q2 D1 Q1 D0 Q0
Q3 Q2 Q1 Q0
CLK
Summary
Different registers take the following number of clock cycles for input and output.
Input Output
SISO n n−1
SIPO n 0
PISO 1 n−1
PISO 1 0
• Each shift left register operation provides multiplication by 2. In ‘n’ left shift
operation performed then data is multiplied by 2n.
• Each shift right operation performed then data is divided by 2. If ‘n’ right shift
operation performed then data is divided by 2n.
Counters
• Counters are basically used to count the number of clock pulses applied. It can also
be used for frequency division, time measurement, frequency measurement, range
measurement, pulse width measurement.
133
Sequential Logic Circuits
Pulse
16 x pulse width = Total width
Type of Counters
Depending on the clock pulse input to the flip flop counters can be of two types:
(i) Asynchronous counters
(ii) Synchronous counters
Asynchronous Synchronous
• Number of stages used in the counter is also called the modulus of the counter.
i.e., if MOD 5 counter = 5 stage.
MOD n counter = n stage.
MOD N
f Counter f/N
Solved Examples
Problem:
A decade counter is applied with frequency of 10 MHz then output frequency is.
fin 10MHz
Solution: fout = = = 1MHz
10 10
134
Sequential Logic Circuits
Cascading of Counters
Let MOD M and MOD N are cascaded then it will act as MOD MN counter.
Ripple Counter
• It is an asynchronous counter which means different FFs are fed with different
clocks.
• All the FFs are operated in toggle mode.
• Only one FF is applied with external clock and other FF’s clock is fed from previous
FF’s output (whether Q or Q).
• The FF applied with an external clock will act as LSB.
I J0 Q0 I J1 Q1 I J2 Q2
I K0 Q0 I K1 Q1 I K2 Q2
CLK Q0 Q1 Q2
LSB MSB
Truth Table
CLK Q3 Q2 Q0
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
8 0 0 0
135
Sequential Logic Circuits
Timing Diagram
1 2 3 4 5 6 7 8 9
CLK
Q0
2T
Q1
4T
Q2
8T
• In n bit ripple counter propagation delay of each FF is tpd FF the time period of the
1 1
clock is. Tclock ≥ n tpd FF or fclock ≥ and fmax =
n tpd FF n tpd FF
1 T0 Q0 1 T1 Q0 1 T2 Q0
Q0 Q0 Q0
clock
LSB MSB
• For the circuit shown in figure Q0 toggles for every clock pulse.
• Q1 toggles when Q0 changes from 0 to 1.
• Q2 toggles when Q1 changes from 0 to 1.
136
Sequential Logic Circuits
Truth Table
Clock Q2 Q1 Q0
0 0 0 0
1 1 1 1
2 1 1 0
3 1 0 1
4 1 0 0
5 0 1 1
6 0 1 0
7 0 0 1
• This is called ripple counter because the input clock is the previous FF output.
• In ripple counter with n FFs maximum possible state is 2n.
f
• Frequency after n FFs in the Ripple counter is n . (i.e., for 3 − FF o/p is f/8)
2
Decoding Error
• If the O/P is (000) and clock is applied then 3tpd FFis delayed.
• Due to different delays encountered by different outputs, there are intermediate
states.
• Unwanted intermediate states are also called transient states.
• Decoding errors or transient state present in ripple counter due to propagation
delay.
• To avoid decoding error strobe signal is used.
1 T0 Q0 1 T1 Q0 1 T2 Q0
CLK
Q0 Q0 Q0
LSB MSB
137
Sequential Logic Circuits
• Strobe signal is zero for n tpd FF and after that if it is one for the next clock. Then
all the output is zero for the transient time therefore due to strobe signals we can
remove decoding errors.
Tclock ≥ ntpd FF + TS
Asynchronous Inputs
• Clear and present are known as asynchronous inputs because they do not depend
on the occurrence of the clock.
• S, R, J, K, D, T are synchronous inputs.
D Q D D
Negative Q Up Counter
Positive Q Up Counter
138
Sequential Logic Circuits
1 J0 Q0 1 J1 Q1 1 J2 Q2 1 J3 Q3
1 K0 Q0 1 K1 Q1 1 K2 Q2 1 K3 Q3
Truth Table
CLK Q3 Q2 Q1 Q0
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
Q3 Q2 Q1 Q0
8 1 0 0 0
1 0 1 0
9 1 0 0 1
0 0 0 0 0
Q3 Q3
Q2 Q2
CLR CLR
Q1 Q1
Q0 Q0
139
Sequential Logic Circuits
Q3 Q3
CLR CLR
Q1 Q1
• All BCD counters are decade counters but the reverse is not true.
• Output frequency of BCD counter is f/10.
• Low for 8 clock and high for 2 clock in Q3. So, the duty cycle is 20%.
Synchronous Counters
Ring Counter
• The last FF output is connected to the first FF input.
D3 Q3 D2 Q2 D1 Q1 D0 Q0
Q3 Q2 Q1 Q0
CLK
Truth Table
CLK Q3 Q2 Q1 Q0
0 0 0 0 0
1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
5 1 0 0 0
• In synchronous counter the triggering may be +ve edge or –ve edge, but the output
remains same.
140
Sequential Logic Circuits
Timing Diagram
1 2 3 4 5 6 7 8
CLK
Q3
Q2
Q1
Q0
f
• n bit = n state and fo =
n
360
• Phase shift between generated waveform is .
n
Application
• Used in stepper motor control.
• In analog to digital converter.
• Number of unused state in ring counter is 2n − n.
J3 Q3 J2 Q2 J1 Q1 J0 Q0
K3 Q3 K2 Q2 K1 Q1 K0 Q0
CLK
141
Sequential Logic Circuits
D3 Q3 D2 Q2 D1 Q1 D0 Q0
Q3 Q2 Q1 Q0
CLK
• Advantage of a ring counter is the decoding is simple and no logic gates are required
for decoding.
• Last output cannot be connected to the input of the self-start ring counter.
Johnson Counter
• It has a symmetric output waveform.
• 8–stages are there for a 4 bit counter.
360
• Phase shift = = 90
4
• It is just like a SISO register.
D3 Q3 D2 Q2 D1 Q1 D0 Q0
Q3 Q2 Q1 Q0
CLK
0 0 0 0
Truth Table
CLK Q3 Q2 Q1 Q0
0 0 0 0 0
1 1 0 0 0
2 1 1 0 0
3 1 1 1 0
4 1 1 1 1
5 0 1 1 1
6 0 0 1 1
7 0 0 0 1
8 0 0 0 0
142
Sequential Logic Circuits
CLK Q3 Q2 Q1 Q0
0 0 0 0 0 → Q3 Q0
1 1 0 0 0 → Q3 Q2
2 1 1 0 0 → Q2 Q1
3 1 1 1 0 → Q1 Q0
4 1 1 1 1 → Q3 Q0
5 0 1 1 1 → Q3 Q2
6 0 0 1 1 → Q2 Q1
7 0 0 0 1 → Q1 Q0
8 0 0 0 0
• In Johnson counter to decode each state, one two input AND/NOR gate is used.
• Lock out may occur (when counter enters into unused state)
Tclock ≥ tpd FF
1
fclock ≤ In synchronous counter
tpd FF
1
fmax =
tpd FF
1 T0 Q0 T1 Q1 T2 Q2 T3 Q3
Q0 Q1 Q2 Q3
LSB MSB
CLK
143
Sequential Logic Circuits
Truth Table
CLK Q3 Q2 Q1 Q0
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
Q0 Q0
Q1
1 T0 Q0 T1 Q1 T2 Q2 T3 Q3
Q0 Q1 Q2 Q3
Clock
144
Sequential Logic Circuits
• Ripple counter < Synchronous serial carry < synchronous parallel carry counter for
faster logic
Solved Examples
Problem:
Design a synchronous counter for the count sequence 0 → 3 → 1 → 3 → 0 using positive
edge triggered D − FF.
00
10 11 State Diagram
01
Solution: Procedure
(i) Identity number of FFs and inputs and outputs.
(ii) Construct state table.
(iii) Logical expression for inputs.
(iv) Minimize.
(v) Implement the circuit.
Now, since the counter is two bits so we will use two FFs having the same clock
(synchronous).
(i)
D1 Q1 D0 Q0
Q1 Q0
145
Sequential Logic Circuits
(iv) Implementation
D1 Q1 D0 Q0
Q1 Q0
Problem:
Design using T – FF whose states are 0 – 3 – 1 – 2 – 0.
Solution:
(i)
T1 Q1 T0 Q0
Q1 Q0
MSB
LSB
CLK
146
Sequential Logic Circuits
Q1 Q0 Q1+ Q0+ T1 T0
0 0 1 1 1 1
1 1 0 1 1 0
0 1 1 0 1 1
1 0 0 0 1 0
(iv) Implementation
T1 Q1 T0 Q0
Q1 Q0
MSB
LSB
CLK
Problem:
The state of the output just before the arrival of the second clock pulse is if initial state
of Xand Y are 0.
1 J Q 1 J Q
CLK CLK X Y
Output
1 K 1 K
Solution:
Given counter is a 2-bit asynchronous/ripple counter because there is no common clock
between both flip-flops.
1 J Q 1 J Q
CLK CLK X Y
Output
1 K 1 K
147
Sequential Logic Circuits
Clock Q 1+ = Y Q 2+ = X
0 0 0
2 1 0
3 0 1
4 0 0
Thus, the value of X and Y just before the arrival of second clock pulse is X = 1, Y = 1.
Parameter of
Sr. No. Registers counters
comparison
Direction of data
5 Bidirectional Bidirectional
transfer
Number of flip-flops
6 One One
per bit
Data storage,
Time and frequency
data shifting,
7 Few application measurement clock A to D
multiplication or
converter
division.
148
Data Converters
Introduction
In this digital age, all the processing is done in digital form but most real world signals
are analog in nature. So, we need an interface between analog and digital signals which
are called data converters. There are two basic types of data converters analog to digital
converter and digital to analog converter.
Va
ADC ADC V0
Important Terms
• Resolution/Step Size
It is the change in analog voltage corresponding to one LSB increment in the Input.
Vr
Resolution =
2 −1
n
• VFS
Full scale voltage is the maximum analog output voltage of DAC.
V
=
V r × 2n −=1 Vr
FS n
2 − 1
149
Data Converters
Resolution 1
=
• % Resolution =
× 100 × 100
V 2n − 1
FS
• Error/Accuracy
Error acceptable in ADC’s or DAC’s is equal to resolution or step size.
Solved Examples
Problem
In a 4 bit DAC reference voltage is 5V, if binary data 1001 is applied then analog voltage is.
Solution:
r
V 5 1
= =
Resolution =
n−1
2 16 − 1 3
1
Vanalog = ×9=
3V
3
Vr
I3 = * b3
R Vr
R1
V
I = r * b2 R
2 2R b3 I3
If
−
T
Vr b2 2R I2
I1 = * b1 T
4R b1 4R I1
T
Vr 8R
I0 = * b0 b0 I0 +
8R T
If = I3 + I2 + I1 + I0
• V0 = −If Rf
150
Data Converters
R – 2R Ladder
R-2R Ladder
Rf
R1
R R VX V0
+
2R 2R 2R 2R
LSB MSB
Vr
Rf
V= 1 + V
0
Rl x
n−1
Vr
Vx = Resolution * Decimal equivalent of binary data. = * ∑ 2 i bi
2n
i=0
n−1
∑ 2i b i
Desimal equivalent b2b1b0 = b2 22 + b1 21 + b0 20 =
i=0
151
Data Converters
n−1
Vr i R
V0 = × ∑ 2 b i * 1 + f
2n
Ri
i=0
Rf
R R R R1
2R 2R 2R 2R V0
Vr
n−1 −R
Vr
• =
V0
2n
× ∑ 2ib i * R + fR
i=0 1
n−1 1
Vr
• =
If × ∑ 2ibi * R + R
2n i=0 1
152
Data Converters
Vr
Rf
I
MSB
I3
I/2 b3
A' If
I/2 −
2R A
R
I2
I/4 b2 V0
A' +
I/4 2R
R
I1
b1
I/8 A'
I/8 2R
R I0
I/16 b0
A'
I/16 2R
LSB
2R
Vr
I =
R
I I I I
• I3 = × b3 , I2 =× b2 , I1 =× b1 , I0 = × b0
2 4 8 16
n − 1
• I = I + I + I + I = I 8b + 4b + 2b + b = Vr 1
f 0 1 2 3
16 3 2 1 0
2n
∑ 2ibi × R
i = 0
n − 1
Vr −R
• V0 =
n
∑ 2 bi R f
i
2 i = 0
153
Data Converters
Solved Examples
Problem:
If a 12-bit (3-digit) DAC that uses the BCD input code has a full scale output of 9.99V,
then the value of Vout for an input code of 0111 1001 0101 is __________ V.
Solution:
9.99
Step size = = 10 mV
999
range
• Resolution =
2n − 1
1
• Resolution = × 100
2 −1
n
V1 > V2 = V0 = Vref V1 +
V1 > V2 = V0 = −Vref
V0
V2 −
Vref
Va
+
− Counter
Digital o/p
CLK
DAC
154
Data Converters
Vr Va
R −
7
+
R 7Vr −
8 + 6
6Vr Y0 PIPO
R − D2 Q0
8 5 8×
+ ×3 Y1
Priority D1 Q1
5Vr Y2
R − Encoder
D0 Q2
8
+ 4
4Vr
R −
8
+ 3
CLK
3Vr
R − 1 Clock required
8 2
+
2Vr
R −
8 1
+
R Vr 1 0
8
no clock
155
Data Converters
SOC EOC
Va S−1 CLK
+ CONTROL SAR
− CKT
VT
DAC (IV)
156
Data Converters
C
R
−
−Va
S −
−Vr +
COUNTER
+
CLK
CONTROL
CKT
T1 (n) T2 (N)
V0
Va Vr
VO =−
RC
× T1 +
RC
( t − T1 ) At time t = T2, V0 = 0
−Va Vr
∴
= 0
RC
. T1 +
RC
(T 2
− T1 ) ⇒ Va=
T1 Vr ( T2 − T1 )
157
Data Converters
Va .2n.TCLK = Vr (NTCLK )
Va 2n Vr
=N = or Va .N
Vr 2n
If Vr = 2n then Va = N
• This is the most accurate ADC among all
• All ripple and noise is separated or compressed by a capacitor. (Therefore this has
more accuracy due to the integrator)
• Maximum number of clock pulse = 2n + 2n − 1 ≈ 2n + 2n = 2n + 1
• Conversion Times for N bit ADCs
Counter Type 2N
Flash Type 1
Application
Mostly used in digital voltmeter.
Input Impedance:
It is generally in the range of 1 KΩ to 1 MΩ and input capacitance is few tens of PicoFarad.
Conversion Time
For a moderately fast ADC the conversion time is 50 μ sec and for a fast ADC the
conversion time is 50 n sec.
Format of ADC
An ADC can be unipolar, bipolar, or 1’s complement or 2’scomplement.
Accuracy
Accuracy of ADC depends upon the quantization error and error due to any external noise
and all other sources of error affect the accuracy of ADC.
158
Data Converters
Solved examples
Problem:
A 10 - bit successive approximation ADC has a resolution of 10 mV. Determine digital
output for analog input of 4.365 V.
Solution:
4.365
Digital output = = 436.510 ≈ 43610
10 mV
Problem:
For a dual slope type ADC, frequency of Clock is 1 MHz, Vreference = −10. Fixed time period T1
is 1 ms, RC time constant is set to 2 ms and Input voltage, Vi = 5V. Value of Ramp voltage
Vs is ___________________V
Solution:
t fix 1
Vs =
− Vin =
−5 =− 2.5V
RC 2
159
Data Converters
160
IC Logic Families
Introduction
Digital logic has advanced rapidly from Small Scale Integration (SSI) with 12 gates per
chip to Very Large Scale Integration (VLSI) with tens of thousands of gates per chip. ICs
pack a lot more circuitry in a small package as compared to discrete components and
this results in smaller size of the circuit. ICs differ in the components that they use in
their circuitry like TTL family uses BJT and CMOS logic family uses MOSFET.
Classification of
logic families
PMOS
Saturated Un-saturated
logic family logic family NMOS
I2L
TTL
HTL
161
IC Logic Families
• tPHL is the propagation delay when output goes from HIGH to LOW and is the
propagation delay when output goes from LOW to HIGH.
A Y
tpd tpd
OFF-ON ON-OFF
• Propagation delay is always measured from 50% value of the input and output
waveforms.
• In Transistors, ON to OFF time is more compared to OFF to ON time due to
saturation or storage time.
In general tpdHL ≠ tpdLH.
If tpdHL = tpdLH the propagation delay can be either of the two tpdLH or tpdHL.
If tpdHL ≠ tpdLH, then propagation delay (tpd) = tpdHL if tpdHL > tpdLH = tpdLH
if tpdLH > tpdHL
Power Dissipation
Power dissipation by each logic gate Pdiss = VCC × mW
Where Vcc is the collector voltage or supply voltage and Iavg is the average supply current.
162
IC Logic Families
Fan Out
Fan-out also known as the loading factor of a logic gate is defined as the number of
loads that the output of a gate can drive.
• It is the maximum number of logic gates that can be driven by a logic gate
IOH
fan outH = IIH
IIH
IOH
IIL
IIH
IOL
IIL
IOL
fanoutL =
IIL
Fan In
Fan-in is defined as the number of independent inputs that the gate is designed to
handle without hampering its normal operation.
For Example:
A three input NAND gate has got a fan-in of 3.
A 13 input NAND gate has got a fan-in of 13.
Noise Margin
• It is the maximum noise voltage that can be added to the logic family which will
not affect the output
VIL ← 0 0 → VIL
VIH ← 0 0 → VOH
163
IC Logic Families
Solved Examples
Problem:
If VOH = 400 µA, IIH = 40 µA, IOL = −16 mA, IIL = 1.6 mA Find a fanout?
Solution:
400 16
fanoutH = = 10 fanoutL = = − 1.0
40 1.6
Construction of Gates
AND Gate
VCC
A B DA DB Y
0 0 ON ON 0
0 1 ON OFF 0
DA
1 0 OFF ON 0
A Y
1 1 OFF OFF 1
DB
B
OR Gate
A B DA DB Y DA
0 0 OFF OFF 0 A
0 1 OFF ON 1
DB V0 = A + B
1 0 ON OFF 1
B
1 1 ON ON 1
NOT
If A = 0, Tr is cutoff, Y = 1.
If A = 1, Tr is Sat., Y = 0. VCC VCC
Y Y
Y VCC
A A
164
IC Logic Families
NAND
VCC
A B Y VCC
0 0 1
0 1 1 Y
1 0 1
A T1
1 1 0 Y
A
B T2
B
NOR
A B Y VCC
0 0 1
VCC
0 1 0
Y
1 0 0
1 1 0 Y
T1 T2
A B A B
Solved Examples
Problem:
VCC
VCC V0
165
IC Logic Families
Solution:
V0 = AB + CD
Note:
• When the logic gate input is 0 (Transistor OFF) it will act as a current source
• When logic gate input is 1 (Transistor ON) it will act as a current sink
VCC
Source
O/1 OFF/ON
Sin k
JE JC Region
RB RB cutoff
RB FB Reverse active
FB RB Active
FB FB Saturation
VCC
A
B
Wired AND
AB . CD
C
A B
D
166
IC Logic Families
• NM = 0.2V
• Fan-out = 3
• Wired AND used
Disadvantage
• Lower speed of operation
• Low noise margin
• Lowest fan out
A B T1 T2 Y
0 0 OFF OFF 1
0 1 OFF ON 0 VCC
1 0 ON OFF 0
1 1 ON OFF 0
T1 T2
A + B +
0.65 V— 0.7 V
—
Disadvantage
Current Hogging: In DCIL logic, if the switches used have different characteristics then
the transistor having lower VBESAT will be first ON and it will not allow other transistors to
turn ON, this phenomenon is known as current hogging.
when when B
A=0 A
A=1
167
IC Logic Families
VCC
R
= R
PNP
SSI - 1 - 12
MSI- B - 99 no. of gates used
•
LSI - 100 - 1000 in this integration.
VISI- > 1000
R = 2K R = 2K
DA D1 D2
A T1
DB
20K
B
168
IC Logic Families
• In I2L logic, due to integration of PNP and NPN transistor. It occupies less area
hence density is more in I2L logic. It is mostly used in MSI and LSI logic families
• Also called MTL (merged logic family) due to integration of transistors
A B T1 Y
0 0 OFF 1
0 1 OFF 1
R = 2K R = 2K
1 0 OFF 1
1 1 ON 0
DA D1 D2
A T1
DB
20K
B
• 20k resistors are used only for discharging the transition capacitance. The
capacitance which is discharge is transition capacitance CC .
• The circuit is called Basic DTL gate
• In this any one of the inputs is low or all the inputs are low, DA or DB will become
forward biased whereas D1 and D2 will become reverse biased due to Transistor T1 is
OFF and output is 1.
• When all the inputs are high then DA and DB become reverse biased and D1 and D2
will become forward biased and T1 is ON and output is low.
NAND Gate
• To increase fan out we introduce Transistor in place of diode
• It provides wired AND operation VCC
169
IC Logic Families
Solved Examples
Problem:
Consider the DTL circuit shown in figure given below. The output Y of the given circuit is
VCC = 5V
1.6k Ω 2k Ω
Y
2k Ω Q1
A Q2
B D2
5k Ω
C
Solution:
When any of the inputs is low, Q1, D2 and Q2 are OFF and hence the output is HIGH and
when all inputs are HIGH, then Q1, D2 and Q2 conduct pulling the output logic LOW.
170
IC Logic Families
VCC
130
4K 1.6K
T4
D
A T1 T2 Y
B
T3
1K
Operation
• Any one of the inputs is low or all inputs are low, then the EB junction is Forward
Biased. (JE = FB) and collector base (JC = RE) is Reverse Biased. Transistor is in
active mode due to this transistor T2 and T3 are OFF (in cut-off region) whereas T4 is
in saturation. Hence, output is 1
• When all the inputs are high then JE (EB junction) of T1 is Reverse Biased. And JC (CB
junction) is Forward Biased. (The mode of operation is Reverse active). T2 and T3 are
in saturation and T4 is in cutoff. Hence output is zero
• VIH = 2V, VOH = 2.4V, VIL = 0.8, VOL = 0.4, tpd = 10 ns
• Pdiss = 10 mw
• Fanout = 10
• NM = 0.4V
• Diode D is used to cutoff Tr T4 when T3 is ON
171
IC Logic Families
Schottky TTL
• Schottky Diode is used between collector and base region then it removes storage
time and saturation delay. The family is known as Schottky TTL.
tpd = 6 nsec
SAT
active
T4
Cutoff
172
IC Logic Families
A+B
Vrcj
A+B
A B = − 1.17V 1.5K
1.5K
Rc
−5.2V
• tpd = 1 nsec
• Fan out = 25
• It basically contains two stages.
(1) Differential amplifier input stage
(2) Common collector or emitter follower output stage
173
IC Logic Families
• Due to the use of differential amplifiers complementary outputs are available in the
ECL logic family. (NOR/OR) gate
• Due to use of a common collector stage in the output fan out is high
• ECL uses negative power supply. Due to this any spikes or negative voltage do not
affect operation
• tpd = 1 ns
• Pdiss = 55 mw
• FOM = 55 PJ
• Fan out = 25
logic 0 = − 1.7V
• NM = 0.3 V It is logic 1 mode only volatge supply is negative
logic 1 = − 0.85V
(A + B) + (C + D)
C
Solution:
+Vcc
Given circuit is shown below,
R1
Z
R2
X Q1
Diode
174
IC Logic Families
Here, transistor (Q1) and diode (D) both can work as a switch and transistor (Q1) is
controlled by input (X) and diode (D) is controlled by input (Y).
+Vcc
R1
Z = Vout = 0
(because of short circuit)
R2
S.C.
X=0
O.C
Y=0
Hence, X = 0 and Y = 0 → Z = 0.
+Vcc
R1
Z = Vout = Vcc = 1
Y=1
Hence, X = 0 and Y = 1 → Z = 1.
175
IC Logic Families
+Vcc
R1
Z = Vout = 0
Y=0
Hence, X = 1 and Y = 0 → Z = 0
+Vcc
R1
Z = Vout = 0
Y=1
Hence, X = 1 and Y = 1 → Z = 0
176
IC Logic Families
X
0 1
Y
0 0 0
1 1 0
XY
Thus, Z = XY
D D
G G Substrate
S S
N–Channel MOS D
Logic ‘0’ = OFF
Logic ‘1’ = ON G
S
P–Channel MOS
D
Logic ‘0’ = ON
G
Logic ‘1’ = OFF S
177
IC Logic Families
Since FET is a voltage variable resistor hence in the MOS circuit in place of the resistor
we use MOSFET.
1 ON 0 T1
A T2
A
A B T2 T3 Y VDD
0 0 OFF OFF 1 VDD
0 1 OFF ON 1
1 0 ON OFF 1 T1
1 1 ON ON 0
Y Y
A T2
A
B Y
B T3
A B
178
IC Logic Families
A B Y −VDD
0 0 1 −VDD
0 1 0
T1
1 0 0
Y
1 1 0 Y
VDD VDD
1 1
VDD VDD
A T1 T2 Y
0 ON OFF 1
1 OFF ON 0 VDD
VDD
T1
T1
A Y
Y
T2
T2
179
IC Logic Families
Transfer Characteristics
V0 V0 V0
V1 V1 V1
Power Dissipation
Static Power dissipation: During logic ‘0’ or logic ‘1’.
2
Dynamic Power dissipation: During transition from 0 → 1 or → 0, PD = cf VDO
A B T1 T2 T3 T4 Y VDD
0 0 ON ON OFF OFF 1
0 1 ON OFF OFF ON 1
1 0 OFF ON ON OFF 1
A T1 B T2
1 1 OFF OFF ON ON 0
A T3
B T4
Advantages of CMOS
(1) Extremely low power dissipation is even smaller than MOS logic
(2) The propagation delay is quite small as output impedance is small
180
IC Logic Families
Disadvantages of CMOS
(1) Difficult to fabricate on IC
(2) Low packing density (so they are not recommended for LSI or VLSI circuits)
Solved Examples
Problem:
The expression for output “Y” for the circuit given below is
+Vdd
A
B
B C
Solution: Y = A (B + C) = A + (B + C) = A + BC = A + BC
Problem:
The expression for output “Y” for the circuit given below is
VSS
P1
P2
A PMOS
PMOS
B N2
NMOS
N1
NMOS
181
IC Logic Families
Solution:
Given circuit can be re-draw as,
VSS
A P1 P2 PMOS
B N2
NMOS
A N1
Y= A ⋅ B
We can also make the truth table of above circuit, based on functionality of NMOS and
PMOS as,
Input PMOS NMOS Output
A B P1 P2 N1 N2 Y
0 0 ON ON OFF OFF 1
0 1 ON OFF OFF ON 1
1 0 OFF ON ON OFF 1
1 1 OFF OFF ON ON 0
182
IC Logic Families
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
The above table satisfy the characteristic of 2-input NAND operation so that, above
circuit becomes,
A
Y=A.B
B
Problem:
The expression for output “V0” for the circuit given below is
5V
X
PMOS
Y
V0
NMOS
Solution:
Given logic circuit of CMOS logic 5V
family is shown below and circuit
can be re-draw as, X P1
PMOS
Y P2
V0
X N1 N2 Y
NMOS
183
IC Logic Families
C= X + Y
We can also make the truth table of above circuit, based on functionality of NMOS and
PMOS as,
X Y P1 P2 N1 N2 Y
0 0 ON ON OFF OFF 1
0 1 ON OFF OFF ON 0
1 0 OFF ON ON OFF 0
1 1 OFF OFF ON ON 0
Input Output
X Y V0
0 0 1
0 1 0
1 0 0
1 1 0
V0
Y
X 0 1
0 1 0
1 0 0
184
IC Logic Families
Power
Logic Propagation Noise
dissipation an-in Fan-out Cost
family delay (ns) margin (V)
(mW)
TTL 9 10 0.4 8 10 Low
185
IC Logic Families
186
Semiconductor Memories
Chapter 7
Semiconductor Memories
Objective
Upon completion of this chapter you will be able to:
• Understand various types of memory used in digital systems
• Learn the basic function of RAM and ROM
• Learn memory management in digital systems
• Easily create the difference between various types of memories
Computer Memory
Memory is defined as the basic unit of a computer where data and instructions are
stored. It is organized into locations. Every memory location is called one memory
word. The number of bits present in each location is called word length of the memory.
It is generally multiplied by 8 bits. The capacity of the memory is defined as the total
numbered location in the memory. The capacity is the product of memory locations and
word length of the memory every memory has specific address. The memory is used to
store information such as instructions, data, intermediate, and final results.
Classifications of Memory
A memory is classified according to its function, contents retention and data access
method. The performance of different memories is compared according to memory
speed, cost per bit, and power dissipation.
Types of memory
RAM ROM
Semiconductor Memories
Semiconductor memories are semiconductor devices in which the basic storage cells are
transistor circuits.
They are of two types:
(i) Random access memories (ii) Sequential access memories
187
Semiconductor Memories
Programmable ROM
Unlike ROM, it can be programmed by the user only once in its lifetime (by using a
special circuit known as PROM programmer).
Note: The bit storage density is the highest for optical type memories and the
lowest for the semiconductor memories. There is nearly an order of magnitude
difference between the semiconductor and magnetic or the magnetic and
optical storage densities. However, semiconductor memories have the following
specialties for which they are used as the main memory and the others as the
secondary or auxiliary memories:
188
Semiconductor Memories
Memory Devices
In most of the digital system, the memory device is one of the most important
components. Especially for a microprocessor-based digital system, memory devices are a
must. Bus refers to the hardware lines through which mainly digital signals flow. Address
lines are unidirectional. Data lines are bidirectional and can both accept and leave data.
The I/O controls the input/output data. Therefore a memory device is a device in which
binary information can be stored. It comes in a variety of organizations: capacity (kilobyte
or megabyte) and speed (lower and higher speed).
189
Semiconductor Memories
(3) Dynamic MOS RAM (DMRAM or DRAM) (it is also R/W memory) It is just a flip-flop
with cross coupled transistors. Static bipolar RAM
Advantage
The main advantage of bipolar static R/W memory is that it is of high speed.
Disadvantages
(1) It has very low packing density (Few numbers of bipolar RAM can be
accommodated in a small area), that is, the space required to fabricate a transistor
is quite large
(2) It consumes more power (as it requires high supply voltage and its input
impedance is not large) and it requires large voltage compared to MOS RAM
(5) With the advent of improved IC technology, the speed of static MOS RAM is even
greater than static bipolar RAM
(6) MOS RAM chips have on-chip decoding circuits for which no external decoding
circuits are needed. If the decoding circuits are external then the speed of static
MOS RAM can be further increased. In MOS technology we can have NMOS and
PMOS technology. NMOSRAM has higher speed than PMOS RAM as the mobility
of electrons is higher than that of holes. Mobility is defined as the drift velocity
per unit applied electric field (E). As the E of the electron is less than hole so the
mobility μ is more
190
Semiconductor Memories
Advantages of DRAM
(1) Its packing density is very large, even larger than static MOS RAM. To store 1
bit, it requires only one transistor, whereas in static MOS RAM it requires four
transistors. 10 bits MOS static RAM requires 40 transistors whereas 10 bit dynamic
MOS RAM needs 10 transistors and 10 capacitors
(2) It requires little standby power
(3) It is quite cheaper
Disadvantages of DRAM
(1) It requires an external memory refresh controller circuit for periodic refreshing of
each DRAM cell
(2) It is slower than static MOS RAM. (Due to the capacitor discharging or charging
time) In a microcomputer system if the memory requirement is larger than DRAM
is always used and for memory requirement is lower we can use static MOS RAM
Disadvantages of EPROM
(1) Selective on board erasing memory location is not possible
(2) Selective on board programming cannot be done, that is, programming should be
sequential. Programming pins for EPROM are large compared to RAM memory
191
Semiconductor Memories
Advantages of EPROM
(1) Available from a variety of sources and with various organization speed and
capacity
(2) Erasing time is quite large = 20 to 30 min
(3) It is not so expensive
Advantages of EAPROM
In this case we can selectively erase a particular location on board. Similarly, we can
perform selectively on board programming and selective on board erasing requires a
threshold voltage of 5 to 8 V. Erasing time is 5 to 10 ms and programming time is 250 μs
to 1 ms for a particular location.
Disadvantages of EAPROM
(1) It is quite expensive
(2) It is not available from a variety of sources
(3) It is not popular as this technology is still not matured
Applications of ROM
(1) ROM can be used to realize in particular combination or sequential logic design
(2) ROM can be used to store the microinstructions of a control unit in a micro
programmed control system
(3) ROM is used for code conversion
(4) ROM is used for storing the lookup tables (as in calculator)
(5) It can be used to store the readymade subroutines or subroutine monitors programs
(6) ROM can be used in the character generator to store information of each character
to be generated on the CRT screen. This is called a character generator
(7) It can be used for effective emulation of other machines by microprocessors using
the firmware approach with ROM
(8) The ROM can be used to store data. The OS is to protect it from computer viruses
192
Semiconductor Memories
193
Semiconductor Memories
194
Microprocessors
Chapter 8 – Microprocessors
Objective
Upon completion of this chapter you will be able to:
• Understand various registers present in 8085 microprocessor
• Learn the instruction set of 8085 μp
• Write the program in Assembly Language 8085 μp
• Determine the output of the assembly language program
Introduction
Microprocessors are regarded as one of the most important devices in our everyday
machines called computers. It is an electronic circuit that functions as the central
processing unit (CPU) of a computer, providing computational control. It is also used in
other advanced electronic systems, such as computer systems printers, automobiles.
Microprocessors incorporate arithmetic and logic functional units as well as the
associate control logic, instruction processing circuitry and a portion of the memory
hierarchy. It is a semiconductor component designed by using VLSI technology and
includes ALU, CU (control unit), and resistor of the CPU in a single package.
Computer
CPU (MP)
ALU
I/P O/P
CU
Devices Devices
Resgister
Memory
195
Microprocessors
Note:
• For a microprocessor, memory is connected externally.
• Busicom (Japan) is the first company who designed the calculator by using discrete
ALU, CU and memory
• After Busicom, Intel designed microprocessors in a single package.
• 1st microprocessor, 1971 → Intel 4004 → 4-bit.
• Bit → Binary digit (0 or 1).
• Nibble → 4-bit.
• Byte → 8-bits.
• Word length → Depends on type of processor.
Micro-Controller
ALU
Timer/
CU Memory
Counter
Resgister
Interfacing
Circuits
Microprocessor Microcontroller
Application Application
E.g.: Intel 8085, 8086, M6800, Z80, i3, i7 E.g.: Intel 8051, 8031, PIC-8 bit/ 16 bit,
196
Microprocessors
Program
& Program Data
Data
• Program & data both are present in • Program and data are separately
same memory present in different memory
• E.g.: Intel 8085, Intel 8086 (MP) • E.g.: Intel 8051 (MC)
I/O
MP Memory
Devices
Note: In the above figure, since only one memory block is present, it shows
program and data both are stored in the same memory, so it is von-neumann
architecture.
Opcode fetch
Reading the opcode byte and decodes, is known as opcode fetch [OPF]
197
Microprocessors
Instruction Fetch
Opcode fetch followed by operand read operation is known as instruction fetch.
IF = OPF + memory Read
And if followed by execution is known as processing
P = IF + E
Memory Read
Reading or accessing the data (stored in memory) from memory
Memory write
Sending or transferring data to memory
I/O Read
Accessing data from input port or device
I/O write
Transferring data to output port or device
System Bus
Typical system uses a number of busses, a collection of wires, which transmit binary
numbers, one bit per wire. A typical microprocessor communicates with memory and
other devices (input and output) using three busses: Address Bus, Data Bus and Control
Bus.
Address Bus
It is used to transfer the address of either memory or I/O device from the processor. It
is unidirectional (from microprocessor to memory I/O device). It defines the maximum
memory that can be connected to a processor given by the relation,
2n = N
Where n → number of address line
N → number of address or memory location.
The Address Bus consists of 16 wires for 8085 microprocessors, therefore 16 bits. Its
"width" is 16 bits. A 16 bit binary number allows 216 different numbers, or 32000 different
numbers, i.e., 0000000000000000 up to 1111111111111111. Because memory consists of
boxes, each with a unique address, the size of the address bus determines the size of
memory, which can be used. To communicate with memory the microprocessor sends an
address on the address bus, Ex. 0000000000000011 (3 in decimal), to the memory. The
memory then selects box number 3 for reading or writing data.
198
Microprocessors
A computer bus that is used to specify a A computer bus that is used to transmit
physical address in the memory. data among components
Unidirectional Bidirectional
Helps to transfer memory addresses of Helps to send and receive data
data and IO
Width determines the amount of memory Width determines the data transferring
a system can address rate
Memory
Memory stores information such as instructions and data in binary format (0 or 1). It
provides this information to the microprocessor whenever it is needed.
• Memory is a collection of resistors.
• Resistors: Collection of flip-flops.
• If flip-flop is a memory unit or cell which can store a bit (0 or 1).
• Most of the memories are designed to hold 1 byte per location. Therefore memory
is represented in terms of bytes.
Memory Flip-Flop
Resister
00 R0 8 bits
R1 or
01
1-byte
10 R2
11
Rn
199
Microprocessors
Solved Examples
Problem:
A processor has 33 address lines, calculate the maximum memory that can be connected
Problem:
A memory of 512 TB can be connected to the processor. Calculate the address line
required.
Problem:
It is required to connect 100 MB to the processor. Calculate the minimum address lines.
Problem:
The maximum memory that can be connected 8085 is?
Solution: address bus for 8085 microprocessor = 16
216 × 26 × 210
64 (1KB) → 64KB
64 × 1024 → 65,536 Bytes
Memory
Hence, 0 ← 0000H R0
1 ← 0001H R1
2 ← 0002H R2
Rn
65,536 ← FFFFH
200
Microprocessors
Note: Address of the memory locations are not stored in memory. It is stored in a
processor.
Data Bus
It is used to transfer data between processor, memory and I/O devices. Data bus is
bidirectional.
It is 8-bit in length for an 8085 microprocessor. Therefore, 28 combinations of binary
digits. Data bus used to transmit "data", i.e., information (results of arithmetic, etc)
between memory and the microprocessor. Size of the data bus determines what
arithmetic can be done. If only 8 bits wide, then the largest number is 11111111 (255 in
decimal). Therefore, larger numbers have to be broken down into chunks of 255. This
slows the microprocessor. Data Bus also carries instructions from memory to the
microprocessor. Size of the bus therefore limits the number of possible instructions to
256, each specified by a separate number.
There are no separate data lines or buses in 8085. The lower 8 address line can be used
both as address and data with the help of a control signal known as ALE (Address latch
enable)
A 15 − A 3
AD7 − AD0
}
Higher order Lower order Multiplexed Address/Data bus
Address Bus Address Bus
Address
Data
WR RD RD WR
ALE A15 R0
0000H
A6 R1
AD7 Latch 1 0 0 1 0 0 1 1 R2
0003H
MP AD0
R
0003
Rn
Memory
201
Microprocessors
Control Bus
It is a group of different control signals required for various operations of the processor.
Control bus is partially uni-directional and partially bi-directional.
Control Busses are various lines which have specific functions for coordinating and
controlling microprocessor operations. E.g., read/not write line, single binary digit.
Control whether memory is being ‘written to’ (data stored in memory) or ‘read from’ (data
taken out of memory). May also include clock line(s) for timing/synchronizing, ‘interrupts’,
‘reset’ etc. Typically microprocessors have 10 control lines. Microprocessor cannot
function correctly without these vital control signals.
Internal Architecture
Internal architecture is divided into five functional units:
• ALU(arithmetic logic unit)
• Resistor unit
• Timing and control unit
• Interrupt control unit
• Serial I/O control unit.
D (8) E (8)
Instruction
Decoder H (8) L (8)
ALU and Stack pointer
Machine 16
cycle Program counter
Encoder 16
Increment/Decrement
Address Latch
Crystal oscillator
X1 Timing & Control
Control Add.Buffer Add/Data
X2 Status DNA
Ready ALE RD WR IO/M S1 S0 Hold HLDA Reset in Reset out Clock out A15 − A8 AD7 − AD0
202
Microprocessors
Register
The 8085 microprocessor includes six registers, one accumulator, and one flag register,
as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and the
program counter.
There are two types of register.
(a) General purpose resistor
(b) Special purpose resistor
203
Microprocessors
E.g.: MOV A, B
Op-Code Fetch
MP
Memory
8000H
XX
8001H
44
IR
XX
PC
8000
8001
Note:
• When data is stored or pushed into stack memory, stack pointer is decremented.
• When data is accessed from the memory stack, the pointer is incremented.
• A single register data cannot be stored in stack memory.
204
Microprocessors
Example: Describe the output of following code using graphical representation if stacks
pointer points to F008H
LXI D, 5566 H
PUSH D
MP Memory
0000H
LIFO
SP-2 = F006H 66
SP-1 = F007H 55
SP
w w = write
F008 SP = F008H 44
F007
F009H 33 D E
F006
. . 55 66
. .
. .
FFFFH
Flag Register
It is an 8-bit register. There are 5 flags which are set or reset after an operation
according to data conditions of the result in the accumulator and other registers. They
are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags. The most
commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to
test data conditions.
As the result is stored in the accumulator, for most of the ALU operations flags are
affected by the content of the accumulator except for a few instructions.
Example: Increment & decrement
Sign Flag
After execution of any arithmetic and logical operation, if D7 of the result is 1, the sign
flag is set. Otherwise it is reset. D7 is reserved for indicating the sign; the remainder is
the magnitude of the number. If D7 is 1, the number will be viewed as a negative number.
If D7 is 0, the number will be viewed as a positive number.
Zero Flag
If the result of arithmetic and logical operation is zero, then zero flag is set otherwise
it is reset. It may also be affected for other general purpose registers in the same
instruction.
205
Microprocessors
Auxiliary Flag
If D3 generates any carry when doing any arithmetic and logical operation, this flag is set.
Otherwise it is reset.
Parity Flag
If the result of arithmetic and logical operation contains an even number of 1's then this
flag will be set and if it is an odd number of 1's it will be reset.
Carry Flag
If any arithmetic and logical operation result in any carry the carry flag is set otherwise it
is reset.
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
Solved Examples
Problem:
A = 15H, B = BEH, then find A + B = ? and also find the flags.
Solution: D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 0 1 0 1
1 0 1 1 1 1 1 0
0 1 1 0 1 0 0 1 1
CY
206
Microprocessors
S Z X AC X P X CY
1 0 0 1 0 0 0 0
9 0
A + B = E3H
Solution:
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 0 1 1 1
0 1 1 1 1 0 0 1
1 0 0 0 0 0 0 0 0
CY
S Z X AC X P X CY
0 1 0 1 0 1 0 1
5 5
Temporary register
W, Z are the two 8-bit registers which are not accessible by the user. They are used by
the processor in some instruction
Note: There are no separate instruction for multiplication and division in 8085
Micro-Programs
It is a program written by a manufacturer to make the processor understand what an
instruction is or it indicates the type of operations to be performed for an instruction.
207
Microprocessors
Example: MOV B, C
fcrystal
Operating frequency = fclock =
2
208
Microprocessors
1 0 1 IO/ R IO read
1 1 0 IO/ W IO write
S1 S0 Status
0 0 Halt
0 1 Memory write
1 0 Memory read
1 1 Opcode fetch
• HOLD
This indicates if any other device is requesting the use of address and data bus.
Then the microprocessor transfers the control to the requesting device as soon
as the current cycle is over. After the process of requesting the device is over, the
control is transferred back to the microprocessor.
• HLDA
HLDA is the acknowledgment signal for HOLD. It indicates whether the HOLD signal
is received or not. After the execution of a HOLD request, HLDA goes low.
5 DMA operation
2
MP HOLD DMA
Controller
HLDA
3
4 1
HOLD
I/O
Regular path
209
Microprocessors
When more or huge data is to be transferred between memory and I/O at a faster rate
DMA operation is used, with the help of DMA controller.
• Reset-in
Low active I/P signal to reset the processor and PC is initialize to 0000H
• Reset-out
Output signal which indicates that processor is reset. It can be used to reset IO
devices.
• Clock-out
• O/P pin on which the same operating frequency of the processor is available. It can
be used to connect to an IO device for synchronizing operation.
• Ready
I/P pin to processor from a slow speed IO device. If ready is high then only the
processor will either transmit data & receive data from IO devices.
• SID
I/P pin through which processor receives serial data.
• SOD
O/P pin by which processor transmits serial data.
Note: Both SID and SOD are internally connected to D7 of the accumulator.
MAR
Memory address register is used to hold the address before it is placed on the address
bus.
MDR
Memory data register is used to hold the data before it is transferred to memory or when
it is accessed from memory to processor.
210
Microprocessors
Functional Description
Classification of Signal
(i) Address bus (unidirectional)
(ii) Data bus (Bi-directional)
(iii) Control and status signal (partially uni/Bi-directional)
(iv) Interrupt and externally initiated
(v) Serial IO ports
(vi) Power supply and frequency signal
RST 6.5 RD
8085
RST 5.5 WR
(iii)
INTR IO/M
(iv) Control and status
S1
signal
S0
Ready
Reset-Out
Hold HLDA
Reset-in INTA
Clock-Out
Interrupts of 8085
It is an internal or external signal which may disturb or alter the sequence of execution of
the process. Interrupt is an event that demands the CPU. In general any microprocessor
is set to be in the fetch execute cycle of the main program, i.e. in processing of the main
program. If occurrence of interrupt event is recognize by the microprocessor then it
perform the following steps (known as interrupts switching steps
Main program
211
Microprocessors
1H
0H 100
150 C) =
1500H
) ← (P
.P
I.S
(PC S) =
Occurance of
to
interrupt event
(TO
s
ter
en
1000H : Current Instruction
µP
1001H : Next Instruction µP
ret
ur ns
P.C 1001H (PC to
)← M.P
(TO RET
Next Address S)
=1
or 001
H
Return Addres
12FFH : HLT
Step-1:
Microprocessor completes execution of commonly fetched instructions.
Step-2:
Microprocessor saves next address or written address available in the program counter
by pushing it into top of the stack & then program counter with vector address,
i.e., starting address of I.S.R
Step-3:
Microprocessor processes interrupt device routine, through fetch & execute cycle
Step-4:
At the end of I.S.R, when microprocessors execute RET interrupt. It retrieves contents of
TOS back into program counter & interrupt resumes main program processes
212
Microprocessors
Classification of Interrupts
Hardware Interrupts
These interrupts are available in the form of input pins i.e., physically available.
• 8085 has 5 hardware interrupts or external interrupts.
RST 7.5
RST 6.5
RST 5.5
• TRAP is both edge and level triggered. It is edge triggered such that it may be
responded quickly. It is level triggered in order to differentiate the original signal
from practical application and error signal due to noise.
• The signal on the TRAP pin must be high for at least 3 clock periods such that the
error signal due to noise may be avoided.
Software Interrupts
These interrupts are available in the form of instruction.
• 8085 has 8 software interrupts
RST 0
RST 1
RST 2
RST 3
RST 4
RST 5 Eight, 1 Byte instruction
RST 6 (Priorlly is not needed here)
RST 7 Because processor don't execute two instruction at a time
213
Microprocessors
Maskable Interrupts
These interrupts can be either enabled or disable by the program. If enabled then only
the interrupt event is recognized by the microprocessor. If disable then occurrence of
interrupt event will be ignored by microprocessor.
• EI(Enable interrupt) & DI(Disable interrupt & SIM(Set interrupt mask) instruction are
provided for masking
• 8085 has 12 maskable interrupts & only one non-mask able interrupts is TRAP/RST 4.5
• All 12 maskable interrupts can be globally enabled or disabled by using ‘EI’ or ‘DI’
Non-Maskable Interrupts
These interrupts cannot be disabled, i.e., always exist in enabled state. 8085
microprocessor has only 1 non mask-able interrupt (TRAP/RST4.5) which is used in
emergency conditions.
• EI, DI & SIM instruction doesn’t affect TRAP
Vectored Interrupts
For these interrupts, vector address, i.e., starting address of I.S.R is prefixed by the
manufactures. 8085 microprocessor has a 12 vectored interrupts and these are:
RST 0 to RST 7 and RST 4.5, RST 5.5, RST 6.5, RST 7.5
• Any interrupt of 8085 in RST is a vectored interrupt
• ‘RST X’ ↔ Corresponding vector address which is completed by the machine
214
Microprocessors
Non-Vectored Interrupt
For these interrupt vectored addresses are not prefixed by the designer. As such for
servicing such interrupt external, dedicated hardware is required, i.e., external hardware
supplies not only required interrupt requests but also required vector addresses.
• 8085 has only 1 non vectored interrupt (INTR) i.e., interrupt request.
• 8259 PIC is normally used for serving non vectored interrupt.
µP
8085µ 8259 IC
Step 2 Step 1
RST 6.5
Step 4
Vector Address
P.C
RST 5.5 Data Bus Address Register
• In order to use INTR, the programmer must select one of the software interrupt
addresses to store the ISR of the I/O device.
• INTR is pseudo interrupt input which can be used for increasing the number of
interrupts of 8085, with the use of 8259 PIC.
• INTA is an active low interrupt ACK active pin. 8085 microprocessor generates on
active low signal via this INTA output, when it receives and recognizes interrupt
requests.
215
Microprocessors
PC
0024H 0024H JMP
JMP 1500H
00
15
0040
Main Program
14FF
1500H
I.S.R
For
RST 4.5
15FFH
1600H I.S.R
For
RST 6
160FH USR = User
define sevice
1610H USR routine
SIM (Set Interrupt Mask): Use to mask the interrupts or make them available.
RIM (Read Interrupt Mask): Use to know the status of pending interrupts.
216
Microprocessors
Programming Model
• Program: Set of instruction.
• Instruction: It is a command given to the computer to perform some specific task.
• Machine level language:
It is a binary means of communication with a computer through a design set of
instructions specific to a system.
• Assembly level language:
Instructions are written in separate words known as ‘Mnemonics’ which are
partially understood by the programmer.
MOV B,C
Example: Here MOV, ADD are Mnemonic (Easy to understand)
ADD D
• Both assembly and machine level language are together called Machine level
language.
• Overall cycle of writing the program till execution:
Assembly Program
Assembler
Execute
Machine-Code
Decode (Microprogram)
Op-code Operands
217
Microprocessors
Length of an Instruction
• Number of bytes occupied by the instruction in the memory.
• There are three types of instruction classified as bases of length.
Example:
4000H: MOV A, C → XX
Memory representation:
F → Fetch
R → Read
Note:
• Op-code is always fetch (In any type of process, fetch is always done first)
• Data is read or write
Memory Rule
In all memory related operations, the data present in the lower byte of register is
transferred to lower address location whereas higher byte data is transferred to high
address location and vice-versa.
218
Microprocessors
Standard Codes
B → 000
C → 001
D → 010 Memory (M) → 110
E → 011 BC → 00
H → 100 DE → 01
L → 101 HL → 10
A → 111 SP → 11
• Every register is given unique code, there 74 different op-codes in 8085 which
result 246 instructions
Addressing Modes
The mode of specifying operand address is known as addressing mode. There are various
formats specifying the operands. It indicates how the data is accessed for an instruction.
There are 5 types of addressing modes.
(1) Register addressing mode.
(2) Implicit/ implied addressing mode.
(3) Immediate addressing mode.
(4) Direct addressing mode.
(5) Indirect addressing mode.
219
Microprocessors
Timing Diagram
Timing diagram is pictorial representation of execution of an instruction with the help of
various control and status signal
T-State
It is one sub-division of an operation performed in one clock period. Sub-divisions are
internal states synchronized with the system clock.
1 1
f= 3MHZ;=
T = = 0.33 µ sec
clk
fclk 3 × 106
Machine Cycle
It is defined as the time required to access either memory or Input-Output or It is also
equivalent to the time required to transfer a data byte to memory or Input-Output. One
machine cycle may contain 3 to 6 T-State
Processor only does this 5 operation:
(1) F (Fetch)
(2) mr (Memory Read)
(3) mw (Memory Write)
220
Microprocessors
Instruction Cycle
It is time required to complete the execution in instruction. One instruction cycle may
contain 1 to 5 machine cycles:
(1) =
IC IFC + EC
(2) =
IC1B OPFC + EC
Execution
• Internal 8 bit operation Will be performed during of OPFC.
• Internal 16 bit operation required two clock cycle extra (2T state).
• External 8 bit operation [MWC, MRC, IOWC, IORC], Required 3T state.
221
Microprocessors
Note:
• Op-code fetch MC’s are 2 types
• Normal OPFC = 4T
• Special OPFC = 6T
OUT F8H ⇒ 2B
⇒ OPFC + mr1c + IOW
⇒ 3MC = 4T + 3T + 3T = 10T states
IN F9H ⇒ 2B
⇒ OPFC + mc + IOR
⇒ 3MC = 4T + 3T + 3T = 10T states
222
Microprocessors
• ADC H, SUB B, SBB, INRH, DCR C, DAA, ANA B, ORA C, RAL, RLC, RAR, RRC
ADDM ⇒ 1 Byte instruction
⇒ OPFC + MRC
⇒ 2MC = 4T + 3T = 7T states
223
Microprocessors
• ACI F4H, SUI 44H, SBI 20H, ORI 40H, ANI 00H, XRI 10H, CPI 11H
DAD H ⇒ 1 Byte instruction
⇒ OPFC + BIC + BIC
⇒ 3MC = 4T + 3T + 3T = 10T
JC 1001H, JPE 1200H, JPO Delay, JNZ 1010H, JZ 1210H, JP 1001H, JM 2100H
CALL 1641H ⇒ 3 Byte instruction
⇒ OPFC + mr1c + mr2c + 2T + Mw1C + Mw2C
⇒ 4T + 3T + 3T + 2T + 3T + 3T = 18T states
224
Microprocessors
• CC 1000H, CPE 1100H, CPO Delay, CNZ 1010H, CZ 1111H, CP 1212H, CM LOOP
RET ⇒ 1 Byte instruction
⇒ OPFC + MR1C + MR2C
⇒ 4T + 3T + 3T = 10T states
Timing Diagram
It is a representation of various control signals generated during execution of an
instruction.
Following Buses and control signals must be shown in the timing diagram.
• High order address buses.
• Lower order address/data buses.
• ALE
• RD
• WR
• IO /M
225
Microprocessors
Instruction cycle
Steps A15
Op-code fetch Memory read
(1) Fetch T1 T2 T3 T4 T5 T6 T7
(2) Decode
µs
0.33µ
(3) Execute
ALE
AD7 − AD0 Z
00H XX 01H 99H
IO/M, IO/M = 0 S1 = 1, S0 = 0
IO/M = 0 S1 S0 = 1
S1 S0
RD
T1 State
• ALE = 1 (high) is indicating all 16 lines are acting as address buses
• contain higher byte of address present in program counter (PC)
• AD7 − AD0 contain lower byte of PC
• IO/M = 0 indicating memory operation
• S1 = S0 = 1 for fetch
• RD = 1, inactive as there is no ‘data bus’ available
T2 State
• As ALE becomes low, AD7 − AD0 act as data bus
• When RD is activated, op-code from the memory location is accessed onto the
data bus.
T2 State
• Op-code from the data bus is accessed into instruction register (IR)
226
Microprocessors
T4 State
• The op-code is decoded (D) and execution may also be completed for some
instruction like MOV A,B; but the instruction considered a memory read operation is
required.
• Status of higher order bus (address) is unknown
Memory Read
T5 State
• ALE is high in order to point next memory location
• T6 and T7 are similar to fetch except that S1 = 1, S2 = 1 for memory use.
• 99H is accessed into Accumulator (A) in T6 and T7 for the instruction given.
Conclusion:
• Length of instruction = 2 byte
• No of machine cycle = 2 (F, R)
• Total T-State = 7 (F → 4, R → 3)
• Total execution time = count period no of T-State count value
1 1
= × T - States × C.V= × 7 × 1= 2.31 µ sec
fclk 3 × 106
• T-State:
Min Max
Fetch 4 6
Machine cycle 3 6
Instruction 4 18
Note:
• The number of machine cycles required for execution of an instruction may or may
not be equal to length of instruction.
• ALE is high in the first T-State of a machine cycle.
227
Microprocessors
Instruction
Notations
r = 8 bit register
rs = 8 bit source register
rd = 8 bit destination register
r16 or rp = 16 bit register pair or 16 bit pointer
228
Microprocessors
Syntax Operation
(SP) decremented by 2
(SP) incremented by 2
229
Microprocessors
Note:
• In almost all data transfer operation, the contain of source is unchanged after the
execution
• Flags are not affected for execution of data transfer groups of instructions, since
ALU is not involved.
• Working principle of stack is LIFO i.e. last pushed number will be popped out first
• Stack pointer contents are decremented by 2 for execution of PUSH and CALL
instruction.
• When PUSH instruction is executed stack pointer decrement first & writes to the
decremented address.
• Stack pointer contents are incremented by 2 for execution of POP and RETURN
instruction.
• When POP instruction is executed, the stack pointer first reads the increment.
• Stack pointer contents is unaltered for XTHL instruction since XTHL = POPH
followed by PUSH H.
IR
XX
3000H XX F
.
.
D .
3500H 77 W
H L C C
35 00 77 77
IR
XX
3000H XX F
.
PC .
3400 D .
3401
3500H 66 W
H L E C
35 00 77 77
230
Microprocessors
IR
XX
3800H XX Fetch (F)
3801H FF
R
PC
3800 D A
3801
FF
A
FF
Z IR
33 XX 4000H XX F
R
4001H 33
PC .
4000 D . 33 Z
4001 .
4002 W
4600H 33
H L
46 00
IR
XX 4700H XX F
4701H 00
PC R
4702H 50 R
4700 D
4701 H L
4702 50 00
4703
H L
50 00
231
Microprocessors
W Z IR
54 00 XX 5100H XX F
5101H 33
R
PC 5102H 54 R
D .
5100 W Z
5101 .
. 54 00
5102
R
5103 5400H 89
A
89 A
89
W Z IR
60 00 XX 5600H XX F
5601H 00
R
PC 5602H 60 R
D .
5600 W Z
5601 .
. 60 00
5602
W
5603 6000H 3F
A
3F A
3F
IR
XX 6200H XX F
.
6300H
.
PC
.
D
6200 W
79
6201
A
B C A 79
63 00 79
232
Microprocessors
IR
XX 6400H XX F
.
.
PC
.
D
6400
6900H 28 W
6401
A
B C A 28
69 00 28
D E IR
98 76 XX 7000H XX F
.
.
PC
.
D
7000
SP-2 = F003H 76
7001 W
SP-1 = F004H 98
SP
SP = F005H WW
F005
.
F004 D E
.
F003 98 76
.
233
Microprocessors
Z IR
XX 7000H XX F
50
50 R
7701H
Z
D 50
PC
Port address 50H
7700
7701
7702 A I/P
Device
WW
Z IR
XX 8000H XX F
70
70 R
8001H
Z
D 70
PC
Port address 70H
8000
8001
8002 A O/P
Device
43
234
Microprocessors
WZ
E4 00 IR XX F
E000H
E4 01 XX 00
E001H R
E4 R
E002H
.
W Z
PC D .
. E4 00
E000
H L E400H 46
E001
E401H 8A R R
E002 8A 89
E003
H L
8A 46
WZ
EB 00 IR E600H XX F
XX 00
E601H R
EB R
E602H
.
W Z
PC D .
. EB 00
E600
H L E800H 57
E601 W
E801H 39 W
E602 39 57
E603
H L
39 57
235
Microprocessors
Arithmetic Instruction
• No multiplexer/division operation is supported by 8085.
• 8085 microprocessor has an accumulator based ALU i.e., in most of the arithmetic
& logical operations accumulator is one of the source operands and also acts as
destination operand for result storage.
(a) Addition; ADD C
(b) Subtraction; SUB M
(c) Increment; INX H
(d) Decrement; DCR M
Syntax Operation
Add r (A) <= (A) + (r)
236
Microprocessors
• 16 bit increment & decrement operations are not performed by ALU, As such flags
are not affected for the execution of INX & DCX operation.
• INR & DCR instruction affects all flags except the CY flag.
• For DAD Accumulator is unchanged after the operation. If there is carry out of 16-
bit, carry flag is affected, remaining flags are unchanged
• DAA is the only instruction which works with the status of auxiliary carry flag
(AC) in BCD conversion. It is used after addition. It converts 8-bit data present in
the accumulator into two 4-bit BCD numbers. It uses the following condition for
execution, after varying the content of accumulator
If D3 − D0 > 9 or AC = 1; Add 6
If D7 − D4 > 9 or CY = 1; Add 6
Example: ADD C
DAA
If (A) = (89)BCD, (C) = 77BCD
(89)BCD = 1 0 0 0 1 0 0 1
(77)BCD = 0 1 1 1 0 1 1 1
CY = 1 = 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
CY 0 1 1 0 0 1 1 0
0 0 1 1 0 0 1 1 0 = 66H
237
Microprocessors
F9 = 1 1 1 1 1 0 0 1
68 = 0 1 1 0 1 0 0 0
CY = 1 0 1 1 0 0 0 0 1
(A) <= 61
S Z X AC X P X CY
0 0 0 1 0 0 0 1
38 = 0 0 1 1 1 0 0 0
C7 = 1 1 0 0 0 1 1 1
CY = 0 1 1 1 1 1 1 1 1
5B = 0 1 0 1 1 0 1 1
2E = 0 0 1 0 1 1 1 0
CY = 0 1 0 0 0 1 0 0 1
(A) <= 89
S Z X AC X P X CY
1 0 0 1 0 0 0 0
1
89 = 1 0 0 0 1 0 0 1
76 = 0 1 1 1 0 1 1 0
CY = 1 0 0 0 0 0 0 0 0
238
Microprocessors
Manual Processor
A−C A+C
94 = 1 0 0 1 0 1 0 0 94 = 1 0 0 1 0 1 0 0
−31 = 1 1 0 0 1 1 1 1 +CF = 1 1 0 0 1 1 1 1
CY = 1 0 1 1 0 0 0 1 1 CY = 1 0 1 1 0 0 0 1 1
S Z X AC X P X CY S Z X AC X P X CY
0 0 0 * 0 1 0 0 0 0 0 1 0 1 0 1
In manual method we are not able to find ‘AC’ flag but the method used by processor
have capability to determine (assign) Auxiliary flag (AC)
Trick
Find ‘AC’ by using a manual method.
If result lower Nibble<Accumulator lower Nibble
Then AC = 1
Else AC = 0
24 = 0 0 1 0 0 1 0 0
−9C = 0 1 1 0 0 1 0 0
CY = 0 1 0 0 0 1 0 0 0
S Z X AC X P X CY
1 0 0 0 0 1 0 0
239
Microprocessors
5A = 0 1 0 1 1 0 1 0
−9F = 0 0 1 0 0 0 0 1
CY = 0 0 1 1 1 1 0 1 1
S Z X AC X P X CY
1 0 0 0 0 1 0 1
68 = 0 1 1 0 1 0 0 0
−AE = 0 1 0 1 0 0 1 0
CY = 0 1 0 1 1 1 0 1 0
S Z X AC X P X CY
1 0 0 0 0 0 0 1
FF = 1 1 1 1 1 1 1 1
+1 = 0 0 0 0 0 0 0 1
CY = 0 0 0 0 0 0 0 0 0
S Z X AC X P X CY
0 1 0 1 0 1 0 X'
8F = 1 0 0 0 1 1 1 1
+1 = 0 0 0 0 0 0 0 1
1 0 0 1 0 0 0 0
S Z X AC X P X CY
1 0 0 1 0 1 0 X'
240
Microprocessors
FFFF = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+1 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 No flag will affect
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 = 0 0 0 0 0 0 0 0
−1 = 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
S Z X AC X P X CY
1 0 0 0 0 1 0 X’
F000 = 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
−1 = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1
F00F = 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
+9876 = 1 0 0 1 1 0 0 0 0 1 1 1 0 1 1 0
CY = 1 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1
(HL) = 8886H
241
Microprocessors
Logical instruction
8085 microprocessor has an accumulator base ALU i.e., in most of the logical operations,
one of the source operands is accumulator and also destination operands for result
storage.
(a) AND; ANA D
(b) OR; ORI FFH
(c) Ex-OR; XRA M
(d) Compare; CDI 00H
(e) Compliment; CMA
(f) Rotate; RRC
Syntax Operation
AND accumulator with r
ANA r
(A) <= (A)∧(r)
ANA M (A) <= (A)∧((HL))
CMC CY <= CY
STC CY <= 1
242
Microprocessors
• For CMP M operation results are not stored in ‘M’, it differs from SUB instruction.
We have to check status from flags.
• CMA instruction is used for 1’s complement performing.
• Rotate operations include only change of carry flag. No other flags are affected
using rotate operation.
• For any AND operation AC = 1 & CY = 0
For any OR operation AC = 0 & CY = 0
Set by microprocessor, remaining flags depend on results
• Comparison is performed by doing internal subtraction but result is not stored
in accumulator i.e. both the operands involved in comparison are unaltered. Flag
register is updated after comparison operation.
0 0 Positive (A)>(B)
0 1 Negative (A)<(B)
Since XRA A takes less machine cycles, we prefer it because it saves memory and
increases the speed of operation. Since MVI A, 00H has also the same machine cycles
but in this operation flags are different for different values but in XRA A, flags are not
affected.
RAL
CY
MSB D6 D5 D4 D3 D2 D1 LSB
243
Microprocessors
RLC
CY
MSB D6 D5 D4 D3 D2 D1 LSB
RAR
CY
MSB D6 D5 D4 D3 D2 D1 LSB
RRC
CY
MSB D6 D5 D4 D3 D2 D1 LSB
244
Microprocessors
by just looking LSB, if LSB = 0then number is even otherwise odd or if LSB = 1, then
number is odd otherwise even. If we want to judge the no is +ve or −ve, then if MSB
−ve number), if MSB = 0 (+ve number), but in microprocessor it is not possible
= 1 (−
to judge directly. So we use the carry flag to check the condition above.
• Rotate left: If we want to check +ve or −ve number, then use RAL (Rotate left with
carry). Thus carry flag content MSB. Now by check carry flag we identify +ve or −ve.
• Rotate right: By using RAR carry flag condition LSB check carry flag. If CY = 1 (odd
number) and if CY = 0 (even number)
55 = 0 1 0 1 0 1 0 1
AA = 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
S Z X AC X P X CY
0 1 0 1 0 1 0 0
DB = 1 1 0 1 1 0 1 1
59 = 0 1 0 1 1 0 0 1
1 1 0 1 1 0 1 1
245
Microprocessors
S Z X AC X P X CY
1 0 0 0 0 1 0 0
Z = 0 & CY = 0
A > B, Positive number
FF = 1 1 1 1 1 1 1 1
FF = 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
S Z X AC X P X CY
0 1 0 0 0 1 0 0
A−C
59 = 0 1 0 1 1 0 0 1
−BE = 0 1 0 0 0 0 1 0
1 0 0 1 1 0 1 1
S Z X AC X P X CY
1 0 0 0 0 1 0 1
MSB D6 D5 D4 D3 D2 D1 LSB
0 1 0 1 0 1 1 1
1 0 1 0 1 0 1 1
(A) <= AB
246
Microprocessors
CY
MSB D6 D5 D4 D3 D2 D1 LSB
0 1 1 0 1 1 0 0
1 0 1 1 0 1 1 0
(A) <= B6
Branching Instruction
This group of instruction is also called a program transfer control group. In this group
the control program is transferred from one location to another conditionally or
unconditionally. These instructions operate on the program counter and in turn change
or alter the sequence of processing.
Conditional Instruction
They depend on the status of flags affected for previous ALU operation (except Auxiliary
carry flag (AC)).
• When the condition is true, control of the program is transferred to the 16-bit
address. 3 machine cycles i.e., 10T states consumed.
• When the condition is false, the very next instruction is executed. 2 machine cycles
i.e., 7T states are consumed.
Test Conditions
247
Microprocessors
JUMP Instruction
Syntax Operation
W Z
30 02
+1
PC 3000
3006
3003
• In this above program if the content of register ‘c’ is ’n’. The loop executes for
n-times where the condition is true for (n − 1) times and false only once.
• The operation of the remaining conditional jump instruction is similar to JNZ except
that flags are different.
248
Microprocessors
CALL Instruction
Syntax Operation
CNC Add 16 CALL address if CY = 0
Return Instruction
Syntax Operation
RZ Return if zero (Z = 1)
RP Return if plus (S = 0)
RM Return if minus (S = 1)
249
Microprocessors
Unconditional Instruction
The control of the program is transferred to the 16-bit address unconditionally.
Syntax Operation
• Term used for call in ‘c’ language is called function calling, but in microprocessor,
function is termed as ‘Subroutine’
• If length of instruction is large, it term as ‘Procedure’
• If length of instruction is small it terms as ‘Macro’
• Call instructions are used to call subroutine main program
Subroutine
Set or group of instructions which perform specific functions written as a separate
program away from the main program is known as subroutine.
When CALL is executed,
Step-1: The content of PC or address of instruction next to call is push onto stack
memory, then SP → SP − 2.
Step-2: The control of the program is transferred to the subroutine address and
execution continues. When RET is executed,
Step-1: The data present at top of stack (2 Bytes) pointed by SP is accessed or loaded
into the program counter. Therefore SP → SP + 2
250
Microprocessors
Step-2:
Control of the program is transferred to the 16-bit address and execution continues.
When RST n is executed,
Step-1: The content of PC or address of instruction next to RST n is push down to stack
memory, therefore SP → SP − 2.
Step-2: Control of the program is transferred to the vector address of RST n and execution
complete.
• CALL & RET operations are known as subroutine handling operations. CALL
instruction is used for transferring the program control to a subroutine from main
program and RET instruction is used for transferring control program back to main
program from subroutine.
ORI FFH
}
ANI FFH These are not executed because of jump instruction
OUIT: HLT
FFFFH
251
Microprocessors
C = 03
02, Z = 0 True
01, Z = 0 True
00, Z = 1 False
Let above program provide ‘x’ second delay, then if we introduce ‘NOP’, then delay
increases by 4 T-states.
252
Microprocessors
SOD pin
D7 D6 D5 D4 D3 D2 D1 D0
Serial O/P
data if 1 = Masked
0 = Available
Reset
Serial data RST 7.5 F.F Mask set enable
Enable 1 = Reset
1 = D2 − D0 = Valid/significant
1 = Enable SOD
0 = D2 − D0 = Invalid/Insignificnt
0 = Disable SOD
• ‘D3’ bit is the control over D2 − D0, if it is 1 they are valid/significant else invalid/
insignificant
0 1 0 0 1 1 0 0
253
Microprocessors
SID pin
D7 D6 D5 D4 D3 D2 D1 D0
Serial I/P
data Status of pending if 1 = Masked
Interrupts 0 = Available
1 = Pending
Interrupt Enable Flip-Flop
1 = Interrupt Enable (For EI)
0 = Interrupt Disable (For DI)
Example: The content of Accumulator after execution of RIM instruction is 9CH. Find:
(i) Interrupt masked
(ii) Interrupt available
(iii) Interrupt pending
(iv) Serial data received
1 0 0 1 1 1 0 0
254
Microprocessors
Note:
SIM → Control the interrupt
RIM → Represent status of interrupt
Conclusion:
* PUSH Rp
* POP Rp
* CALL SP → SP − 2 SP SP + 2
* RST n * Retun
Solved Examples
Problem:
9900H: LXI H, 1230H
9903H: PCHL
9904H: MVI A, FFH
9906H: HLT
What is content of “A” after execution of above program
Solution:
Since, PCHL operation changes the PC to 9906H, hence instruction at 9904H is not
executed. Hence content of A is undefined.
Problem:
After the execution, what is the content of SP and data present at CFFEH
LXI SP, FF00H
LXI H, D000H
SPHL
PUSH B
POP B
HLT
Solution:
(SP) = FF00H
(HL) = D000H
(SP) = D000H
SP = D000H after PUSH & POP operation because PUSH and POP cancel out each other
At CFFEH → 00H (When push perform, SP → SP-2 i.e., CFFEH and at this position lower
bit of HL is place i.e., 00H)
255
Microprocessors
Problem:
Write an assembly language program (ALP) to perform Ex-Or operation between first two
memory location data and store the content of flag register and accumulator to the next
memory location.
Solution:
LDA 6000H
MOV B,A
LDA 6001
XRA B
LXI SP 6004
PUSH PSW
HLT
B = E7 = 1 1 1 0 0 1 1 1
A = −B1 = 1 0 0 0 0 0 0 1
0 1 1 0 0 1 1 0
S Z X AC X P X CY
0 0 0 0 0 1 0 0
Problem:
Write an assembly language program to access a data byte from port address 70H
compliment it, rotate the result left side for 5 times. Store the resultant value at 900FH
after transferring it to port add 90H.
Solution:
IN 70H
CMA
MVI B, 05 H
L1: RLC
DCR B
JNZ: L1
OUT 90H
STA 900FH
HLT
256
Microprocessors
Problem:
LHLD 7000H
LXI D, 7003H
7000H 02
LDAX D
7001H 70
MOV B,M
ANA B 7002H BD
DAD H 7003H 3C
SPHL
PUSH PSW
HLT
Then find the address stored in SP and Top of stack & also find the value stored in the
accumulator.
Solution:
(i) H = 70, L = 02
D = 70, E = 02
(ii) A = 3C
(iii) B = BD
(iv) 3C = 0 0 1 1 1 1 0 0
BD = 1 0 1 1 1 1 0 1
0 0 1 1 1 1 0 0 = 3CH
S Z X AC X P X CY
0 0 0 1 0 1 0 0
PSW = 3C14H
7002
(v) 7002
E004
(vi) SP → E004
(vii) SP → E002
257
Microprocessors
Problem:
Write an assembly language program for 8085 to transfer 4-bytes of data starting from
7000 to 8000H.
Solution:
LXI H 7000H
LXI D 8000H
MVI B, 04H
Rept: MOV A,M
STAX D
INX H
INX D
DCR B
JNZ: Rept
HLT
Problem:
Find the content of SP and data present at the top of the stack after the execution of
program
900H: LXI SP, FF00H
9003H: LXI H, 9009H
9006H: PCHL
9007H: MVI B, 66H
9009H: CALL R1
900CH: JMP QUIT
R1 : 900FH: XRA A
9010H: RP
QUIT: 9011H: HLT
Solution:
SP = FF00H SP-2 = FEFEH 0C
HL = 9009H SP-1 = FEFFH 90
PC = 9009 SP = FF00H 55
90 0C
B = 66H
Due to Call instruction, the contents of Program Counter are stored in Stack and Program
counter contains the address of the subroutine.
258
Microprocessors
1
• Total execution time = × T − States × C.V
fclk
• Count values means the number of times that program executes (i.e., no of time
program runs during loop).
Solved Examples
Problem:
Find the total execution time for a program of 8085 it consumes 450 T-States when
crystal frequency is 6MHZ.
Solution:
fcrystal 6MHz
( fclk )
Operating frequency = =
2
= 3MHz
2
1
T.E.T= × 450 × 1= 150 µsec
3 × 106
Problem:
Find the total execution time for the following program.
Operating frequency is 5 MHz
T-State
LXI D, 66CCH - 10
MOV A,E - 4
ANA D - 4
JNC L4 - 7/10
259
Microprocessors
MVI B, 77H - 7
L4: STA 5000H - 13
HLT - 5
Solution:
ANA D ⇒ CC = 1 1 0 0 1 1 0 0
66 = 0 1 1 0 0 1 1 0
0 1 0 0 0 1 0 0
S Z X AC X P X CY
0 0 0 1 0 1 0 0
1
Total execution time = × 46 × 1 = 9.2 µs
5 × 106
Problem:
How many times loop execute, if Z = 0
L1: LXI B, 0003H
DCX B
JNZ L1
HLT
Solution:
DCX → B Never effect flag
(BC) = 0003H
Since, Z = 0, hence JNZ is always true
Thus loop will be rotating infinite no of times
Problem:
How many times loop execute,
XRA A
L1: LXI B, 0003H
260
Microprocessors
DCX B
JNZ L1
HLT
Solution:
XRA A → Z = 1 (it affect zero flags)
Hence, JNZ is executed and condition is false
So, n = 1
In this question, DCX B does not affect flags but because of XRA A flag already affect and
Z=1
Memory Interfacing
memory location = 2Number of address i/p lines
• A memory with n address i/p lines will have 2n bytes.
• Number of address i/p lines is going to decide the memory.
Memory Mapping
Given names to or addressing memory location is known as memory mapping, Memory
map indicates starting and ending and range of a memory chip.
Solved Examples
A15
A14
Problem:
A13
Find the memory map A12
A11
for given interfacing logic.
A10 CS RD WR
A0
.
.
. 1 KB
.
. n = 10
.
.
.
A9
261
Microprocessors
Solution:
For chip select, NAND gate output must be zero it happens only when:
Problem:
Find the memory map for given interfacing logic.
A15
A14
A13
A12
A11 CS RD WR
A0
.
.
. 2 KB
.
. 11 address
. line
.
.
A10
Solution:
For chip select, NAND gate output must be zero it happens only when:
Problem:
Find the ending address of a 4KB ROM if starting address is C3A9H.
262
Microprocessors
Solution:
4 KB = 12 address line [4KB = 212 ⇒ n = 12]
Problem:
Calculate the starting address for a 8KB RAM if the ending address is 60AB H.
Solution:
8 KB = 13 address line [8KB = 213 ⇒ n = 13]
Problem:
A15
A14
E Y0
Y1
A13 C A0 CS
Y2 .
Decoder .
Y3 . 2 KB
A12 B
Y4 .
. RAM
Y5 A10
A11 A
Y6
Y7
Solution:
C B A
O/P
A13 A12 A11
1 0 0 Y4
263
Microprocessors
• This device address is 16-bit. Thus A0 • In this I/O device address is 8-bit. Thus
to A15 lines are used to generate device A0 to A7 or A8 to A15 lines are used to
address generate device address
264
Microprocessors
265