Cache Memory Organization
Cache Memory Organization
Code Cache
The code cache is 8 KB read only cache and is organized as a 2-way set associative cache. The two
ways are called way zero and way one. Each cache line is 32 bytes.
Total size of cache = 8 KB.
Size of each way = 4 KB.
Cache line size = 32 bytes.
Total number of lines in one way = 128
There is a separate 128 entry directory associated with each cache way. The 4Gb memory space of the
processor is mapped into the 4KB cache way, i.e. the 4 GB memory space is assumed to be divided into
pages each of size 4 KB.
Hence total number of pages = 1 M or 220
Thus, each cache directory entry stores this 20 bit tag (page no) address A [31-12].
The entry also consists of one state bit (to indicate S/I) and a parity bit P.
The parity bit is used to detect errors when reading each entry.
The cache directories are triple ported to allow three simultaneous directory accesses.
Two of the ports support the split line access capability, while the third port is used for snooping.
Each cache line holds four quad words and a parity bit for each quad word.
When the prefetcher issues an instruction request, the code cache is checked to see if a copy is
available.
Assuming a cache miss, a cache line-fill request is made to the bus unit, i.e. a cache line is brought in
from L2 cache/ memory.
Main Memory Address (32-bits) Interpretation
Page Number (Tag) Line Number (Index) Location within the line (byte)
20 bits 7 bits 5 bits
Code Cache Directory Entry
Split-Line Access(Optional)
In a CISC Processor like Pentium , instructions are of variable length
In the Pentium Processor the smallest instruction is one byte while the maximum length is 15 bytes
A code cache always results in a 32 byte cache line fill, if it’s a cacheable address
Multi byte instructions may span two sequential lines stored in the code cache
When the prefetcher determines that the instruction is straddled across two lines, it would have to
perform two sequential cache accesses, which would hamper performance
For this reason the Pentium processor incorporate a split line access which allows the upper half of
one line and lower half of next line to be accessed in one cycle
When a split line access is made the byte must be rotated so that they are in proper order for the split
access to work efficiently , instruction boundaries within the cache line need to be defined.
When an instruction is decoded for the first time the length of instruction is fed back to the cache.
Each code cache entry marks instruction boundries within the line , so that if necessary split line
accesses can be performed.
Page Number (Tag) Line Number (Index) Bank Select XX (Don't care)
20 bits 7 bits 3 bits 2 bits