Chapter 1
Chapter 1
Chapter 1
Chapter 1
Digital Systems & Binary Numbers
Goals
Background
• Digital systems have revolutionized our world
– Cell phones, Internet, rapid advances in medicine, etc.
• The semiconductor industry grew from $21 billion in 1985 to $213 billion
in 2004 and is expected to reach over $300 billion by 2013
The Digital
Abstraction
• Most physical variables
are continuous, for
example
– Voltage on a wire
– Frequency of an oscillation
– Position of a mass
• Instead of considering all values, the digital
abstraction considers only a discrete subset of values
– Considering discrete voltages instead of continuous voltages
used by analog circuits
– Digital circuits are simpler to design than analog circuits –
can build more sophisticated systems
– Digital systems replacing analog predecessors such as digital
cameras, digital television, cell phones, CDs etc.
Digital Systems
• Digital Computers are heavily employed in design
manufacturing, distribution and sales.
• General-purpose digital computing systems follow a
sequence of instructions, called an algorithm, and
implemented as a computer program that operates on
a given data.
Signal
• An information variable represented by physical quantity.
• For digital systems, the variable takes on discrete values.
• Two level binary values are the most prevalent in digital systems.
• Binary values are represented abstractly by: – digits 0 and 1 (Bits)
– words (symbols) False (F) and True (T) –
words (symbols) Low (L) and High (H) –
and words On and Off.
• Binary values are represented by values or ranges of values of physical
quantities
• 1 and 0 can be represented by specific voltage levels, rotating gears, fluid
levels, etc.
• Digital circuits usually depend on specific voltage levels to represent 1
and 0
• Bit: Binary digit
Graph of an analog quantity
Logic Levels
5V 4 .5 V
Logic Levels
Driver Receiver
The HIGH range typically corresponds to binary 1 and LOW range to binary 0.
The forbidden zone (or the threshold region) is a range of voltages for which
the input voltage value cannot be interpreted reliably as either a zero (0) or a
one (1).
Noise Margins
Driver Receiver
– CPU: Voltage
– Disk: Magnetic Field Direction
– CD: Surface Pits/Light
– Dynamic RAM: Electrical Charge
NUMBER SYSTEMS
Commonly occurring bases
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Numbers in different bases
Decimal Binary Octal Hexadecimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 a
11 1011 13 b
12 1100 14 c
13 1101 15 d
14 1110 16 e
15 1111 17 f
16 10000 20 10
Binary-Decimal Conversions
• To convert from binary to decimal, use
decimal arithmetic to form S (digit ×
respective power of 2).
• Example: Convert 110102 to N10:
– (11010)2 = 0 x 20 + 1 x 21 + 0 x 22 + 1 x 23 + 1 x 24 = (26)10
Binary-Decimal Conversions
• To convert from decimal to binary
– Subtract the largest power of 2 that gives a positive
remainder and record the power.
– Repeat, subtracting from the prior remainder and
recording the power, until the remainder is zero.
– Place 1’s in the positions in the binary result
corresponding to the powers recorded; in all other
positions place 0’s.
• Example: Convert 62510 to N2
Binary-Decimal Conversions
• Decimal numbers
537410 =
• Binary numbers
11012 =
Binary-Decimal Conversions
• Decimal numbers
• Binary numbers
11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 1310
one one no one eight four two one
Powers of Two
• 20 = • 28 =
• 21 = • 2 9 = • 22 = • 210 =
• 23 = • 211 =
• 24 = • 212 =
• 25 = • 213 =
• 26 = • 214 =
• 27 = • 215 =
Powers of Two
• 20 = 1 • 29 = 512
• 21 = 2 • 210 = 1024
• 22 = 4 • 211 = 2048
• 23 = 8 • 212 = 4096
• 24 = 16 • 213 = 8192
• 2 = 32
5 • 214 =
• 26 = 64 16384
• 2 = 128
7 • 215 =
• 28 = 32768
256
• Handy to memorize up to 29
Binary-Decimal Conversions
•
Decimal to binary conversion:
–
Convert 100112 to decimal
•
Decimal to binary conversion:
–
Convert 4710 to binary
Binary-Decimal Conversions
•
Decimal to binary conversion:
–
Convert 100112 to decimal
–
16×1 + 8×0 + 4×0 + 2×1 + 1×1 = 1910
•
Decimal to binary conversion:
–
Convert 4710 to binary
–
32×1 + 16×0 + 8×1 + 4×1 + 2×1 + 1×1 = 1011112
Binary Values and Range
• N - digit decimal number
– How many values? 10N
– Range? [0, 10N - 1]
– Example: 3-digit decimal number:
• 103 = 1000 possible values
• Range: [0, 999]
•
Hexadecimal to decimal conversion:
–
Convert 4AF16 to decimal
–
162×4 + 161×10 + 160×15 = 119910
bit bit
10010110
nibble
• Bytes
CEBF9AD7
most least
significant significant byte
byte
Powers of Two
• 2 10 = 1 kilo ≈ 1000 (1024)
• 2 20 = 1 mega ≈ 1 million (1,048,576)
• 2 30 = 1 giga ≈ 1 billion (1,073,741,824)
Estimating Powers of Two
• What is the value of 224?
CONVERSIONS
INVOLVING FRACTIONS
Conversions involving fractions
• To convert a number with a fractional part
from one base to another:
– Convert the integer part
– Convert the fraction part
– Join the two results with a radix point
Conversions involving fractions
• To convert the integer part, repeatedly divide the number
by the new radix and save the remainders. The digits for
the new radix are the remainders in reverse order of
their computation. If the new radix is > 10, then convert
all remainders > 10 to digits A, B, …
• In general, it may take many bits to get this to happen or it may never
happen.
• Binary
11
1011 carries
OPERATIONS
Single Bit Binary Addition with Carry
Given two binary digits (X,Y), a carry in (Z) we get the
following sum (S) and carry (C):
Z 0 0 0 0
Carry in (Z) of 0: X 0 0 1 1
+Y
Carry in (Z) of 1:
Z 1 1 1 1
X 0 0 1 1
CS 00
+Y
CS 01
111
• Add the following 4-bit 1011
binary numbers
Overflow!
Overflow
•
Digital systems operate on a fixed number
of bits
•
Addition overflows when the result is too
big to fit in the available number of bits
•
See previous example of 11 + 6
Subtraction: Signed Binary Numbers
• Sign/Magnitude Numbers
• Two’s Complement Numbers
Sign/Magnitude Numbers
•
1 sign bit, N-1 magnitude bits
•
Sign bit is the most significant (left-most) bit
– Positive number: sign bit = 0
– Negative number: sign bit = 1
•
Example, 4-bit sign/mag representations of ± 6:
+6 = 0110
- 6 = 1110
•
Range of an N-bit sign/magnitude number:
[-(2N-1-1), 2N-1-1]
Sign/Magnitude Numbers
• Problems:
–
Addition doesn’t work, for example -6 + 6:
1110
+ 0110
10100 (wrong!)
–
Two representations of 0 (± 0):
1000
0000
Two’s Complement Numbers
• Don’t have same problems as
sign/magnitude numbers:
– Addition works
– Single representation for 0
Two’s Complement Numbers
• Same as unsigned binary, but the most significant bit
(msb) has value of -2N-1
• Most positive 4-bit number: 0111
• Most negative 4-bit number: 1000
• The most significant bit still indicates the sign
(1 = negative, 0 = positive)
• Range of an N-bit two’s comp number: [-(2N-1), 2N-1-1]
“Taking the Two’s Complement”
•
Flip the sign of a two’s complement
number
•
Method:
1. Invert the bits
2. Add 1
•
Example: Flip the sign of 310 = 00112
“Taking the Two’s Complement”
•
Flip the sign of a two’s complement
number
•
Method:
1. Invert the bits
2. Add 1
•
Example: Flip the sign of 310 = 00112
1. 1100
2. + 1
1101 = -310
•
What is the decimal value of the two’s
complement number 10012?
1. 0110
2. + 1
Sign-Extension
•
Sign bit is copied into most significant bits.
•
Number value remains the same.
•
Example 1:
– 4-bit representation of 3 = 0011 –
8-bit sign-extended value:
00000011
•
Example 2:
– 4-bit representation of -5 = 1011
– 8-bit sign-extended value: 11111011
Zero-Extension
•
Zeros are copied into most significant bits.
•
Value will change for negative numbers.
•
Example 1:
– 4-bit value = 00112 = 310
– 8-bit zero-extended value: 00000011 = 310
•
Example 2:
– 4-bit value = 1011 = -510
– 8-bit zero-extended value: 00001011 = 1110
Unsigned 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111 Two's Complement
0000
1111 1110 1101 1100 1011 1010 1001 0001 0010 0011 0100 0101 0110 0111 Sign/Magnitude
1000
Binary multiplication
• The binary multiplication table is simple:
0 0=0 | 1 0=0 | 0 1=0 | 1 1=1
• Extending multiplication to multiple digits:
Multiplicand 1011
Multiplier x 101
Partial Products 1011
0000-
1011 --
Product 110111
Multiplication/Division by 2n
• Multiplication by 1002 B3 B2 B1 B0
– Shift left by 2 0
0
C
C5 C4 C3 C2 1 C0
0
C
B3 B2 B1 B0
• Division by 1002
– Shift right by 2 0
C3 2 C1 C0 C- 1 C- 2
(b)
CODING
ASCII Character Codes
• American Standard Code for Information Interchange.
• Other non-printing characters are used for record marking and flow
control (e.g. STX and ETX start and end text areas).
UNICODE
• UNICODE extends ASCII to 65,536 universal characters codes
– For encoding characters in world languages
– Available in many modern applications
– 2 byte (16-bit) code words
– See Reading Supplement – Unicode on the Companion
Website http://www.prenhall.com/mano
There are over 8,000 ways that you can chose 10 elements from the 16 binary
numbers of 4 bits.
If the digit sum is > 9, add one to the next significant digit
BCD Addition Example
• Add 448BCD to 489BCD showing carries and digit
corrections.
1 1 0
Carry In
• In binary:
– 1001 + 1001 + 1 = 1 0011 = 13 and not 19 –
The difference is 6!
End of chapter !