summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-04-13 17:12:36 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-05-08 21:46:21 +0000
commit0b0629cda6cbb4fdc1c1087c762c27c426e8a1c9 (patch)
treedf68c654288b7bb55c496f84d71674d8d77b262b
parent376f1b2ff7034f4d084a087a68307b11042d2a9d (diff)
downloadgem5-0b0629cda6cbb4fdc1c1087c762c27c426e8a1c9.tar.xz
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>
-rw-r--r--src/mem/cache/blk.cc30
-rw-r--r--src/mem/cache/blk.hh14
-rw-r--r--src/mem/cache/cache.cc10
-rw-r--r--src/mem/cache/tags/base.cc14
4 files changed, 49 insertions, 19 deletions
diff --git a/src/mem/cache/blk.cc b/src/mem/cache/blk.cc
index 9475bda31..233f38052 100644
--- a/src/mem/cache/blk.cc
+++ b/src/mem/cache/blk.cc
@@ -43,6 +43,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
{
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index b57c61b63..b634d21f1 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -253,6 +253,20 @@ class CacheBlk : public ReplaceableEntry
}
/**
+ * 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.
*/
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 28c4343d1..2d3ab8312 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -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);
}
}
diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc
index 2f8d428c7..1d6ed4663 100644
--- a/src/mem/cache/tags/base.cc
+++ b/src/mem/cache/tags/base.cc
@@ -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;