CS251 - Computer Organization and Design - Spring 2008
Lecture 10 - Numbers
Practical Details
- Assignment 1, giving back.
- Assignment 2.
- Next Friday.
- Book sections, in order: 3.1 to 3.3, 2.5, B.5 (ignore verilog), 3.4,
3.6
SSRAM and SDRAM
The first `S' stands for synchronized.
DDR SDRAM
Double data rate
Numbers
Computers store and retrive data as words, which usually correspond to
- the bus width
- the register size
- the instruction size
- etc.
The word length is usually the first decision a designer makes when
designing a new CPU.
- usually a power of two: 8-bit, 16-bit, 32-bit, 64-bit
- but not necessarily: 23 bit Russian computer
MIPS
The Word
- 32-bit word
- 4 bytes per word
- 8 bits per byte
- bits numbered 0, 1, ..., 31
- most significant bit (MSB) is 31
- least significant bit (LSB) is 0
The important issue is: how will we interpret these bits?
Bytes
Coded in ASCII
- 7 bits encode 128 characters
8th bit usually used for parity
- Characters include
- upper and lower case letters,
- numerals,
- puctuation
- miscellaneous, largely obsolete
ASCII has served us well for thirty years, but may be on the way out
- Unicode, but ...
- `Many were called but few were chosen.'
Characters coded as bytes will go with ASCII.
Unsigned numbers
abcdefghijklmnopqrstuvwxyzABCDEF, where each character is a binary bit
means
- a*2^31 + b*2^30 + c*2^29 + ... + E*2 + F
- the natural numbers from 0 to 2^32 - 1 = 4,294,967,295
- These play an important role as addresses
- Addition works nicely, even overflow if you have a sufficiently low
level definition of `nicely'.
Signed binary
The first idea was `signed-magnitude binary'.
- MSB is the sign
- numbers from -2^31 + 1 to 2^31-1.
- How many numbers are there?
- What is the extra one?
- Gaack!
- What if we add +5 to -5?
- This also looks like trouble.
Two's complement
Interpret the MSB as -2^31 instead of 2^31. Then,
- 10000...000 is -2^31, the smallest number
- 011111...111 is 2^32 - 1, the biggest number
- 1111...111 is -1, 0000...000 is zero, and 0000...001 is +1
Exercise for the reader
- Calculate -1 + 1 in two's complement.
- Addition and subtraction just work, except
- 0111...111 + 0000...001 =
- Wrap-around is still here
Negation
- Take an arbitrary two's complement number, y,
- Make a second two's complement number, x, by inverting all its bits
- Add them together
- The result is necessarily -1.
- y + x = -1 => -y = x + 1
Sign extension
Return to: