슬라이드 1 - Tistory

Download Report

Transcript 슬라이드 1 - Tistory

Nonlinear & Neural Networks LAB.
CHAPTER 1
INTRODUCTION
NUMBER SYSTEMS AND CONVERSION
1.1
1.2
1.3
1.4
1.5
Digital Systems and Switching Circuits
Number Systems and Conversion
Binary Arithmetic
Representation of Negative Numbers
Binary Codes
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”
Good things in Binary Number
- 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)…)
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
Decimal:
953.7810  9 102  5 101  3100  7 101  8 102
Binary:
1011.112  1 23  0  2 2  1 21  1 20  1 2 1  1 2 2
 8  0  2 1
1 1
3
  11  11.7510
2 4
4
N  (a4 a3a2 a1a0 .a1a2 a3 ) R
Radix(Base):
 a4  R 4  a3  R 3  a2  R 2  a1  R1  a0  R 0
 a1  R 1  a2  R 2  a3  R 3
Example:
147.38  1 82  4  81  7  80  3  81  64  32  7 
3
8
 103.37510
Hexa-Decimal:
A2F16  10162  2 161 15160  2560 32  15  260710
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Conversion of Decimal to Base-R
N  (anan1    a2a1a0 ) R  an Rn  an1Rn1      a2 R2  a1R1  a0
N
 an R n 1  an 1 R n  2      a2 R1  a1  Q1 , remainder a0
R
Q1
 an R n  2  an 1 R n 3      a3 R1  a2  Q2 , remainder a1
R
Q2
 an R n 3  an 1 R n  4      a3  Q3 , remainder a2
R
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Example: Decimal to Binary Conversion
2
53
2
26
rem. = 1 = a0
2
13
rem. = 0 = a1
2
6
rem. = 1 = a2
2
3
rem. = 0 = a3
2
1
rem. = 1 = a4
0
rem. = 1 = a5
5310  1101012
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Conversion of a decimal fraction to Base-R
F  (.a1a2a3    am ) R  a1R1  a2 R2  a3 R3      am Rm
FR  a1  a2 R1  a3 R2      am Rm1  a1  F1
F1R  a2  a3 R1      am Rm2  a2  F2
F2 R  a3      am Rm3  a3  F3
Example:
F  .625

2
1.250
(a1  1)
F1  .250
F2  .500
 2
0.500
( a  2  0)
 2
1.000
(a3  1)
.62510  .1012
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Example: Convert 0.7 to binary
.7
2
(1).4
2
(0).8
2
(1).6
2
(1).2
2
(0).4
2
Process starts repeating here because .4 was previously
obtained
(0).8
0.710  0.1 011001100110  2
Nonlinear & Neural Networks LAB.
1.2 Number Systems and Conversion
Example: Convert 231.3 to base-7
231 .34  2 16  3  4  1 
7
45
7
6
rem.3
0
rem.6
.75
7
(5).25
3
 45.7510
4
45.7510  63.5151  7
7
(1).75
7
(5).25
7
(1).75
1001101.0101112  0100
 1101
 0101
 1100
  4D.5C16
4
D
5
C
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
=(
(1101101000)2
=(
)16, Hexadecimal
)16, Hexadecimal
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Addition
000
0 1  1
1 0 1
1 1  0
Example:
and carry 1 to the next column
1111
carries
1310  1101
1110  1011
11000 2410
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Subtraction
00  0
0 1  1
1 0 1
1 1  0
and borrow 1 from the next column
Example:
1
11101
 10011
1010
(indicates
a borrow
From the
3rd column)
1111
10000

11
1101
borrows
111
111001
 1011
101110
borrows
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Subtraction Example with Decimal
column 2
205
 18
187
205 18  [2 102  0 101  5 100 ]
[
column 1
1101  8 100 ]
note borrow from column 1
 [2 102  (0  1) 101  (10  5) 100 ]
[
1101 
8 100 ]
note borrow from column 2
 [(2  1) 102  (10  0  1) 101  15100 ]
