Upload
chloe-small
View
229
Download
1
Tags:
Embed Size (px)
Citation preview
Chapter 1
Number Systems and Codes
1
Outline
1. NUMBER SYSTEMS AND CODES2. DIGITAL ELECTRONIC SIGNALS AND SWITCHES3. BASIC LOGIC GATES4. PROGRAMMABLE LOGIC DEVICES: CPLDS AND FPGAS WITH VHDL DESIGN 5. BOOLEAN ALGEBRA AND REDUCTION TECHNIQUES6. EXCLUSIVE-OR AND EXCLUSIVE-NOR GATES7. ARITHMETIC OPERATIONS AND CIRCUITS8. CODE CONVERTERS, MULTIPLEXERS, AND DEMULTIPLEXERS9. LOGIC FAMILIES AND THEIR CHARACTERISTICS10. FLIP-FLOPS AND REGISTERS11. PRACTICAL CONSIDERATIONS FOR DIGITAL DESIGN
Chapter Objectives
• Determine the weighting factor of each digit position in the decimal, binary, octal, and hexadecimal numbering systems.
• Convert any number among the four number systems, and its equivalent value in any of the remaining three numbering systems.
• Describe binary coded decimal (BCD) numbers.• Translate alphanumeric data to and from ASCII
using the ASCII code translation table.
2
Digital versus Analog
• Digital– OFF and ON states that can be represented using
0s and 1s (respectively).
• Analog– Continuously varying
– Examples: temperature, pressure, velocity
4
Digital vs. Digital vs. AnalogAnalog
5
Analog Signal Voltages and Their Digital Equivalents
Digital-to-Analog and Digital-to-Analog and Back AgainBack Again
8
Binary numbers
• An electronic signal in logic circuits carries one digit of information. – Each digit is allowed to take on only two possible
values, usually denoted as 0 and 1.
– -> Information in logic circuits is represented as combinations of 0 and 1 digits.
• Q: How to represent numbers (E.g., positive integers) using only binary digits 0 and 1?
8
Decimal Numbering System (Base 10)
• 10 possible digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
• Least-significant position is on the right end
• Most-significant position is on the left end
• Weighting factor of 10
10
Cont’
• A decimal integer is expressed by an n-tuple comprising n decimal digits
D = dn-1dn-2 ∙ ∙ ∙ d1d0
which represents the value
V(D) = dn-1×10n-1 + dn-2×10n-2 + ∙ ∙ ∙ + d1×101 + d0×100
• This is referred to as the positional number representation.
10
Binary Numbering System (Base 2)
• Only two possible digits: 0 and 1
• Weighting factor of 2
• Conversion techniques– Digit times weighting factor
– Successive division
11
Binary (base-2) number system
• Logic circuits use the binary system whose positional number representation is
B = bn-1bn-2 ∙ ∙ ∙ b1b0
V(B) = bn-1×2n-1 + bn-2×2n-2 + ∙ ∙ ∙ + b1×21 + b0×20
E.g., (1101)2 = 1×23 + 1×22 + 0×21+1×20=(13)10
bn-1 is the most significant bit (MSB),
b0 is the least significant bit (LSB),
12
Numbers in decimal and binary
Decimal representation
Binary representation
00 0000
01 0001
02 0010
03 0011
04 0100
05 0101
06 0110
07 0111
08 1000
Decimal representation
Binary representation
09 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
13
Decimal-to-Binary Conversion- Successive subtraction
12
Power
857 - 512(29) = 345 1 MSB - 9th
345 - 256(28) = 89 1
89 - 128(27) < 0 0
89 - 64(26) = 25 1
25 - 32(25) < 0 0
25 - 16(24) = 9 1
9 - 8(23) = 1 1
1 - 4(22) < 0 0
1 - 2(21) < 0 0
1 - 1(20) = 0 1 LSB
Method 2 – successive division
Remainder
857 / 2 = 428 1 LSB
428 / 2 = 214 0
214 / 2 = 107 0
107 / 2 = 53 1
53 / 2 = 26 1
26 / 2 = 13 0
13 / 2 = 6 1
6 / 2 = 3 0
3 / 2 = 1 1
1 / 2 = 0 1 MSB
15
Octal Numbering System (Base 8)
• Eight allowable digits: 0, 1, 2, 3, 4, 5, 6, 7
• Weighting factor of 8
13
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
14
Hexadecimal Numbering System (Base 16)
• 16 allowable digits.– 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F
• Each hex digit represents a 4-bit group– See Table 1-3
• Two hex digits are used to represent 8 bits– 8 bits are called a byte
– 4 bits are called a nibble
15
Hexadecimal Numbering System
Hexadecimal Conversions
• Binary-to-hexadecimal conversion–Group the binary in groups of four
–Write the equivalent hex digit
• Hexadecimal-to-binary conversion–Reverse the process
16
Hexadecimal Conversions
• Hexadecimal-to-decimal conversion–Multiply by weighting factors
• Decimal-to-hexadecimal conversion–Successive division
17
Binary-Coded-Decimal System(BCD)
• Each of the 10 decimal digits is represented by its 4-bit binary equivalent.
• Decimal-to-BCD conversion– Convert each decimal digit to its 4-bit binary
code
• BCD-to-Decimal conversion– Reverse the process
18
The ASCII Code
• American Standard Code for Information Interchange (ASCII)– 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
20
21
Numbering System Applications
• Because digital systems must work with 1s and 0s, learning the different numbering systems is important.
• Which system is used is determined by how the data were developed and how they are to be used.
• Several numbering system applications follow.
22
Application 1-1
22
The four chemical storage tanks shown are monitored for temperature (T) and pressure (P).
Application 1-1 (continued)
• Using the table shown below, interpret the following:– If the computer reads a binary string of
0010 1000 what problems exist?
– This indicates that the pressure in tanks C and B are too high.
22
0 0 1 0 1 0 0 0
Application 1-1 (continued)
• Using the table shown below, interpret the following:– If the computer reads a hex value of 55H what
problems exist?
– Since 55H =0101 0101 This indicates that all tank temperatures are too high.
22
0 1 0 1 0 1 0 1
Application 1-1 (continued)
• Using the table shown below, interpret the following:– If the temperature and pressure in tanks B and
D are too high, what hex value is read by the computer?
– This condition would produce a digital output of 1100 1100 = CCH.
22
Application 1-1 (continued)
• Using the table shown below, interpret the following:– Assume that tanks A and B are shut down
and all sensors are tied high (1s). What is the lowest decimal value that indicates a problem in the other two tanks?
– With the four low-order bits tied high, the lowest value that indicates a problem is 0001 111 or 3110.
22
Application 1-1 (continued)
• Using the table shown below, interpret the following:– If only tanks A, B, and C are monitored, what
octal value indicates tank B has both temperature and pressure problems?
– The binary output would be 001 1002 = 148.
22
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.
29
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.
30