Upload
marvin-ralph-reed
View
218
Download
0
Embed Size (px)
Citation preview
Nonlinear & Neural Networks LAB.
CHAPTER 1
INTRODUCTION NUMBER SYSTEMS AND CONVERSION
1.1 Digital Systems and Switching Circuits1.2 Number Systems and Conversion1.3 Binary Arithmetic1.4 Representation of Negative Numbers1.5 Binary Codes
Nonlinear & Neural Networks LAB.
Objectives
Topics introduced in this chapter:
• Difference between Analog and Digital System
• Difference between Combinational and Sequential Circuits
• Binary number and digital systems
• Number systems and Conversion
• Add, Subtract, Multiply, Divide Positive Binary Numbers
• 1’s Complement, 2’s Complement for Negative binary number
• BCD code, 6-3-1-1 code, excess-3 code
Nonlinear & Neural Networks LAB.
1.1 Digital Systems and Switching Circuits
• Digital systems: computation, data processing, control,
communication, measurement
- Reliable, Integration• Analog – Continuous
- Natural Phenomena
(Pressure, Temperature, Speed…)
- Difficulty in realizing, processing using electronics
• Digital – Discrete
- Binary Digit Signal Processing as Bit unit
- Easy in realizing, processing using electronics
- High performance due to Integrated Circuit Technology
Nonlinear & Neural Networks LAB.
Binary Digit?
• Binary:- Two values(0, 1)
- Each digit is called as a “bit”
- Number representation with only two values (0,1)
- Can be implemented with simple electronics devices
(ex: Voltage High(1), Low(0)
Switch On (1) Off(0)…)
Good things in Binary Number
Nonlinear & Neural Networks LAB.
Switching Circuit
• Combinational Circuit :
outputs depend on only present inputs, not on past inputs
• Sequential Circuit:
- outputs depend on both present inputs and past inputs
- have “memory” function
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
33
22
11
00
11
22
33
44
32101234
).(
RaRaRa
RaRaRaRaRa
aaaaaaaaN R
10
10128
375.1038
373264838784813.147
2101210 10810710310510978.953
10
2101232
75.114
311
4
1
2
11208
21212121202111.1011
Decimal:
Binary:
Radix(Base):
Example:
10012
16 260715322560161516216102 FAHexa-Decimal:
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
01
12
21
10121 )( aRaRaRaRaaaaaaN nn
nnRnn
0111
22
11 remainder , aQaRaRaRa
R
N nn
nn
1221
33
121 remainder , aQaRaRaRa
R
Q nn
nn
2334
132 remainder , aQaRaRa
R
Q nn
nn
Conversion of Decimal to Base-R
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Example: Decimal to Binary Conversion
532
262
132
62
32
12
rem. = 1 = a0
rem. = 0 = a1
rem. = 1 = a2
rem. = 0 = a3
rem. = 1 = a4
0 rem. = 1 = a5
210 11010153
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
mmRm RaRaRaRaaaaaF
33
22
11321 )(.
1112
31
21 FaRaRaRaaFR mm
2221
321 FaRaRaaRF mm
333
32 FaRaaRF mm
)1(
250.1
2
625.
1
a
F
)0(
500.0
2
250.
2
1
a
F
)1(
000.1
2
500.
3
2
a
F
210 101.625.
Conversion of a decimal fraction to Base-R
Example:
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Example: Convert 0.7 to binary
8).0(
2
4).0(
2
2).1(
2
6).1(
2
8).0(
2
4).1(
2
7.
Process starts repeating here because .4 was previouslyobtained
210 0110 0110 0110 1.07.0
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
1654
2 5.41100 0101 1101 0100010111.1001101 CDCD
Example: Convert 231.3 to base-7
104 75.454
31431623.231
457
67
0 rem.6
rem.3
75).1(
7
25).5(
7
75).1(
7
25).5(
7
75.
710 5151.6375.45
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Conversion of Binary to Octal, Hexa-decimal
(101011010111 )2 = ( )8, octal
(10111011)2 = ( )8, octal
(1010111100100101)2 = ( )16, Hexadecimal
(1101101000)2 = ( )16, Hexadecimal
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
10
10
10
24 11000
1011 11
1011 13
1111
carries
Addition
Example:
01 1
10 1
11 0
00 0
and carry 1 to the next column
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
01 1
10 1
11 0
00 0
and borrow 1 from the next column
1010
00111
11101
1
(indicatesa borrowFrom the3rd column)
1101
11
10000
11 1 1
borrows
101110
0111
111001
11 1
borrows
Subtraction
Example:
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
187]107 108 101[
]108 101) [
]101510)1010(10)12[(
]108 101 [
]10)510(10)10(102[
]108101 [
]105100102[18205
012
01
012
01
012
01
012
note borrow from column 1
note borrow from column 2
Subtraction Example with Decimal
187
18
205
column 2 column 1
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
111
001
010
000
1014310001111
1101
0000
1101
1101
1011
1101
11000011
1111
)1001011(
1111
)01111(
0000
1111
1011
1111 multiplicand
multiplier
first partial product
second partial product
sum of first two partial products
third partial product
sum after adding third partial product
fourth partial product
final product (sum after adding fourth partial prodoc
t)
Multiplication Multiply: 13 x11(10)
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Division
10
1011
1101
1011
1110
1011
10010001 1011
1101
The quotient is 1101 with a remainderof 10.
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
bn 1– b1 b0
Magnitude
MSB
(a) Unsigned number
bn 1– b1 b0
MagnitudeSign
(b) Signed number
bn 2–
0 denotes1 denotes
+
–
MSB
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
NN n 2*
2’s complement representation for Negative Numbers
1111
1110
1101
1100
1011
1010
1001
1000
-
-
1111
1110
1101
1100
1011
1010
1001
1000
1000
1001
1010
1011
1100
1101
1110
1111
-
-0
-1
-2
-3
-4
-5
-6
-7
-8
0000
0001
0010
0100
0101
0110
0111
+0
+1
+2
+3
+4
+5
+6
+7
1’s complement 2’s complement N*
Sign and
magnitude
Negative integers
-N
Positive
integers
(all systems)+N N
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
101010
010101
11111112
N
N
n
11)12(2* NNNN nn
NNNN nn )12( and *2
11 222 nnn
1’s complement representation for Negative Numbers
NN n )12(
Example:
== 2’s complement: 1’s complement + ‘1’
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Number
6
5
1011
0110
0101
wrong answer because of overflow (+11 requires5 bits including sign)
6
5
1111
1010
0101
(correct answer)
6
5
0001)1(
0110
1011
correct answer when the carry from the sign bitis ignored (this is not an overflow)
Case 1
Case 2
Case 3
Case 4
Addition of 2’s complement Numbers
7
4
3
0111
0100
0011
(correct answer)
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
7
4
3
1001)1(
1100
1101
correct answer when the last carry is ignored(this is not an overflow)
6
5
0101)1(
1010
1011
wrong answer because of overflow (-11 requires 5 bits including sign)
Case 5
Case 6
Addition of 2’s complement Numbers
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
1
6
5
1110
1001
0101
(correct answer)
(end-around carry)(correct answer, no overflow)
6
5
0001
1
0000 )1(
0110
1010
(end-around carry)(correct answer, no overflow)
6
5
1000
1
0111 )1(
1011
1100
Case 3
Case 4
Case 5
Addition of 1’s complement Numbers
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
(end-around carry)(wrong answer because of overflow)
6
5
0100
1
0011 )1(
1001
1010
1)(2)12(
) (where :4
ABBABA
ABBACasenn
1)](12[2)12()12(
)2( :5 1
BABABA
BABACasennnn
n
Case 6
Addition of 1’s complement Numbers
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
)20(
)11(
3011100000
1
11011111 )1(
11101011
11110100
(end-around carry)
11
19
)8(
00010110)1(
00010011
11110001
(end-around carry)
Addition of 1’s complement Numbers
Addition of 2’s complement Numbers
Nonlinear & Neural Networks LAB.
1.5 Binary Codes
Decimal
Digit
8-4-2-1
Code
(BCD)
6-3-1-1
Code
Excees-3
Code
2-out-of-5
Code
Gray
Code
0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0000
0001
0011
0100
0101
0111
1000
1001
1011
1100
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
00011
00101
00110
01001
01010
01100
10001
10010
10100
11000
0000
0001
0011
0010
0110
1110
1010
1011
1001
1000
5 2 . 7 3 9
0101 0010 . 0111 0011 1001
Nonlinear & Neural Networks LAB.
1.5 Binary Codes
00112233 awawawawN
811110316 N
1010011 1110100 1100001 1110010 1110100
S t a r t
6-3-1-1 Code:
ASCII Code