+ All Categories
Home > Documents > Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course...

Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course...

Date post: 29-Mar-2021
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
17
Computer System Architecture © Korea Univ. of Tech. & Edu. Dept. of Info. & Comm. Chap. 2 Number Systems and Codes 2-1 Chap. 2 Number Systems and Codes Chapter Outcomes (Objectives) Convert a number from one number system (decimal, binary, hexadecimal) to its equivalent in one of the other number systems. Cite the advantages of the hexadecimal number system. Count in hexadecimal. Represent decimal numbers using the BCD code; cite the pros and cons of using BCD. Explain the difference between BCD and straight binary. Explain the purpose of alphanumeric codes such as the ASCII code. Explain the parity method for error detection. Determine the parity bit to be attached to a digital data string.
Transcript
Page 1: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-1Chap. 2 Number Systems and Codes

Chapter Outcomes (Objectives)

Convert a number from one number system (decimal, binary, hexadecimal) to its equivalent in one of the other number systems.

Cite the advantages of the hexadecimal number system. Count in hexadecimal. Represent decimal numbers using the BCD code; cite the pros and cons of

using BCD. Explain the difference between BCD and straight binary. Explain the purpose of alphanumeric codes such as the ASCII code. Explain the parity method for error detection. Determine the parity bit to be attached to a digital data string.

Page 2: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-2

Data Representation in Digital System (Data Types) Numbers used in arithmetic computations Letters of the alphabet used in data processing (ASCII Code) Other discrete symbols used for specific purpose

위의 Number 와 Letter 이외모두예) control word, gray code, error detection code, …

0 1 0 0 0 0 0 1

65? A? control word? BCD code?

Chap. 2 Number Systems and Codes

Page 3: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-32-1 Binary to Decimal Conversions

Binary-to-Decimal Conversions 1. Weighted Sum method

1011.1012 = (1 x 23) + (0 x 22)+ (1 x 21) + (1 x 2o) + (1 x 2-1) + (0 x 2-2) + (1 x 2-3)= 810+ 0 + 210 + 110 + 0.510 + 0 + 0.12510

= 11.62510

2. Double Dabble method

Page 4: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-42-2 Decimal to Binary Conversions

Decimal-to-Binary Conversions Method 1

Decimal number is simply expressed as a sum of powers of 24510 = 3210 + 810 + 410 + 110 = 25 + 0 + 23 + 22 + 0 + 2o

= 1 0 1 1 0 12

Method 2 : Exam. 2-1 Repeated division(See Fig. 2-1)

37 / 2 = 18 remainder 1 (binary number will end with 1) : LSB18 / 2 = 9 remainder 0

9 / 2 = 4 remainder 14 / 2 = 2 remainder 02 / 2 = 1 remainder 01 / 2 = 0 remainder 1 (binary number will start with 1) : MSB

Read the result upward to give an answer of 3710 = 1001012

Counting Range(Using N bits) 0 to 2N-1 value range, 2N different values

Exam. 2-2

소수점변환0.375 x 2 = 0.750 integer 0 MSB0.750 x 2 = 1.500 integer 1 .0.500 x 2 = 1.000 integer 1 LSBRead the result downward .37510 = .0112

Page 5: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-5

Hex-to-Decimal Conversion2AF16 = (2 x 162) + (10 x 161) + (15 x 16o)

= 51210 + 16010 + 1510

= 68710

Decimal-to-Hex Conversion : Exam. 2-342310 / 16 = 26 remainder 7 (Hex number will end with 7) : LSB2610 / 16 = 1 remainder 10110 / 16 = 0 remainder 1 (Hex number will start with 1) : MSB

Read the result upward to give an answer of 42310 = 1A716

Hex-to-Binary Conversion9F216 = 9 F 2

= 1001 1111 0010= 1001111100102

Counting in Hexadecimal Once a digit position reaches the value F, it is reset to 0, and the next digit position is

incremented

With N hex digit : decimal 0 to 16N -1, 16N different values

2-3 Hexadecimal Number System

Table 2-1Hex Binary Decimal

0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 78 1000 89 1001 9A 1010 10B 1011 11C 1100 12D 1101 13E 1110 14F 1111 15

