$\require{cancel}$
Memory Overview
- This is still Jorgensen chapter 2.
- But I am going to go in a different order.
- Main Memory
- You can think of main memory as an array.
- It has an address or index
- At each address it has data.
- Memory is generally byte addressable.
- The data at location 0 consists of 8 bits.
- The data at location 1 consists of 8 bits.
- Frequently, however, we want more than one byte.
- The term word is dependent on the computer
- A word is the most general unit of operation for that specific computer.
- Most computers today are 64 bit computers, or a word consists of 64 bits.
- Many programming languages still operate with a word as a 32 bit element.
- So a piece of data may be spread across multiple memory addresses.
- Say we have a 32 bit number stored in memory.
- It would require 4 bytes.
- So it could be stored at location 0,1,2,3
- Or it could be stored at location 32,33,34,35
- In general the MSB would be at position 8 of the first address.
- And the LSB would be stored at position 0 of the last address.
- This is called little-endian.
- We could also store it in the other way, which would be big-endian.
- Different computers use different schemes
- Bytes in order or in reverse order.
- Bits in bytes in order or reverse order.
- We need to be aware of this, mostly when sending data between machines.
- In general however, programmers thank of memory as this array.
- But memory is more complex.
- It is a problem of speed.
- How do we measure speed?
- In seconds, duh!
- But that is not small enough.
- 1 milisecond (1ms) is 1/1000 ($10^{-3}$)of a second.
- 1 microsecond (1μs) is 1/1,000,000, ($10^{-6}$) of a second.
- 1 nanosecond (1ns) is ($10^{-9}$) of a second.
- 1 picosecond (1ps) is ($10^{-12}$) of a second.
- Or there are 1,000,000,000,000 (1 trillion) pico seconds in a second)
- The typical processor runs in the 100s of picoseconds per instruction.
- Or a fraction of a nanosecond.
- Or multiple billions instructions per second.
- Registers must perform their work at the speed of the processor, so they operate in the picosecond range.
- But memory operates in the 100 ns range.
- Even fast memory
- And there are other factors, such as bus transfer speed that impact this discussion.
- So memory is at least 100 times slower than the processor.
- Cache is the way to mitigate this problem.
- Cache is a layer between main memory and the registers.
- Actually it might be multiple layers (L1, L2, ...)
- The operation of cache is somewhat complex, so we will delay discussion
- But cache is invisible to the programmer.
- Two pictures from your book: