gem5 v24.1.0.1
Loading...
Searching...
No Matches
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
41namespace gem5
42{
43
44void
46{
47 assert(sector_blk != nullptr);
48 _sectorBlk = sector_blk;
49}
50
53{
54 return _sectorBlk;
55}
56
57void
58SectorSubBlk::setSectorOffset(const int sector_offset)
59{
60 _sectorOffset = sector_offset;
61}
62
63int
68
69Addr
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
78void
84
85void
87{
88 // Make sure it is not overwriting another sector
90 !_sectorBlk->match(tag), "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.address != MaxAddr)) {
95 _sectorBlk->insert(tag);
96 }
98}
99
100void
106
107std::string
109{
110 return csprintf("%s sector offset: %#x", CacheBlk::print(),
112}
113
115 : TaggedEntry(), _validCounter(0)
116{
117}
118
119bool
121{
122 // If any of the blocks in the sector is valid, so is the sector
123 return _validCounter > 0;
124}
125
126uint8_t
128{
129 return _validCounter;
130}
131
132void
137
138void
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
148void
149SectorBlk::setPosition(const uint32_t set, const uint32_t way)
150{
152 for (auto& blk : blks) {
153 blk->setPosition(set, way);
154 }
155}
156
157std::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
void insert(const KeyType &tag, const int src_requestor_ID, const uint32_t task_ID, const uint64_t partition_id)
Set member variables when a block insertion occurs.
Definition cache_blk.cc:50
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:372
virtual void invalidate() override
Invalidate the block and clear all state.
Definition cache_blk.hh:202
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
A Basic Sector block.
void invalidateSubBlk()
Decrease the number of valid sub-blocks.
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
std::string print() const override
Print relevant information for this sector block and its sub-blocks.
bool isValid() const override
Checks that a sector block is valid.
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
void setPosition(const uint32_t set, const uint32_t way) override
Sets the position of the sub-entries, besides its own.
uint8_t _validCounter
Counter of the number of valid sub-blocks.
void validateSubBlk()
Increase the number of valid sub-blocks.
int getSectorOffset() const
Get offset of this sub-block within the sector.
Definition sector_blk.cc:64
SectorBlk * _sectorBlk
Sector block associated to this block.
Definition sector_blk.hh:57
void setSectorBlock(SectorBlk *sector_blk)
Set sector block associated to this block.
Definition sector_blk.cc:45
void setSectorOffset(const int sector_offset)
Set offset of this sub-block within the sector.
Definition sector_blk.cc:58
Addr getTag() const override
Get tag associated to this block.
Definition sector_blk.cc:70
void invalidate() override
Invalidate the block and inform sector block.
void setValid() override
Set valid bit and inform sector block.
Definition sector_blk.cc:79
void insert(const KeyType &tag) override
Insert the block by assigning it a tag and marking it valid.
Definition sector_blk.cc:86
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
int _sectorOffset
The offset of this sub-block in the sector.
Definition sector_blk.hh:62
SectorBlk * getSectorBlock() const
Get sector block associated to this block.
Definition sector_blk.cc:52
A tagged entry is an entry containing a tag.
virtual bool isValid() const
Checks if the entry is valid.
std::string print() const override
Prints relevant information about this entry.
bool match(const KeyType &key) const
Checks if the given tag information corresponds to this entry's.
virtual void invalidate()
Invalidate the block.
virtual void insert(const KeyType &key)
Insert the block by assigning it a tag and marking it valid.
virtual Addr getTag() const
Get tag associated to this block.
virtual void setValid()
Set valid bit.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:214
Bitfield< 12, 11 > set
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
const Addr MaxAddr
Definition types.hh:171
Copyright (c) 2018, 2020 Inria All rights reserved.

Generated on Mon Jan 13 2025 04:28:38 for gem5 by doxygen 1.9.8