+ CS 325: CS Hardware and Software Organization and Architecture Gates and Boolean Algebra Part 2.
CS 325: CS Hardware and Software Organization and Architecture
-
Upload
avram-tucker -
Category
Documents
-
view
26 -
download
0
description
Transcript of CS 325: CS Hardware and Software Organization and Architecture
+ CS 325: CS Hardware and SoftwareOrganization and Architecture
Integers and Arithmetic
+Outline
Number Representation Decimal Binary Hexadecimal
Decimal vs. Hexadecimal vs. Binary
Number Conversions Dec Bin, Dec Hex Bin Dec, Bin Hex Hex Dec, Hex Bin
+Decimal Numbers: Base 10
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Example: 4923 =
(4x103) + (9x102) + (2x101) + (3x100)
+Number Base:
Number with base x x digits:Base 10 (Decimal): 0, 1, 2, 3, 4 ,5 ,6 ,7 , 8,
9Base 2 (Binary): 0, 1
Number representation:d31d30d29….d2d1d0 is a 32 digit number
4326210 is a 5 digit base 10 (Dec) number
101011010112 is a 11 digit base 2 (Bin) number
+Binary Numbers: Base 2
Digits: 0, 1
Example:101011=
(1x25) + (0x24) + (1x23) + (0x22) + (1x21) + (1x20)
= 4310
What about a base that converts to binary easily?
32 16 8 4 2 1
25 24 23 22 21 20
1 0 1 0 1 1
+Hexadecimal Numbers: Base 16
Digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Decimal digits + A – F
Example:12E = (1x162) + (2x161) + (Ex160) = 30210
A B C D E F
10 11 12 13 14 15
+Decimal vs. Hexadecimal vs. BinaryDEC HEX BIN
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
DEC HEX BIN
16 10 0001 0000
17 11 0001 0001
18 12 0001 0010
19 13 0001 0011
20 14 0001 0100
21 15 0001 0101
22 16 0001 0110
23 17 0001 0111
24 18 0001 1000
25 19 0001 1001
26 1A 0001 1010
27 1B 0001 1011
28 1C 0001 1100
29 1D 0001 1101
30 1E 0001 1110
31 1F 0001 1111
+Number Conversion: Dec Bin
Converting from base 10 to base 2: Continue dividing decimal number by 2 and keep the remainder
Example: 3510
1000112
35/2 17 1 LSB
17/2 8 1
8/2 4 0
4/2 2 0
2/2 1 0
1/2 0 1 MSB
+Number Conversion: Dec Bin
Example: Convert 42310 to Bin
1101001112
+Number Conversion: Dec Hex
Converting from base 10 to base 16:
Example: 3510
2316
35/16 2 3 LSB
2/16 0 2 MSB
+Number Conversion: Dec Hex
Example: Convert 21010 to Hex
D216
+Number Conversion: Bin Dec
Converting from base 2 to base 10:
Example: 110102
(1x24) + (1x23) + (0x22) + (1x21) + (0x20)
16 + 8 + 0 + 2 + 0 = 2610 16 8 4 2 1
1 1 0 1 0
MSB LSB
+Number Conversion: Bin Dec
Example: Convert 101011102 to Dec
17410
+Number Conversion: Bin Hex
Converting from base 2 to base 16:
Example: 110101102 1 Hex digit represents 16 Decimal values 4 Binary digits represent 16 Decimal values 1 Hex digit replaces 4 Binary digits
D616
1 1 0 1 0 1 1 0
13 D 6
+Number Conversion: Bin Hex
Example: Convert 110011112 to Hex
CF16
+Number Conversion: Hex Dec
Converting from base 16 to base 10:
Example: 8E316
(8x162) + (Ex161) + (3x160)
2048 + 224 + 3 = 227510
+Number Conversion: Hex Dec
Example: Convert 63F16 to Dec
159910
+Number Conversion: Hex Bin
Converting from base 16 to base 2:
Example: 9A2E16
10011010001011102
9 1001 MSB
A 1010
2 0010
E 1110 LSB
+Number Conversion: Hex Bin
Example: Convert 26FA16 to Bin
100110111110102
+What to do with representations of numbers?
add, subtract, multiply, divide, compare
Example: 8 + 6 = 14
1 0 0 0
+0 1 1 0
1 1 1 0
Simple enough to add in binary that we can build circuits to do it.
+Which base do we use?
Decimal: Great for human, especially when doing arithmetic
Hex: Easier for humans to read than long strings of binary numbers. Easy to convert to binary, each hex decimal = 4 binary bits.
Binary: used by all computers. Bin represents an abstraction…but and abstraction of what?
+The Transistor
A controlled switch.Collector – positive leadEmitter – negative leadBase – control lead
A binary “1” represents an active transistor.
+The Transistor
+Limits of Computer Numbers
Bits can represent anythingCharacters
‘a’, ‘F’7 bit ASCII, 8 bit Extended ASCII
Logical Values0 False, 1 True
Colors?Locations/addresses? Commands?But N bits only 2N things