gem5  v19.0.0.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 
37 
38 #include <cassert>
39 
40 #include "base/cprintf.hh"
41 #include "base/logging.hh"
42 
43 void
45 {
46  assert(sector_blk != nullptr);
47  _sectorBlk = sector_blk;
48 }
49 
50 const SectorBlk*
52 {
53  return _sectorBlk;
54 }
55 
56 void
57 SectorSubBlk::setSectorOffset(const int sector_offset)
58 {
59  _sectorOffset = sector_offset;
60 }
61 
62 int
64 {
65  return _sectorOffset;
66 }
67 
68 Addr
70 {
71  return _sectorBlk->getTag();
72 }
73 
74 void
76 {
79 }
80 
81 void
83 {
86 }
87 
88 void
90 {
93 }
94 
95 void
96 SectorSubBlk::insert(const Addr tag, const bool is_secure,
97  const int src_master_ID, const uint32_t task_ID)
98 {
99  // Make sure it is not overwriting another sector
101  ((_sectorBlk->getTag() != tag) ||
102  (_sectorBlk->isSecure() != is_secure)),
103  "Overwriting valid sector!");
104 
105  CacheBlk::insert(tag, is_secure, src_master_ID, task_ID);
106 
107  // Set sector tag
108  _sectorBlk->setTag(tag);
109 }
110 
111 std::string
113 {
114  return csprintf("%s sector offset: %#x", CacheBlk::print(),
115  getSectorOffset());
116 }
117 
119  : ReplaceableEntry(), _validCounter(0), _tag(MaxAddr), _secureBit(false)
120 {
121 }
122 
123 bool
125 {
126  // If any of the blocks in the sector is valid, so is the sector
127  return _validCounter > 0;
128 }
129 
130 uint8_t
132 {
133  return _validCounter;
134 }
135 
136 bool
138 {
139  // If any of the valid blocks in the sector is secure, so is the sector
140  return _secureBit;
141 }
142 
143 void
145 {
146  _tag = tag;
147 }
148 
149 Addr
151 {
152  return _tag;
153 }
154 
155 void
157 {
158  _validCounter++;
159 }
160 
161 void
163 {
164  // If all sub-blocks have been invalidated, the sector becomes invalid,
165  // so clear secure bit
166  if (--_validCounter == 0) {
167  _secureBit = false;
168  }
169 }
170 
171 void
173 {
174  _secureBit = true;
175 }
176 
177 void
178 SectorBlk::setPosition(const uint32_t set, const uint32_t way)
179 {
181  for (auto& blk : blks) {
182  blk->setPosition(set, way);
183  }
184 }
const SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Definition: sector_blk.cc:51
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: sector_blk.cc:112
const Addr MaxAddr
Definition: types.hh:166
void setValid() override
Set valid bit and inform sector block.
Definition: sector_blk.cc:75
int _sectorOffset
The offset of this sub-block in the sector.
Definition: sector_blk.hh:61
virtual void setValid()
Set valid bit.
Definition: cache_blk.hh:256
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:349
Addr tag
Data block tag value.
Definition: cache_blk.hh:94
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
Definition: sector_blk.hh:169
Addr _tag
Sector tag value.
Definition: sector_blk.hh:158
bool isValid() const
Checks that a sector block is valid.
Definition: sector_blk.cc:124
bool _secureBit
Whether sector blk is in secure-space or not.
Definition: sector_blk.hh:163
void validateSubBlk()
Increase the number of valid sub-blocks.
Definition: sector_blk.cc:156
virtual void setSecure()
Set secure bit.
Definition: cache_blk.hh:265
void invalidate() override
Invalidate the block and inform sector block.
Definition: sector_blk.cc:89
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
Definition: sector_blk.cc:131
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
Addr getTag() const
Get tag associated to this block.
Definition: sector_blk.cc:150
virtual void insert(const Addr tag, const bool is_secure, const int src_master_ID, const uint32_t task_ID)
Set member variables when a block insertion occurs.
Definition: cache_blk.cc:46
void setSecure()
Set secure bit.
Definition: sector_blk.cc:172
Copyright (c) 2018 Inria All rights reserved.
SectorBlk * _sectorBlk
Sector block associated to this block.
Definition: sector_blk.hh:56
void setSectorBlock(SectorBlk *sector_blk)
Set sector block associated to this block.
Definition: sector_blk.cc:44
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void setTag(const Addr tag)
Set tag associated to this block.
Definition: sector_blk.cc:144
void setSectorOffset(const int sector_offset)
Set offset of this sub-block within the sector.
Definition: sector_blk.cc:57
int getSectorOffset() const
Get offset of this sub-block within the sector.
Definition: sector_blk.cc:63
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:178
void invalidateSubBlk()
Decrease the number of valid sub-blocks.
Definition: sector_blk.cc:162
bool isSecure() const
Checks that a sector block is secure.
Definition: sector_blk.cc:137
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
A Basic Sector block.
Definition: sector_blk.hh:145
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
uint8_t _validCounter
Counter of the number of valid sub-blocks.
Definition: sector_blk.hh:152
void insert(const Addr tag, const bool is_secure, const int src_master_ID, const uint32_t task_ID) override
Set member variables when a block insertion occurs.
Definition: sector_blk.cc:96
virtual void invalidate()
Invalidate the block and clear all state.
Definition: cache_blk.hh:214
void setSecure() override
Set secure bit and inform sector block.
Definition: sector_blk.cc:82
Addr getTag() const
Get tag associated to this block.
Definition: sector_blk.cc:69

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13