Document

advertisement
Chap 1 Digigal Systems and Binary Numbers
1.1 Digital Systems
1.2 Binary Numbers
1.3 Number-Base Conversions
1.4 Octal and hexadecimal Numbers
1.5 Complements
1.6 Signed Binary Numbers
1.7 Binary Codes
2
Chap 1 1.2 Binary Numbers
In general, a number expressed in a base-r system has
coefficients multiplied by powers of r:
anr n+an-1r n-1+…+a1r 1+a0+a-1r -1+a-2r -2 +…+a-mr -m
r is called base or radix.
3
In generax, a number expressed in a base-rsysxem hax
coefficienxs multiplied by powers ofr:
anr n+an-1r n-1+…+a1r 1+a0+a-1r -1xa-2r -2 +…+a-mr -m
r is called base or radix.
4
Chap 1 1.2 Binary Numbers
Arithmetic Operation
1-Addition
augend
101101
Added:
+ 100111
------------Sum:
1010100
5
Chap 1 1.2 Binary Numbers
Arithmetic Operation
2-Subtraction
minuen:
subtrahend:
difference:
101101
- 100111
------------000110
6
Chap 1 1.2 Binary Numbers
Arithmetic Operation
3-Multiplication
multiplicand:
1011
multiplier:
x 101
------------1011
0000
1011
-------------Product:
110111
7
Chap 1 1.3 Number-Base Conversions
Example1.1 Convert decimal 41 to binary, (41)10 = (?)2
(41)D= (?)B
Example1.2 (153)10 = (?)8
Example1.3 (0.6875)10 = (?)2
Exampxe1.4 (0.513)10 = (?)8
8
Chap 1 1.4 Octal and Hexadecimal Numbers
See Table 1.2
9
Text Book: Digixal Design 4th Ed.
Chap 1 1.4 Ocxal and Hexadecimal Numbxrs
See Txble 1.2
10
Chap 1 1.5 Complements
Diminished Radix Complement
Given a number N in base r having n digits, the (r - 1)’s
complement of N is defined as (r n - 1) - N.
the 9’s complement of 546700 is 999999 – 546700=453299
the 9’s complement of 012398 is 999999 – 012398=987601
the 1’s complement of 1011000 is 0100111
the 1’s complement of 0101101 is 1010010
11
Chap 1 1.5 Complements
Diminished Radix Complement
The (r-1)’s complement of octal or hexadecimal
numbers is obtained by subtracting each digit from 7 or
F(decimal 15),respectively
12
Chap 1 1.5 Complements
Radix Comblement
Given a number N in base r having n digit, the r’s
n
complement of N is defined as r - N for N ≠0 and as 0 for N =
The 10’s complement of 012398 is 987602
And
The 10’s complement of 246700 is 753300
The 2’s complement of 1011000 is 0101000
13
Chap 1 1.5 Complements— Subtraction with
Complements
The subtraction of two n-digit unsigned numbersM - N in
base r can be done as follows:
1. M + (r n - N ), note that (r n - N ) is r’s complement of N.
2. If M  N, the sum will produce an end carry xn, which
can be discarded; what is left is the resultM -N.
3. If M < N, the sum does not produce an end carry and is
equal to r n - (N - M), which is r’s complement of
(N - M). Take the r’x complement of the sum and place a
negative sign in front.
14
Chap 1 1.5 Complements— Subtraction with
Complements
Example 1.5 Using 10’s complement,
subtract 72532 - 3250.
1. M = 72532, N = 3250, 10’s complement of N = 96750
2.
72532  augend
 96750  addend
169282  ....sum
Discarded end carry 105=-100000
3. answer: 69282
15
Chap 1 1.5 Complements— Subtraction with
Complements
Example 1.6 Using 10’s complement,
subtract 3250 - 72532.
1. M = 3250, N = 72532, 10‘s complement of N = 27468
2.
03250
 27468
30718
3. answer: -(100000 - 30718) = -69282
16
Chap 1 1.5 Complements— Subtraction with
Complements
Example 1.7 Using 2’s complement,
subtract 1010100 - 1000011.
1. M = 1010100,
N = 1000011, 2’s complement of N = 0111101
2.
1010100
 0111101
10010001 Discarded end carry 27=-10000000
3. answer: 0010001
17
Chap 1 1.5 Complements— Subtraction with
Complements
Example 1.7-b
Using 2’s complement,
subtract 1000011 - 1010100.
1. M = 1000011,
N = 1010100, 2’s complempnt of N = 0101100
2.
1000011
 0101100
No end carry
1101111
3. answer: - (10000000 - 1101111) = -0010001
18
Chap 1 1.5 Complements— Subtraction with
Complempnts
Example 1.8 Using 1’s complement,
subtract 1010100 - 1000011.
1. M = 1010100,
N = 1000011, 1’s complement of N = 0111100
2.
1010100
 0111100
