82
P-1/80 2008/3/12 Part I Chapter1: Binary System : 教授 INSTRUCTOR : Prof. Jiun-In Guo 課程名稱 課程名稱 : : 數位系統設計導論 數位系統設計導論 E-mail: [email protected]

DLD Part1 Chapter1

Embed Size (px)

DESCRIPTION

slides with good describtion

Citation preview

:

2008/3/12 P-1/80

Part I Chapter1: Binary System : INSTRUCTOR : Prof. Jiun-In GuoE-mail: [email protected]

:

2008/3/12 P-2/80

Special thanks to Prof. CHING-LING SU for providing this course materials !!!!

Chapter 1

2008/3/12 P-3/80

Chapter 1 Binary Systems

Outline

2008/3/12 P-4/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.1 Digital Systems

2008/3/12 P-5/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.1 Digital Systems1.

2008/3/12 P-6/80

2. 3. 4. 5.

6.

Digital Systems Digital system examples: Digital telephones, digital TV, DVD, digital cameras (DC), digital videos (DV), and digital computers. Digital systems: Manipulate discrete data Binary: Numbers are presented by two discrete values (0 and 1), Binary digit = Bit Group of bits: Binary code Digital systems: A system manipulates discrete elements of information that is represented internally binary form. HDL (Hardware description language): A programming language and suitable for describing digital circuits in textual form.

1.2 Binary Numbers

2008/3/12 P-7/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.2 Binary Numbers

2008/3/12 P-8/80

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

2008/3/12 P-9/80

Decimal Number with Binary Number 11010.11=26.75 124+ 123+ 022+ 121+ 020+ 12-1+ 12-2=26.75

1.2 Binary Numbers

2008/3/12 P-10/80

Base-r Number with Binary Number an rn + an-1 rn-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

1.2 Binary Numbers

2008/3/12 P-11/80

Base-r Number System 1. 2. 3. 4. Base-2, Binary Base-8, Octal Base-10, Decimal Base-16, Hexadecimal, (10=A, 11=B, 12=C, D=13, E=14, F=15)

1.2 Binary Numbers

2008/3/12 P-12/80

Base-2 Power of n 1. 2. 3. 4. n=10, n=20, n=30, n=40, 210=1024, K (kilo) 220=1048576, M (mega) 230=130023424, G (giga) 240=133143986176, T (tera)

1.2 Binary Numbers

2008/3/12 P-13/80

Example: Base-2, Power of n 1. 4K=4210=212 2. 16M=16220=224 3. 4G=4230=232

1.2 Binary Numbers

2008/3/12 P-14/80

Arithmetic Operation - Addition

Augend: Addend: Sum:

101101 100111 1010100

1.2 Binary Numbers

2008/3/12 P-15/80

Arithmetic Operation - Subtraction

Minuend: Subtrahend: Difference:

101101 100111 000110

1.2 Binary Numbers

2008/3/12 P-16/80

Arithmetic Operation - Multiplication

Multiplicand: Multiplier:

1011 101 1011 0000 1011

Product:

110111

1.3 Number Base Conversions

2008/3/12 P-17/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.3 Number Base Conversions

2008/3/12 P-18/80

Decimal to Binary Conversion: Iterative Division

1.3 Number Base ConversionsExample of Decimal to Binary Conversion: (41)10 to (101001)2Integer Quotient Reminder Coefficient

2008/3/12 P-19/80

41/2= 20/2= 10/2= 5/2= 2/2= 1/2=

20 + 10 + 5+ 2+ 1+ 0+

0 0 0

a0=1 a1=0 a2=0 a3=1 a4=0 a5=1

Answer: (41)10=(a5a4a3a2a1a0)2=(101001)2

1.3 Number Base ConversionsConveniently Process: (41)10 to (101001)2

2008/3/12 P-20/80

2 2 2 2 2 2

41 20 10 5 2 1 0 1 0 0 1 0 1Answer: 1 0 1 0 0 1

1.3 Number Base ConversionsConveniently Process: Decimal (Base-10) to Octal (Base-8)

2008/3/12 P-21/80

8 8 8

153 19 2 0 1 3 2Answer: ( 2 3 1 )8

1.3 Number Base Conversions

2008/3/12 P-22/80

Fraction Part Conversion : Iterative Multiplication

1.3 Number Base Conversions

2008/3/12 P-23/80

Example of Decimal to Binary Conversion: (0.6875)10 to (0.1011)2Integer Fraction Coefficient

