diff options
author | David Li <li.davidm96@gmail.com> | 2015-12-27 09:27:23 -0700 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2015-12-27 09:27:23 -0700 |
commit | 6fbeb4e5ec5f12916853f9a168d6a730992dd63e (patch) | |
tree | 359d328b24ee2d68de72e976b222958a26883e69 /src/memory.rs | |
parent | ccac1d5977e913ef0d3317e3e3074912e6ba59b2 (diff) |
Include fetch requests in cache
Diffstat (limited to 'src/memory.rs')
-rw-r--r-- | src/memory.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/memory.rs b/src/memory.rs index ae3b6fc..e65eb10 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -33,12 +33,20 @@ pub struct Memory { } #[derive(Clone)] +struct FetchRequest { + cycles_left: u32, +} + +#[derive(Clone)] struct CacheBlock { valid: bool, tag: u32, contents: Vec<u32>, + fetch_request: Option<FetchRequest>, } +type CacheSet = Vec<CacheBlock>; + // TODO: probably want different caches for different strategies, and // investigate how LRU is implemented // TODO: use hashtable for a way? @@ -47,7 +55,7 @@ pub struct Cache { num_sets: usize, num_ways: usize, block_words: usize, - cache: Vec<Vec<CacheBlock>>, + cache: Vec<CacheSet>, } impl Memory { @@ -95,15 +103,17 @@ impl MemoryInterface for Memory { impl Cache { pub fn new(sets: usize, ways: usize, block_words: usize) -> Cache { + let set = vec![CacheBlock { + valid: false, + tag: 0, + contents: vec![0; block_words], + fetch_request: None, + }; ways]; Cache { num_sets: sets, num_ways: ways, block_words: block_words, - cache: vec![vec![CacheBlock { - valid: false, - tag: 0, - contents: vec![0; block_words], - }; ways]; sets], + cache: vec![set; sets], } } |