Chapter 2_Number Systems and Codes

18 363 0
Chapter 2_Number Systems and Codes

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1 Lecture: DIGITAL SYSTEMS Nguyen Thanh Hai, PhD Chapter 2: Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 2 Nguyen Thanh Hai, PhD 2.1 Binary to Decimal Conversions 2.2 Decimal to Binary Conversions 2.3 Octal Number System 2.4 Hexadecimal Number System 2.5 BCD Code 2.6 Gray code 2.7 Putting It All Together 2.8 Applications Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 3 Basic Concepts Nguyen Thanh Hai, PhD Bit: a binary digit composed of 0 or 1 Byte: composed of 8 bits Word: composed of 4 bytes and equal to 32 bits Base 2 (binary digits): numbers composed of bits 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 Base 8 (octal digit): numbers composed of the digits from 0-7 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 4 1 0 1 1 0 1 0 1 Binary digits: MSB (Most Significant Bit) LSB (Least Significant Bit) bit 1 Byte = 8 bits bitbitKbKbit 1024 2)( 1 10 == Binary system: 0 and 1 Binary digits Nguyen Thanh Hai, PhD Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 5 Ex. 1: 11010101 2 = = (1x 2 7 ) + (1x 2 6 ) + (0x2 5 ) + (1x2 4 ) + (0x2 3 ) + (1x2 2 ) + (0x 2 1 ) + (1x 2 0 ) = 128 + 64 + 0x32 + 16 + 0x8 + 4 + 0x2 + 1 = 213 10 1 1 0 1 0 1 0 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 =128 =64 =32 =16 =8 =4 =2 =1 MSD LSD 2.1 Binary to Decimal Conversion Binary digits Weights Nguyen Thanh Hai, PhD MSD: Most Significant Digit Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 6 Ex. 2: 1101.101 2 = = (1x 2 3 ) + (1x 2 2 ) + (0x2 1 ) + (1x2 0 ) + (1x2 -1 ) + (0x2 -2 ) + (1x 2 -3 ) = 8 + 4 + 0 + 1 + 0.5 + 0 + 0.125 = 13.625 10 1 1 0 1 . 1 0 1 2 3 2 2 2 1 2 0 2 -1 2 -2 2 -3 =8 =4 =2 =1 =1/2 =1/4 =1/8 MSB Binary point LSB Binary digits Weights Nguyen Thanh Hai, PhD 2.1 Binary to Decimal Conversion (Cont.) Decimal point Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 7 25 2 = 12 + remainder of 1 12 2 = 6 + remainder of 0 6 2 = 3 + remainder of 0 3 2 = 1 + remainder of 1 1 2 = 0 + remainder of 1 25 10 = 1 1 0 0 1 2 LSB MSB EX. 3: 45 10 = = 1 0 1 1 0 1 2 Convert number 25: 2.2 Decimal to Binary Conversion Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 8 0.25x2 = 0.50 + remainder of 0 0.25 10 = 0 1 0 2 = 0.010 2 MSB LSB Convert number 0.25: 0.5x2 = 1.0 + remainder of 1 0x2 = 0 + remainder of 0 0.010= 0x2 -1 + 1x2 -2 + 0x2 -3 = 0 + 0.25 + 0=0.25 Notice: 2.2 Decimal to Binary Conversion Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 9 Ex. 4: 372 8 = = 3x(8 2 ) + 7x(8 1 ) + 2x(8 0 ) = 3x64 + 7x8 + 2x1 = 250 10 2.3 Octal Number System Nguyen Thanh Hai, PhD Ex. 5: 24.6 8 = = 2x(8 1 ) + 4x(8 0 ) + 6x(8 -1 ) = 2x8 + 4x1 + 6/8 = 20.75 10 Octal to Decimal Conversion Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 10 Decimal to Octal Conversion 266 8 = 33 + remainder of 2 33 8 = 4 + remainder of 1 4 8 = 0 + remainder of 4 266 10 = 4 1 2 8 LSD MSD EX. 6: 145 10 = 145 8 = 18 + remainder of 1 18 8 = 2 + remainder of 2 2 8 = 0 + remainder of 2 145 10 = 2 2 1 8 LSD MSD Convert number 266: Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 11 Ý nghĩa một số nhị phân: 0 1 2 3 4 5 6 7 000 001 010 011 100 101 110 111 Octal to Binary Conversion Octal digit Binary equivalent Nguyen Thanh Hai, PhD Ex. 7: 472 8 = 4 7 2 100 111 010 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 12 000 001 010 011 100 101 110 111 0 1 2 3 4 5 6 7 Binary to Octal Conversion Octal equivalent Binary digit Nguyen Thanh Hai, PhD Ex. 8: 111 101 110 7 5 6 8 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 13 Ex. 9: 356 16 = = 3x(16 2 ) + 5x(16 1 ) + 6x(16 0 ) = 3x256 + 5x15 + 6x1 = 768 + 80 + 6 = 854 10 2.4 Hexadecimal Number System Nguyen Thanh Hai, PhD Ex. 10: 2AF 16 = = 2x(16 2 ) + 10x(16 1 ) + 15x(16 0 ) = 512 + 160 + 15 = 687 10 Ex. 11: 2B.E 16 = = 2x(16 1 ) + 11x(16 0 ) + 14x(16 -1 ) = 32 + 11 + 0.875 = 43.875 10 Hex to Decimal Conversion Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 14 Decimal to Hex Conversion 423 16 = 26 + remainder of 7 26 16 = 1 + remainder of 10 1 16 = 0 + remainder of 1 423 10 = 1 A 7 16 LSD MSD EX. 12: 145 10 = 145 16 = 9 + remainder of 1 9 16 = 0 + remainder of 9 145 10 = 9 1 16 LSD MSD Convert number 423: Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 15 Hex to Binary Conversion Nguyen Thanh Hai, PhD 9F2 16 = 9 F 2 = 1001 1111 0010 = 100111110010 2 1110100110 2 = 0011 1010 0110 = 3 A 6 = 3A6 16 Binary to Hex Conversion EX. 13: 1AF 16 = EX. 14: 11010011001 2 = Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 16 Hex to Octal Conversion Nguyen Thanh Hai, PhD B2F 16 = 1011 0010 1111 = 101 100 101 111 = 5 4 5 7 8 2.5 BCD Code (Binary-Coded-Decimal Code) 8 7 4 (decimal) 1000 0111 0100 (BCD) EX. 15: 1BC 16 = EX. 16: 195 BCD = Number Systems and Codes University of Technical 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. 137 10 = 10001001 2 (binary) 137 10 = 0001 0011 0111 (BCD) number. 17 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering 2.6 The Gray Code The unique aspect of the Gray code is that only one bit ever changes between two successive numbers in the sequence. 18 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering Converting binary to Gray 19 Number Systems and Codes University of Technical Education Faculty of Electrical & Electronic Engineering Converting Gray to binary. 20 [...]... Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Open and closed switches representing 0 and 1, respectively Absence or presence of holes in paper tape representing 0 and 1, respectively 27 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Typical voltage assignments in digital system Typical... Engineering Number Systems and Codes Parallel transmission between two computers with 8 bits 31 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Series transmission between two computers Nguyen Thanh Hai, PhD 32 University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Comparison... University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes A digital circuit responds to an input’s binary level (0 or 1) and not to its actual voltage 29 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Application 5: Solution: 1 False 2 Yes 3 Logic 4 Timing diagram Nguyen Thanh... Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Example 1: Example 2: Solution: 1 Convert to decimal 2 110002 Nguyen Thanh Hai, PhD 3 212 - 1 22 University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes 2.8 Applications Application 1: A typical CD-ROM can store 650 megabytes of digital data... Comparison between non-memory and memory operation Functional Diagram of a digital computer 33 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes -Take a look Examples - Answer Review questions at pages 20 - Homework at pages 21-22 [1] Ronald J Tocci, Neal S Widmer, Digital Systems: Principles and Applications, 8th Ed Prentice... Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes Application 4: Most calculators use BCD to store the decimal values as they are entered into the keyboard and to drive the digit displays Solution: a If a calculator is designed to handle 8-digit decimal numbers, how many bits does this require? a 8 x 4 = 32 bits b What bits are stored... Solution: 650 x 220 x 8 = 5,452,595,200 bits 23 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes 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 = 4 b What is the range of addresses in octal? b 00008... 00008 to 77778 c How many memory locations are there? c With 4 octal digit, 84= 4096 24 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes 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 = 5 hex digits b What is the...University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes 2.7 Putting It All Together Decimal Binary 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 Octal Hex BCD Gray 0 1 2 3 4 5 6 7 10 11 12... Applications, 8th Ed Prentice Hall, 2007 [2] N D Phu, N T Duy Giao Trinh: Ky Thuat So, 2013 34 Nguyen Thanh Hai, PhD University of Technical Education Faculty of Electrical & Electronic Engineering Number Systems and Codes The End 35 Nguyen Thanh Hai, PhD . Engineering 6 Ex. 2: 1101.101 2 = = (1x 2 3 ) + (1x 2 2 ) + (0x2 1 ) + (1x2 0 ) + (1x2 -1 ) + (0x2 -2 ) + (1x 2 -3 ) = 8 + 4 + 0 + 1 + 0.5 + 0 + 0. 125 = 13. 625 10 1 1 0 1 . 1 0 1 2 3 2 2 2 1 2 0 2 -1 2 -2 2 -3 =8. 11010101 2 = = (1x 2 7 ) + (1x 2 6 ) + (0x2 5 ) + (1x2 4 ) + (0x2 3 ) + (1x2 2 ) + (0x 2 1 ) + (1x 2 0 ) = 128 + 64 + 0x 32 + 16 + 0x8 + 4 + 0x2 + 1 = 21 3 10 1 1 0 1 0 1 0 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 = 128 . 0 2 = 0.010 2 MSB LSB Convert number 0 .25 : 0.5x2 = 1.0 + remainder of 1 0x2 = 0 + remainder of 0 0.010= 0x2 -1 + 1x2 -2 + 0x2 -3 = 0 + 0 .25 + 0=0 .25 Notice: 2. 2 Decimal to Binary Conversion Number

Ngày đăng: 19/07/2015, 19:52

Tài liệu cùng người dùng

Tài liệu liên quan