0.68752= 0.37502= 0.75002= 0.50002=

1+ 0+ 1+ 1+

0.3750 0.7500 0.5000 0.0000

a-1=1 a-2=0 a-3=1 a-4=1

Answer: (0.6875)10=(0.a-1a-2a-3a-4)2=(0.1011)2

1.3 Number Base Conversions

2008/3/12 P-24/80

Conveniently Process: (0.513)10 to Octal

0.513 0.104 0.832 0.656 0.248 0.984

8= 8= 8= 8= 8= 8=

4.104 0.832 6.656 5.248 1.984 7.872

Answer: (0.513)10=(0.406517)8

1.3 Number Base Conversions

2008/3/12 P-25/80

Complete Number Conversion: 1. (41.6875)10 = (101001.1011)2 2. (153.513)10 = (231.406517)8

1.4 Octal and Hexadecimal Numbers

2008/3/12 P-26/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.4 Octal and Hexadecimal Numbers

2008/3/12 P-27/80

Octal and Hexadecimal vs. Binary:

Octal Digit Hexadecimal Digit

= 23 =3 bits = 24 =4 bits

1.4 Octal and Hexadecimal Numbers

2008/3/12 P-28/80

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

1.4 Octal and Hexadecimal Numbers

2008/3/12 P-29/80

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

1.5 Complements

2008/3/12 P-30/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.5 Complements

2008/3/12 P-31/80

ComplementsArithmetic Operation : Subtraction Logic Operation : 0 1 Complement r's Complement For base-r r-1's Complement

1.5 Complements

2008/3/12 P-32/80

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) - NIf

r =10 r-1=9 : 9s complements of N = (10n-1) - N

1.5 Complements

2008/3/12 P-33/80

Decimal Example: n = 6 (6 digit)

106-1=999999

The 9s complement of 546700 is 999999 - 546700 = 453299 012398 is 999999 - 012398 = 987601

1.5 Complements

2008/3/12 P-34/80

For Binary Number (r-1)s Complement: r=2

r-1=1

The 1s complement of N is (2n-1)-N, if n = 4 24=(10000)2 then (2n-1)-N = (1111)2-N

1.5 Complements

2008/3/12 P-35/80

Binary (r-1)s Example: n = 7 (7 digit) 27-1=(1111111)2

The 1s (r-1)s complement ofToggle Each Digit : 0 1

1111111 - 1011000 = 0100111 1111111 - 0101101 = 1010010

1.5 Complements

2008/3/12 P-36/80

Diminished Radix rs Complements

Given a number N in base-r having n digits, the rs complement of N : rn-N, for N 0 0, for N = 0

1.5 Complements

2008/3/12 P-37/80

Comparison of rs and (r-1)s complement

rs complement: rn- N = [(rn-1) N]+1 = (r-1)s complement +1

(r-1)s complement: (rn-1) N

1.5 Complements

2008/3/12 P-38/80

Example of rs complement

10s (rs) complement of decimal 2389 012398 246700 7610 (9s complement) +1= 7611 987601 +1= 987602 753299 +1=753300

1.5 Complements

2008/3/12 P-39/80

Example of rs complement

2s (rs) complement of binary 1101100 0110111 0010011 +1= 0010100 1001000 +1= 1001001

1.5 ComplementsSubtraction with Complements 1. Add the minuend, M, to the rs complement of subtrahend, N. This performs M+(rn-N)=M-N+rn

2008/3/12 P-40/80

2. If M N, the sum will produce an end carry, rn, which can be discarded; what is left is the result MN. 3. If M < N, the sum dose not produce an end carry and is equal to rn-(N-M), which is the rs complement of (N-M). To obtain the answer in a familiar form, take the rs complement of the sum and place a negative sign in front.

1.5 Complements

2008/3/12 P-41/80

Example of Subtraction with Complements: Using 10s (rs) complement, subtract 72532-3250M= 72532 N= + 9 6 7 5 0 = 169282 105= -1 0 0 0 0 0 = 69282

10's complement of Sum Discard and carry Answer

1.5 Complements

2008/3/12 P-42/80

Example of Subtraction with Complements: Using 10s (rs) complement, subtract 3250-7253210's complement of Sum No carry !! Answer : - (10's complement of 30718) = -69282 M= 03250 N= + 2 7 4 6 8 = 30718

