22
Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Embed Size (px)

Citation preview

Page 1: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Chapter 1

Number Systems and Codes

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 2: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Digital Versus Analog

• Digital– ON and OFF– 0 and 1

• Analog– continuously varying– temperature, pressure, velocity

• See Figure 1-1

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 3: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Figure 1-1

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 4: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Digital Representations of Analog Quantities

• Audio Recording– CD or DAT

• Conversions– digital-to-analog– analog voltage to 8-bit Digital equivalent

• See Figure 1-2 and 1-3

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 5: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Figure 1-2

Figure 1-3

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 6: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Decimal Numbering System (Base 10)

• 10 different possible digits

• Least significant position– rightmost

• Most significant digit– leftmost

• Weighting factor of 10

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 7: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Binary Numbering System (Base 2)

• Only 0 and 1

• Weighting factor of 2

• Conversion techniques– digit times weighting factor– successive division

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 8: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Decimal-to-Binary Conversion

• Subtracting weighting factors

• Successive division

• Least Significant Bit (LSB)

• Most Significant Bit (MSB)

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 9: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Octal Numbering System(Base 8)

• Allowable digits– 0,1,2,3,4,5,6,7

• Weighting factor of 8

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 10: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Octal Conversions• Binary to Octal

– group binary positions in groups of three– write the octal equivalent

• Octal to Binary– reverse the process

• Octal to Decimal– multiply by weighting factors

• Decimal to Octal– successive division

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 11: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Hexadecimal Numbering System(Base 16)

• 4-bit groupings

• See Table 1-3

• Two hex digits are used to represent 8 bits– a byte– 4 bits are a nibble

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 12: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 13: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Hexadecimal Conversions

• Binary to Hexadecimal– group the binary in groups of four– write the equivalent hex digit

• Hexadecimal to Binary– reverse the process

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 14: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Hexadecimal Conversions

• Hexadecimal to Decimal– multiply by weighting factors

• Decimal to Hexadecimal– successive division

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 15: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Binary-Coded-Decimal SystemBCD

• Each of the 10 decimal digits has a 4-bit binary code

• Conversion– convert each decimal digit to its 4-bit binary

code– BCD to Decimal - reverse the process

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 16: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Comparison of Numbering Systems

• See Table 1-4

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 17: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 18: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

The ASCII Code

• Represents alphanumeric data

• Uses 7 bits

• 128 different code combinations

• See Table 1-5– 3-bit group is most significant– 4-bit group is least significant

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 19: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 20: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Summary

• Numerical quantities occur in analog form but must be converted to digital form to be used by computers or digital circuitry.

• The binary numbering system is used in digital systems because the 1’s and 0’s are easily represented by ON or OFF transistors, which output 0V for 0 and 5V for 1.

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 21: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Summary• Any number system can be converted to

decimal by multiplying each digit by its weighting factor.

• The weighting factor for the least significant digit in any number system is always 1.

• Binary numbers can be converted to octal by forming groups of 3 bits and to hexadecimal by forming groups of 4 bits.

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.

Page 22: Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle

Summary• The successive division procedure can be

used to convert from decimal to binary, octal or hexadecimal

• The binary-coded-decimal system uses groups of 4 bits to drive decimal displays such as those in a calculator.

• ASCII is used by computers to represent all letters, numbers and symbols in digital form.

William KleitzDigital Electronics with VHDL, Quartus® II Version

Copyright ©2006 by Pearson Education, Inc.Upper Saddle River, New Jersey 07458

All rights reserved.