1 / 17

Chap. 2 Number Systems and Codes

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.

suzannem
Download Presentation

Chap. 2 Number Systems and Codes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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, … 01 0 0 00 0 1 65? A? control word? BCD code?

  3. 2-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

  4. 2-2 Decimal to Binary Conversions • Decimal-to-Binary Conversions • Method 1 • Decimal number is simply expressed as a sum of powers of 2 4510 = 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) : LSB 18 / 2 = 9 remainder 0 9 / 2 = 4 remainder 1 4 / 2 = 2 remainder 0 2 / 2 = 1 remainder 0 1 / 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.375x 2 = 0.750 integer 0 MSB • 0.750 x 2 = 1.500 integer 1 . • 0.500 x 2 = 1.000 integer 1 LSB • Read the result downward .37510 = .0112

  5. 2-3Hexadecimal Number System • Hex-to-Decimal Conversion 2AF16 = (2 x 162) + (10 x 161) + (15 x 16o) = 51210 + 16010 + 1510 = 68710 • Decimal-to-Hex Conversion : Exam. 2-3 42310 / 16 = 26 remainder 7 (Hex number will end with 7) : LSB 2610 / 16 = 1 remainder 10 110 / 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 Conversion 9F216 = 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 Table 2-1 Hex Binary Decimal 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 50101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 A 1010 10 B 1011 11 C 1100 12 D 1101 13 E 1110 14 F 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

  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

  7. Octal 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

  8. 2-4BCD 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 )

  9. 2-5The 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 equivalents BinaryGray Code B2 B1 B0 G2 G1 G0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 0

  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 • 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

  15. 2-8 Alphanumeric Codes2-9 Parity Method for Error Detection Transmitter Receiver  ~ ~ • 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 Fig. 2-6 Noise causing an error in the transmission of digital data

  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 aneven 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 oddnumber 1 1 0 0 0 0 0 1 • 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 1 1 0 0 0 0 1 1 “C”1 1 0 0 0 0 1 0 ”B” (Even-parity Generator) (Even-parity Checker)

  17. Application 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

More Related