Binary-to-Hex Conversion 1 1 1 0 1 0 0 1 1 02 = 0 0 1 1 1 0 1 0 0 1 1 0

3 A 6= 3A616

Page 6: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-6

Usefulness of Hex and Octal To illustrate the advantage of hex/octal representation of a binary string

Printout the contents of 50 memory locations, and check it against a list» Each memory location is 16-bit number

Which one would you be more apt to read incorrectly? » Check 50 numbers like 010111001100111 or 6E67

Digital circuits all work in binary. Hex and Octal are simply used as a convenience for the humans involved

Exam. 2-4 : Dec 378 → Hex 17A → Bin 0000 0001 0111 1010 (16bit), and Exam. 2-5

Summary of Conversions Decimal Binary, Octal, Hex

1. Bin, Oct, Hex Dec : Weighted sum or Double dabble 2. Dec Bin, Oct, Hex : Repeated divide by 2, 8, 16

Binary Octal, Hex 3. Bin Oct, Hex : Group the bits in 3(Oct) or 4(Hex), and convert each group

into the correct Octal or Hex digit. 4. Oct, Hex Bin : Convert each digit into its 3 or 4 bit equivalent

Oct Hex : Oct Bin, Bin Hex

Page 7: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-7Octal Number System

Octal Number System Composed of 8 symbols or numerals : 0, 1, 2, 3, 4, 5, 6, 7,

Octal to Decimal Conversion ( 83) + ( 82)+ ( 81) + (8o) • (8-1) + ( 8-2) + ( 8-3) Weighted system : octal point

Decimal to Octal Conversion : repeated division by 8

Octal to Binary Conversion Binary to Octal Conversion Counting in Octal : 000 ~ 777 Decimal to Binary Conversion

1. By first converting to octal 2. Decimal to Octal : 17710 → 2618

3. Octal to Binary : 2618 → 010 110 0012

Page 8: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-82-4 BCD Code

Code Special group of symbols(Number, letter, words) are being encoded

Straight binary coding A decimal number is represented by its equivalent binary number

Binary-Coded-Decimal Code Each digit of a decimal number is represented by its binary equivalent

8 7 4 (Decimal)

1000 0111 0100 (BCD) only the four bit binary numbers from 0000 through 1001 are used

Comparison of BCD and Binary 13710 = 100010012 (Binary) - require only 8 bits : straight binary coding

13710 = 0001 0011 0111BCD (BCD) - require 12 bits : BCD coding

Exam. 2-6 : BCD to Dec. & Exam. 2-7 : forbidden code 1100 (12) Exam. 2-8 : ATM ( the amount of cash you wish to withdraw in decimal ) Exam. 2-9 : Cell phone ( 10 decimal-digit phone number input )

Page 9: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-92-5 The Gray Code

Gray Code : to represent a sequence of numbers when the three-bit binary number for 3 changes to 4, all three bits must

change state : 011 → 100 reduce the likelihood of a digital circuit misinterpreting a changing input used in applications where numbers change rapidly only one bit changes between two successive numbers : Tab. 2-2

Tab. 2-2 three-bit binary and Gray code equivalentsBinary Gray Code

B2 B1 B0 G2 G1 G0 0 0 0 0 0 00 0 1 0 0 10 1 0 0 1 10 1 1 0 1 01 0 0 1 1 01 0 1 1 1 11 1 0 1 0 11 1 1 1 0 0

Page 10: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-10

Conversion from Binary to Gray code : Fig. 2-2(a) 1. Binary MSB (B2) is used as Gray MSB (G2) : G2 2. Compare B2 (MSB) with B1 : G1

Same: G1= 0 Different: G1= 1

3. Compare B1 with B0 : G0 Same: G0= 0 Different: G0= 1

Conversion from Gray code to Binary : Fig. 2-2(b) 1. Gray MSB (G2) is used as Binary MSB (B2) : B2 2. Compare B2 (MSB) with G1 : B1

Same: B1= 0 Different: B1= 1

3. Compare B1 with G0 : B0 Same: B0= 0 Different: B0= 1

An eight-position, three-bit shaft encoder : Fig. 2-3

Page 11: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-11

Fig. 2-2 Converting (a)binary to Gray code and (b) Gray to binary

Fig. 2-3 An eight-position, three-bit shaft encoder

Page 12: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-12

Quadrature Encoders The most common application of the Gray code To determine which direction the shaft is rotating : speed or position As the shaft rotates, this device produces a two-bit Gray code sequence The two-bit Gray code from a quadrature shaft encoder : Tab. 2-3 A mechanical contact quadrature encoder : Fig. 2-4 Operation of a quadrature encoder : Fig. 2-5

Fig. 2-5 Operation of a quadrature encoder Tab. 2-3 The 2-bit Gray code from a quadrature shaft encoder

B

A

CW CCW

Page 13: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-13

Putting it all together : Table 2-4

Decimal Binary Hexadecimal BCD Gray0 0000 0 0000 00001 0001 1 0001 00012 0010 2 0010 00113 0011 3 0011 00104 0100 4 0100 01105 0101 5 0101 01116 0110 6 0110 01017 0111 7 0111 01008 1000 8 1000 11009 1001 9 1001 110110 1010 A 0001 0000 111111 1011 B 0001 0001 111012 1100 C 0001 0010 101013 1101 D 0001 0011 101114 1110 E 0001 0100 100115 1111 F 0001 0101 1000

2-6 Putting it al together

Page 14: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-14

1 byte A string of eight bits 1 Byte = 8 Bits

1 nibble = 4 bits 1 word = size depends on data pathway size.

Word size in a simple system may be one byte (8 bits) Word size in a PC is eight bytes (64 bits)

Exam. 2-10 ~ Exam. 2-14

bytebyte

1001110000010110683910

2.7 Byte, Nibble, and Word

Page 15: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-152-8 Alphanumeric Codes2-9 Parity Method for Error Detection

Alphanumeric Codes In addition to numerical data, computer should recognize alphabet letters,

punctuation marks, and other special characters ASCII Code : Table 2-5

American Standard Code for Information Interchange(ASCII) 7 bit code, 27 = 128 possible codes

Exam. 2-15 ~ Exam. 2-16

Parity Method for Error Detection Binary Data Communication Examples

The transmission of digitized voice over a microwave link The data retrieval from external memory devices(magnetic tape/disk) The information transmission from a computer to a remote terminal by modem

Electrical noise : spurious fluctuations in voltage/current

Transmitter Receiver~ ~

Fig. 2-6 Noise causing an error in the transmission of digital data

Page 16: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-16

Parity method One of the simplest and most widely used schemes for error detection Checksum, CRC(cyclic redundant check), ECC(error correct code) : 데이터통신

Parity Bit An extra bit attached to a code group

Even-parity method The value of the parity bit is chosen so that the total number of 1s (including the parity

bit) is an even number 1 1 0 0 0 0 1 1

Odd-parity method Exactly the same way except that the total number of 1s is an odd number

1 1 0 0 0 0 0 1 Error Detection

Fig. 4-25 Can not tell which bit in error Can detect only single bit error

Exam. 2-172-10. Applications : App). 2-1, 2-2, 2-3, 2-4, 2-5, 2-6

Added parity bit

Added parity bit

1 1 0 0 0 0 1 1 “C” 1 1 0 0 0 0 1 0 ”B”

(Even-parity Generator) (Even-parity Checker)

Page 17: Chap. 2 Number Systems and Codes 2-1 - KOREATECHmicrocom.koreatech.ac.kr/course backup/IFC130/d-ch02-12th... · 2021. 2. 18. · change state : 011 →100 reduce the likelihood of

Computer System Architecture© Korea Univ. of Tech. & Edu.

Dept. of Info. & Comm.Chap. 2 Number Systems and Codes

2-17Application 2-5

ASCII Code : # → 23 → 1010 0011 MSB D7 D6 D5 D4 D3 D2 D1 D0 LSB

1 0 1 0 0 0 1 1 LSB D0 D1 D2 D3 D4 D5 D6 D7 MSB

1 1 0 0 0 1 0 1

1 1 0 0 0 1 0 1


Recommended