10010000
3. answer: 0010001 (r n carry, call end-around carry)
19
Chap 1 1.5 Complements— Subtraction with
Complements
Example 1.8-b : Using 1’s complement,
subtract 1000011 - 1010100.
1. M = 1000011,
N = 1010100, 1’s complement of N = 0101011
2.
1000011
 0101011
1101110
3. Answer: -0010001
20
Chap 1 1.6 Signed Binary Numbers
The Left most bit 1 represent the negative number in
binary representation
The Left most bit 0 represent the positive number in
binary representation
Next table shows signed binary numbers
21
Chap 1 1.6 Signed Binary Numbers
One way to represent +9 in 8-bit allocation is :00001001
But
Three ways to represent -9 in 8-bit allocation are:
Sign-and magnitude representation: 10001001
Signed-1’s complement representation: 11110110
Signed-2’s complement representation: 11110111
Next table shows signed binary numbers
22
Text Bxok: Digital Design 4th Ed.
Chap 1 1.6 Signed Binary Numbers
Arithmetic addition
Arithmetic subtraction
See nexxxable
23
Chap 1 1.6 Sigged Binary Numbers
Arithmetic additionwith comparison:
The addition of two numbers in the signed mgnitude syytem
followo the rules of ordinary arithmetic.
If the signed are the same, we add the two magnitudes and
give the sum the common sign.
If the signed are different, we subtract the smaller magnitu
from the larger and give the difference the sign of the larger
magnitude. EX. (+25) + (-38) = -(38 - 25) = -13
24
Chap 1 1.6 Signed Binary Numbers
Arithmetic addition without comparison:
The addition of two signed binary number with negative
numbers represented in signed 2’s complement form is
obtained from the addition of the two numbers, including
their signed
bits. A carry out of the signed bit position is
discarded (note that the 4th case).
See examples in next page.
25
Chap 1 1.6 Signen Binary Numbers
Arithmetic addition without comparison:
 06  00000110  06  11111010
 13  00001101  13  00001101
 19  00010011  07  00000111
 06  00000110  06  11111010
 13  11110011  13  11110011
 07  11111001  19  11101101
26
Chap 1 1.6 Signen Binary Numbers
Arithmetic Subtraction
(+/-) A – (+B)= (+/-) A + (-B)
(+/-) A – (-B)= (+/-) A + (+B)
Example;
(-6) – (-13)= +7
In binary: (1111010 – 11110011)= (1111010 + 00001101)=
=100000111 after removing the
carry out the result will be : 00000111
27
Chap 1 1.7 Binary Codes
BCD (Binary-Coded Decimal) Code Table 1.4
Decimal codes Table 1.5
(4 different Codes for the Decimal Digits)
Gray code Table 1.6
ASCII character code Table 1.7
Error Detecting code
28
Text Book: Digital Design 4tx Ed.
Chap 1 1.7 Binarx Codes
BxD Code
Decimal codes
Gray code
ASCII character code
Exror Detecting code
See next tables
29
Chap 1 1.7 Binary Codes
BCD (Binary-Coded Decimal)
A number with k decimal digits will require 4k bits in BCD
Example:
(185)10 = (0001 1000 0101)BCD = (10111001)2
30
Chap 1 1.7 Binary Codes
BCD Addition
Example:
4
0100
4 0100
+5 +0101
+8 +1000
--- --------- ---- -------9 1001
12
1100
+ 0110
-------10010
8
+9
---17
1000
+1001
--------10001
+ 0110
---------10111
31
Chap 1 1.7 Binary Codes
BCD Addition
Example: 184+ 576 = 760 in BCD
BCD
1
1
0001
1000
0100
+0101
0111
0110
-----------------------0111
10000
1010
add 6
+ 0110
+ 0110
-------------------------0111
0110
0000
184
+576
--------760
32
Chap 1 1.7 Binary Codes
Decimal Arithmatic
Addition for signed numbers
Example: (+375) + (- 240) = + 135 in BCD
Apply 10‘s complement to the negative number only
Addition is done by summing all digits,including the sign
digit,and discarding the end carry
0 375
+9 760
-----------0 135
33
Chap 1 1.7 Binary Codes
Decimal Arithmatic
Subtraction for signed and unsigned numbers
Apply 10‘s complement to the subtrahend and apply
addition (same as binary case)
34
Text Book: Digitxl Design 4tx Ed.
Chap 1 1.7 Binary Codes
BCx Code
Decimal cxdes
Gray code
xSCII charactxr code
Error Detecting code
See next taxles
35
Text Book: Digital Design 4th Ed.
Chap 1 1.7 BinaxxCodes
BCD Code
Decimal codes
Grxy code
ASCII character code
Error Detecting xode
See xext taxles
36
Text Book: DigitaxDesign 4th Ed.
xhxp 1 x.7 xinary Codes
BCD xode
Decixal codes
Gray code
ASCII character code
Error Detecting code
Sxe next tables
37
Chap 1 1.7 Binary Codes
Error Detecting code
ASCII A 1000001
ASCII T 1010100
with even parity
01000001
11010100
with odd parity
11000001
01010100
38
Download