1.5 ComplementsExample of Subtraction with Complements: Using 2s (rs) complement, perform X-Y and Y-X X=1010100, Y=1000011 (a) X-Y : X= 1010100 2's complement of Y= + 0111101 Sum = 10010001 = - 10000000 Discard end carry 27 Answer X-Y = 0010001(a) Y-X : Y= 1000011 2's complement of X= + 0101100 Sum = 1101111 No carry 27, Answer= -(2'sc of 1101111) Answer = - 0010001

2008/3/12 P-43/80

1.5 ComplementsExample of Subtraction with Complements: Using 1s (1s) complement, perform X-Y and Y-X X=1010100, Y=1000011 (a) X-Y : X= 1010100 1's complement of Y= + 0111100 Sum = 10010000 1'sc+1=2'sc End-around carry 27 = + 1 Answer X-Y = 0010001 (a) Y-X : Y= 1000011 1's complement of X= + 0101011 Sum = 1101110 No carry 27, Answer= -(1'sc of 1101110) Answer = - 0010001

2008/3/12 P-44/80

1.6 Signed Binary Numbers

2008/3/12 P-45/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.6 Signed Binary NumbersSigned Binary Numbers

2008/3/12 P-46/80

an, an-1, an-2, , a0 Sign Bit (0=+, 1=-) Magnitude BitsExample 9 (unsigned binary)01001 9 (signed binary) 25 (unsigned binary) 11001 -9 (signed binary)

1.6 Signed Binary Numbers

2008/3/12 P-47/80

Presentation formats of value -9Signed-magnitude -9 Signed-1'sc Signed-2'sc 10001001 11110110 11110111

1.6 Signed Binary NumbersPresentation formats for 4-bit binary valueDecimal +7 +6 +5 +1 +0 -0 -1 -2 -6 -7 -8 2sc 0111 0110 0101 0001 0000 -----1111 1110 1010 1001 1000 1sc 0111 0110 0101 0001 0000 1111 1110 1101 1001 1000 -----Signed-Magnitude 0111 0110 0101 0001 0000 1000 1001 1010 1110 1111 ------

2008/3/12 P-48/80

1.6 Signed Binary Numbers

2008/3/12 P-49/80

Features of Number SystemsSigned-Magnitude System: For Ordinary Arithmetic 1'sc: For Logical Operation 2'sc: For Computer Arithmetic Operation (without end-around carry)

1.6 Signed Binary Numbers

2008/3/12 P-50/80

Arithmetic Addition of Signed-Magnitude System 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 !!

1.6 Signed Binary NumbersFour 2sc Cases of Arithmetic Operations Signed-bit Discard Extension+6 +13 +19 00000110 00001101 00010011 -6 +13 +7 11111010 00001101 00000111 n bits +6 -13 -7 00000110 11110011 11111001 -6 -13 -19 11111010 11110011 11101101 n+1 bits

2008/3/12 P-51/80

1.6 Signed Binary Numbers

2008/3/12 P-52/80

Four 2sc Cases of Arithmetic Subtraction(A)-(+B)=(A)+(-B)(A)-(-B)=(A)+(+B)

2'sc of -B

1.7 Binary Codes

2008/3/12 P-53/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.7 Binary Codes

2008/3/12 P-54/80

Binary Codes n-bit binary code can distinct 2n discrete values !!

1.7 Binary CodesBCD (Binary Coded Decimal)Decimal Symbol 0 1 2 3 4 5 6 7 8 9 BCD Digit 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

2008/3/12 P-55/80

1.7 Binary Codes

2008/3/12 P-56/80

Feature of BCD k-digit decimal requires 4k-bits in BCD !!

Example of BCD (185)10=(0001 1000 0101)BCD=(10111001)2

1.7 Binary CodesBCD Addition k-digit decimal requires 4k-bits in BCD !! Example of BCD Addition4 +5 9 0100 +0101 1001 4 0100 +8 +1000 12 1100>9 Carry out 1100 +0110 1 0010

2008/3/12 P-57/80

8 1000 +9 +1001 17 10001>9 Carry out 10001 +0110 1 0111

1.7 Binary CodesWhy add 0110 into result if result >9 ?Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1 0000 1 0001 1 0010 1 0011 1 0100 1 0101

2008/3/12 P-58/80

+6 +6 +6 +6 +6 +6

1.7 Binary Codes

2008/3/12 P-59/80

Example of BCD Addition: 184+576 in BCDBCD carry Binary Sum Add 6 BCD Sum 1 1 0001 1000 +0101 0111 0111 10000 0110 0111 0110 0100 0110 1010 0110 0000 184 +576 760

1.7 Binary Codes

2008/3/12 P-60/80

Decimal Arithmetic(+375) + (-240) = +135 Negative 0 375 + 9 760 0 135

1.7 Binary CodesOther Decimal CodesDecimal digit 0 1 2 3 4 5 6 7 8 9 BCD 8421 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 2421 0000 0001 0010 0011 0100 1011 1100 1101 1110 1111 0101 0110 0111 1000 1001 1010 Excess-3 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 0000 0001 0010 1101 1110 1111 8 4-2-1 0 0 0 0 0 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0Self-complementing Code

2008/3/12 P-61/80

Unused Bits

000 001 001 110 110 111

1.7 Binary Codes

2008/3/12 P-62/80

Example of Self-complementing Code: 9s complement of (395)10 in Exceed-3 code(395)10 = 0110 1100 1000 (in Exceed-3) = 1001 0011 0111 (9'sc 604)

1.7 Binary CodesGray CodeDecimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary Gray Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000

2008/3/12 P-63/80

Binary:

0 bn

...

b3 b2 b1 b0

Gray Code:

gn

...

g3 g2 g1 g0

1.7 Binary Codes

2008/3/12 P-64/80

Feature of Gray Code Only one bit in the code group changes from one number to the next !For Example 7 8 Gray Code: Binary Code:Only one bit change !!

0100 1100 0111 10004 bit change

1.7 Binary CodesASCII Code (American Standard Code for Information Interchange)

2008/3/12 P-65/80

1.7 Binary Codes

2008/3/12 P-66/80

Extended ASCII Code

1.7 Binary Codes

2008/3/12 P-67/80

Error-Detecting Code: Communication and computation will cause errorEven Parity 01000001 11010100 Odd Parity 11000001 01010100

ASCII A=1000001 ASCII T=1010100

1.8 Binary Storage and Registers

2008/3/12 P-68/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.8 Binary Storage and Registers

2008/3/12 P-69/80

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

1.8 Binary Storage and Registers

2008/3/12 P-70/80

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.

1.8 Binary Storage and Registers

2008/3/12 P-71/80

Transfer of Information with Register

1.8 Binary Storage and RegistersMemory Unit 0000000000 Operand 1 Operand 2 0011100001 0001000010 Sum

2008/3/12 P-72/80

Transfer of Information with Register

0001000010

R1

Digital logic circuits for binary addition

0100100011

R3

0011100001

R2 Processor Unit

1.9 Binary Logic

2008/3/12 P-73/80

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9

Digital Systems Binary Numbers Number Base Conversions Octal and Hexadecimal Numbers Complements Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic

1.9 Binary Logic

2008/3/12 P-74/80

Binary Logic 1. 2. 3. 0/1 True/False Yes/No

1.9 Binary Logic

2008/3/12 P-75/80

Definition of Binary Logic

Binary Logic:

1. Arithmetic operation 2. Logical operation

Basic Logical Operation: AND / OR/ NOT

1.9 Binary LogicBinary Logicx y=z or xy=z Why? OR x y=z x'=z or x=z x OR y is equal to z

2008/3/12 P-76/80

AND

x AND y is equal to z

NOT

NOT x is equal to z

1.9 Binary Logic

2008/3/12 P-77/80

Truth Table for AND/OR/NOTAND x 0 0 1 1 y x y 0 0 1 0 0 0 1 1 x 0 0 1 1 OR y x+y 0 0 1 1 0 1 1 1 NOT x 0 1 x 1 0

1.9 Binary LogicExample of a Digital SystemVolts

2008/3/12 P-78/80

4 3 Range for Logic 1Transition occurs between these limits

1 0 Range for Logic 0

1.9 Binary Logic

2008/3/12 P-79/80

Symbol for Digital Logic Circuitx y x y x z=x y Two Input AND Gate Two Input OR Gate NOT Gate or Inverter

z=x+y

x'

1.9 Binary Logic

2008/3/12 P-80/80

Input-Output Signal for Logic Gates

1.9 Binary Logic

2008/3/12 P-81/80

Gates with Multiple InputsA B C A B C 3 Input AND Gate

F=A B C

G=A+B+C

3 Input OR Gate

Exercise Problem set 1.1, 1.4, 1.10, 1.13, 1.14, 1.17, 1.20, 1.25, 1.27, 1.28, 1.34, 1.35

2008/3/12 P-82/80

Deadline 2008/03/05