chap 1 digi g al systems and binary numbers 1.1 digita l systems 1.2 binary numbers 1.3 number-base...
TRANSCRIPT
Chap 1 Digigal Systems and Binary Numbers
1.1 Digital Systems1.2 Binary Numbers1.3 Number-Base Conversions1.4 Octal andhexadecimal Numbers 1.5 Complements1.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 n-1 1 0 -1 -2 -mr +an r +…+an-1 r +a1 +a r +a-1 r +…+a-2 r-m
r is called base or radix.
3
In generax, a number expressed in a base-r sysxem hax
coefficienxs multiplied by powers ofr:
an n-1 1 0 -1 -2 -m
r is called base or radix.
r +an r +…+an-1 r +a1 +a r xa-1 r +…+a-2 r-m
4
Chap 1 1.2 Binary Numbers
5
Arithmetic Operation
1-Addition augend 101101Added: + 100111 -------------Sum: 1010100
Chap 1 1.2 Binary Numbers
6
Arithmetic Operation
2-Subtraction minuen: 101101subtrahend: - 100111 -------------difference: 000110
Chap 1 1.2 Binary Numbers
7
Arithmetic Operation3-Multiplication multiplicand: 1011multiplier: x 101 ------------- 1011 0000 1011 --------------Product: 110111
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 ComplementGiven a number N in base r having ndigits, the (r - 1)’s
complement of N is defined as (r - 1) - N.n
the 1’s complement of 1011000 is 0100111
11
the 9’s complement of 012398 is 999999 – 012398=987601
the 9’s complement of 546700 is 999999 – 546700=453299
the 1’s complement of 0101101 is 1010010
Chap 1 1.5 Complements
Diminished Radix Complement
12
The (r-1)’s complement of octal or hexadecimal numbers is obtained by subtracting each digit from 7 or F(decimal 15),respectively
Chap 1 1.5 Complements
Radix Comblement
13
The 10’s complement of 012398 is 987602AndThe 10’s complement of 246700 is 753300
Given a number N in base r having ndigit, the r’s
complement of N is defined asr - N for N ≠0 and as 0 for N = 0 .n
The 2’s complement of 1011000 is 0101000
Chap 1 1.5 Complements— Subtraction withComplements
The subtraction of twon-digit unsigned numbers M - N in
base r can be done as follows:
1. M + (r - N ), note that (r - N ) is r’s complement of N.n n
2. If M N, the sum will produce an end carryx , whichcan be discarded; what is left is the resultM -N.
n
3. If M < N, the sum does not produce an end carry and isequal to r - (N - M), which is r’s complement ofn
(N - M). Take the r’xcomplement of the sum and place anegative sign in front.
14
Chap 1 1.5 Complements—Subtraction withComplements
Example 1.5 Using 10’s complement,
subtract 72532 - 3250.
1. M = 72532, N = 3250, 10’s complement of N = 96750
2.
3. answer: 69282
72532 augend 96750 addend
169282 ....sum
15
Discarded end carry 105=-100000
Chap 1 1.5 Complements— Subtraction withComplements
Example 1.6 Using 10’s complement,
subtract 3250 - 72532.
1. M = 3250, N = 72532, 10‘s complement of N = 27468
2.
3. answer: -(100000 - 30718) = -69282
03250 27468
30718
16
Chap 1 1.5 Complements— Subtraction withComplements
Example 1.7 Using 2’s complement,
subtract 1010100 - 1000011.
1. M = 1010100,
N = 1000011, 2’s complement ofN = 0111101
2.
3. answer: 0010001
1010100 0111101
10010001
17
Discarded end carry 27=-10000000
Chap 1 1.5 Complements— Subtraction withComplements
Example 1.7-b Using 2’s complement,
subtract 1000011 - 1010100.
1. M = 1000011,
N = 1010100, 2’s complempnt ofN = 0101100
2.
3. answer: - (10000000 - 1101111) = -0010001
1000011 0101100
1101111
18
No end carry
Chap 1 1.5 Complements— Subtraction withComplempnts
Example 1.8 Using 1’s complement,
subtract 1010100 - 1000011.
1. M = 1010100,
N = 1000011, 1’s complement of N = 0111100
2.
3. answer: 0010001 (r carry, call end-around carry)n
1010100 0111100
10010000
19
Chap 1 1.5 Complements—Subtraction withComplements
Example 1.8-b : Using 1’s complement,
subtract 1000011 - 1010100.
1. M = 1000011,
N = 1010100, 1’s complement of N = 0101011
2.
3. Answer: -0010001
1000011 0101011
1101110
20
Chap 1 1.6 Signed Binary Numbers
Next table shows signed binary numbers
21
The Left most bit 1 represent the negative number in binary representationThe Left most bit 0 represent the positive number in binary representation
Chap 1 1.6 Signed Binary Numbers
Next table shows signed binary numbers
22
One way to represent +9 in 8-bit allocation is :00001001ButThree ways to represent -9 in 8-bit allocation are:Sign-and magnitude representation: 10001001Signed-1’s complement representation: 11110110Signed-2’s complement representation: 11110111
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 syytemfollowo the rules of ordinary arithmetic.
If the signed are the same, we add the two magnitudes andgive the sum thecommon sign.
If the signed are different, we subtract the smaller magnitudefrom the larger and give the difference the sign of the largermagnitude. EX. (+25) + (-38) = -(38 - 25) = -13
24
Arithmetic addition without comparison:
The addition of two signed binary number with negativenumbers represented in signed 2’s complement form is
obtained from the addition of the two numbers, includingtheir signed bits. A carry out of the signed bit position isdiscarded (note that the 4th case).
See examples in next page.
Chap 1 1.6 Signed Binary Numbers
25
Chap 1 1.6 Signen Binary Numbers
Arithmetic addition without comparison:
19 1110110113 1111001106 11111010
07 1111100113 1111001106 00000110
07 00000111
13 0000110106 11111010
19 0001001113 0000110106 00000110
26
Chap 1 1.6 Signen Binary Numbers
Arithmetic Subtraction
27
(+/-) A – (+B)= (+/-) A + (-B) (+/-) A – (-B)= (+/-) A + (+B)
Example; (-6) – (-13)= +7In binary: (1111010 – 11110011)= (1111010 + 00001101)= =100000111 after removing the carry out the result will be : 00000111
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 8 1000+5 +0101 +8 +1000 +9 +1001--- --------- ---- -------- ---- ---------91001 12 1100 17 10001 + 0110 + 0110 -------- ---------- 10010 10111 31
Chap 1 1.7 Binary Codes
BCD AdditionExample: 184+ 576 = 760 in BCDBCD 1 1 0001 1000 0100 184 +0101 0111 0110 +576 --------- -------- --------- 0111 10000 1010 add 6 + 0110 + 0110 ---------- -------- ---------- --------- 0111 0110 0000 760
32
Chap 1 1.7 Binary Codes
Decimal ArithmaticAddition for signed numbersExample: (+375) + (- 240) = + 135 in BCD
Apply 10‘s complement to the negative number onlyAddition 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 ArithmaticSubtraction 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
38
with even parity with odd parityASCII A 1000001 01000001 11000001ASCII T 1010100 11010100 01010100