mem-cache: Create block insertion function
Create a block insertion function to be used when inserting blocks. This resets the number of references to 1 (the insertion is taken into account), sets the insertion tick, and set secure state. Change-Id: Ifc34cbbd1c125207ce47912d188809221c7a157e Reviewed-on: https://gem5-review.googlesource.com/9824 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
376f1b2ff7
commit
0b0629cda6
30
src/mem/cache/blk.cc
vendored
30
src/mem/cache/blk.cc
vendored
@@ -42,6 +42,36 @@
|
||||
|
||||
#include "base/cprintf.hh"
|
||||
|
||||
void
|
||||
CacheBlk::insert(const Addr tag, const State is_secure,
|
||||
const int src_master_ID, const uint32_t task_ID)
|
||||
{
|
||||
// Touch block
|
||||
isTouched = true;
|
||||
|
||||
// Set block tag
|
||||
this->tag = tag;
|
||||
|
||||
// Set source requestor ID
|
||||
srcMasterId = src_master_ID;
|
||||
|
||||
// Set task ID
|
||||
task_id = task_ID;
|
||||
|
||||
// Set insertion tick as current tick
|
||||
tickInserted = curTick();
|
||||
|
||||
// Insertion counts as a reference to the block
|
||||
refCount = 1;
|
||||
|
||||
// Set secure state
|
||||
if (is_secure) {
|
||||
status = BlkSecure;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CacheBlkPrintWrapper::print(std::ostream &os, int verbosity,
|
||||
const std::string &prefix) const
|
||||
|
||||
14
src/mem/cache/blk.hh
vendored
14
src/mem/cache/blk.hh
vendored
@@ -252,6 +252,20 @@ class CacheBlk : public ReplaceableEntry
|
||||
return (status & BlkSecure) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set member variables when a block insertion occurs. Resets reference
|
||||
* count to 1 (the insertion counts as a reference), and touch block if
|
||||
* it hadn't been touched previously. Sets the insertion tick to the
|
||||
* current tick. Does not make block valid.
|
||||
*
|
||||
* @param tag Block address tag.
|
||||
* @param is_secure Whether the block is in secure space or not.
|
||||
* @param src_master_ID The source requestor ID.
|
||||
* @param task_ID The new task ID.
|
||||
*/
|
||||
void insert(const Addr tag, const State is_secure, const int src_master_ID,
|
||||
const uint32_t task_ID);
|
||||
|
||||
/**
|
||||
* Track the fact that a local locked was issued to the
|
||||
* block. Invalidate any previous LL to the same address.
|
||||
|
||||
10
src/mem/cache/cache.cc
vendored
10
src/mem/cache/cache.cc
vendored
@@ -397,10 +397,7 @@ Cache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat,
|
||||
}
|
||||
tags->insertBlock(pkt, blk);
|
||||
|
||||
blk->status = (BlkValid | BlkReadable);
|
||||
if (pkt->isSecure()) {
|
||||
blk->status |= BlkSecure;
|
||||
}
|
||||
blk->status |= (BlkValid | BlkReadable);
|
||||
}
|
||||
// only mark the block dirty if we got a writeback command,
|
||||
// and leave it as is for a clean writeback
|
||||
@@ -460,10 +457,7 @@ Cache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat,
|
||||
}
|
||||
tags->insertBlock(pkt, blk);
|
||||
|
||||
blk->status = (BlkValid | BlkReadable);
|
||||
if (pkt->isSecure()) {
|
||||
blk->status |= BlkSecure;
|
||||
}
|
||||
blk->status |= (BlkValid | BlkReadable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
src/mem/cache/tags/base.cc
vendored
14
src/mem/cache/tags/base.cc
vendored
@@ -100,26 +100,18 @@ BaseTags::insertBlock(PacketPtr pkt, CacheBlk *blk)
|
||||
blk->invalidate();
|
||||
}
|
||||
|
||||
// Touch block
|
||||
blk->isTouched = true;
|
||||
blk->refCount = 1;
|
||||
blk->tickInserted = curTick();
|
||||
|
||||
// Previous block, if existed, has been removed, and now we have
|
||||
// to insert the new one
|
||||
tagsInUse++;
|
||||
|
||||
// Set tag for new block. Caller is responsible for setting status.
|
||||
blk->tag = extractTag(addr);
|
||||
|
||||
// Deal with what we are bringing in
|
||||
MasterID master_id = pkt->req->masterId();
|
||||
assert(master_id < cache->system->maxMasters());
|
||||
occupancies[master_id]++;
|
||||
blk->srcMasterId = master_id;
|
||||
|
||||
// Set task id
|
||||
blk->task_id = pkt->req->taskId();
|
||||
// Insert block with tag, src master id and task id
|
||||
blk->insert(extractTag(addr), pkt->isSecure(), master_id,
|
||||
pkt->req->taskId());
|
||||
|
||||
// We only need to write into one tag and one data block.
|
||||
tagAccesses += 1;
|
||||
|
||||
Reference in New Issue
Block a user