pub fn allocate_new_line(&self, index: u64, policy: PlacementPolicy) -> u8 {
		match policy {
			PlacementPolicy::Random => {
				let mut non_inclusive_ways = vec![];
				for way in 0..L2_SET_ASSOCIATIVE_WAY {
					if self.data[index as usize].data[way as usize].l1_inclusive == false {
						non_inclusive_ways.push(way);
					}
				}
				non_inclusive_ways[(random::<u8>() % (non_inclusive_ways.len() as u8)) as usize]
					as u8
			}
			PlacementPolicy::LRU => {
				// @TODO: LRU
				0
			}
			PlacementPolicy::FIFO => {
				// @TODO: FIFO
				0
			}
		}
	}
/// Placement policy
/// supporting Random, LRU and FIFO
///
/// # Arguments
/// * `index`: index of cache set
Placement policy
supporting Random, LRU and FIFO
Placement policy supporting Random LRU and FIFO
pub fn allocate_new_line(&self, index: u64, policy: PlacementPolicy) -> u8 {
		match policy {
			PlacementPolicy::Random => {
				let mut non_inclusive_ways = vec![];
				for way in 0..L2_SET_ASSOCIATIVE_WAY {
					if self.data[index as usize].data[way as usize].l1_inclusive == false {
						non_inclusive_ways.push(way);
					}
				}
				non_inclusive_ways[(random::<u8>() % (non_inclusive_ways.len() as u8)) as usize]
					as u8
			}
			PlacementPolicy::LRU => {
				// @TODO: LRU
				0
			}
			PlacementPolicy::FIFO => {
				// @TODO: FIFO
				0
			}
		}
	}
pub fn allocate_new_line ( & self , index : u64 , policy : PlacementPolicy ) -> u8 { match policy { PlacementPolicy :: Random => { let mut non_inclusive_ways = vec ! [ ] ; for way in 0 .. L2_SET_ASSOCIATIVE_WAY { if self . data [ index as usize ] . data [ way as usize ] . l1_inclusive == false { non_inclusive_ways . push ( way ) ; } } non_inclusive_ways [ ( random :: < u8 > ( ) % ( non_inclusive_ways . len ( ) as u8 ) ) as usize ] as u8 } PlacementPolicy :: LRU => { // @TODO: LRU 0 } PlacementPolicy :: FIFO => { // @TODO: FIFO 0 } } }
Placement policy
supporting Random, LRU and FIFO
Placement policy supporting Random LRU and FIFO
&self
index
u64
policy
PlacementPolicy