aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shareable_cache.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shareable_cache.rs b/src/shareable_cache.rs
index 9f558cd..9e0725a 100644
--- a/src/shareable_cache.rs
+++ b/src/shareable_cache.rs
@@ -45,6 +45,16 @@ impl<'a> ShareableCache<'a> {
(primary_accessible, secondary_accessible)
}
+
+ fn snoop(cache: &mut SharedMemory<'a>,
+ address: isa::Address, value: isa::Word) {
+ // Cache snooping: update all cache lines when a write is made
+ if cache.borrow().is_address_accessible(address) {
+ // Depends on invariant: write_word completes instantly
+ // when the address is accessible (in-cache)
+ cache.borrow_mut().write_word(address, value);
+ }
+ }
}
impl<'a> MemoryInterface for ShareableCache<'a> {
@@ -97,22 +107,27 @@ impl<'a> MemoryInterface for ShareableCache<'a> {
self.address_accessible(address);
if primary_accessible {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
else if secondary_accessible {
+ ShareableCache::snoop(&mut self.primary, address, value);
self.secondary.borrow_mut().write_word(address, value)
}
else {
self.use_secondary = !self.use_secondary;
if self.use_secondary {
+ ShareableCache::snoop(&mut self.primary, address, value);
self.secondary.borrow_mut().write_word(address, value)
}
else {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
}
}
else {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
}