# Lecture 10 - Numbers

## Practical Details

1. Assignment 1, giving back.
2. Assignment 2.
3. Next Friday.
4. 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.

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

1. 32-bit word
• 4 bytes per word
• 8 bits per byte
2. 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

1. 7 bits encode 128 characters

8th bit usually used for parity

2. 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'.
• also subtraction.

#### Signed binary

The first idea was `signed-magnitude binary'.

1. MSB is the sign
2. numbers from -2^31 + 1 to 2^31-1.
• How many numbers are there?
• What is the extra one?
• Gaack!
3. 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

• Calculate -1 + 1 in two's complement.
• Addition and subtraction just work, except
• 0111...111 + 0000...001 =
• Wrap-around is still here

#### Negation

1. Take an arbitrary two's complement number, y,
2. Make a second two's complement number, x, by inverting all its bits