co2-crr
Transcript of co2-crr
-
8/8/2019 co2-crr
1/19
2 November 2010 C.Ravindra Murthy 1
Computer Organization
C.Ravindra Murthy
-
8/8/2019 co2-crr
2/19
2 November 2010 C.Ravindra Murthy 2
Data Types Information that a computer is dealing with:
Data
Numeric Data Integer, real
Non-Numeric Data Letters, Symbols
Relationship between data elements Data Structures
Linear Lists, Trees, Queues, etc.,
Programs Instructions
-
8/8/2019 co2-crr
3/19
2 November 2010 C.Ravindra Murthy 3
Data Types: Numeric Data
Representation Non-positional number System
Roman number system
Positional number System Each digit position has a value called a weight associated with it
Examples: Decimal, Octal, Hexadecimal, Binary
Base (or radix) R number Uses R distinct symbols for each digit
Example AR = an-1, an-2, .. a1, a0, a-1, a-m V(AR) = SUM (ak* R
k) for k = -m to n-1 R = 10 Decimal number System
R = 2 Binary
R = 8 Octal
R = 16 Hexadecimal
-
8/8/2019 co2-crr
4/19
2 November 2010 C.Ravindra Murthy 4
Data Types: Numeric Data
Representation Why Positional Number System for Digital
Computers??
Major consideration is the COST and TIME Cost of building hardware
ALU, CPU and Communications
Time to processing
Arithmetic Addition of Numbers Table foraddition Non-positional Number System
Table for addition is infinite Impossible to build, very expensive even if it can be built
-
8/8/2019 co2-crr
5/19
2 November 2010 C.Ravindra Murthy 5
Data Types: Numeric Data
Representation Positional Number System
Table for addition is finite
Physically realizable, but cost wise the smaller thetable size, the less expensive
Binary is favorable to Decimal
-
8/8/2019 co2-crr
6/19
2 November 2010 C.Ravindra Murthy 6
Positive (unsigned) Binary
Numbers Unsigned binary numbers are typically used to represent
computer addresses or other values that are guaranteednot to be negative
An n-bit unsigned binary integer A = an-1, an-2, .. a1, a0 hasa value of
For example1011 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= 8 + 2 + 1 = 11
An n-bit unsigned binary integer has a range from 0 to 2n - 1
-
8/8/2019 co2-crr
7/19
2 November 2010 C.Ravindra Murthy 7
Octal and Hexadecimal Numbers Octal, base 8 numbers were used in the early days of computing to
represent binary numbers
Octal numbers are made by grouping binary numbers together
three bits at a time Hexadecimal base 16 numbers are representation of choice today
Hexadecimal numbers are made by grouping binary numberstogether four bits at a time
For example:
Octal: 7 2 5 1 7 5 2 2 .
Binary: 1 1 1 0 1 0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 0
Hex: E A 9 F 5 2
-
8/8/2019 co2-crr
8/19
-
8/8/2019 co2-crr
9/19
2 November 2010 C.Ravindra Murthy 9
Complements of NumbersTwo types of complements for base R number system:
Rs complement (R-1)s complement
The (R-1)s Complement
Subtract each digit of a number from (R-1)
Examples: 9s complement of 83510 is 164101s complement of 10102 is 01012(bit by bit complement operation)
The Rs ComplementAdd 1 to the low-order digit of its (R-1)s complement
Examples: 10s complement of 83510 is 16410 + 1 = 165102s complement of 10102 is 01012 + 1 = 01102
-
8/8/2019 co2-crr
10/19
2 November 2010 C.Ravindra Murthy 10
Negative (Signed) Binary
NumbersOnes complement format
Negative numbers are represented by a bit-by-bit
complementation of the (positive) magnitude (the process of
negation)
Sign bit interpreted as in sign-magnitude format
Examples (8-bit words):
+42 = 0 00101010
-42 = 1 11010101
Min: - (2 n - 2 -m) = 1111 1111 . 1111 1111
Max: + (2 n - 2 -m) = 0111 1111 . 1111 1111
Zero: - 0 = 1111 1111 . 1111 1111
Zero: +0 = 0000 0000 . 0000 0000
-
8/8/2019 co2-crr
11/19
2 November 2010 C.Ravindra Murthy 11
Negative (Signed) Binary
NumbersTwos complement format
Negative numbers, -X, are represented by the pseudo-
positive number: 2n - |X|
An n-bit unsigned binary integer A = an-1 an-2... a1 a0 has avalue of
For example: 1011 = -1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= -8 + 2 + 1 = -5
With 2n digits: 2 n-1 -1 positive numbers
2 n -1 negative numbers
Given the representation for +X, the representation for -X is
found by taking the 1s complement of +X and adding 1
-
8/8/2019 co2-crr
12/19
2 November 2010 C.Ravindra Murthy 12
Negative (Signed) Binary
NumbersTwos complement format
Most significant bit is the sign bit.
Number representation is not symmetric.
Only one representation for zero.Easy to negate, add, and subtract numbers.
A little bit trickier for multiply and divide.
Min: - (2 n) = 1000 0000 . 0000 0000
Max: + (2 n - 2 -m) = 0111 1111 . 1111 1111
Zero: = 0000 0000 . 0000 0000
-
8/8/2019 co2-crr
13/19
2 November 2010 C.Ravindra Murthy 13
Signed 2s Complement AdditionAdd the two numbers, including their sign bit, and discard any carryout of left-most(sign) bit
Examples:
6 0 0110 -6= 1 1010+ 9 0 1001 + 9= 0 1001
15 0 1111 3= 0 0011
6 0 0110 -9 1 0111
+ -9 1 0111 + -9 1 0111
-3 1 1101 -18 (1) 0 1110
9 0 1001
+ 9 0 1001
18 1 0010
-
8/8/2019 co2-crr
14/19
2 November 2010 C.Ravindra Murthy 14
Detecting 2s Complement
OverflowWhen adding two's complement numbers, overflowwill only occur if
the numbers being added have the same sign the sign of the result
is different
Ifwe perform the addition
an-1 an-2 ... a1 a0+ bn-1bn-2 b1 b0----------------------------------
= sn-1sn-2 s1 s0
Overflow can be detected as
where cn-1and cn are the carry in and carry out of the most
significant bit.
1! nn ccV
-
8/8/2019 co2-crr
15/19
2 November 2010 C.Ravindra Murthy 15
Signed 2s Complement
SubtractionTo subtract two's complement numbers we first negate the second
number and then add the corresponding bits of both numbers.
Examples:
3 = 0011 -3 = 1101 -3 = 1101 3 = 0011- 2 = 0010 - -2 = 1110 - 2 = 0010 - -2 = 1110
become:
3 = 0011 -3 = 1101 -3 = 1101 3 = 0011+ -2 = 1110 + 2 = 0010 + -2 = 1110 + 2 = 0010
1 = 0001 -1 = 1111 -5 = 1011 5 = 0101
-
8/8/2019 co2-crr
16/19
2 November 2010 C.Ravindra Murthy 16
Floating Point Number
RepresentationThe location of the fractional point is not fixed to a certain location
--> The range of the representable numbers is wide
--> high precision
F = EM
m n e k e k-1 ... e 0 m n-1 m n-2 ... m 0 . m -1 ... m -m
sign exponent mantissa
MantissaSigned fixed point number, either an integer or a fractional number
Exponent
Designates the position of the radix point
-
8/8/2019 co2-crr
17/19
2 November 2010 C.Ravindra Murthy 17
Floating Point Number
RepresentationDecimal Value:
V = M * R E
Where: M= Mantissa
E= ExponentR= Radix (10)
Example (decimal):
1234.5678
Exponent Mantissa
Sign Value Sign Value
0 4 0 0.12345678
==> 0.12345678 x 10
+4
-
8/8/2019 co2-crr
18/19
2 November 2010 C.Ravindra Murthy 18
Floating Point Number
RepresentationExample (binary):
+ 1001.11 (= 9.75)
Make a fractional number, counting the number of shifts:
+ .100111 ==> 4 shifts
Exponent Mantissa
Sign Value Sign Value
0 100 0 1001111
Or for a 16-bit numberwith a sign, 5-bit exponent, 10-bit mantissa:
0 00100 1001111000
-
8/8/2019 co2-crr
19/19
2 November 2010 C.Ravindra Murthy 19
Error Detecting Codes ParityParity System: Simplest method for error detectionOne parity bit attached to the information
Even Parity and Odd Parity
EvenP
arityOne bit is attached to the information so that the total number
of 1 bits is an even number
1011001 0
1010010 1 ==> B even = B n-1 (+) B n-2 (+) B 0
Odd ParityOne bit is attached to the information so that the total number
of 1 bits is an odd number
1011001 1
1010010 0 ==> B odd = B n-1 (+) B n-2 (+) B 0 (+) 1