base_set_assoc.hh (12727:56c23b54bcb1) base_set_assoc.hh (12728:57bdea4f96aa)
1/*
2 * Copyright (c) 2012-2014,2017 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 34 unchanged lines hidden (view full) ---

43/**
44 * @file
45 * Declaration of a base set associative tag store.
46 */
47
48#ifndef __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
49#define __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
50
1/*
2 * Copyright (c) 2012-2014,2017 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 34 unchanged lines hidden (view full) ---

43/**
44 * @file
45 * Declaration of a base set associative tag store.
46 */
47
48#ifndef __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
49#define __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
50
51#include <functional>
51#include <string>
52#include <vector>
53
54#include "base/logging.hh"
55#include "base/types.hh"
56#include "debug/CacheRepl.hh"
57#include "mem/cache/base.hh"
58#include "mem/cache/blk.hh"

--- 234 unchanged lines hidden (view full) ---

293 * @param block The block.
294 * @return the block address.
295 */
296 Addr regenerateBlkAddr(const CacheBlk* blk) const override
297 {
298 return ((blk->tag << tagShift) | ((Addr)blk->set << setShift));
299 }
300
52#include <string>
53#include <vector>
54
55#include "base/logging.hh"
56#include "base/types.hh"
57#include "debug/CacheRepl.hh"
58#include "mem/cache/base.hh"
59#include "mem/cache/blk.hh"

--- 234 unchanged lines hidden (view full) ---

294 * @param block The block.
295 * @return the block address.
296 */
297 Addr regenerateBlkAddr(const CacheBlk* blk) const override
298 {
299 return ((blk->tag << tagShift) | ((Addr)blk->set << setShift));
300 }
301
301 /**
302 * Called at end of simulation to complete average block reference stats.
303 */
304 void cleanupRefs() override;
302 void forEachBlk(std::function<void(CacheBlk &)> visitor) override {
303 for (CacheBlk& blk : blks) {
304 visitor(blk);
305 }
306 }
305
307
306 /**
307 * Print all tags used
308 */
309 std::string print() const override;
310
311 /**
312 * Called prior to dumping stats to compute task occupancy
313 */
314 void computeStats() override;
315
316 /**
317 * Visit each block in the tag store and apply a visitor to the
318 * block.
319 *
320 * The visitor should be a function (or object that behaves like a
321 * function) that takes a cache block reference as its parameter
322 * and returns a bool. A visitor can request the traversal to be
323 * stopped by returning false, returning true causes it to be
324 * called for the next block in the tag store.
325 *
326 * \param visitor Visitor to call on each block.
327 */
328 void forEachBlk(CacheBlkVisitor &visitor) override {
308 bool anyBlk(std::function<bool(CacheBlk &)> visitor) override {
329 for (CacheBlk& blk : blks) {
309 for (CacheBlk& blk : blks) {
330 if (!visitor(blk))
331 return;
310 if (visitor(blk)) {
311 return true;
312 }
332 }
313 }
314 return false;
333 }
334};
335
336#endif //__MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
315 }
316};
317
318#endif //__MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__