65 writes.insert(std::make_pair(serial,
72 auto it =
writes.find(serial);
75 warn(
"Could not locate write transaction: serial = %d, complete = %d\n",
82 it->second.complete = _complete;
103 if (!
writes.erase(serial)) {
104 warn(
"Could not locate write transaction: serial = %d\n", serial);
122 outstandingReads.insert(std::make_pair(serial,
129 _lastExpectedData.clear();
131 bool wc_overlap =
true;
135 *lastCompletedTransaction(&readObservations, start);
140 for (
auto cluster = writeClusters.rbegin();
141 cluster != writeClusters.rend() && wc_overlap; ++cluster) {
142 for (
const auto& addr_write : cluster->writes) {
152 if (write.
data == data) {
158 _lastExpectedData.push_back(write.
data);
178 last_obs_valid =
false;
185 if (last_obs_valid) {
189 if (last_obs.
data == data) {
194 _lastExpectedData.push_back(last_obs.
data);
200 if (!writeClusters.empty() && wc_overlap) {
202 assert(writeClusters.begin()->start < complete &&
203 writeClusters.rbegin()->complete >
start);
208 if (_lastExpectedData.empty()) {
213 "complete = %d, data = %#x\n", start, complete, data);
223 auto it = outstandingReads.find(serial);
225 if (it == outstandingReads.end()) {
227 warn(
"Could not locate read transaction: serial = %d, complete = %d\n",
233 outstandingReads.erase(it);
236 const bool result = inExpectedData(start, complete, data);
238 readObservations.emplace_back(serial, start, complete, data);
247 if (writeClusters.empty() || writeClusters.back().isComplete()) {
248 writeClusters.emplace_back();
251 return &writeClusters.back();
258 getIncompleteWriteCluster()->startWrite(serial, start, data);
264 getIncompleteWriteCluster()->completeWrite(serial, complete);
271 getIncompleteWriteCluster()->abortWrite(serial);
280 const Tick before = outstandingReads.empty() ?
curTick() :
281 outstandingReads.begin()->second.start;
284 readObservations.erase(readObservations.begin(),
285 lastCompletedTransaction(&readObservations, before));
288 if (!writeClusters.empty()) {
289 writeClusters.erase(writeClusters.begin(),
290 lastCompletedTransaction(&writeClusters, before));
301 "completing read: serial = %d, complete = %d, " 302 "addr = %#llx, size = %d\n", serial, complete, addr, size);
304 for (
size_t i = 0;
i < size; ++
i) {
318 "failed: received %#x, expected ",
319 (
unsigned long long)(addr + i), data[i]);
342 for (
size_t i = 0;
i < size; ++
i) {
348 MemCheckerParams::create()
void abortWrite(Serial serial)
Aborts a write transaction.
Tick complete
Completion tick.
bool completeRead(Serial serial, Tick complete, Addr addr, size_t size, uint8_t *data)
Completes a previously started read transaction.
ByteTracker * getByteTracker(Addr addr)
Returns the instance of ByteTracker for the requested location.
The Transaction class captures the lifetimes of read and write operations, and the values they consum...
std::unordered_map< Serial, Transaction > writes
Map of Serial –> Transaction of all writes in cluster; contains all, in-flight or already completed...
void completeWrite(Serial serial, Tick _complete)
Completes a write transaction.
const std::vector< uint8_t > & lastExpectedData() const
This function returns the expected data that inExpectedData iterated through in the last call...
#define chatty_assert(cond,...)
The chatty assert macro will function like a normal assert, but will allow the specification of addit...
uint64_t Serial
The Serial type is used to be able to uniquely identify a transaction as it passes through the system...
MemChecker(const MemCheckerParams *p)
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
std::unordered_map< Addr, ByteTracker > byte_trackers
Maintain a map of address –> byte-tracker.
uint64_t Tick
Tick count type.
The ByteTracker keeps track of transactions for the same byte – all outstanding reads, the completed reads (and what they observed) and write clusters (see WriteCluster).
void reset()
Resets the entire checker.
std::string errorMessage
Detailed error message of the last violation in completeRead.
void completeWrite(Serial serial, Tick complete)
Completes a write transaction.
WriteCluster * getIncompleteWriteCluster()
Convenience function to return the most recent incomplete write cluster.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void startWrite(Serial serial, Tick start, uint8_t data)
Starts a write transaction.
bool inExpectedData(Tick start, Tick complete, uint8_t data)
Given a start and end time (of any read transaction), this function iterates through all data that su...
static const Tick TICK_INITIAL
The initial tick the system starts with.
The WriteCluster class captures sets of writes where all writes are overlapping with at least one oth...
Tick start
Start of earliest write in cluster.
bool completeRead(Serial serial, Tick complete, uint8_t data)
Completes a read transaction that is still outstanding.
void abortWrite(Serial serial)
Aborts a write transaction.
uint8_t data
Depending on the memory operation, the data value either represents: for writes, the value written up...
void startWrite(Serial serial, Tick _start, uint8_t data)
Starts a write transaction.
void pruneTransactions()
Prunes no longer needed transactions.
static const Tick TICK_FUTURE
The maximum value that curTick() could ever return.
Tick complete
Completion of last write in cluster.
void startRead(Serial serial, Tick start)
Starts a read transaction.