gem5  v22.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 
47 namespace gem5
48 {
49 
50 GEM5_DEPRECATED_NAMESPACE(ReplacementPolicy, replacement_policy);
51 namespace replacement_policy
52 {
53  class Base;
54 }
55 class ReplaceableEntry;
56 
65 class SectorTags : public BaseTags
66 {
67  private:
72 
73  protected:
75  unsigned allocAssoc;
76 
78  const bool sequentialAccess;
79 
82 
84  const unsigned numBlocksPerSector;
85 
87  const unsigned numSectors;
88 
89  // Organization of an address:
90  // Tag | Placement Location | Sector Offset # | Offset #
92  const int sectorShift;
93 
95  const unsigned sectorMask;
96 
98  {
99  const SectorTags& tags;
100 
101  SectorTagsStats(BaseTagStats &base_group, SectorTags& _tags);
102 
103  void regStats() override;
104 
108 
109  public:
111  typedef SectorTagsParams Params;
112 
116  SectorTags(const Params &p);
117 
121  virtual ~SectorTags() {};
122 
126  void tagsInit() override;
127 
134  void invalidate(CacheBlk *blk) override;
135 
146  CacheBlk* accessBlock(const PacketPtr pkt, Cycles &lat) override;
147 
154  void insertBlock(const PacketPtr pkt, CacheBlk *blk) override;
155 
156  void moveBlock(CacheBlk *src_blk, CacheBlk *dest_blk) override;
157 
166  CacheBlk* findBlock(Addr addr, bool is_secure) const override;
167 
177  CacheBlk* findVictim(Addr addr, const bool is_secure,
178  const std::size_t size,
179  std::vector<CacheBlk*>& evict_blks) override;
180 
187  int extractSectorOffset(Addr addr) const;
188 
195  Addr regenerateBlkAddr(const CacheBlk* blk) const override;
196 
205  void forEachBlk(std::function<void(CacheBlk &)> visitor) override;
206 
216  bool anyBlk(std::function<bool(CacheBlk &)> visitor) override;
217 };
218 
219 } // namespace gem5
220 
221 #endif //__MEM_CACHE_TAGS_SECTOR_TAGS_HH__
A common base class of Cache tagstore objects.
Definition: base.hh:74
const unsigned size
The size of the cache.
Definition: base.hh:81
BaseTagsParams Params
Definition: base.hh:161
A Basic Cache block.
Definition: cache_blk.hh:71
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
A SectorTags cache tag store.
Definition: sector_tags.hh:66
Addr regenerateBlkAddr(const CacheBlk *blk) const override
Regenerate the block address from the tag and location.
Definition: sector_tags.cc:332
const unsigned sectorMask
Mask out all bits that aren't part of the sector tag.
Definition: sector_tags.hh:95
std::vector< SectorSubBlk > blks
The cache blocks.
Definition: sector_tags.hh:69
replacement_policy::Base * replacementPolicy
Replacement policy.
Definition: sector_tags.hh:81
SectorTagsParams Params
Convenience typedef.
Definition: sector_tags.hh:111
gem5::SectorTags::SectorTagsStats sectorStats
int extractSectorOffset(Addr addr) const
Calculate a block's offset in a sector from the address.
Definition: sector_tags.cc:326
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:250
SectorTags(const Params &p)
Construct and initialize this tag store.
Definition: sector_tags.cc:51
void forEachBlk(std::function< void(CacheBlk &)> visitor) override
Visit each sub-block in the tags and apply a visitor.
Definition: sector_tags.cc:363
std::vector< SectorBlk > secBlks
The cache sector blocks.
Definition: sector_tags.hh:71
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:276
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition: sector_tags.hh:78
bool anyBlk(std::function< bool(CacheBlk &)> visitor) override
Find if any of the sub-blocks satisfies a condition.
Definition: sector_tags.cc:371
virtual ~SectorTags()
Destructor.
Definition: sector_tags.hh:121
void tagsInit() override
Initialize blocks as SectorBlk and SectorSubBlk instances.
Definition: sector_tags.cc:71
void insertBlock(const PacketPtr pkt, CacheBlk *blk) override
Insert the new block into the cache and update replacement data.
Definition: sector_tags.cc:179
const unsigned numSectors
The number of sectors in the cache.
Definition: sector_tags.hh:87
const unsigned numBlocksPerSector
Number of data blocks per sector.
Definition: sector_tags.hh:84
const int sectorShift
The amount to shift the address to get the sector tag.
Definition: sector_tags.hh:92
unsigned allocAssoc
The allocatable associativity of the cache (alloc mask).
Definition: sector_tags.hh:75
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:119
CacheBlk * accessBlock(const PacketPtr pkt, Cycles &lat) override
Access block and update replacement data.
Definition: sector_tags.cc:142
void moveBlock(CacheBlk *src_blk, CacheBlk *dest_blk) override
Move a block's metadata to another location decided by the replacement policy.
Definition: sector_tags.cc:204
A common base class of cache replacement policy objects.
Definition: base.hh:56
Statistics container.
Definition: group.hh:94
A vector of scalar stats.
Definition: statistics.hh:2007
STL vector class.
Definition: stl.hh:37
Declaration of a common base class for cache tagstore objects.
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Declaration of the Packet class.
Copyright (c) 2018, 2020 Inria All rights reserved.
Declaration of Statistics objects.
TODO: It would be good if these stats were acquired after warmup.
Definition: base.hh:109
void regStats() override
Callback to set stat parameters.
Definition: sector_tags.cc:350
statistics::Vector evictionsReplacement
Number of sub-blocks evicted due to a replacement.
Definition: sector_tags.hh:106
SectorTagsStats(BaseTagStats &base_group, SectorTags &_tags)
Definition: sector_tags.cc:341

Generated on Wed Dec 21 2022 10:22:37 for gem5 by doxygen 1.9.1