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
1 changed files with 25 additions and 2 deletions

View File

@ -88,15 +88,38 @@ class L1DCache(L1Cache):
# Set the default size
size = '64kB'
assoc = 8
SimpleOpts.add_option('--l1d_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):
super(L1DCache, self).__init__(opts)
if not opts or not opts.l1d_size:
if not opts:
return
self.size = opts.l1d_size
if 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):
"""Connect this cache's port to a CPU dcache port"""