configs: caches.py: Allow simulation of cache replacement policies

The current cache configuration script does not allow specifying
cache replacement policies for testing. Add parser options to
support this.
This commit is contained in:
Sanchayan Maity 2017-01-24 10:28:38 +05:30
parent 2e1e1aedc7
commit 6e058b9eb3

View file

@ -88,16 +88,39 @@ class L1DCache(L1Cache):
# Set the default size # Set the default size
size = '64kB' size = '64kB'
assoc = 8
SimpleOpts.add_option('--l1d_size', SimpleOpts.add_option('--l1d_size',
help="L1 data cache size. Default: %s" % size) help="L1 data cache size. Default: %s" % size)
SimpleOpts.add_option('--l1d_assoc',
help="L1 data cache associativity. Default: %s" % assoc)
SimpleOpts.add_option('--replacement_policy',
help="L1 cache replacement policy. [NMRU,LRU,Random]")
def __init__(self, opts=None): def __init__(self, opts=None):
super(L1DCache, self).__init__(opts) super(L1DCache, self).__init__(opts)
if not opts or not opts.l1d_size: if not opts:
return return
if opts.l1d_size:
self.size = opts.l1d_size self.size = opts.l1d_size
if opts.l1d_assoc:
self.size = opts.l1d_assoc
if opts.replacement_policy == "NMRU":
from m5.objects import NMRU
self.tags = NMRU()
elif opts.replacement_policy == "Random":
from m5.objects import RandomRepl
self.tags = RandomRepl()
elif opts.replacement_policy == "LRU":
from m5.objects import LRU
self.tags = LRU()
elif opts.replacement_policy:
fatal("Unsupported replacement policy: %s" %
opts.replacement_policy)
def connectCPU(self, cpu): def connectCPU(self, cpu):
"""Connect this cache's port to a CPU dcache port""" """Connect this cache's port to a CPU dcache port"""
self.cpu_side = cpu.dcache_port self.cpu_side = cpu.dcache_port