18.4 A More Complex Cache System

Using g-cache, we can simulate more complex cache systems. Let
us consider the structure described by figure 5.

Figure 5. A More Complex Cache System

What we want to simulate is a system with separate instruction and data caches
at level 1 backed by a level 2 cache. We will connect this memory hierarchy to
an x86 processor. The dotted components in the diagram represent elements that
are introduced in Simics to complete the simulation. Let us have a look at
these components:

id-splitter

This module is used by Simics to
separate instruction and data accesses and send them to separate L1 caches.

splitter

Since we are simulating an x86 machine,
accesses can cross a cache-line boundary. To avoid that, we connect two
splitters before the caches. The splitters will let uncacheable and correctly
aligned accesses go through untouched, whereas others will be split in two
accesses.

trans-staller

The trans-staller is a
very simple device that will simulate the memory latency. It will stall all
accesses by a fixed amount of cycles.

Once this is done, we can simply plug the id-splitter to the
main memory:

@conf.phys_mem0.timing_model = conf.id

Note the way the penalties have been set: we don't use _next
penalties but let the next level report penalties in case they are accessed. In
this configuration, a read hit in L1 would take 3 cycles; a read miss that goes
to memory would take 3 + 10 + 200 = 213 cycles if no copy-back is
performed in the L2 cache. There's no best way to set up the penalties so it's
up to you to decide how your model should behave.