gem5  v21.1.0.2
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 
107  } sectorStats;
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__
gem5::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:119
gem5::SectorTags::sectorShift
const int sectorShift
The amount to shift the address to get the sector tag.
Definition: sector_tags.hh:92
gem5::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:179
gem5::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:250
gem5::SectorTags::allocAssoc
unsigned allocAssoc
The allocatable associativity of the cache (alloc mask).
Definition: sector_tags.hh:75
gem5::SectorTags::blks
std::vector< SectorSubBlk > blks
The cache blocks.
Definition: sector_tags.hh:69
gem5::SectorTags::~SectorTags
virtual ~SectorTags()
Destructor.
Definition: sector_tags.hh:121
gem5::SectorTags::regenerateBlkAddr
Addr regenerateBlkAddr(const CacheBlk *blk) const override
Regenerate the block address from the tag and location.
Definition: sector_tags.cc:332
gem5::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:276
gem5::SectorTags::Params
SectorTagsParams Params
Convenience typedef.
Definition: sector_tags.hh:111
gem5::BaseTags::BaseTagStats
TODO: It would be good if these stats were acquired after warmup.
Definition: base.hh:108
gem5::SectorTags::tagsInit
void tagsInit() override
Initialize blocks as SectorBlk and SectorSubBlk instances.
Definition: sector_tags.cc:71
gem5::SectorTags::SectorTagsStats
Definition: sector_tags.hh:97
gem5::statistics::Vector
A vector of scalar stats.
Definition: statistics.hh:2003
std::vector
STL vector class.
Definition: stl.hh:37
gem5::SectorTags::numBlocksPerSector
const unsigned numBlocksPerSector
Number of data blocks per sector.
Definition: sector_tags.hh:84
gem5::CacheBlk
A Basic Cache block.
Definition: cache_blk.hh:70
packet.hh
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::BaseTags::Params
BaseTagsParams Params
Definition: base.hh:161
gem5::SectorTags::secBlks
std::vector< SectorBlk > secBlks
The cache sector blocks.
Definition: sector_tags.hh:71
gem5::auxv::Base
@ Base
Definition: aux_vector.hh:76
gem5::SectorTags::sectorStats
gem5::SectorTags::SectorTagsStats sectorStats
gem5::BaseTags::size
const unsigned size
The size of the cache.
Definition: base.hh:81
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::SectorTags::replacementPolicy
replacement_policy::Base * replacementPolicy
Replacement policy.
Definition: sector_tags.hh:81
gem5::SectorTags::SectorTagsStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: sector_tags.cc:350
base.hh
sector_blk.hh
Copyright (c) 2018, 2020 Inria All rights reserved.
gem5::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:363
gem5::SectorTags::accessBlock
CacheBlk * accessBlock(const PacketPtr pkt, Cycles &lat) override
Access block and update replacement data.
Definition: sector_tags.cc:142
gem5::SectorTags::anyBlk
bool anyBlk(std::function< bool(CacheBlk &)> visitor) override
Find if any of the sub-blocks satisfies a condition.
Definition: sector_tags.cc:371
gem5::replacement_policy::Base
A common base class of cache replacement policy objects.
Definition: base.hh:55
gem5::SectorTags::SectorTagsStats::evictionsReplacement
statistics::Vector evictionsReplacement
Number of sub-blocks evicted due to a replacement.
Definition: sector_tags.hh:106
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::SectorTags::SectorTagsStats::tags
const SectorTags & tags
Definition: sector_tags.hh:99
gem5::SectorTags::SectorTagsStats::SectorTagsStats
SectorTagsStats(BaseTagStats &base_group, SectorTags &_tags)
Definition: sector_tags.cc:341
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::SectorTags
A SectorTags cache tag store.
Definition: sector_tags.hh:65
gem5::SectorTags::sequentialAccess
const bool sequentialAccess
Whether tags and data are accessed sequentially.
Definition: sector_tags.hh:78
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::SectorTags::SectorTags
SectorTags(const Params &p)
Construct and initialize this tag store.
Definition: sector_tags.cc:51
gem5::SectorTags::sectorMask
const unsigned sectorMask
Mask out all bits that aren't part of the sector tag.
Definition: sector_tags.hh:95
gem5::BaseTags
A common base class of Cache tagstore objects.
Definition: base.hh:73
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::SectorTags::numSectors
const unsigned numSectors
The number of sectors in the cache.
Definition: sector_tags.hh:87
gem5::SectorTags::extractSectorOffset
int extractSectorOffset(Addr addr) const
Calculate a block's offset in a sector from the address.
Definition: sector_tags.cc:326
gem5::SectorTags::moveBlock
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
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:25:30 for gem5 by doxygen 1.8.17