mem: Add explicit Cache subclass and make BaseCache abstract
Open up for other subclasses to BaseCache and transition to using the explicit Cache subclass. --HG-- rename : src/mem/cache/BaseCache.py => src/mem/cache/Cache.py
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Authors: Nathan Binkert
|
||||
# Andreas Hansson
|
||||
|
||||
from m5.params import *
|
||||
from m5.proxy import *
|
||||
@@ -46,6 +47,7 @@ from Tags import *
|
||||
|
||||
class BaseCache(MemObject):
|
||||
type = 'BaseCache'
|
||||
abstract = True
|
||||
cxx_header = "mem/cache/base.hh"
|
||||
|
||||
size = Param.MemorySize("Capacity")
|
||||
@@ -81,3 +83,7 @@ class BaseCache(MemObject):
|
||||
"Address range for the CPU-side port (to allow striping)")
|
||||
|
||||
system = Param.System(Parent.any, "System we belong to")
|
||||
|
||||
class Cache(BaseCache):
|
||||
type = 'Cache'
|
||||
cxx_header = 'mem/cache/cache.hh'
|
||||
2
src/mem/cache/SConscript
vendored
2
src/mem/cache/SConscript
vendored
@@ -30,7 +30,7 @@
|
||||
|
||||
Import('*')
|
||||
|
||||
SimObject('BaseCache.py')
|
||||
SimObject('Cache.py')
|
||||
|
||||
Source('base.cc')
|
||||
Source('cache.cc')
|
||||
|
||||
12
src/mem/cache/base.cc
vendored
12
src/mem/cache/base.cc
vendored
@@ -65,13 +65,13 @@ BaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name,
|
||||
{
|
||||
}
|
||||
|
||||
BaseCache::BaseCache(const Params *p)
|
||||
BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
|
||||
: MemObject(p),
|
||||
cpuSidePort(nullptr), memSidePort(nullptr),
|
||||
mshrQueue("MSHRs", p->mshrs, 4, p->demand_mshr_reserve, MSHRQueue_MSHRs),
|
||||
writeBuffer("write buffer", p->write_buffers, p->mshrs+1000, 0,
|
||||
MSHRQueue_WriteBuffer),
|
||||
blkSize(p->system->cacheLineSize()),
|
||||
blkSize(blk_size),
|
||||
lookupLatency(p->hit_latency),
|
||||
forwardLatency(p->hit_latency),
|
||||
fillLatency(p->response_latency),
|
||||
@@ -774,11 +774,3 @@ BaseCache::regStats()
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
BaseCache *
|
||||
BaseCacheParams::create()
|
||||
{
|
||||
assert(tags);
|
||||
|
||||
return new Cache(this);
|
||||
}
|
||||
|
||||
3
src/mem/cache/base.hh
vendored
3
src/mem/cache/base.hh
vendored
@@ -473,8 +473,7 @@ class BaseCache : public MemObject
|
||||
virtual void regStats();
|
||||
|
||||
public:
|
||||
typedef BaseCacheParams Params;
|
||||
BaseCache(const Params *p);
|
||||
BaseCache(const BaseCacheParams *p, unsigned blk_size);
|
||||
~BaseCache() {}
|
||||
|
||||
virtual void init();
|
||||
|
||||
11
src/mem/cache/cache.cc
vendored
11
src/mem/cache/cache.cc
vendored
@@ -63,8 +63,8 @@
|
||||
#include "mem/cache/prefetch/base.hh"
|
||||
#include "sim/sim_exit.hh"
|
||||
|
||||
Cache::Cache(const Params *p)
|
||||
: BaseCache(p),
|
||||
Cache::Cache(const CacheParams *p)
|
||||
: BaseCache(p, p->system->cacheLineSize()),
|
||||
tags(p->tags),
|
||||
prefetcher(p->prefetcher),
|
||||
doFastWrites(true),
|
||||
@@ -2382,6 +2382,13 @@ CpuSidePort::CpuSidePort(const std::string &_name, Cache *_cache,
|
||||
{
|
||||
}
|
||||
|
||||
Cache*
|
||||
CacheParams::create()
|
||||
{
|
||||
assert(tags);
|
||||
|
||||
return new Cache(this);
|
||||
}
|
||||
///////////////
|
||||
//
|
||||
// MemSidePort
|
||||
|
||||
3
src/mem/cache/cache.hh
vendored
3
src/mem/cache/cache.hh
vendored
@@ -57,6 +57,7 @@
|
||||
#include "mem/cache/blk.hh"
|
||||
#include "mem/cache/mshr.hh"
|
||||
#include "mem/cache/tags/base.hh"
|
||||
#include "params/Cache.hh"
|
||||
#include "sim/eventq.hh"
|
||||
|
||||
//Forward decleration
|
||||
@@ -419,7 +420,7 @@ class Cache : public BaseCache
|
||||
|
||||
public:
|
||||
/** Instantiates a basic cache object. */
|
||||
Cache(const Params *p);
|
||||
Cache(const CacheParams *p);
|
||||
|
||||
/** Non-default destructor is needed to deallocate memory. */
|
||||
virtual ~Cache();
|
||||
|
||||
Reference in New Issue
Block a user