summaryrefslogtreecommitdiff
path: root/src/mem/protocol/MOESI_CMP_token-L2cache.sm
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2015-08-14 00:19:39 -0500
committerJoel Hestness <jthestness@gmail.com>2015-08-14 00:19:39 -0500
commitbf06911b3f6d992dc78489d66410f4580a17db7b (patch)
tree74799214cc889c3531d263543af4d144d5a3bf9c /src/mem/protocol/MOESI_CMP_token-L2cache.sm
parent9567c839fecfdb29a59f9da50cf706fcb22a2bb1 (diff)
downloadgem5-bf06911b3f6d992dc78489d66410f4580a17db7b.tar.xz
ruby: Change PerfectCacheMemory::lookup to return pointer
CacheMemory and DirectoryMemory lookup functions return pointers to entries stored in the memory. Bring PerfectCacheMemory in line with this convention, and clean up SLICC code generation that was in place solely to handle references like that which was returned by PerfectCacheMemory::lookup.
Diffstat (limited to 'src/mem/protocol/MOESI_CMP_token-L2cache.sm')
-rw-r--r--src/mem/protocol/MOESI_CMP_token-L2cache.sm35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/mem/protocol/MOESI_CMP_token-L2cache.sm b/src/mem/protocol/MOESI_CMP_token-L2cache.sm
index 6542ede49..ad746a275 100644
--- a/src/mem/protocol/MOESI_CMP_token-L2cache.sm
+++ b/src/mem/protocol/MOESI_CMP_token-L2cache.sm
@@ -123,7 +123,7 @@ machine(L2Cache, "Token protocol")
DataBlock DataBlk, desc="data for the block";
}
- structure(DirEntry, desc="...") {
+ structure(DirEntry, desc="...", interface="AbstractEntry") {
Set Sharers, desc="Set of the internal processors that want the block in shared state";
bool exclusive, default="false", desc="if local exclusive is likely";
}
@@ -157,6 +157,10 @@ machine(L2Cache, "Token protocol")
return cache_entry;
}
+ DirEntry getDirEntry(Address address), return_by_pointer="yes" {
+ return localDirectory.lookup(address);
+ }
+
void functionalRead(Address addr, Packet *pkt) {
testAndRead(addr, getCacheEntry(addr).DataBlk, pkt);
}
@@ -241,8 +245,9 @@ machine(L2Cache, "Token protocol")
void removeSharer(Address addr, NodeID id) {
if (localDirectory.isTagPresent(addr)) {
- localDirectory[addr].Sharers.remove(id);
- if (localDirectory[addr].Sharers.count() == 0) {
+ DirEntry dir_entry := getDirEntry(addr);
+ dir_entry.Sharers.remove(id);
+ if (dir_entry.Sharers.count() == 0) {
localDirectory.deallocate(addr);
}
}
@@ -250,7 +255,8 @@ machine(L2Cache, "Token protocol")
bool sharersExist(Address addr) {
if (localDirectory.isTagPresent(addr)) {
- if (localDirectory[addr].Sharers.count() > 0) {
+ DirEntry dir_entry := getDirEntry(addr);
+ if (dir_entry.Sharers.count() > 0) {
return true;
}
else {
@@ -264,7 +270,8 @@ machine(L2Cache, "Token protocol")
bool exclusiveExists(Address addr) {
if (localDirectory.isTagPresent(addr)) {
- if (localDirectory[addr].exclusive) {
+ DirEntry dir_entry := getDirEntry(addr);
+ if (dir_entry.exclusive) {
return true;
}
else {
@@ -278,29 +285,33 @@ machine(L2Cache, "Token protocol")
// assumes that caller will check to make sure tag is present
Set getSharers(Address addr) {
- return localDirectory[addr].Sharers;
+ DirEntry dir_entry := getDirEntry(addr);
+ return dir_entry.Sharers;
}
void setNewWriter(Address addr, NodeID id) {
if (localDirectory.isTagPresent(addr) == false) {
localDirectory.allocate(addr);
}
- localDirectory[addr].Sharers.clear();
- localDirectory[addr].Sharers.add(id);
- localDirectory[addr].exclusive := true;
+ DirEntry dir_entry := getDirEntry(addr);
+ dir_entry.Sharers.clear();
+ dir_entry.Sharers.add(id);
+ dir_entry.exclusive := true;
}
void addNewSharer(Address addr, NodeID id) {
if (localDirectory.isTagPresent(addr) == false) {
localDirectory.allocate(addr);
}
- localDirectory[addr].Sharers.add(id);
- // localDirectory[addr].exclusive := false;
+ DirEntry dir_entry := getDirEntry(addr);
+ dir_entry.Sharers.add(id);
+ // dir_entry.exclusive := false;
}
void clearExclusiveBitIfExists(Address addr) {
if (localDirectory.isTagPresent(addr)) {
- localDirectory[addr].exclusive := false;
+ DirEntry dir_entry := getDirEntry(addr);
+ dir_entry.exclusive := false;
}
}