Uploaded by ksh2000go

ch1

advertisement
Ch. 1 Digital systems and information
 Information representation
 Number systems
 Arithmetic operations
 Decimal codes
 Alphanumeric codes
 Gray codes
1
디지털공학
Information representation
 Continuous vs discrete
 Continuous
 in most physical world, taking on all possible value over a defined
range
 Discrete
 in the man-made world
 Analog signal vs digital signal
 Analog signal
 continuous
 Digital signal
 Taking on discrete values that occupy only a finite number of
values over a range
 Binary
 Two discrete values used in most digital systems, called 0 and 1
2
디지털공학
 Example of voltage ranges and waveforms for binary signals
 High vs. low
 Bit
 A binary digit
 Information is represented in digital computers by groups of bits
 Positive logic vs. negative logic
 Positive logic (convention)
 TRUE and 1 → HIGH
 FALSE and 0 → LOW
3
디지털공학
 Digital computer
Central
processing
unit
Performing arithmetic
and other data-processing
operations as specified
by the program
 Embedded system
and Analog
Output Devices
4
디지털공학
 Ex) Temperature measurement
and display
 Fahrenheit
9
[o F ]  [o C ]   32
5
5
디지털공학
Number systems
 Decimal number system
 Base or radix 10
 An-1An-2…A1A0.A-1A-2…A-m+1A-m
 Each coefficient Ai: one of 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
 The coefficients are multiplied by powers of 10
724.5  7 102  2 101  4 100  5 101
 In general, a number in base r
 An-1An-2…A1A0.A-1A-2…A-m+1A-m = An-1ⅹrn-1+An-2ⅹrn-2+…+A1
ⅹr1+A0ⅹr0+A-1ⅹr-1+A-2ⅹr-2+…+A-m+1ⅹr-m+1+A-mⅹr-m
 “.”: radix point
 An-1: the most significant digit
 A-m: the least significant digit
 Ex) (312.4)5  3  52  1 51  2  50  4  51
 75  5  2  0.8  (82.8)10
6
디지털공학
 Alternative method to reduce the number of operations
 (…((An-1r+An-2)r+An-3)r+…+A1)r+A0+(A-1+(A-2+(A-3+…+(A-m+1+A-mr -1)r -1)r 1…)r -1)r -1)r -1
1
 Ex) (312.4)5  ((3  5  1)  5)  2  4  5
 16  5  2  0.8  (82.8)10
 Binary number
 A base 2 system with two digits: 0 and 1
 The decimal equivalent of a binary number
 (11010) 2  1 2  1 2  0  2  1 2  0  2  (26)10
 In a digital system
4

3
2
1
0
210 → K (kilo), 220 → M (mega), 230 → G (giga), 240 → T (tera)
 The conversion of a decimal number, N, to binary
 First, find the greatest number that is a power of two and that, subtracted
from N, produces a positive difference (N1)
 Find the greatest number that is a power of two and that, subtracted from
N1, produces a positive difference (N2)
 Continue the procedure until the difference is zero
7
디지털공학
 Ex) 625  512  113  N1
512  29
113  64  49  N 2
64  26
49  32  17  N 3 32  25
17  16  1  N 4 16  24
1  1  0  N 5 1  20
(625)10  29  26  25  24  20  (1001110001) 2
 Octal number
 A base 8 system with digits 0, 1, 2, 3, 4, 5, 6, 7
 (127.4)8  1 82  2  81  7  80  4  81  (87.5)10
 The conversion from binary to octal
 Each octal digit corresponds to three binary digits
 Partitioning the binary number into groups of three bits each, starting from
the binary point and proceeding to the left and to the right
(010 110 001 101 011.111 100 000 110) 2  (26153.7406)8
8
디지털공학
 Hexadecimal number
 A base 16 system
 The values 10, 11, 12, 13, 14, 15 → A, B, C, D, E, F in a hexadecimal number
 ( B65F )16  11163  6 162  5 161  15 160  (46687)10
 Conversion from binary to hexadecimal
 Each hexadecimal digit corresponds to four binary digits
(0010 1100 0110 1011.1111 0000 0110) 2  (2C 6 B.F 06)16
 Conversion from hexadecimal to binary
 Each hexadecimal digit is converted to its 4-bit binary equivalent
(3 A6.C )16  0011 1010 0110.1100  (1110100110.11) 2
9
디지털공학
 Numbers with different bases
Decimal (base 10)
Binary (base 2)
Octal (base 8)
Hexadecimal (base16)
00
0000
00
0
01
0001
01
1
02
0010
02
2
03
0011
03
3
04
0100
04
4
05
0101
05
5
06
0110
06
6
07
0111
07
7
08
1000
10
8
09
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
10
디지털공학
Arithmetic operators
 Addition of two binary numbers
 Carries:
00000
101100
Augend: 01100
10110
Addend: +10001
+10111
Sum:
11101
101101
 Any carry obtained in a given position is added to the bits in
the column one significant position higher
 Subtraction of two binary numbers
 Borrows:
00000
00110
00110
Minuend:
10110
10110
10011
11110
Subtrahend: -10010 -10011
-11110
-10011
Difference: 00100
00011
-01011
 A borrow into a given column adds 2 to the minuend bit
11
디지털공학
 Binary multiplication
 Multiplicand:
Multiplier:
Product:
1011
x 101
1011
0000
1011
110111
12
디지털공학
 Conversion from decimal to other bases
 If the number includes a radix point, separate the number into an
integer part and a fraction part
 The conversion of a decimal integer to a number in base r
 Dividing the number and all successive quotients by r and accumulating
the remainders
 Ex) conversion of decimal integers to octal
 153/8 = 19 + 1/8 remainder = 1

19/8 = 2 + 3/8
=3

2/8 = 0 + 2/8
=2
 → (153)10=(231)8
least significant number
most significant number
 Ex) conversion of decimal integers to binary







41/2 = 20 + 1/2 remainder = 1
20/2 = 10 + 0/2
=0
10/2 = 5 + 0/2
=0
5/2 = 2 + 1/2
=1
2/2 = 1 + 0/2
=0
1/2 = 0 + 1/2
=1
→ (41)10=(101001)2
13
디지털공학
 Example 1-2, 1-3
 Conversion of a decimal fraction to base r
 Multiplication by r is used instead of division
 Integers are accumulated instead of remainders
 Ex) conversion of decimal fractions to binary





0.6875 x 2 = 1.3750 integer = 1
0.3750 x 2 = 0.7500
=0
0.7500 x 2 = 1.5000
=1
0.5000 x 2 = 1.0000
=1
→ (0.6875)10=(0.1011)2
most significant number
least significant number
 Ex) conversion of decimal fractions to octal






Convert decimal 0.513 to a three-digit octal fraction
0.513 x 8 = 4.104 integer = 4
0.104 x 8 = 0.832
=0
0.832 x 8 = 6.656
=6
0.656 x 8 = 5.248
=5
→ (0.513)10=(0.407)8
14
디지털공학
Decimal codes
 Binary coded decimal (BCD)
 Arranging four bits into 10 distinct combinations
 Ex) decimal 396
 Represented in BCD with 12 bits as 0011 1001 0110
 A BCD number needs more bits than its equivalent binary value.
 Ex) (185)10=(0001 1000 0101)BCD=(10111001)2
 The BCD value has 12 bits
 The equivalent binary number needs only 8bits
 BCD addition
 Two decimal digits: 0~19
 in binary, from 0000 to 10011
 In BCD, from 0000 to 1 1001
 When the binary sum is less than 1010 without a carry
 The corresponding BCD digit is correct
 When the binary sum is greater than or equal to 1010
 The result is an invalid BCD digit
 The addition of binary 6, (0110)2, to the sum converts it to the correct digit
 6 = 16 (the carry in a 4-bits binary number )- 10(the carry in a BCD)
15
디지털공학
 Ex) BCD arithmetic
16
디지털공학
Alphanumeric codes
 ASCII character code
 The standard binary code for the alphanumeric characters
 94 characters that can be printed and 34 control characters beginning with
00
 The 26 uppercase letters, the 26 lowercase letters, the 10 numerals, and 32
special printable characters such as %, @ and $
17
디지털공학
 34 control characters: for routing data and arranging the printed text into a
prescribed format
 ASCII: a 7-bit code
 ASCII characters most often are stored one per byte, with the most significant
bit set to 0
18
디지털공학
 Parity bit
 To detect errors in data communication and processing
 An additional bit is added to define its parity
 Parity bit
 The extra bit to make the total number of 1s in the resulting code word either
even or odd
with even parity
with odd parity
1000001
01000001
11000001
1010100
11010100
01010100
 For even parity
 The extra bit in the most significant position of the code produces an even
number of 1s in the code
 For odd parity
 The extra bit produces an odd number of 1s in the code
19
디지털공학
Gray code
 Gray code
 Consecutive numbers differ in only one bit
Binary reflected Gray code
 Useful in coding the position of a continuous device
 If there is some uncertainty as to the exact position → only 1 bit is in doubt
 Cf) in a normal binary code, all 4 bits would change as it moved from 7 to 8
20
디지털공학
 Gray code for a counting sequence of n(=even) binary code
words
 Replacing each of the first n/2 numbers in the sequence with a code word
consisting of 0 followed by the even parity for each bit of the binary code
word and the bit to its left
 Ex) for the binary code word 0100
 the Gray code word is 0, parity(0,1), parity(1,0), parity(0,0) = 0110
 Taking the sequence of numbers and copying it in reverse order with
leftmost 0 replaced by a 1
 Ex) for BCD codes,
 The first five Gray codes, 0000, 0001, 0011, 0010, 0110
 Reversing the order of these codes and replacing the leftmost 0 with a 1
 1110, 1010, 1011, 1001, 1000
21
디지털공학
 etc
 Hamming code
 Single-error-correction code
 Check bits are added to the information bits
 If at most 1 bit is changed, the original value can be restored
 Number the bits starting at 1
 Check bits: a power of 2 (1, 2, 4, 8)
 The check bit
 Chosen so that the total number of 1’s in the bits selected is even (referred
to as a parity check)
a1  a3  a5  a7
a2  a3  a6  a7
a4  a5  a6  a7
  : exclusive OR
 The result is 1 if and only if an odd number of the operands are
1
22
디지털공학
 When a word received,
e1  a1  a3  a5  a7
e2  a2  a3  a6  a7
e4  a4  a5  a6  a7
 If no errors were made, all three computation would produce 0
23
디지털공학
 Ex) received 0010011
 e1=0, e2=1, e4=0
 a2 is in error → the correct word is 0110011
 Ex) received 1101101
 e1=1, e2=0, e4=1
 a5 is in error → the correct word is 1101001
24
디지털공학
Homework
 Problems
 1-3, 1-6, 1-9, 1-12, 1-20, 1-28
25
디지털공학
Download