What is cache memory? 5m Dec2005
A two-way set-associative cache memory uses blocks of four words.
The cache can accommodate a total of 2048 words from the main memory.
The main memory size is 128K x 32. What are the sizes of the following?
- TAG
- INDEX
- Data
- Cache Memory
Cache Memory
Cache memory is an extremely fast, small memory between CPU and main memory whose access time is closer to the processing speed of the CPU. It acts as a high-speed buffer between CPU and main memory and is used to temporarily store currently active data and instructions during processing. Since the cache memory is faster than main memory, the processing speed is increased by making data and instructions needed in present processing available in the cache memory.
What are the sizes of:-
Main memory is respresented as = 128K x 32, Therefore
Main memory Size = 128K Words = 27 * 210 = 217
The Maximum size of physical memory address in the present machine= 17 bits
Main Memory word size = 32 bits
Answer 3: Data is equal to main memory word size = 32 bits
Cache memory is respresented as = 2048 words, and Cache memory uses blocks of four words, Therefore
Cache Memory Size = 2048/4 = 512 Blocks
Answer 4: Cache Memory Size in bits = 2048*32 = 64*1024 = 64K bits or 8K btyes
Cache Sets in two-way set-associative = 512/2 = 256 Sets
Cache Memory Block size = 32*4 = 128 bits
⇒1 Block of Cache = 4 Words of RAM
⇒ Total number of possible Blocks in Main Memory = 128K/4 = 32K blocks
Division of Address bits:
Memory Address ( 17 bits ) |
||
Block Address ( 15 bits ) |
Block offset ( 2 bits ) |
|
Tag |
Index |
Block offset ( 2 bits ) |
Block offset = 2 comes from
1 Block of Cache = 4 Words of RAM and 4 = 22 = block offset
Memory Address (17 bits ) |
||
Block Address ( 15 bits ) |
Block offset ( 2 bits ) |
|
Tag ( 7 bits ) |
Index ( 8 bits ) |
Block offset ( 2 bits ) |
Index of 2w set-associative mapping = 8 comes from
In case Direct Mapping:-
Cache Memory Size = 2048/4 = 512 Blocks i.e. 512= 29 = index
In case 2w set-associative mapping:-
Cache Memory Size = 2048/4 = 512/2 Sets/ i.e. 256= 28 = index
Answer 2: Index of 2w set-associative mapping =8 bits
Tag is the remaining from Block Address – Index = 15 – 8 = 7 bits
Answer 1: Tag of 2w set-associative mapping =7 bits