Download presentation
Presentation is loading. Please wait.
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.
2
Chap. 2 Number Systems and Codes
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, … 65? A? control word? BCD code?
3
2-1 Binary to Decimal Conversions
1. Weighted Sum method = (1 x 23) + (0 x 22)+ (1 x 21) + (1 x 2o) + (1 x 2-1) + (0 x 2-2) + (1 x 2-3) = = 2. Double Dabble method
4
2-2 Decimal to Binary Conversions
Method 1 Decimal number is simply expressed as a sum of powers of 2 4510 = = o = Method 2 : Exam. 2-1 Repeated division(See Fig. 2-1) 37 / 2 = remainder 1 (binary number will end with 1) : LSB 18 / 2 = remainder 0 9 / 2 = remainder 1 4 / 2 = remainder 0 2 / 2 = remainder 0 1 / 2 = remainder 1 (binary number will start with 1) : MSB Read the result upward to give an answer of = Counting Range(Using N bits) 0 to 2N-1 value range, 2N different values Exam. 2-2 소수점 변환 0.375 x 2 = integer 0 MSB 0.750 x 2 = integer 0.500 x 2 = integer 1 LSB Read the result downward =
5
2-3 Hexadecimal Number System
Hex-to-Decimal Conversion 2AF16 = (2 x 162) + (10 x 161) + (15 x 16o) = = Decimal-to-Hex Conversion : Exam. 2-3 / 16 = remainder 7 (Hex number will end with 7) : LSB 2610 / 16 = remainder 10 110 / 16 = remainder 1 (Hex number will start with 1) : MSB Read the result upward to give an answer of = 1A716 Hex-to-Binary Conversion 9F216 = F = = 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 Table 2-1 Hex Binary Decimal A B C D E F Binary-to-Hex Conversion = A = 3A616
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 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 (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
7
Octal Number System Octal Number System Octal to Decimal Conversion
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 : → 2618 3. Octal to Binary : →
8
2-4 BCD Code Code Straight binary coding Binary-Coded-Decimal 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 (Decimal) (BCD) only the four bit binary numbers from 0000 through 1001 are used Comparison of BCD and Binary = (Binary) - require only 8 bits : straight binary coding = BCD (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 )
9
2-5 The Gray Code Tab. 2-2 three-bit binary and Gray code equivalents
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 three-bit binary and Gray code equivalents Binary Gray Code B2 B1 B G2 G1 G0
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
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
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
13
2-6 Putting it al together
Putting it all together : Table 2-4
14
2.7 Byte, Nibble, and Word 1 byte 1 nibble = 4 bits
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 ~ Exam. 2-14
15
2-8 Alphanumeric Codes 2-9 Parity Method for Error Detection
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 ~ 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 Noise causing an error in the transmission of digital data
16
2-10. Applications : App). 2-1, 2-2, 2-3, 2-4, 2-5, 2-6
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 Odd-parity method Exactly the same way except that the total number of 1s is an odd number Error Detection Fig. 4-25(p.189) Can not tell which bit in error Can detect only single bit error Exam. 2-17 2-10. Applications : App). 2-1, 2-2, 2-3, 2-4, 2-5, 2-6 Added parity bit Added parity bit “C” ”B” (Even-parity Generator) (Even-parity Checker)
17
Application 2-5 1 1 0 0 0 1 0 1 ASCII Code : # → 23 → 1010 0011
MSB D7 D6 D5 D4 D3 D2 D1 D0 LSB LSB D0 D1 D2 D3 D4 D5 D6 D7 MSB
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.