gem5  v20.1.0.0
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 const 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  return _sectorBlk->getTag();
70 }
71 
72 void
74 {
77 }
78 
79 void
81 {
84 }
85 
86 void
88 {
91 }
92 
93 void
94 SectorSubBlk::insert(const Addr tag, const bool is_secure,
95  const int src_requestor_ID, const uint32_t task_ID)
96 {
97  // Make sure it is not overwriting another sector
99  ((_sectorBlk->getTag() != tag) ||
100  (_sectorBlk->isSecure() != is_secure)),
101  "Overwriting valid sector!");
102 
103  CacheBlk::insert(tag, is_secure, src_requestor_ID, task_ID);
104 
105  // Set sector tag
107 }
108 
109 std::string
111 {
112  return csprintf("%s sector offset: %#x", CacheBlk::print(),
113  getSectorOffset());
114 }
115 
117  : ReplaceableEntry(), _validCounter(0), _tag(MaxAddr), _secureBit(false)
118 {
119 }
120 
121 bool
123 {
124  // If any of the blocks in the sector is valid, so is the sector
125  return _validCounter > 0;
126 }
127 
128 uint8_t
130 {
131  return _validCounter;
132 }
133 
134 bool
136 {
137  // If any of the valid blocks in the sector is secure, so is the sector
138  return _secureBit;
139 }
140 
141 void
143 {
144  _tag = tag;
145 }
146 
147 Addr
149 {
150  return _tag;
151 }
152 
153 void
155 {
156  _validCounter++;
157 }
158 
159 void
161 {
162  // If all sub-blocks have been invalidated, the sector becomes invalid,
163  // so clear secure bit
164  if (--_validCounter == 0) {
165  _secureBit = false;
166  }
167 }
168 
169 void
171 {
172  _secureBit = true;
173 }
174 
175 void
176 SectorBlk::setPosition(const uint32_t set, const uint32_t way)
177 {
179  for (auto& blk : blks) {
180  blk->setPosition(set, way);
181  }
182 }
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
CacheBlk::setValid
virtual void setValid()
Set valid bit.
Definition: cache_blk.hh:253
SectorBlk::_validCounter
uint8_t _validCounter
Counter of the number of valid sub-blocks.
Definition: sector_blk.hh:150
SectorSubBlk::setSecure
void setSecure() override
Set secure bit and inform sector block.
Definition: sector_blk.cc:80
SectorSubBlk::invalidate
void invalidate() override
Invalidate the block and inform sector block.
Definition: sector_blk.cc:87
MaxAddr
const Addr MaxAddr
Definition: types.hh:166
SectorBlk::_secureBit
bool _secureBit
Whether sector blk is in secure-space or not.
Definition: sector_blk.hh:161
SectorBlk::setTag
void setTag(const Addr tag)
Set tag associated to this block.
Definition: sector_blk.cc:142
SectorBlk::getTag
Addr getTag() const
Get tag associated to this block.
Definition: sector_blk.cc:148
SectorSubBlk::_sectorBlk
SectorBlk * _sectorBlk
Sector block associated to this block.
Definition: sector_blk.hh:54
SectorBlk::blks
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
Definition: sector_blk.hh:167
SectorSubBlk::insert
void insert(const Addr tag, const bool is_secure, const int src_requestor_ID, const uint32_t task_ID) override
Set member variables when a block insertion occurs.
Definition: sector_blk.cc:94
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:160
SectorSubBlk::getTag
Addr getTag() const
Get tag associated to this block.
Definition: sector_blk.cc:67
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:176
ReplaceableEntry::setPosition
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
Definition: replaceable_entry.hh:83
SectorSubBlk::setValid
void setValid() override
Set valid bit and inform sector block.
Definition: sector_blk.cc:73
sector_blk.hh
Copyright (c) 2018 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:346
CacheBlk::invalidate
virtual void invalidate()
Invalidate the block and clear all state.
Definition: cache_blk.hh:211
SectorBlk::getNumValid
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
Definition: sector_blk.cc:129
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
CacheBlk::setSecure
virtual void setSecure()
Set secure bit.
Definition: cache_blk.hh:262
SectorBlk::isValid
bool isValid() const
Checks that a sector block is valid.
Definition: sector_blk.cc:122
CacheBlk::tag
Addr tag
Data block tag value.
Definition: cache_blk.hh:91
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:154
SectorSubBlk::print
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: sector_blk.cc:110
SectorBlk::isSecure
bool isSecure() const
Checks that a sector block is secure.
Definition: sector_blk.cc:135
SectorBlk::setSecure
void setSecure()
Set secure bit.
Definition: sector_blk.cc:170
CacheBlk::insert
virtual 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:46
SectorSubBlk::setSectorOffset
void setSectorOffset(const int sector_offset)
Set offset of this sub-block within the sector.
Definition: sector_blk.cc:55
SectorSubBlk::getSectorOffset
int getSectorOffset() const
Get offset of this sub-block within the sector.
Definition: sector_blk.cc:61
SectorBlk::_tag
Addr _tag
Sector tag value.
Definition: sector_blk.hh:156
SectorSubBlk::getSectorBlock
const SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Definition: sector_blk.cc:49
logging.hh
SectorBlk
A Basic Sector block.
Definition: sector_blk.hh:143
SectorBlk::SectorBlk
SectorBlk()
Definition: sector_blk.cc:116
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158

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