textbook: digital design, 4 . edition m. morris mano and ...soc.eecs.yuntech.edu.tw/course/digital...
TRANSCRIPT
P-1/82 2012/3/14
Textbook: Digital Design, 4th. Edition
M. Morris Mano and Michael D. Ciletti
Prentice-Hall, Inc.
教 師 : 蘇 慶 龍 INSTRUCTOR : CHING-LUNG SU
課程名稱: 數位邏輯設計
E-mail: [email protected]
P-3/82 2012/3/14
Outline of Chapter 1
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-4/82 2012/3/14
1.1 Digital Systems
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-5/82 2012/3/14
Digital Systems
1. Digital system examples: Digital telephones, digital
TV, DVD, digital cameras (DC), digital videos (DV),
MP3 Player and digital computers.
2. Digital systems: Manipulate discrete data
3. Binary: Numbers are presented by two discrete
values (0 and 1), Binary digit = Bit
4. Group of bits: Binary code
5. Digital systems: A system manipulates discrete
elements of information that is represented
internally binary form.
6. HDL (Hardware description language): A
programming language and suitable for describing
digital circuits in textual form.
1.1 Digital Systems
P-6/82 2012/3/14
1.2 Binary Numbers
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-7/82 2012/3/14
Decimal Number
1. Decimal number 7392:
7392=7103+ 3 102+ 9 101+ 2 100
2. Decimal number representation: a5a4a3a2a1a0.a-1a-2a-3
= 105a5+104a4+103a3+102a2+101a1+100a0+10-1a-1+10-2a-2+10-3a-3
1.2 Binary Numbers
P-8/82 2012/3/14
1.2 Binary Numbers
Decimal Number with Binary Number
11010.11=26.75
124+ 123+ 022+ 121+ 020+ 12-1+ 12-2=26.75
P-9/82 2012/3/14
1.2 Binary Numbers
Base-r Number with Binary Number
an rn + an-1 r
n-1 +… + a2 r2 + a1 r
+ a0 + a-1 r
-1 + a-2 r-2 + …+ a-m r
-m
(4021.2)5 = 453+ 052+ 251+ 150+ 25-1 = (511.4)10
(127.4)8 = 182+ 281+ 780+ 48-1 = (87.5)10
(B65F)16 = 11163+ 6162+ 5161+ 15160 = (46687)10
(110101)2 = 32+16+4+1 = (53)10
P-10/82 2012/3/14
1.2 Binary Numbers
Base-r Number System
1. Base-2, Binary
2. Base-8, Octal
3. Base-10, Decimal
4. Base-16, Hexadecimal, (10=A, 11=B, 12=C, D=13, E=14,
F=15)
P-11/82 2012/3/14
1.2 Binary Numbers
Base-2 Power of n
1. n=10, 210=1024, K (kilo)
2. n=20, 220=1048576, M (mega)
3. n=30, 230=130023424, G (giga)
4. n=40, 240=133143986176, T (tera)
P-12/82 2012/3/14
Example: Base-2, Power of n
1. 4K=4210=212
2. 16M=16220=224
3. 4G=4230=232
1.2 Binary Numbers
P-13/82 2012/3/14
Powers of Two
n 2n n 2n n 2n
0 1 8 256 16 65,536
1 2 9 512 17 131,072
2 4 10 1,024 18 262,144
3 8 11 2,048 19 524,288
4 16 12 4,096 20 1,048,576
5 32 13 8,192 21 2,097,152
6 64 14 16,384 22 4,194,304
7 128 15 32,768 23 8,388,608
1.2 Binary Numbers
P-14/82 2012/3/14
Arithmetic Operation - Addition
1.2 Binary Numbers
Augend: 101101
Addend: 100111
Sum: 1010100
P-15/82 2012/3/14
Arithmetic Operation - Subtraction
Minuend: 101101
Subtrahend: 100111
Difference: 000110
1.2 Binary Numbers
P-16/82 2012/3/14
Arithmetic Operation - Multiplication
Multiplicand: 1011
Multiplier: 101
1011
0000
1011
Product: 110111
1.2 Binary Numbers
P-17/82 2012/3/14
1.3 Number Base Conversions
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-19/82 2012/3/14
1.3 Number Base Conversions
Example of Decimal to Binary Conversion:
(41)10 to (1011001)2
Integer Reminder Coefficient
Quotient
41/2= 20 + ½ a0=1
20/2= 10 + 0 a1=0
10/2= 5 + 0 a2=0
5/2= 2 + ½ a3=1
2/2= 1 + 0 a4=0
1/2= 0 + ½ a5=1
Answer: (41)10=(a5a4a3a2a1a0)2=(101001)2
P-20/82 2012/3/14
1.3 Number Base Conversions
Conveniently Process: (41)10 to (1011001)2
412
202 1
102 0
52 0
22 1
12 0
0 1 Answer: 1 0 1 0 0 1
P-21/82 2012/3/14
1.3 Number Base Conversions
Conveniently Process:
Decimal (Base-10) to Octal (Base-8)
1538
198 1
28 3
0 2 Answer: ( 2 3 1 )8
P-23/82 2012/3/14
Example of Decimal to Binary Conversion:
(0.6875)10 to (0.1011)2
Integer Fraction Coefficient
0.68752= 1 + 0.3750 a-1=1
0.37502= 0 + 0.7500 a-2=0
0.75002= 1 + 0.5000 a-3=1
0.50002= 1 + 0.0000 a-4=1
Answer: (0.6875)10=(0.a-1a-2a-3a-4)2=(0.1011)2
1.3 Number Base Conversions
P-24/82 2012/3/14
1.3 Number Base Conversions
Conveniently Process: (0.513)10 to Octal
0.513 8= 4.104
0.104 8= 0.832
0.832 8= 6.656
0.656 8= 5.248
0.248 8= 1.984
0.984 8= 7.872
Answer: (0.513)10=(0.406517…)8
P-25/82 2012/3/14
1.3 Number Base Conversions
Complete Number Conversion:
1. (41.6875)10 = (101001.1011)2
2. (153.513)10 = (231.406517)8
P-26/82 2012/3/14
1.4 Octal and Hexadecimal Numbers
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-27/82 2012/3/14
1.4 Octal and Hexadecimal Numbers
Numbers with Different Bases
Decimal Binary Octal Hexadecimal
(base 10) (base 2) (base 8) (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
P-28/82 2012/3/14
Octal and Hexadecimal vs. Binary:
Octal Digit = 23 =3 bits
Hexadecimal Digit = 24 =4 bits
1.4 Octal and Hexadecimal Numbers
P-29/82 2012/3/14
1.4 Octal and Hexadecimal Numbers
Number Conversion between Binary to Octal
(10 110 001 101 011 . 111 100 000 110)2 = (26153.7406)8
2 6 1 5 3 . 7 4 0 6
Number Conversion between Binary to Hexadecimal
(10 1100 0110 1011 . 1111 0010)2 = (2C6B.F2)16
2 C 6 B . F 2
P-30/82 2012/3/14
1.4 Octal and Hexadecimal Numbers
Number Conversion between Octal to Binary
(673.124)8 = (110 111 011 . 001 010 100)2
6 7 3 . 1 2 4
Number Conversion between Hexadecimal to Binary
(306.D)16 = (0011 0000 0110 . 1101)2
3 0 6 . D
P-31/82 2012/3/14
1.5 Complements
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-32/82 2012/3/14
1.5 Complements
Complements
Arithmetic Operation : SubtractionLogic Operation : 0 1
Complement
For base-r
r's Complement
r-1's Complement
P-33/82 2012/3/14
1.5 Complements
Diminished Radix (r-1)’s Complements
Given a number N in base-r having n digits,
the (r-1)’s complement of N : (rn-1) - N
If
r =10 r-1=9 :
9’s complements of N = (10n-1) - N
P-34/82 2012/3/14
1.5 Complements
Decimal Example: n = 6 (6 digit) 106-1=999999
The 9’s complement of
546700 is 999999 - 546700 = 453299
012398 is 999999 - 012398 = 987601
P-35/82 2012/3/14
1.5 Complements
For Binary Number (r-1)’s Complement: r=2 r-1=1
The 1’s complement of N is (2n-1)-N, if n = 4
24=(10000)2 then (2n-1)-N = (1111)2-N
P-36/82 2012/3/14
Binary (r-1)’s Example: n = 7 (7 digit)
27-1=(1111111)2
The 1’s (r-1)’s complement of
1.5 Complements
1111111 - 1011000 = 01001111111111 - 0101101 = 1010010
Toggle Each Digit : 01
P-37/82 2012/3/14
1.5 Complements
Diminished Radix r’s Complements
Given a number N in base-r having n digits,
the r’s complement of N :
rn-N, for N 0
0, for N 0
P-38/82 2012/3/14
1.5 Complements
Comparison of r’s and (r-1)’s complement
r’s complement: (r-1)’s complement:
rn- N
= [(rn-1) – N]+1
= (r-1)’s complement +1
(rn-1) – N
P-39/82 2012/3/14
1.5 Complements
Example of r’s complement
10’s (r’s) complement of decimal
2389 7610 (9’s complement) +1= 7611
012398 987601 +1= 987602
246700 753299 +1=753300
P-40/82 2012/3/14
1.5 Complements
Example of r’s complement
2’s (r’s) complement of binary
1101100 0010011 +1= 0010100
0110111 1001000 +1= 1001001
P-41/82 2012/3/14
1.5 Complements
Subtraction with Complements
1. Add the minuend, M, to the r’s complement of
subtrahend, N. This performs M+(rn-N)=M-N+rn
2. If M N, the sum will produce an end carry, rn,
which can be discarded; what is left is the result M-
N.
3. If M < N, the sum dose not produce an end carry
and is equal to rn-(N-M), which is the r’s
complement of (N-M). To obtain the answer in a
familiar form, take the r’s complement of the sum
and place a negative sign in front.
P-42/82 2012/3/14
1.5 Complements
Example of Subtraction with Complements:
Using 10’s (r’s) complement, subtract 72532-3250
M= 7 2 5 3 2
10's complement of N= + 9 6 7 5 0
Sum = 1 6 9 2 8 2
Discard and carry 105= -1 0 0 0 0 0
Answer = 6 9 2 8 2
P-43/82 2012/3/14
1.5 Complements
Example of Subtraction with Complements:
Using 10’s (r’s) complement, subtract 3250-72532
M= 0 3 2 5 0
10's complement of N= + 2 7 4 6 8
Sum = 3 0 7 1 8
No carry !!
Answer : - (10's complement of 30718)
= - 6 9 2 8 2
P-44/82 2012/3/14
1.5 Complements
Example of Subtraction with Complements:
Using 2’s (r’s) complement, perform X-Y and Y-X
X= 1010100
2's complement of Y= + 0111101
Sum = 10010001
Discard end carry 27 = - 10000000
Answer X-Y = 0010001
X=1010100, Y=1000011
(a) X-Y :
Y= 1000011
2's complement of X= + 0101100
Sum = 1101111
No carry 27, Answer= -(2'sc of 1101111)
Answer = - 0010001
(a) Y-X :
P-45/82 2012/3/14
1.5 Complements
Example of Subtraction with Complements:
Using 1’s (1’s) complement, perform X-Y and Y-X
X= 1010100
1's complement of Y= + 0111100
Sum = 10010000
End-around carry 27 = + 1
Answer X-Y = 0010001
X=1010100, Y=1000011
(a) X-Y :
Y= 1000011
1's complement of X= + 0101011
Sum = 1101110
No carry 27, Answer= -(1'sc of 1101110)
Answer = - 0010001
(a) Y-X :
1'sc+1=2'sc
P-46/82 2012/3/14
1.6 Signed Binary Numbers
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-47/82 2012/3/14
1.6 Signed Binary Numbers
Signed Binary Numbers
an, an-1, an-2, …, a0
Sign Bit Magnitude Bits
(0=+, 1=-)
Example
01001
9 (unsigned binary)
9 (signed binary)
11001
25 (unsigned binary)
-9 (signed binary)
P-48/82 2012/3/14
Presentation formats of value -9
-9
Signed-magnitude 10001001
Signed-1'sc 11110110
Signed-2'sc 11110111
1.6 Signed Binary Numbers
P-49/82 2012/3/14
Presentation formats for 4-bit binary value
1.6 Signed Binary Numbers
Decimal 2’sc 1’sc Signed-Magnitude
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
…
+1 0001 0001 0001
+0 0000 0000 0000
-0 ------ 1111 1000
-1 1111 1110 1001
-2 1110 1101 1010
…
-6 1010 1001 1110
-7 1001 1000 1111
-8 1000 ------ ------
P-50/82 2012/3/14
Features of Number Systems
1.6 Signed Binary Numbers
Signed-Magnitude System: For Ordinary Arithmetic
1'sc: For Logical Operation
2'sc: For Computer Arithmetic Operation
(without end-around carry)
P-51/82 2012/3/14
Arithmetic Addition of Signed-Magnitude System
1.6 Signed Binary Numbers
1. The same signed number:
Adder the two magnitudes and give the sum common
sign.
2. Different signed number:
Subtract the smaller magnitude form the larger and
give the result the sign of the larger magnitude.
(+25)+(-37)=-(37-25)=-12
Additional 2 Steps: Compare Magnitude and Signed bit !!
P-52/82 2012/3/14
Four 2’sc Cases of Arithmetic Operations
1.6 Signed Binary Numbers
+6 00000110
+13 00001101
+19 00010011
-6 11111010
+13 00001101
+7 00000111
+6 00000110
-13 11110011
-7 11111001
-6 11111010
-13 11110011
-19 11101101
Discard
n bits
n+1 bits
Signed-bitExtension
P-53/82 2012/3/14
Four 2’sc Cases of Arithmetic Subtraction
1.6 Signed Binary Numbers
(A)-(+B)=(A)+(-B)
(A)-(-B)=(A)+(+B)
2'sc of -B
P-54/82 2012/3/14
1.7 Binary Codes
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-55/82 2012/3/14
1.7 Binary Codes
Binary Codes
n-bit binary code can distinct 2n discrete values !!
P-56/82 2012/3/14
1.7 Binary Codes
BCD (Binary Coded Decimal)
Decimal Symbol BCD Digit
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
P-57/82 2012/3/14
1.7 Binary Codes
Feature of BCD
k-digit decimal requires 4k-bits in BCD !!
Example of BCD
(185)10=(0001 1000 0101)BCD=(10111001)2
P-58/82 2012/3/14
1.7 Binary Codes
BCD Addition
k-digit decimal requires 4k-bits in BCD !!
Example of BCD Addition
4 0100
+5 +0101
9 1001
4 0100
+8 +1000
12 1100>9
Carry out
1100
+0110
1 0010
8 1000
+9 +1001
17 10001>9
Carry out
10001
+0110
1 0111
P-59/82 2012/3/14
1.7 Binary Codes
Why add 0110 into result if result >9 ?
Decimal Binary BCD
0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 +6 1 0000
11 1011 +6 1 0001
12 1100 +6 1 0010
13 1101 +6 1 0011
14 1110 +6 1 0100
15 1111 +6 1 0101
P-60/82 2012/3/14
1.7 Binary Codes
Example of BCD Addition: 184+576 in BCD
BCD carry 1 1
0001 1000 0100 184
+0101 0111 0110 +576
Binary Sum 0111 10000 1010
Add 6 0110 0110
BCD Sum 0111 0110 0000 760
P-61/82 2012/3/14
1.7 Binary Codes
Decimal Arithmetic
(+375) + (-240) = +135
0 375
+ 9 760
0 135
Negative
P-62/82 2012/3/14
1.7 Binary Codes
Other Decimal Codes
Decimal BCD 2421 Excess-3 8 4-2-1
digit 8421
0 0000 0000 0011 0 0 0 0
1 0001 0001 0100 0 1 1 1
2 0010 0010 0101 0 1 1 0
3 0011 0011 0110 0 1 0 1
4 0100 0100 0111 0 1 0 0
5 0101 1011 1000 1 0 1 1
6 0110 1100 1001 1 0 1 0
7 0111 1101 1010 1 0 0 1
8 1000 1110 1011 1 0 0 0
9 1001 1111 1100 1 1 1 1
1010 0101 0000 0 0 0 1
1011 0110 0001 0 0 1 0
Unused Bits 1100 0111 0010 0 0 1 1
1101 1000 1101 1 1 0 0
1110 1001 1110 1 1 0 1
1111 1010 1111 1 1 1 0
Self-complementing Code
P-63/82 2012/3/14
1.7 Binary Codes
Example of Self-complementing Code:
9’s complement of (395)10 in Exceed-3 code
(395)10
= 0110 1100 1000 (in Exceed-3)
= 1001 0011 0111 (9'sc 604)
P-64/82 2012/3/14
1.7 Binary Codes
Gray Code Decimal Binary Gray
Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Binary: 0 bn ...
b3 b
2 b
1 b
0
Gray Code: gn ...
g3 g
2 g
1 g
0
P-65/82 2012/3/14
1.7 Binary Codes
Feature of Gray Code
Only one bit in the code group changes from one number
to the next !
For Example 7 8
Gray Code: 0100 1100
Binary Code: 0111 1000
Only one bitchange !!
4 bit change
P-68/82 2012/3/14
1.7 Binary Codes
Error-Detecting Code:
Communication and computation will cause error
Even Parity Odd Parity
ASCII A=1000001 01000001 11000001
ASCII T=1010100 11010100 01010100
P-69/82 2012/3/14
1.8 Binary Storage and Registers
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-70/82 2012/3/14
1.8 Binary Storage and Registers
Register
1. A register is a group of binary cells.
2. A register with n cells can store n-bit information.
3. A register with 16 cells can be in one of 216 possible
states, i.e. number 0~ 216-1 .
4. A 16-bit example: 1100 0011 1100 1001
P-71/82 2012/3/14
1.8 Binary Storage and Registers
Register Transfer
1. A register transfer operation is a basic operation in
digital systems.
2. It transfer binary information from one set of
registers to another set of registers.
P-72/82 2012/3/14
1.8 Binary Storage and Registers
Transfer of Information with Register
keybord
J
O
H
N
Keyboard
ControllerStrike
8-bitRegister
Input Unit
8-bitRegister
8-bitRegister
8-bitRegister
8-bitRegister
Processor Unit
Processor Register
01001010 01001111 11001000 11001110
J O H N
Memory Unit
Memory Register
P-73/82 2012/3/14
1.8 Binary Storage and Registers
Transfer of
Information with
Register
Digital logic
circuits for
binary addition
0100100011
0001000010
0011100001
R1
R2
R3
Processor Unit
0000000000
0011100001
0001000010
Memory Unit
Operand 1
Operand 2
Sum
P-74/82 2012/3/14
1.9 Binary Logic
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number Base Conversions
1.4 Octal and Hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
1.8 Binary Storage and Registers
1.9 Binary Logic
P-76/82 2012/3/14
Definition of Binary Logic
1.9 Binary Logic
Binary Logic: 1. Arithmetic operation
2. Logical operation
Basic Logical Operation: AND / OR/ NOT
P-77/82 2012/3/14
Binary Logic
1.9 Binary Logic
AND
NOT
OR
x y=z
or
xy=z
x y=z
x'=z
or
x=z
x AND y is equal to z
x OR y is equal to z
NOT x is equal to z
Why?
P-78/82 2012/3/14
Truth Table for AND/OR/NOT
1.9 Binary Logic
x y x y
0 0 0
0 1 0
1 0 0
1 1 1
AND
x y x+y
0 0 0
0 1 1
1 0 1
1 1 1
OR
x x’
0 1
1 0
NOT
P-79/82 2012/3/14
Example of a Digital System
1.9 Binary Logic
0
1
3
4
Range for Logic 0
Range for Logic 1
Transition occursbetween these limits
Volts
P-80/82 2012/3/14
Symbol for Digital Logic Circuit
1.9 Binary Logic
x
yz=x y
x
yz=x+y
x x'
Two Input
AND Gate
Two Input
OR Gate
NOT Gate or
Inverter
P-81/82 2012/3/14
Input-Output Signal for Logic Gates
1.9 Binary Logic
x 0 1 1 0 0
y 0 0 1 1 0
AND: x · y 0 0 1 0 0
OR : x + y 0 1 1 1 0
NOT: x’ 1 0 0 1 1