Slide 1 1 KỸ THUẬT SỐ HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering CHƯƠNG 1 GIỚI THIỆU VÀ MÃ Assoc Prof Nguyen Thanh Hai HCMC University of Technology and[.]
HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering KỸ THUẬT SỐ CHƯƠNG 1: GIỚI THIỆU VÀ MÃ Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Basic Concepts Bit: a binary digit composed of or Byte: composed of bits Word: composed of bytes and equal to 32 bits Base (binary digits): numbers composed of bits, VD 10002 Base 10 (decimal digit): numbers composed of the digits from 0-9 Base 16 (hexa digit or hexadecimal): numbers composed of the digits from 0-9 and letters A-F, VD 168916, 4573AF16 BAEH Base (octal digit): numbers composed of the digits from 0-7 BCD code: 0000 to 1001 tương đương đến Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Binary digits Binary system: and LSB (Least Significant Bit) MSB (Most Significant Bit) Binary digits: 1 1 bit Byte = bits Kbit ( Kb) 10 bit 1024 bit Memory register: ghi nhớ Assoc Prof Nguyen Thanh Hai 2138= 2x82 1x81 +3x80=13910 21316= 2x162 1x161 +3x160=53110 21B16= 2x162 1x161 +11x160=53910 HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.1 Binary to Decimal Conversion Binary digits Weights 27 26 25 24 23 22 21 20 =128 =64 =32 =16 =8 =4 =2 =1 MSD LSD MSD: Most Significant Digit Ex 1: 110101012 = = (1x 27) + (1x 26) + (0x25) + (1x24) + (0x23) + (1x22) + (0x 21 ) + (1x 20) = 128 + 64 + 0x32 + 16 + 0x8 + + 0x2 + = 21310 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.1 Binary to Decimal Conversion (Cont.) Binary digits Weights 23 22 21 20 =8 =4 =2 =1 MSB 2-1 2-2 2-3 =1/2 =1/4 =1/8 Binary point LSB Ex 2: 1101.1012 = = (1x 23) + (1x 22) + (0x21) + (1x20) + (1x2-1) + (0x2-2) + (1x 2-3 ) = + + + + 0.5 + + 0.125 = 13.62510 Assoc Prof Nguyen Thanh Hai Decimal point HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.2 Decimal to Binary Conversion Convert number 2510 : 25 = 12 + remainder of LSB 12 = + remainder of = + remainder of = + remainder of 2138= 2x82 1x81 +3x80=13910 21316= 2x162 1x161 +3x160=53110 21B16= 2x162 1x161 +11x160=53910 EX 3: 4510 = =1 1 12 = + remainder of MSB 2510 = 1 0 12 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.2 Decimal to Binary Conversion Convert number 0.25: 0.25x2 = 0.50 + remainder of MSB 0.5x2 = + remainder of 0x2 = + remainder of LSB Notice: 0.010= 0x2-1 + 1x2-2 + 0x2-3 = + 0.25 + 0=0.25 Assoc Prof Nguyen Thanh Hai 0.2510 = 02 = 0.012 HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.3 Octal Number System Octal to Decimal Conversion Ex 4: 3728 Ex 5: 24.68 = = 3x(82) + 7x(81) + 2x(80) = 3x64 + 7x8 + 2x1 = 25010 = = 2x(81) + 4x(80) + 6x(8-1) = 2x8 + 4x1 + 6/8 = 20.7510 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Decimal to Octal Conversion Convert number 266: 266 = 33 + remainder of LSD LSD 145 = 18 + remainder of 33 = + remainder of = + remainder of EX 6: 14510 = MSD 18 = + remainder of MSD = + remainder of 26610 = 28 14510 = 2 18 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Octal to Binary Conversion Octal digit Binary equivalent một1số nhị phân: Ý nghĩa 000 001 010 011 100 101 110 111 Ex 7: 4728= 100 111 0102 10 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Binary to Octal Conversion Octal equivalent 000 001 010 011 100 101 110 111 Binary digit 111 101 110 7 Ex 8: 68 11 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.4 Hexadecimal Number System Hex to Decimal Conversion Ex 9: 35616 = = 3x(162) + 5x(161) + 6x(160) = 3x256 + 5x16 + 6x1 = 768 + 80 + = 85410 Ex 10: 2AF16 Ex 11: 2B.E16 = = 2x(161) + 11x(160) + 14x(16-1) = 32 + 11 + 0.875 = 43.87510 = = 2x(162) + 10x(161) + 15x(160) = 512 + 160 + 15 = 68710 12 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Decimal to Hex Conversion Convert number 423: 423 = 26 + remainder of 16 LSD 26 = + remainder of 10 16 = + remainder of 16 MSD 42310 = A 716 EX 12: 14510 = LSD 145 = + remainder of 16 MSD = + remainder of 16 14510 = 116 13 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Hex to Binary Conversion 9F216= = = F EX 13: 1AF16 = 1001 1111 0010 1001111100102 Binary to Hex Conversion 11101001102 = 0011 = = 3A616 1010 A 0110 EX 14: 110100110012 = 14 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Hex to Octal Conversion B2F16 = 1011 0010 = 101 100 = 1111 101 111 78 EX 15: 1BC16 = 2.5 BCD Code (Binary-Coded-Decimal Code) 1000 0111 0100 (decimal) EX 16: 19510 = (BCD) 15 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Comparison of BCD and Binary It is important to realize that BCD is not another number system like binary, decimal, and hexadecimal 13710 = 100010012 13710 = 0001 0011 0111BCD number (binary) (BCD) 16 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Example 1: Example 2: Solution: Convert to decimal 110002 212 - Assoc Prof Nguyen Thanh Hai 17 HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.8 Applications Application 1: A typical CD-ROM can store 650 megabytes of digital data Since mega = 220, how many bits of data can a CD-ROM hold? Solution: 650 x 220 x = 5,452,595,200 bits 18 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering 2.8 Applications Application 2: A small process-control computer uses octal codes to represent its 12-bit memory addresses Solution: a How many octal digits are required? a 12/3 = b What is the range of addresses in octal? b 00008 to 77778 c How many memory locations are there? c With octal digit, 84= 4096 19 Assoc Prof Nguyen Thanh Hai HCMC University of Technology and Education Faculty of Electrical & Electronic Engineering Application 3: A typical PC uses a 20-bit address code for its memory locations Solution: a How many hex digits are needed to represent a memory address? a 20/4 = hex digits b What is the range of addresses? b 0000016 to FFFFF16 c What is the total number of memory locations? c With hex digits, 165= 1,048,576 20 Assoc Prof Nguyen Thanh Hai