[
 [1102
1) 101  8 100 ]
 8 101
 7 100 ]  187
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Multiplication
Multiply: 13 x11(10)
00  0
0 1  0
1 0  0
1 1  1
1101
1011
1101
1101
0000
1101
10001111 14310
1111
1011
1111
multiplicand
multiplier
first partial product
second partial product
0000
(01111) sum of first two partial products
third partial product
1111
(1001011
) sum after adding third partial product
fourth partial product
1111
11000011 final product (sum after adding fourth partial prodoct)
Nonlinear & Neural Networks LAB.
1.3 Binary Arithmetic
Division
1101
1011 10010001
1011
1110
1011
1101
1011
The quotient is 1101 with a remainder
of 10.
10
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
bn – 1
b1
b0
b1
b0
Magnitude
MSB
(a) Unsigned number
bn – 1 bn – 2
Magnitude
Sign
0 denotes +
MSB
1 denotes
–
(b) Signed number
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
2’s complement representation for Negative Numbers
N *  2n  N
Negative integers
+N
+0
+1
+2
+3
+4
+5
+6
+7
Positive
integers
(all systems)
0000
0001
0010
0100
0101
0110
0111
-N
Sign and
magnitude
2’s complement
N*
1’s complement
N
-0
-1
-2
-3
-4
-5
-6
-7
-8
1000
1001
1010
1011
1100
1101
1110
1111
-
1111
1110
1101
1100
1011
1010
1001
1000
1111
1110
1101
1100
1011
1010
1001
1000
-
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
1’s complement representation for Negative Numbers
N  (2 n  1)  N
Example:
2n  1  111111
N  010101
N  101010
N*  2n  N  (2n 1  N )  1  N  1
== 2’s complement: 1’s complement + ‘1’
N  2n  N * and N  (2n 1)  N
2n  2n1  2n1
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Number
Addition of 2’s complement Numbers
Case 1
Case 2
Case 3
3
4
7
0011
0100
0111
5
0101
6
0110
1011
5
6
Case 4
5
6
0101
1010
1111
(correct answer)
wrong answer because of overflow (+11 requires
5 bits including sign)
(correct answer)
1011
0110
(1)0001
correct answer when the carry from the sign bit
is ignored (this is not an overflow)
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
Addition of 2’s complement Numbers
Case 5
3
4
7
1101
1100
(1)1001
Case 6
5
6
correct answer when the last carry is ignored
(this is not an overflow)
1011
1010
(1)0101
wrong answer because of overflow
(-11 requires 5 bits including sign)
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
Addition of 1’s complement Numbers
Case 3
Case 4
5
6
1
5
6
Case 5
5
6
0101
1001
1110
(correct answer)
1010
0110
(1) 0000
1 (end-around carry)
0001 (correct answer, no overflow)
1100
1011
(1) 0111
1 (end-around carry)
1000 (correct answer, no overflow)
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
Addition of 1’s complement Numbers
Case 6
1010
5
6
1001
(1) 0011
1 (end-around carry)
0100 (wrong answer because of overflow)
Case 4 :  A  B (where B  A)
A  B  (2n  1  A)  B  2n  ( B  A)  1
Case 5 :
 A  B ( A  B  2n1 )
A  B  (2n  1  A)  (2n  1  B)  2n  [2n  1  ( A  B)]  1
Nonlinear & Neural Networks LAB.
1.4 Representation of Negative Numbers
Addition of 1’s complement Numbers
11110100
11101011
(1) 11011111
1
11100000 30
(11)
 (20)
(end-around carry)
Addition of 2’s complement Numbers
(8)
 19
(1)00001011  11
11111000
00010011
(end-around carry)
Nonlinear & Neural Networks LAB.
1.5 Binary Codes
9 3 7.2 5
    
1001 0011 0111 . 0010 0101
Decimal
Digit
0
1
2
3
4
5
6
7
8
9
8-4-2-1
Code
(BCD)
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
6-3-1-1
Code
0000
0001
0011
0100
0101
0111
1000
1001
1011
1100
Excees-3
Code
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
2-out-of-5
Code
00011
00101
00110
01001
01010
01100
10001
10010
10100
11000
Gray
Code
0000
0001
0011
0010
0110
1110
1010
1011
1001
1000
Nonlinear & Neural Networks LAB.
1.5 Binary Codes
6-3-1-1 Code:
N  w3a3  w2a2  w1a1  w0a0
N  6 1  3  0  1 1  1 1  8
ASCII Code
1010011 1110100 1100001 1110010 1110100
S
t
a
r
t
Nonlinear & Neural Networks LAB.