gem5  v20.1.0.0
sector_tags.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
34 #ifndef __MEM_CACHE_TAGS_SECTOR_TAGS_HH__
35 #define __MEM_CACHE_TAGS_SECTOR_TAGS_HH__
36 
37 #include <cstdint>
38 #include <string>
39 #include <vector>
40 
41 #include "base/statistics.hh"
42 #include "mem/cache/tags/base.hh"
44 #include "mem/packet.hh"
45 #include "params/SectorTags.hh"
46 
48 class ReplaceableEntry;
49 
58 class SectorTags : public BaseTags
59 {
60  private:
65 
66  protected:
68  unsigned allocAssoc;
69 
71  const bool sequentialAccess;
72 
75 
77  const unsigned numBlocksPerSector;
78 
80  const unsigned numSectors;
81 
82  // Organization of an address:
83  // Tag | Placement Location | Sector Offset # | Offset #
85  const int sectorShift;
86 
88  const unsigned sectorMask;
89 
90  struct SectorTagsStats : public Stats::Group
91  {
92  const SectorTags& tags;
93 
94  SectorTagsStats(BaseTagStats &base_group, SectorTags& _tags);
95 
96  void regStats() override;
97 
100  } sectorStats;
101 
102  public:
104  typedef SectorTagsParams Params;
105 
109  SectorTags(const Params *p);
110 
114  virtual ~SectorTags() {};
115 
119  void tagsInit() override;
120 
127  void invalidate(CacheBlk *blk) override;
128 
140  CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) override;
141 
148  void insertBlock(const PacketPtr pkt, CacheBlk *blk) override;
149 
158  CacheBlk* findBlock(Addr addr, bool is_secure) const override;
159 
169  CacheBlk* findVictim(Addr addr, const bool is_secure,
170  const std::size_t size,
171  std::vector<CacheBlk*>& evict_blks) override;
172 
179  int extractSectorOffset(Addr addr) const;
180 
187  Addr regenerateBlkAddr(const CacheBlk* blk) const override;
188 
197  void forEachBlk(std::function<void(CacheBlk &)> visitor) override;
198 
208  bool anyBlk(std::function<bool(CacheBlk &)> visitor) override;
209 };
210 
211 #endif //__MEM_CACHE_TAGS_SECTOR_TAGS_HH__
SectorTags::extractSectorOffset
int extractSectorOffset(Addr addr) const
Calculate a block's offset in a sector from the address.
Definition: sector_tags.cc:275
SectorTags::replacementPolicy
BaseReplacementPolicy * replacementPolicy
Replacement policy.
Definition: sector_tags.hh:74
ReplaceableEntry
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
Definition: replaceable_entry.hh:53
SectorTags::sequentialAccess
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition: sector_tags.hh:71
SectorTags::anyBlk
bool anyBlk(std::function< bool(CacheBlk &)> visitor) override
Find if any of the sub-blocks satisfies a condition.
Definition: sector_tags.cc:319
SectorTags::forEachBlk
void forEachBlk(std::function< void(CacheBlk &)> visitor) override
Visit each sub-block in the tags and apply a visitor.
Definition: sector_tags.cc:311
SectorTags::~SectorTags
virtual ~SectorTags()
Destructor.
Definition: sector_tags.hh:114
SectorTags::numBlocksPerSector
const unsigned numBlocksPerSector
Number of data blocks per sector.
Definition: sector_tags.hh:77
SectorTags::allocAssoc
unsigned allocAssoc
The allocatable associativity of the cache (alloc mask).
Definition: sector_tags.hh:68
SectorTags::regenerateBlkAddr
Addr regenerateBlkAddr(const CacheBlk *blk) const override
Regenerate the block address from the tag and location.
Definition: sector_tags.cc:281
SectorTags::secBlks
std::vector< SectorBlk > secBlks
The cache sector blocks.
Definition: sector_tags.hh:64
SectorTags::SectorTagsStats::evictionsReplacement
Stats::Vector evictionsReplacement
Number of sub-blocks evicted due to a replacement.
Definition: sector_tags.hh:99
SectorTags::tagsInit
void tagsInit() override
Initialize blocks as SectorBlk and SectorSubBlk instances.
Definition: sector_tags.cc:65
SectorTags::SectorTagsStats::tags
const SectorTags & tags
Definition: sector_tags.hh:92
std::vector< SectorSubBlk >
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
SectorTags::findBlock
CacheBlk * findBlock(Addr addr, bool is_secure) const override
Finds the given address in the cache, do not update replacement data.
Definition: sector_tags.cc:196
packet.hh
SectorTags::SectorTagsStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: sector_tags.cc:298
SectorTags::insertBlock
void insertBlock(const PacketPtr pkt, CacheBlk *blk) override
Insert the new block into the cache and update replacement data.
Definition: sector_tags.cc:172
SectorTags::SectorTagsStats::SectorTagsStats
SectorTagsStats(BaseTagStats &base_group, SectorTags &_tags)
Definition: sector_tags.cc:289
BaseReplacementPolicy
A common base class of cache replacement policy objects.
Definition: base.hh:46
BaseTags
A common base class of Cache tagstore objects.
Definition: base.hh:70
statistics.hh
SectorTags
A SectorTags cache tag store.
Definition: sector_tags.hh:58
SectorTags::SectorTagsStats
Definition: sector_tags.hh:90
BaseTags::Params
BaseTagsParams Params
Definition: base.hh:158
SectorTags::sectorShift
const int sectorShift
The amount to shift the address to get the sector tag.
Definition: sector_tags.hh:85
base.hh
sector_blk.hh
Copyright (c) 2018 Inria All rights reserved.
SectorTags::sectorStats
SectorTags::SectorTagsStats sectorStats
BaseTags::BaseTagStats
TODO: It would be good if these stats were acquired after warmup.
Definition: base.hh:105
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SectorTags::blks
std::vector< SectorSubBlk > blks
The cache blocks.
Definition: sector_tags.hh:62
SectorTags::SectorTags
SectorTags(const Params *p)
Construct and initialize this tag store.
Definition: sector_tags.cc:48
SectorTags::findVictim
CacheBlk * findVictim(Addr addr, const bool is_secure, const std::size_t size, std::vector< CacheBlk * > &evict_blks) override
Find replacement victim based on address.
Definition: sector_tags.cc:223
CacheBlk
A Basic Cache block.
Definition: cache_blk.hh:84
SectorTags::numSectors
const unsigned numSectors
The number of sectors in the cache.
Definition: sector_tags.hh:80
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Stats::Group
Statistics container.
Definition: group.hh:83
addr
ip6_addr_t addr
Definition: inet.hh:423
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
SectorTags::Params
SectorTagsParams Params
Convenience typedef.
Definition: sector_tags.hh:104
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
SectorTags::accessBlock
CacheBlk * accessBlock(Addr addr, bool is_secure, Cycles &lat) override
Access block and update replacement data.
Definition: sector_tags.cc:135
BaseTags::size
const unsigned size
The size of the cache.
Definition: base.hh:78
SectorTags::sectorMask
const unsigned sectorMask
Mask out all bits that aren't part of the sector tag.
Definition: sector_tags.hh:88
SectorTags::invalidate
void invalidate(CacheBlk *blk) override
This function updates the tags when a block is invalidated but does not invalidate the block itself.
Definition: sector_tags.cc:113

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17