gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sector_blk.cc
Go to the documentation of this file.
1 
35 
36 #include <cassert>
37 
38 #include "base/cprintf.hh"
39 #include "base/logging.hh"
40 
41 void
43 {
44  assert(sector_blk != nullptr);
45  _sectorBlk = sector_blk;
46 }
47 
48 SectorBlk*
50 {
51  return _sectorBlk;
52 }
53 
54 void
55 SectorSubBlk::setSectorOffset(const int sector_offset)
56 {
57  _sectorOffset = sector_offset;
58 }
59 
60 int
62 {
63  return _sectorOffset;
64 }
65 
66 Addr
68 {
69  // If the sub-block is valid its tag must match its sector's
70  const Addr tag = _sectorBlk->getTag();
71  assert(!isValid() || (CacheBlk::getTag() == tag));
72  return tag;
73 }
74 
75 void
77 {
80 }
81 
82 void
83 SectorSubBlk::insert(const Addr tag, const bool is_secure)
84 {
85  // Make sure it is not overwriting another sector
87  !_sectorBlk->matchTag(tag, is_secure), "Overwriting valid sector!");
88 
89  // If the sector is not valid, insert the new tag. The sector block
90  // handles its own tag's invalidation, so do not attempt to insert MaxAddr.
91  if ((_sectorBlk && !_sectorBlk->isValid()) && (tag != MaxAddr)) {
92  _sectorBlk->insert(tag, is_secure);
93  }
94  CacheBlk::insert(tag, is_secure);
95 }
96 
97 void
99 {
102 }
103 
104 std::string
106 {
107  return csprintf("%s sector offset: %#x", CacheBlk::print(),
108  getSectorOffset());
109 }
110 
112  : TaggedEntry(), _validCounter(0)
113 {
114 }
115 
116 bool
118 {
119  // If any of the blocks in the sector is valid, so is the sector
120  return _validCounter > 0;
121 }
122 
123 uint8_t
125 {
126  return _validCounter;
127 }
128 
129 void
131 {
132  _validCounter++;
133 }
134 
135 void
137 {
138  // If all sub-blocks have been invalidated, the sector becomes invalid,
139  // so clear secure bit
140  if (--_validCounter == 0) {
141  invalidate();
142  }
143 }
144 
145 void
146 SectorBlk::setPosition(const uint32_t set, const uint32_t way)
147 {
149  for (auto& blk : blks) {
150  blk->setPosition(set, way);
151  }
152 }
153 
154 std::string
156 {
157  std::string sub_blk_print;
158  for (const auto& sub_blk : blks) {
159  if (sub_blk->isValid()) {
160  sub_blk_print += "\t[" + sub_blk->print() + "]\n";
161  }
162  }
163  return csprintf("%s valid sub-blks (%d):\n%s",
164  TaggedEntry::print(), getNumValid(), sub_blk_print);
165 }
TaggedEntry::print
std::string print() const override
Prints relevant information about this entry.
Definition: tagged_entry.hh:108
TaggedEntry::insert
virtual void insert(const Addr tag, const bool is_secure)
Insert the block by assigning it a tag and marking it valid.
Definition: tagged_entry.hh:90
SectorBlk::print
std::string print() const override
Print relevant information for this sector block and its sub-blocks.
Definition: sector_blk.cc:155
TaggedEntry
Copyright (c) 2020 Inria All rights reserved.
Definition: tagged_entry.hh:43
SectorBlk::_validCounter
uint8_t _validCounter
Counter of the number of valid sub-blocks.
Definition: sector_blk.hh:138
SectorSubBlk::invalidate
void invalidate() override
Invalidate the block and inform sector block.
Definition: sector_blk.cc:98
TaggedEntry::matchTag
virtual bool matchTag(Addr tag, bool is_secure) const
Checks if the given tag information corresponds to this entry's.
Definition: tagged_entry.hh:78
MaxAddr
const Addr MaxAddr
Definition: types.hh:172
SectorSubBlk::_sectorBlk
SectorBlk * _sectorBlk
Sector block associated to this block.
Definition: sector_blk.hh:54
SectorSubBlk::insert
void insert(const Addr tag, const bool is_secure) override
Insert the block by assigning it a tag and marking it valid.
Definition: sector_blk.cc:83
SectorBlk::blks
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
Definition: sector_blk.hh:144
CacheBlk::invalidate
virtual void invalidate() override
Invalidate the block and clear all state.
Definition: cache_blk.hh:196
SectorSubBlk::setSectorBlock
void setSectorBlock(SectorBlk *sector_blk)
Set sector block associated to this block.
Definition: sector_blk.cc:42
SectorBlk::invalidateSubBlk
void invalidateSubBlk()
Decrease the number of valid sub-blocks.
Definition: sector_blk.cc:136
SectorBlk::setPosition
void setPosition(const uint32_t set, const uint32_t way) override
Sets the position of the sub-entries, besides its own.
Definition: sector_blk.cc:146
ReplaceableEntry::setPosition
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
Definition: replaceable_entry.hh:87
SectorSubBlk::setValid
void setValid() override
Set valid bit and inform sector block.
Definition: sector_blk.cc:76
sector_blk.hh
Copyright (c) 2018, 2020 Inria All rights reserved.
cprintf.hh
CacheBlk::print
std::string print() const override
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI...
Definition: cache_blk.hh:360
TaggedEntry::isValid
virtual bool isValid() const
Checks if the entry is valid.
Definition: tagged_entry.hh:54
SectorSubBlk::getTag
Addr getTag() const override
Get tag associated to this block.
Definition: sector_blk.cc:67
SectorBlk::getNumValid
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
Definition: sector_blk.cc:124
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
SectorSubBlk::getSectorBlock
SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Definition: sector_blk.cc:49
SectorSubBlk::_sectorOffset
int _sectorOffset
The offset of this sub-block in the sector.
Definition: sector_blk.hh:59
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:197
SectorBlk::validateSubBlk
void validateSubBlk()
Increase the number of valid sub-blocks.
Definition: sector_blk.cc:130
SectorSubBlk::print
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: sector_blk.cc:105
CacheBlk::insert
void insert(const Addr tag, const bool is_secure, const int src_requestor_ID, const uint32_t task_ID)
Set member variables when a block insertion occurs.
Definition: cache_blk.cc:47
TaggedEntry::invalidate
virtual void invalidate()
Invalidate the block.
Definition: tagged_entry.hh:100
SectorSubBlk::setSectorOffset
void setSectorOffset(const int sector_offset)
Set offset of this sub-block within the sector.
Definition: sector_blk.cc:55
TaggedEntry::getTag
virtual Addr getTag() const
Get tag associated to this block.
Definition: tagged_entry.hh:68
SectorSubBlk::getSectorOffset
int getSectorOffset() const
Get offset of this sub-block within the sector.
Definition: sector_blk.cc:61
logging.hh
SectorBlk
A Basic Sector block.
Definition: sector_blk.hh:131
SectorBlk::isValid
bool isValid() const override
Checks that a sector block is valid.
Definition: sector_blk.cc:117
SectorBlk::SectorBlk
SectorBlk()
Definition: sector_blk.cc:111
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
TaggedEntry::setValid
virtual void setValid()
Set valid bit.
Definition: tagged_entry.hh:127

Generated on Tue Jun 22 2021 15:28:29 for gem5 by doxygen 1.8.17