(course code: ee222) lecture 0 3: digital electronics...
TRANSCRIPT
1/14/2019
1
Digital Logic and Design (Course Code: EE222)
Lecture 0‐3: Digital Electronics Fundamentals
Indian Institute of Technology Jodhpur, Year 2018‐2019
Course Instructor: Shree Prakash TiwariEmail: [email protected]
Office: 210, Phone: 1356
Webpage: http://home.iitj.ac.in/~sptiwari/
Course related documents will be uploaded on http://home.iitj.ac.in/~sptiwari/DLD/
1
Note: The information provided in the slides are taken form text books Digital Electronics (including Mano & Ciletti), and various other resources from internet, for teaching/academic use only
Digital Logic and Design
Objectives:
• To introduce the basic concepts of digital system and the use of Boolean algebra in logic analysis
d d iand design
• Understand the principles and methodology of digital logic design at the gate and switch level, including both combinational and sequential logic elements.
T i t d b i t l f l i d i d• To introduce basic tools of logic design and provide hands‐on experience designing digital circuits and components through simple logic circuits to hardware description language
2
1/14/2019
2
Digital Logic and Design
Learning Outcomes:
• Apply Boolean algebra and other techniques to express and simplify logic expressionsto express and simplify logic expressions.
• Analyze and design combinational and sequential digital systems.
• Use different techniques among them a hardware description language and a programming language, to design digital systems.
3
Digital Logic and DesignCourse Contents: • Number system: binary numbers, 1s and 2s complement, arithmetic
operations in integer and floating point systems; ASCII, binary and gray codes;
• Boolean algebra: Boolean Equations, Minimization of Boolean functions; D i i bi ti l Ci it i t d/ M lti lDesigning combinational Circuits using gates and/or Multiplexers
• Combinational circuit: Adder, decoder, multiplexers, code converters (binary, gray and BCD);
• Sequential circuit: Bistable, Monostable, latches and flip‐flops, counters (binary, ring and Johnson), shift register, timer circuits;
• Hardware Description Languages: Combinational Logic, Structural Modeling, Sequential Logic, More Combinational Logic, Finite State Machines, Parameterized Modules, Testbenches
• Digital IC families: DTL TTL ECL MOS CMOS and their interfacingDigital IC families: DTL, TTL, ECL, MOS, CMOS and their interfacing.• ADC and DAC: Sample and hold circuits, ADCs, DACs.• Memories: semiconductor memories, PALs, PLAs and FPGAs; Pipelining
and timing issues, PROMs;
4
1/14/2019
3
Digital Logic and DesignLaboratory: Laboratory will contain experiments from following topics:
i) Familiarization with logic gates and logic building.
ii) Encoders and decoders
iii) Adder circuits: half adder and full adder
iv) Flip flops and countersiv) Flip‐flops and counters
v) Latches and memories
vi) Seven segment display
vii) Arithmetic logic circuits
viii) Digital to analog converters
ix) Analog to digital converters
x) Serial communication
xi) AND OR and EX OR gates using Nand (7400) gates; BCD to 6 3 1 1 Code converter;xi) AND, OR and EX_ OR gates using Nand (7400) gates; BCD to 6‐3‐1‐1 Code converter; 6‐3‐1‐1 to Gray Code converter; full adder circuit using AND, OR and XOR gates; a 4 ‐ Bit comparator using logic gates; Pseudo‐random bit generator; 4 ‐ bit ripple carry adder; Master ‐ Slave J‐K Flip‐Flop using Logic gates; Bi ‐ directional counter using J‐K Flip‐flops;
Priority encoder, multiplexer and decoder; VHDL code for simulation of a 4‐ Bit fast look ahead carry adder; VHDL code for simulation of an 8‐bit signed integer multiplier.
5
Digital Logic and Design
Tentative Assessment: First Mid Semester Exam = 20%,
Second Mid Semester Exam = 20%,
End Semester Exam = 35%,
Laboratory: 20%, Quizzes: 5%
Reference Books
• M. Morris Mano, Michael D. Ciletti, "Digital Design: With an Introduction to the Verilog HDL", 5th edition, Prentice Hall of India, 2012
• Ronald J. Tocci, Neal Widmer, Greg Moss, Digital Systems: Principles and Applications, 10th edition, Pearson, 2009.
• D. M. Harris and S. L. Harris, Digital Design and Computer Architecture, Second Edition, Morgan Kuffmann
6
1/14/2019
4
Evolution of Electronic Devices
7
Integrated Circuits
22 nm CMOS
8
1/14/2019
5
Before Electronics Era
9http://www.leapsecond.com/notes/cartoons.htm
After Electronics Revolution
10http://www.leapsecond.com/notes/cartoons.htm
1/14/2019
6
There are two way of representing the
numerical value of quantities:
analog
digital
Analog representation:
A quantity is represented by a voltage, current or meter movement that is proportional to the value of that quantityof that quantity
Example :
Automobile speedometer
Audio microphone
Analog quantities can vary over a continuous rangeof values
1/14/2019
7
Digital representation:The quantities are represented not by proportional quantities but by symbols called digitsExample :….Digital watch
It provides the time of day in the form of decimal digits which represent hours and minutes (and sometimes seconds)
The digital representation of the time of day changes in discrete steps
Advantages of Digital Techniques
1. Digital systems are easier to design as circuits usedare only switching circuits having only HIGH and LOWrange
2 I f ti t i2. Information storage is easy.
3. Accuracy and precision are greater
4. Operation can be programmed.
5. Digital circuits are less affected by noise, as thespurious fluctuation in voltage (noise) are not ascritical in digital systems became the exact value of avoltage is not important.
Limitation of Digital Techniques
The real world is mainly analog
1/14/2019
8
Design Hierarchy
SYSTEM
+
CIRCUIT
GATE
MODULE
n+n+S
GD
DEVICE
CIRCUIT
15
Digital Number System
Many number systems are in use in digitaltechnologytechnology
The most common are
DecimalBinaryBinaryOctalHexadecimal
1/14/2019
9
Numbers Every number system is associated with a base or radix
The decimal system has a base of 10 and uses symbols (0,1,2,3,4,5,6,7,8,9) to represent
5 4 3 2 1 05 4 3 2 1 0 5 4 3 2 1 0( )ra a a a a a a r a r a r a r a r a r
A positional notation is commonly used to express numbers
numbers
3 2 1 010(2009) 2 10 0 10 0 10 9 10
2 1 0 1 210(123.24) 1 10 2 10 3 10 2 10 4 10
An octal number system has a base 8 and uses symbols (0,1,2,3,4,5,6,7)
3 2 1 08(2007) 2 8 0 8 0 8 7 8
What decimal number does it represent?
1 08(2007) 2 512 0 64 0 8 7 8 1033
A hexadecimal system has a base of 16
3 2 1 0(2 9) 2 16 16 16 9 16BC B C
Number Symbol
0 0
1 1
2 2
10(2 9) 2 16 16 16 9 16BC B C 3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
How do we convert it into decimal number?
1 010(2 9) 2 4096 11 256 12 16 9 16 11209BC
10 A
11 B
12 C
13 D
14 E
15 F
1/14/2019
10
Example : the number 1011.1012
23 22 21 20 2‐1 2‐2 2‐3
1 0 1 1 1 0 1
Most Significant Bit(MSB) Binary Point
.Least Significant Bit(LSB)
A Binary system has a base 2 and uses only two symbols 0, 1 to represent all the numbers
3 2 1 02(1101) 1 2 1 2 0 2 1 2
20 1
21 2
22 4
23 8Which decimal number does this correspond to ?
1 02(1101) 1 8 1 4 0 2 1 2 13
1 1 0 1 . 1 0 0 1
2‐4
24 16
25 32
26 64
27 128
28 256
29 51223 22 21 20
2‐1 2‐32‐22‐4 29 512
210 1024(K)
220 1048576(M)
2‐1 2‐2 2‐3 2‐4 2‐5 2‐6
0.5 0.25 0.125 0.0625 0.03125 0.015625
1/14/2019
11
Converting decimal to binary number
Convert 45 to binary number
10 1 0(45) .......n nb b b
1 11 1 045 2 2 ....... 2n n
n nb b b b
Divide both sides by 2
1 2 01 1 0
4522.5 2 2 ....... 2 0.5n n
n nb b b b 1 1 02 n n
1 2 01 1 022 0.5 2 2 ....... 2 0.5n n
n nb b b b
0 1b
1 2 01 1 022 0.5 2 2 ....... 2 0.5n n
n nb b b b 0 1b
1 2 1 01 2 122 2 2 ....... 2 2n n
n nb b b b
Divide both sides by 2
2 3 01 2 1
2211 2 2 ....... 2 0.5
2n n
n nb b b b 1 0b
2 3 1 011 2 2 2 2n nb b b b 1 3 211 2 2 ...... 2 2n nb b b b
3 4 01 3 25.5 2 2 ...... 2 0.5n n
n nb b b b 2 1b
3 4 1 01 4 35 2 2 ...... 2 2n n
n nb b b b
1/14/2019
12
3 4 1 01 4 35 2 2 ...... 2 2n n
n nb b b b
4 5 01 4 32.5 2 2 ...... 2 0.5n n
n nb b b b 3 1b
4 5 1 01 5 42 2 2 ...... 2 2n n
n nb b b b
5 6 01 5 41 2 2 ...... 2 0.5n n
n nb b b b 4 0b
5 1b
10 5 4 3 2 1 0(45) 101101b b b b b b
Converting decimal to binary number
Method of successive division by 2
45 remainder
22 1
11 0
5 1
2 1 45 = 1 0 1 1 0 1
1 0
0 1
1/14/2019
13
Convert (153)10 to octal number system
10 1 0 8(153) ( ....... )n nb b b
1 110 1 1 0(153) 8 8 ....... 8n n
n nb b b b
Divide both sides by 8Divide both sides by 8
1 2 0 01 1
15319.125 8 8 ....... 8
8 8n n
n n
bb b b
0 0.1258
b 0 1b
153
19 1
remainder
19 1
2 3
0 2153 = (231)8
Converting decimal to binary number
Convert (0.35)10 to binary number
10 1 2 3(0.35) 0. ....... nb b b b
1 21 20.35 0 2 2 ....... 2 n
nb b b
How do we find the b‐1 b‐2 …coefficients?
Multiply both sides by 2
1 11 20.7 2 ....... 2 n
nb b b 1 0b
1 2 12 30.7 2 2 ....... 2 n
nb b b
1/14/2019
14
1 2 12 30.7 2 2 ....... 2 n
nb b b
Multiply both sides by 2
1 22 31.4 2 ....... 2 n
nb b b
2 1b Note that ½+1/4+1/8+……1
1 2 23 40.4 2 2 ....... 2 n
nb b b
1 30 8 2 2 nb b b 3 0b 3 40.8 2 ....... 2nb b b 3
0 .
0 . 25
125
x2
x2
0.125 = ?
Converting decimal to binary number
5
1. 00.125 = (.001)2
x2
0 .x2
0.8125 = ?0 . 8125
x21 . 625
25
0. 5
x2
1 .x2
1. 0
x2
0.8125 = (.1101)2
1/14/2019
15
Binary numbers
1011000111
Binary digit = bit
Least significant bit or LSBMost significant bit or MSB
This is a 10 bit number
decimal 2bit 3bit 4bit 5bit
0 00 000 0000 00000
1 01 001 0001 00001
2 10 010 0010 00010
3 11 011 0011 00011
4 100 0100 00100
5 101 0101 00101
6 110 0110 00110
7 111 0111 00111
8 1000 01000
N‐bit binary number can represent numbers from 0 to 2N ‐1
9 1001 01001
10 1010 01010
11 1011 01011
12 1100 01100
13 1101 01101
14 1110 01110
15 1111 01111
Converting Binary to Hex and Hex to BinaryNumber Symbol
0(0000) 0
1(0001) 1
2(0010) 2
3(0011) 3
4(0100) 4
5(0101) 5
7 6 5 4 3 2 1 0 1 0( ) ( , )b Hexb b b b b b b b h h
7 6 5 4 3 2 1 17 6 5 4 3 2 1 0 1 02 2 2 2 2 2 2 16b b b b b b b b h h
5(0101) 5
6(0110) 6
7(0111) 7
8(1000) 8
9(1001) 9
10(1010) A
11(1011) B
12(1100) C
3 2 1 4 3 2 1 17 6 5 4 3 2 1 0 1 0( 2 2 2 )2 ( 2 2 2 ) 16b b b b b b b b h h
h1 h0
(10110011) (1011)(0011) ( 3)b HB 13(1101) D
14(1110) E
15(1111) F
(10110011) (1011)(0011) ( 3)b HexB
(110011) (11)(0011) (33)b Hex
( ) (1110)(1100) (11101100)Hex bEC
1/14/2019
16
Binary Addition/Subtraction
0
0
0
0
1
1 1
1
1
1
0
1 01
1
1
1 1
1 0 1
1 1 0
1 0 1 1
1 1 0 1
1 1 0 1 1
+ 1 1 1 0
Complement of a number
Decimal system:
9’s complement
10’s complement
9’s complement of n‐digit number x is 10n ‐1 ‐x
10’s complement of n‐digit number x is 10n ‐x
9’s complement of 85 ? 210 1 85 99 85 14
9's complement of 123 = 999 123 876
10's complement of 123 = 9's complement of 123+1 877
1/14/2019
17
Complement of a binary number
Binary system:
1’s complement
2’s complement
1’s complement of n‐bit number x is 2n ‐1 ‐x
2’s complement of n‐bit number x is 2n ‐x
1’s complement of 1011 ? 42 1 1011 1111 1011 0100
1's complement of 1001101 = ?
0110010
1’s complement is simply obtained by flipping a bit (changing 1 to 0 and 0 to 1)
2's complement of 1010 = 1's complement of 1010+1 0110
2's complement of 110010 =
Leave all least significant 0’s as they are leave first 1 unchanged and then flip all subsequent bits
001110
Leave all least significant 0 s as they are, leave first 1 unchanged and then flip all subsequent bits
1011 0101
101101100 010010100
1/14/2019
18
Advantages of using 2’s complement
Adderx1
x2
S
CY
Can we carry out Y = X1 – X2 using such an adder?1 2
x
Adder
2's Complement
Y = S if Sign = 0Y = 2's Complement of S if Sign = 1
SYx1
x1,x2: N bit numbers
SignCYx2
Sign = 0 for psotive numbers = 1 for negative numbers
22N x1 2( , ) 2NCY S x x
Note that carry will be there only if x1 – x2 is positive as 2N is N+1 bits (1 followed by N zeros)
Sign = 0 for positive numbers= 1 for negative numbers
Advantages of using 2’s complement
Adder
2' C l t
Y = S if Sign = 0Y = 2's Complement of S if Sign = 1
SYx1
x1,x2: N bit numbers
SiCYx2
2's Complement Sign
Sign = 0 for psotive numbers = 1 for negative numbers
CY
22N x1 2( , ) 2NCY S x x
Note that carry will be there only if x1 – x2 is positive as 2N is N+1 bits (1 followed by N zeros)
Sign = 0 for positive numbers= 1 for negative numbers
A zero carry implies a negative number whose magnitude (x2 – x1) can be found as follows:
1 22NS x x
1 2 2 12'scomplement of 2 ( 2 )N NS x x x x
1/14/2019
19
Adder
Y = S if Sign = 0Y = 2's Complement of S if Sign = 1
SYx1=1010
Example
10 01000100
Adder
2's Complement Sign
Sign = 0 for psotive numbers = 1 for negative numbers
CYx2=0110
61010
1 0 1 0+ 1 0 1 0
1 0Sign = 0 for positive numbers= 1 for negative numbers
1 0 1 0 0
Adder
Y = S if Sign = 0Y = 2's Complement of S if Sign = 1
SYx1=0110
Example
6 11000100
dde
2's Complement Sign
Sign = 0 for psotive numbers = 1 for negative numbers
CYx2=1010
100110
0 1 1 0+ 0 1 1 0
0 1Sign = 0 for positive numbers= 1 for negative numbers
1 1 0 0
It makes sense to use adder as a subtractor as well provided additional circuit required for carrying out 2’s complement is simple
1/14/2019
20
Subtraction using 10’s complement
SYx1
x1,x2: N digit numbers
Y = S if Sign = 0Y = 10's Complement of S if Sign = 1
8
55
x2
Adder
Sign
Sign = 0 for psotive numbers = 1 for negative numbers
CY10's Complement
8
310‐3=7
10Sign = 0 for positive numbers
= 1 for negative numbers
This way of subtraction would make sense only if subtracting a number x2 from 10N is much simpler than directly subtracting it directly from x1
Representing positive and negative binary numbers
One extra bit is required to carry sign information. Sign bit = 0 represents positive number and Sign bit = 1 represents negative number
decimal Signed Magnitude
0 0000
1 0001
decimal Signed 1’s complement
0 0000
1 0001
decimal Signed 2’s complement
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
‐0 1000
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
‐0 1111
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
‐1 1111‐1 1001
‐2 1010
‐3 1011
‐4 1100
‐5 1101
‐6 1110
‐7 1111
‐1 1110
‐2 1101
‐3 1100
‐4 1011
‐5 1010
‐6 1001
‐7 1000
1 1111
‐2 1110
‐3 1101
‐4 1100
‐5 1011
‐6 1010
‐7 1001
1/14/2019
21
If we represent numbers in 2’s complement form carrying out subtraction is same as addition
Adder
Y = S if Sign = 0Y = 2's Complement of S if Sign = 1
SYx1
x1,x2: N bit numbers
CYx2
2's Complement Sign
Sign = 0 for psotive numbers = 1 for negative numbers
CY
S
x1
Answer is in 2’s complement form
Sign = 0 for positive numbers= 1 for negative numbers
Adder
x2
x1,x2: N bit numbers in 2's complement
CY
Example
Adder
S
x1
x2
x1,x2: N bit numbers in 2's complement
CY
1, 2 p
0 1 0 1+ 0 0 1 0
0 1 1 1
+ 5+ 2+7
+ 5- 2+3
0 1 0 1+ 1 1 1 0
0 0 1 1
- 5+ 2- 3
1 0 1 1+ 0 0 1 0
1 1 0 1
2’s complement is 0011 = 3
- 5- 2- 7
1 0 1 1+ 1 1 1 0
1 0 0 1
2’s complement is 0111 = 7
1/14/2019
22
CODES
When numbers, letters or words arerepresented by a special group of symbols, wesay that they are being encoded and they y ggroup of symbols is called code.
Binary‐ Coded‐ Decimal Code (BCD)
If each digit of a decimal number is represented by its binary equivalent the result is a code called binarybinary equivalent, the result is a code called binary‐coded‐ decimal. Since a decimal digit can be as large as 9, 4 bits are required to code each digit.
Ex. 874 = 1000 0111 0100 (BCD)
1/14/2019
23
Gray code
It belongs to a class of codes called minimum‐change codes, in which only one bit in the code groupscodes, in which only one bit in the code groups changes when going from one stage to the next. The Gray code is an unweighted code.
So, this code is not suited for arithmetic operation but finds application in input/output devices and
f A l Di i l C (ADC )some types of Analog to Digital Converters (ADCs).
Binary Equivalent Gray Code0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 10 0 1 0 0 0 1 10 0 1 1 0 0 1 0 0 1 0 0 0 1 1 00 1 0 0 0 1 1 00 1 0 1 0 1 1 10 1 1 0 0 1 0 10 1 1 1 0 1 0 01 0 0 0 1 1 0 01 0 0 1 1 1 0 11 0 1 0 1 1 1 11 0 1 1 1 1 1 01 1 0 0 1 0 1 01 1 0 1 1 0 1 11 1 1 0 1 0 0 11 1 1 1 1 0 0 0
1/14/2019
24
Alphanumeric Codes
An alphanumeric code represents all of the various characters and functions that are found in a standard typewriter (or computer) keyboard.yp ( p ) y
ASCII Code: The most widely used alphanumeric code, the American standard code for Information Interchange as is used in most micro computers and minicomputers and in many mainframes. The ASCII d i 7 bit d d it h 27 128 ibl dcode is a 7 bit code and so it has 27 =128 possible code
groups.
Character 7- Bit ASCII Hex A 1000001 41B 1000010 42C 1000011 43... …. …... …. …
Z 1011010 5A0 0110000 30
… … …
9 0111001 39
a, b, … blank, etc.
1/14/2019
25
Example : When writing a BASIC Programme,
instruction GO TO 25
G 01000111
O 01001111O 01001111
T 01010100
O 01001111
2 00110010
5 00110101
0 is added because the codes must be stored as bytes (8bits).
This adding of an extra bit is called padding with 0s.
Boolean Algebra
Algebra on Binary numbers
A variable x can take two values {0,1} 0
False
No
Low voltage
1
True
Yes
High voltage
Basic operations:
1 2AND: y = x . x
Y is 1 if and only if both x1 and x2 are 1, otherwise zero
x1 x2 y
0 0 0 0 1 0
1 0 0 1 1 1
Truth Table
1/14/2019
26
Basic operations:
1 2OR: y = x + x
Y is 1 if either x1 and x2 is 1. Or y= 0 if and only if both variables are zero
x x yx1 x2 y
0 0 0 0 1 1
1 0 1 1 1 1
NOT: y = xyx
1
1
0
0
What next……
• Digital Cont..
52