gem5  v21.1.0.2
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 namespace gem5
42 {
43 
44 void
46 {
47  assert(sector_blk != nullptr);
48  _sectorBlk = sector_blk;
49 }
50 
51 SectorBlk*
53 {
54  return _sectorBlk;
55 }
56 
57 void
58 SectorSubBlk::setSectorOffset(const int sector_offset)
59 {
60  _sectorOffset = sector_offset;
61 }
62 
63 int
65 {
66  return _sectorOffset;
67 }
68 
69 Addr
71 {
72  // If the sub-block is valid its tag must match its sector's
73  const Addr tag = _sectorBlk->getTag();
74  assert(!isValid() || (CacheBlk::getTag() == tag));
75  return tag;
76 }
77 
78 void
80 {
83 }
84 
85 void
86 SectorSubBlk::insert(const Addr tag, const bool is_secure)
87 {
88  // Make sure it is not overwriting another sector
90  !_sectorBlk->matchTag(tag, is_secure), "Overwriting valid sector!");
91 
92  // If the sector is not valid, insert the new tag. The sector block
93  // handles its own tag's invalidation, so do not attempt to insert MaxAddr.
94  if ((_sectorBlk && !_sectorBlk->isValid()) && (tag != MaxAddr)) {
95  _sectorBlk->insert(tag, is_secure);
96  }
97  CacheBlk::insert(tag, is_secure);
98 }
99 
100 void
102 {
105 }
106 
107 std::string
109 {
110  return csprintf("%s sector offset: %#x", CacheBlk::print(),
111  getSectorOffset());
112 }
113 
115  : TaggedEntry(), _validCounter(0)
116 {
117 }
118 
119 bool
121 {
122  // If any of the blocks in the sector is valid, so is the sector
123  return _validCounter > 0;
124 }
125 
126 uint8_t
128 {
129  return _validCounter;
130 }
131 
132 void
134 {
135  _validCounter++;
136 }
137 
138 void
140 {
141  // If all sub-blocks have been invalidated, the sector becomes invalid,
142  // so clear secure bit
143  if (--_validCounter == 0) {
144  invalidate();
145  }
146 }
147 
148 void
149 SectorBlk::setPosition(const uint32_t set, const uint32_t way)
150 {
152  for (auto& blk : blks) {
153  blk->setPosition(set, way);
154  }
155 }
156 
157 std::string
159 {
160  std::string sub_blk_print;
161  for (const auto& sub_blk : blks) {
162  if (sub_blk->isValid()) {
163  sub_blk_print += "\t[" + sub_blk->print() + "]\n";
164  }
165  }
166  return csprintf("%s valid sub-blks (%d):\n%s",
167  TaggedEntry::print(), getNumValid(), sub_blk_print);
168 }
169 
170 } // namespace gem5
gem5::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:86
gem5::SectorBlk::validateSubBlk
void validateSubBlk()
Increase the number of valid sub-blocks.
Definition: sector_blk.cc:133
gem5::SectorSubBlk::setSectorBlock
void setSectorBlock(SectorBlk *sector_blk)
Set sector block associated to this block.
Definition: sector_blk.cc:45
gem5::SectorSubBlk::_sectorBlk
SectorBlk * _sectorBlk
Sector block associated to this block.
Definition: sector_blk.hh:57
gem5::SectorSubBlk::setSectorOffset
void setSectorOffset(const int sector_offset)
Set offset of this sub-block within the sector.
Definition: sector_blk.cc:58
gem5::TaggedEntry::print
std::string print() const override
Prints relevant information about this entry.
Definition: tagged_entry.hh:111
gem5::SectorBlk::invalidateSubBlk
void invalidateSubBlk()
Decrease the number of valid sub-blocks.
Definition: sector_blk.cc:139
gem5::ReplaceableEntry::setPosition
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
Definition: replaceable_entry.hh:93
gem5::SectorBlk::SectorBlk
SectorBlk()
Definition: sector_blk.cc:114
gem5::SectorBlk
A Basic Sector block.
Definition: sector_blk.hh:134
gem5::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:81
gem5::TaggedEntry::getTag
virtual Addr getTag() const
Get tag associated to this block.
Definition: tagged_entry.hh:71
gem5::csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
gem5::SectorSubBlk::getSectorBlock
SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Definition: sector_blk.cc:52
gem5::SectorBlk::blks
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
Definition: sector_blk.hh:147
gem5::SectorSubBlk::setValid
void setValid() override
Set valid bit and inform sector block.
Definition: sector_blk.cc:79
gem5::TaggedEntry
A tagged entry is an entry containing a tag.
Definition: tagged_entry.hh:46
gem5::MaxAddr
const Addr MaxAddr
Definition: types.hh:171
gem5::SectorSubBlk::_sectorOffset
int _sectorOffset
The offset of this sub-block in the sector.
Definition: sector_blk.hh:62
gem5::SectorSubBlk::getTag
Addr getTag() const override
Get tag associated to this block.
Definition: sector_blk.cc:70
gem5::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:364
sector_blk.hh
Copyright (c) 2018, 2020 Inria All rights reserved.
cprintf.hh
gem5::TaggedEntry::invalidate
virtual void invalidate()
Invalidate the block.
Definition: tagged_entry.hh:103
gem5::SectorSubBlk::print
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: sector_blk.cc:108
gem5::SectorBlk::_validCounter
uint8_t _validCounter
Counter of the number of valid sub-blocks.
Definition: sector_blk.hh:141
gem5::SectorBlk::isValid
bool isValid() const override
Checks that a sector block is valid.
Definition: sector_blk.cc:120
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
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:203
gem5::SectorSubBlk::invalidate
void invalidate() override
Invalidate the block and inform sector block.
Definition: sector_blk.cc:101
gem5::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:93
gem5::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:149
logging.hh
gem5::SectorSubBlk::getSectorOffset
int getSectorOffset() const
Get offset of this sub-block within the sector.
Definition: sector_blk.cc:64
gem5::CacheBlk::invalidate
virtual void invalidate() override
Invalidate the block and clear all state.
Definition: cache_blk.hh:200
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::TaggedEntry::setValid
virtual void setValid()
Set valid bit.
Definition: tagged_entry.hh:130
gem5::SectorBlk::getNumValid
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
Definition: sector_blk.cc:127
gem5::TaggedEntry::isValid
virtual bool isValid() const
Checks if the entry is valid.
Definition: tagged_entry.hh:57
gem5::SectorBlk::print
std::string print() const override
Print relevant information for this sector block and its sub-blocks.
Definition: sector_blk.cc:158
gem5::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:50

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