fn l1_miss_handler(&mut self, index: u64) -> Result<u64, ()> {
		// let index: u64 = (index >> L1_CACHE_OFFSET_BITS) & ((1 << L1_CACHE_INDEX_BITS) - 1);
		let way = self
			.l1_cache
			.allocate_new_line(index, PlacementPolicy::Random);
		let victim = self.l1_cache.data[index as usize].data[way as usize];

		// Detect victim cache line
		// write back the victim
		match victim.valid {
			true => {
				self.l1_write_back(victim, index);
				// Latency for checking
				self.clock = self.clock.wrapping_add(L1_CACHE_HIT_LATENCY as u64);
			}
			false => {
				// Latency for checking
				self.clock = self.clock.wrapping_add(L1_CACHE_HIT_LATENCY as u64);
			}
		}

		Ok(way as u64)
	}
/// Allocate a new L1 entry
/// with returning the allocated way index
///
/// # Arguments
/// * `index`: physical address
Allocate a new L1 entry
with returning the allocated way index
Allocate a new L1 entry with returning the allocated way index
fn l1_miss_handler(&mut self, index: u64) -> Result<u64, ()> {
		// let index: u64 = (index >> L1_CACHE_OFFSET_BITS) & ((1 << L1_CACHE_INDEX_BITS) - 1);
		let way = self
			.l1_cache
			.allocate_new_line(index, PlacementPolicy::Random);
		let victim = self.l1_cache.data[index as usize].data[way as usize];
		// Detect victim cache line
		// write back the victim
		match victim.valid {
			true => {
				self.l1_write_back(victim, index);
				// Latency for checking
				self.clock = self.clock.wrapping_add(L1_CACHE_HIT_LATENCY as u64);
			}
			false => {
				// Latency for checking
				self.clock = self.clock.wrapping_add(L1_CACHE_HIT_LATENCY as u64);
			}
		}
		Ok(way as u64)
	}
fn l1_miss_handler ( & mut self , index : u64 ) -> Result < u64 , ( ) > { // let index: u64 = (index >> L1_CACHE_OFFSET_BITS) & ((1 << L1_CACHE_INDEX_BITS) - 1); let way = self . l1_cache . allocate_new_line ( index , PlacementPolicy :: Random ) ; let victim = self . l1_cache . data [ index as usize ] . data [ way as usize ] ; // Detect victim cache line // write back the victim match victim . valid { true => { self . l1_write_back ( victim , index ) ; // Latency for checking self . clock = self . clock . wrapping_add ( L1_CACHE_HIT_LATENCY as u64 ) ; } false => { // Latency for checking self . clock = self . clock . wrapping_add ( L1_CACHE_HIT_LATENCY as u64 ) ; } } Ok ( way as u64 ) }
Allocate a new L1 entry
with returning the allocated way index
Allocate a new L1 entry with returning the allocated way index
&mut self
index
u64