Content deleted Content added
m Task 18 (cosmetic): eval 9 templates: del empty params (15×); |
DioneCassini (talk | contribs) m Improved formatting and wording for the Direct-Mapped Section of this page. |
||
Line 27:
=== Example ===
[[File:Direct-Mapped Cache Snehal Img.png|thumb|500x500px|Direct-Mapped Cache]]
Consider a main memory of 16 kilobytes, which is organized as 4-byte blocks, and a direct-mapped cache of 256 bytes with a block size of 4 bytes. Because the main memory is 16kB, we need a minimum of 14 bits to uniquely represent a memory address.
Since each cache block is of size 4 bytes, the total number of sets in the cache is 256/4, which equals 64 sets.
Line 33:
The incoming address to the cache is divided into bits for [[CPU cache#Cache entry structure|Offset]], [[CPU cache#Cache entry structure|Index]] and [[CPU cache#Cache entry structure|Tag]].
* ''Offset'' corresponds to the bits used to determine the byte to be accessed from the cache line. Because the cache lines are 4 bytes long, there are ''2 offset bits''.
* ''Index'' corresponds to bits used to determine the set of the Cache. There are 64 sets in the cache, and because 2^6 = 64, there are ''6 index bits.''
Below are memory addresses and an explanation of which cache line they map to:
# Address <code>0x0000</code> (tag -
# Address <code>0x0004</code> (tag -
# Address
▲Address 0x0000(tag - 00_0000, index – 00_0000, offset – 00) maps to block 0 of the memory and occupies the set 0 of the cache.
▲Address 0x0004(tag - 00_0000, index – 00_0001, offset – 00) maps to block 1 of the memory and occupies the set 1 of the cache.
▲Similarly, address 0x00FF(tag – 00_0000, index – 11_1111, offset – 11) maps to block 63 of the memory and occupies the set 63 of the cache.
▲Address 0x0100(tag – 00_0001, index – 00_0000, offset – 00) maps to block 64 of the memory and occupies the set 0 of the cache.
== Fully associative cache ==
|