Informationcputnam/Comp516/Overheads/PDFChap03.pdf · 2009-03-19 · 1111 10110 11101 100100 10...
Transcript of Informationcputnam/Comp516/Overheads/PDFChap03.pdf · 2009-03-19 · 1111 10110 11101 100100 10...
Chapter
Information Representation
3
(a)
(c)
A seven-bit cell.
Some possible values in a
seven-bit cell.
0 1 1 0 1 0 1
1 1 0 1 1 0 0
0 0 0 0 0 0 0
Some impossible values in a
seven-bit cell.
6 8 0 7 2 5 1
J A N U A R Y
1 1 0 1 0
(b)
Figure 3.1
(a)
(c)
A seven-bit cell.
Some possible values in a
seven-bit cell.
0 1 1 0 1 0 1
1 1 0 1 1 0 0
0 0 0 0 0 0 0
Some impossible values in a
seven-bit cell.
6 8 0 7 2 5 1
J A N U A R Y
1 1 0 1 0
(b)
Figure 3.1(Continued)
(a)
(c)
A seven-bit cell.
Some possible values in a
seven-bit cell.
0 1 1 0 1 0 1
1 1 0 1 1 0 0
0 0 0 0 0 0 0
Some impossible values in a
seven-bit cell.
6 8 0 7 2 5 1
J A N U A R Y
1 1 0 1 0
(b) Figure 3.1(Continued)
0 7 14 21 28 35 1 8 15 22 29 36 2 9 16 23 30 37 3 10 17 24 31 38 4 11 18 25 32 . 5 12 19 26 33 . 6 13 20 27 34 .
Counting in decimal
0 7 16 25 34 43 1 10 17 26 35 44 2 11 20 27 36 45 3 12 21 30 37 46 4 13 22 31 40 . 5 14 23 32 41 . 6 15 24 33 42 .
Counting in octal
0 21 112 210 1001 1022 1 22 120 211 1002 1100 2 100 121 212 1010 1101 10 101 122 220 1011 1102 11 102 200 221 1012 . 12 110 201 222 1020 . 20 111 202 1000 1021 .
Counting in base 3
0 111 1110 10101 11100 100011 1 1000 1111 10110 11101 100100 10 1001 10000 10111 11110 100101 11 1010 10001 11000 11111 100110 100 1011 10010 11001 100000 . 101 1100 10011 11010 100001 . 110 1101 10100 11011 100010 .
Counting in binary
(b)(a) The place values for
10110 (bin).
1’s place
2’s place
4’s place
8’s place
16’s place
1 0 1 1 0
0
2
4
0
16
0
1
1
0
1
1’s place
2’s place
4’s place
8’s place
16’s place
=
=
=
=
=
22 (dec)
Converting 10110 (bin) to
decimal.
Figure 3.2
1’s place
10’s place
100’s place
1,000’s place
10,000’s place
5 8 0 63
Figure 3.3
(a) The binary number 10110.
1 2 0 14
2 21
0 20
1 22
5 10 8 0410
3 102
3 101 6 100
(b) The decimal number 58,036.
Figure 3.4
Remainders
Dividends
22
11
5
2
1
0
0
1
1
0
1
Figure 3.5
0 0 1 0 1 1 0
Figure 3.6
Binary addition rules
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10
– 0 0 1 0 1
Figure 3.7
Magnitude
Sign bit
Figure 3.8
• The NEG operation
‣ Taking the two’s complement
• The NOT operation
‣ Change the 1’s to 0’s and the 0’s to 1’s
• The two’s complement of a number is 1 plus its one’s complement
• NEG x = 1 + NOT x
The two’s complement rule
Decimal
–7
–6
–5
–4
–3
–2
–1
Binary
1001
1010
1011
1100
1101
1110
1111
Figure 3.9
Figure 3.10
Decimal
–8
–7
–6
–5
–4
–3
–2
–1
0
1
2
3
4
5
6
7
Binary
1000
1001
1010
1011
1100
1101
1110
1111
0000
0001
0010
0011
0100
0101
0110
0111
Decimal
–8
–7
–6
–5
–4
–3
–2
–1
0
1
2
3
4
5
6
7
Binary
1000
1001
1010
1011
1100
1101
1110
1111
0000
0001
0010
0011
0100
0101
0110
0111
1 1 1 1 0 1 1 0 1 0
1’s place
4’s place
32’s place
Figure 3.11
0 1 2 3 4 5 6 7
111110101100011010001000
Figure 3.12
–4 –3 –2 –1 0 1 2 3
011010001000111110101100
(b) Shifting the right part to the left side.
0 1 2 3 4 5 6 7
111110101100011010001000
(a) Breaking the number line in the middle.
Figure 3.13
–4 –3 –2 –1 0 1 2 3
32107654
Figure 3.14
The status bits• N = 1 if the result is negative
N = 0 otherwise
• Z = 1 if the result is all zeros
Z = 0 otherwise
• V = 1 if a signed integer overflow occurred
V = 0 otherwise
• C = 1 if an unsigned integer overflow occurred
C = 0 otherwise
p AND q
0
0
0
1
(a)
0
0
1
1
p q
0
1
0
1
p OR q
0
1
1
1
(b)
0
0
1
1
p q
0
1
0
1
p XOR q
0
1
1
0
(c)
0
0
1
1
p q
0
1
0
1
Figure 3.15
p AND q
0
0
0
1
(a)
0
0
1
1
p q
0
1
0
1
p OR q
0
1
1
1
(b)
0
0
1
1
p q
0
1
0
1
p XOR q
0
1
1
0
(c)
0
0
1
1
p q
0
1
0
1
p AND q
true
false
false
false
true
true
false
false
p
(a)
q
true
false
true
false
p OR q
true
true
true
false
(b)
true
true
false
false
p q
true
false
true
false
p XOR q
false
true
true
false
(c)
true
true
false
false
p q
true
false
true
false
Figure 3.16
p AND q
true
false
false
false
true
true
false
false
p
(a)
q
true
false
true
false
p OR q
true
true
true
false
(b)
true
true
false
false
p q
true
false
true
false
p XOR q
false
true
true
false
(c)
true
true
false
false
p q
true
false
true
false
Operation RTL Symbol
< >{ }
;
,
AND
OR
XOR
NOT
Implies
Transfer
Bit index
Informal description
Sequential separator
Concurrent separator
Figure 3.17
RTL specification of OR operation
c! a"b ; N! c< 0 , Z! c= 0
C
0
Figure 3.18
C! r"0# , r"0..4# ! r"1..5# , r"5# ! 0 ;
N! r < 0 , Z! r = 0 , V! {overflow}
Figure 3.19
RTL specification is a problem for the student
C
0 7 E 15 1C 23 1 8 F 16 1D 24 2 9 10 17 1E 25 3 A 11 18 1F 26 4 B 12 19 20 . 5 C 13 1A 21 . 6 D 14 1B 22 .
Counting in hexadecimal
(b)(a)
1’s place
16’s place
256’s place
4096’s place
8 B E 7
7
14
11
8
35,815
The place values for 8BE7. Converting 8BE7 to decimal.
1
16
256
4096 32,768
2,816
224
7
Figure 3.20
4
20
36
52
68
84
100
116
132
148
164
180
196
212
228
244
4
5
21
37
53
69
85
101
117
133
149
165
181
197
213
229
245
5
6
22
38
54
70
86
102
118
134
150
166
182
198
214
230
246
6
7
23
39
55
71
87
103
119
135
151
167
183
199
215
231
247
7
8
24
40
56
72
88
104
120
136
152
168
184
200
216
232
248
8
9
25
41
57
73
89
105
121
137
153
169
185
201
217
233
249
9 A
10
26
42
58
74
90
106
122
138
154
170
186
202
218
234
250
B
11
27
43
59
75
91
107
123
139
155
171
187
203
219
235
251
0_
1_
2_
3_
4_
5_
6_
7_
8_
9_
A_
B_
C_
D_
E_
F_
C
12
28
44
60
76
92
108
124
140
156
172
188
204
220
236
252
D
13
29
45
61
77
93
109
125
141
157
173
189
205
221
237
253
E
14
30
46
62
78
94
110
126
142
158
174
190
206
222
238
254
F
15
31
47
63
79
95
111
127
143
159
175
191
207
223
239
255
1
17
33
49
65
81
97
113
129
145
161
177
193
209
225
241
1
2
18
34
50
66
82
98
114
130
146
162
178
194
210
226
242
2
3
19
35
51
67
83
99
115
131
147
163
179
195
211
227
243
3
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
0
Figure 3.21
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Hexadecimal
Figure 3.22
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Hexadecimal
Char
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
Bin
000 0000
000 0001
000 0010
000 0011
000 0100
000 0101
000 0110
000 0111
000 1000
000 1001
000 1010
000 1011
000 1100
000 1101
000 1110
000 1111
001 0000
001 0001
001 0010
001 0011
001 0100
001 0101
001 0110
001 0111
001 1000
001 1001
001 1010
001 1011
001 1100
001 1101
001 1110
001 1111
Hex
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
Char
SP
Bin
010 0000
010 0001
010 0010
010 0011
010 0100
010 0101
010 0110
010 0111
010 1000
010 1001
010 1010
010 1011
010 1100
010 1101
010 1110
010 1111
011 0000
011 0001
011 0010
011 0011
011 0100
011 0101
011 0110
011 0111
011 1000
011 1001
011 1010
011 1011
011 1100
011 1101
011 1110
011 1111
Hex
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
Char Bin
100 0000
100 0001
100 0010
100 0011
100 0100
100 0101
100 0110
100 0111
100 1000
100 1001
100 1010
100 1011
100 1100
100 1101
100 1110
100 1111
101 0000
101 0001
101 0010
101 0011
101 0100
101 0101
101 0110
101 0111
101 1000
101 1001
101 1010
101 1011
101 1100
101 1101
101 1110
101 1111
Hex
40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
Char
DEL
Bin
110 0000
110 0001
110 0010
110 0011
110 0100
110 0101
110 0110
110 0111
110 1000
110 1001
110 1010
110 1011
110 1100
110 1101
110 1110
110 1111
111 0000
111 0001
111 0010
111 0011
111 0100
111 0101
111 0110
111 0111
111 1000
111 1001
111 1010
111 1011
111 1100
111 1101
111 1110
111 1111
Hex
60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F
70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F
Abbreviations for Control Characters
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
null, or all zeros
start of heading
start of text
end of text
end of transmission
enquiry
acknowledge
bell
backspace
horizontal tabulation
line feed
vertical tabulation
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
form feed
carriage return
shift out
shift in
data link escape
device control 1
device control 2
device control 3
device control 4
negative acknowledge
synchronous idle
end of transmission block
CAN
EM
SUB
ESC
FS
GS
RS
US
SP
DEL
cancel
end of medium
substitute
escape
file separator
group separator
record separator
unit separator
space
delete
Char
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
Bin
000 0000
000 0001
000 0010
000 0011
000 0100
000 0101
000 0110
000 0111
000 1000
000 1001
000 1010
000 1011
000 1100
000 1101
000 1110
000 1111
001 0000
001 0001
001 0010
001 0011
001 0100
001 0101
001 0110
001 0111
001 1000
001 1001
001 1010
001 1011
001 1100
001 1101
001 1110
001 1111
Hex
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
Char
SP
Bin
010 0000
010 0001
010 0010
010 0011
010 0100
010 0101
010 0110
010 0111
010 1000
010 1001
010 1010
010 1011
010 1100
010 1101
010 1110
010 1111
011 0000
011 0001
011 0010
011 0011
011 0100
011 0101
011 0110
011 0111
011 1000
011 1001
011 1010
011 1011
011 1100
011 1101
011 1110
011 1111
Hex
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
Char Bin
100 0000
100 0001
100 0010
100 0011
100 0100
100 0101
100 0110
100 0111
100 1000
100 1001
100 1010
100 1011
100 1100
100 1101
100 1110
100 1111
101 0000
101 0001
101 0010
101 0011
101 0100
101 0101
101 0110
101 0111
101 1000
101 1001
101 1010
101 1011
101 1100
101 1101
101 1110
101 1111
Hex
40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F
50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F
Char
DEL
Bin
110 0000
110 0001
110 0010
110 0011
110 0100
110 0101
110 0110
110 0111
110 1000
110 1001
110 1010
110 1011
110 1100
110 1101
110 1110
110 1111
111 0000
111 0001
111 0010
111 0011
111 0100
111 0101
111 0110
111 0111
111 1000
111 1001
111 1010
111 1011
111 1100
111 1101
111 1110
111 1111
Hex
60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F
70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F
Abbreviations for Control Characters
NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
HT
LF
VT
null, or all zeros
start of heading
start of text
end of text
end of transmission
enquiry
acknowledge
bell
backspace
horizontal tabulation
line feed
vertical tabulation
FF
CR
SO
SI
DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
form feed
carriage return
shift out
shift in
data link escape
device control 1
device control 2
device control 3
device control 4
negative acknowledge
synchronous idle
end of transmission block
CAN
EM
SUB
ESC
FS
GS
RS
US
SP
DEL
cancel
end of medium
substitute
escape
file separator
group separator
record separator
unit separator
space
delete
Figure 3.23(Continued)
Binary
1100 0001
1100 0010
1100 0011
·
·
·
1111 0000
1111 0001
1111 0010
·
·
·
A
B
C
·
·
·
0
1
2
·
·
·
EBCDIC
Figure 3.24
(b)(a) The place values for
101.011 (bin).
18’s place
14’s place
12’s place
1’s place
2’s place
0 1 0 1 1
0.125
0.25
0.0
1.0
0.0
1
1
0
1
0
18’s place
14’s place
12’s place
1’s place
2’s place
=
=
=
=
=
5.375 (dec)
Converting 101.011 (bin) to
decimal.
4’s place
1 .
4.01 4’s place =
Figure 3.25
(a) The binary number 101.011.
1 2 0 02
21
21
1 20
5 10 0 6210
1 100
7 101
2 102
1 103
(b) The decimal number 506.721.
1 22
1 23
Figure 3.26
.5859375
1 .171875
0 .34375
0 .6875
1 .375
0 .75
1 .5
1 .0
(b) Convert the fractional part
6.5859375
6 (dec) = 110 (bin)
(a) Convert the whole partFigure 3.27
.5859375
1 .171875
0 .34375
0 .6875
1 .375
0 .75
1 .5
1 .0
(b) Convert the fractional part
6.5859375
6 (dec) = 110 (bin)
(a) Convert the whole part
.2
0 .4
0 .8
1 .6
1 .2
0 .4
0 .8
1 .6
Figure 3.28
Significand
Exponent
Sign
Figure 3.29
Two’s
Decimal Excess 3 Complement
4 100
3 000 101
2 001 110
1 010 111
0 011 000
1 100 001
2 101 010
3 110 011
4 111
Figure 3.30
Special value• Zero
‣ Exponent field all 0’s
‣ Significand all 0’s
‣ There is a +0 and a –0
31.0 0.1328125 0.13281250.0 31.0
Neg
ativ
e over
flow
Neg
ativ
e norm
aliz
ed
Neg
ativ
e under
flow
Zer
o
Posi
tive
under
flow
Posi
tive
norm
aliz
ed
Posi
tive
over
flow
Figure 3.31
Special value• Infinity
‣ Exponent field all 1’s
‣ Significand all 0’s
‣ There is a +∞ and a –∞‣ Produced by operation that gives result in
overflow region
Special value• Not a Number (NaN)
‣ Exponent field all 1’s
‣ Significand nonzero
‣ Produced by illegal math operations
Special value• Denormalized number
‣ Exponent field all 0’s
‣ Significand nonzero
‣ Hidden bit is assumed to be 0 instead of 1
‣ If the exponent is stored in excess n for normalized numbers, it is stored in excess n – 1 for denormalized numbers
3.5 Floating Point Representation 123
Not a Number 1 111 nonzero
Negative infinity 1 111 0000 !"
Negative 1 110 1111 !1.1111 # 23 !15.5normalized 1 110 1110 !1.1110 # 23 !15.0
... ... ...1 011 0001 !1.0001 # 20 !1.06251 011 0000 !1.0000 # 20 !1.01 010 1111 !1.1111 # 2!1 !0.96875... ... ...1 001 0001 !1.0001 # 2!2 !0.2656251 001 0000 !1.0000 # 2!2 !0.25
Negative 1 000 1111 !0.1111 # 2!2 !0.234375denormalized 1 000 1110 !0.1110 # 2!2 !0.21875
... ... ...1 000 0010 !0.0010 # 2!2 !0.031251 000 0001 !0.0001 # 2!2 !0.015625
Negative zero 1 000 0000 !0.0
Positive zero 0 000 0000 +0.0
Positive 0 000 0001 0.0001 # 2!2 0.015625denormalized 0 000 0010 0.0010 # 2!2 0.03125
... ... ...0 000 1110 0.1110 # 2!2 0.218750 000 1111 0.1111 # 2!2 0.234375
Positive 0 001 0000 1.0000 # 2!2 0.25normalized 0 001 0001 1.0001 # 2!2 0.265625
... ... ...0 010 1111 1.1111 # 2!1 0.968750 011 0000 1.0000 # 20 1.00 011 0001 1.0001 # 20 1.0625... ... ...0 110 1110 1.1110 # 23 15.00 110 1111 1.1111 # 23 15.5
Positive infinity 0 111 0000 +"
Not a Number 0 111 nonzero
ScientificBinary notation Decimal
Figure 3.32Floating point values for a three-bitoperand and four-bit significand.
Figure 3.32
3.5 Floating Point Representation 123
Not a Number 1 111 nonzero
Negative infinity 1 111 0000 !"
Negative 1 110 1111 !1.1111 # 23 !15.5normalized 1 110 1110 !1.1110 # 23 !15.0
... ... ...1 011 0001 !1.0001 # 20 !1.06251 011 0000 !1.0000 # 20 !1.01 010 1111 !1.1111 # 2!1 !0.96875... ... ...1 001 0001 !1.0001 # 2!2 !0.2656251 001 0000 !1.0000 # 2!2 !0.25
Negative 1 000 1111 !0.1111 # 2!2 !0.234375denormalized 1 000 1110 !0.1110 # 2!2 !0.21875
... ... ...1 000 0010 !0.0010 # 2!2 !0.031251 000 0001 !0.0001 # 2!2 !0.015625
Negative zero 1 000 0000 !0.0
Positive zero 0 000 0000 +0.0
Positive 0 000 0001 0.0001 # 2!2 0.015625denormalized 0 000 0010 0.0010 # 2!2 0.03125
... ... ...0 000 1110 0.1110 # 2!2 0.218750 000 1111 0.1111 # 2!2 0.234375
Positive 0 001 0000 1.0000 # 2!2 0.25normalized 0 001 0001 1.0001 # 2!2 0.265625
... ... ...0 010 1111 1.1111 # 2!1 0.968750 011 0000 1.0000 # 20 1.00 011 0001 1.0001 # 20 1.0625... ... ...0 110 1110 1.1110 # 23 15.00 110 1111 1.1111 # 23 15.5
Positive infinity 0 111 0000 +"
Not a Number 0 111 nonzero
ScientificBinary notation Decimal
Figure 3.32Floating point values for a three-bitoperand and four-bit significand.
Figure 3.32(Continued)
Bits 1 8 23
Bits 1 11 52
(a) Single precision
(b) Double precision
Figure 3.33
NevadaCalifornia
Las Vegas
Santa Barbara
San Francisco
Sacramento
Reno
40
60
40
65
55
70
Palm Springs
San Diego
Los Angeles
70
60
35
45
40
80
50
30
Figure 3.34
4 San Francisco
5 Sacramento
6 Reno
7 Las Vegas
0
1
2
3
4
5
6
7
1e30
35
45
40
55
65
80
70
0
City Numbers
0 Los Angeles
1 San Diego
2 Palm Springs
3 Santa Barbara
35
1e30
30
1e30
1e30
1e30
1e30
1e30
1
45
30
1e30
1e30
1e30
1e30
1e30
60
2
40
1e30
1e30
1e30
70
1e30
1e30
1e30
3
55
1e30
1e30
70
1e30
40
60
1e30
4
65
1e30
1e30
1e30
40
1e30
40
1e30
5
80
1e30
1e30
1e30
60
40
1e30
50
6
70
1e30
60
1e30
1e30
1e30
50
1e30
7
Figure 3.35
Route
number
0
1
2
3
4
5
6
7
8
9
10
11
12
13
Cost
35
45
40
55
65
80
70
30
60
70
40
60
40
50
From
0
0
0
0
0
0
0
1
2
3
4
4
5
6
To
1
2
3
4
5
6
7
2
7
4
5
6
6
7
Figure 3.36