21 line_size_(line_size),
25 "Cache line size must be a power of 2. line_size=" << line_size);
31 line_size_(rhs.line_size_),
39 BasicCacheItem::operator=(rhs);
40 line_size_ = rhs.line_size_;
49 void reset(uint64_t addr)
52 BasicCacheItem::setAddr(addr);
56 void setValid(
bool v) { valid_ = v; }
59 bool isValid()
const {
return valid_; }
62 void setModified(
bool m) { (void) m; }
65 bool read(uint64_t offset, uint32_t size, uint32_t *buf)
const
75 bool write(uint64_t offset, uint32_t size, uint32_t *buf)
const
90 class SimpleDL1 :
public sparta::cache::SimpleCache2<SimpleCacheLine>,
92 public sparta::cache::PreloadableIF,
93 public sparta::cache::PreloadDumpableIF
97 using Handle = std::shared_ptr<SimpleDL1>;
99 uint64_t cache_size_kb,
101 const sparta::cache::ReplacementIF& rep) :
102 sparta::cache::SimpleCache2<SimpleCacheLine> (cache_size_kb,
108 sparta::cache::PreloadableIF(),
109 sparta::cache::PreloadDumpableIF(),
110 preloadable_(
this, std::bind(&SimpleDL1::preloadPkt_,
this, _1),
111 std::bind(&SimpleDL1::preloadDump_,
this, _1))
117 bool preloadPkt_(sparta::cache::PreloadPkt& pkt)
override
119 sparta::cache::PreloadPkt::NodeList lines;
121 for (
auto& line_data : lines)
123 uint64_t va = line_data->getScalar<uint64_t>(
"va");
124 auto& cache_line = getLineForReplacement(va);
125 std::cout << *
this <<
" : Preloading VA: 0x" << std::hex << va
127 allocateWithMRUUpdate(cache_line, va);
135 void preloadDump_(sparta::cache::PreloadEmitter& emitter)
const override
137 emitter << sparta::cache::PreloadEmitter::BeginMap;
138 emitter << sparta::cache::PreloadEmitter::Key <<
"lines";
139 emitter << sparta::cache::PreloadEmitter::Value;
140 emitter << sparta::cache::PreloadEmitter::BeginSeq;
141 for (
auto set_it = begin();
142 set_it != end(); ++set_it)
144 for (
auto line_it = set_it->begin();
145 line_it != set_it->end(); ++line_it)
147 if(line_it->isValid())
149 std::map<std::string, std::string> map;
151 t <<
"0x" << std::hex << line_it->getAddr();
157 emitter << sparta::cache::PreloadEmitter::EndSeq;
158 emitter << sparta::cache::PreloadEmitter::EndMap;
162 sparta::cache::PreloadableNode preloadable_;