use super::*;
#[derive(Debug, Default, Clone, Copy)]
pub enum SatCounter {
StronglyNotTaken,
#[default]
WeaklyNotTaken,
WeaklyTaken,
StronglyTaken,
}
impl SatCounter {
pub fn increment(self) -> Self {
match self {
SatCounter::StronglyNotTaken => SatCounter::WeaklyNotTaken,
SatCounter::WeaklyNotTaken => SatCounter::WeaklyTaken,
SatCounter::WeaklyTaken => SatCounter::StronglyTaken,
SatCounter::StronglyTaken => SatCounter::StronglyTaken,
}
}
pub fn decrement(self) -> Self {
match self {
SatCounter::StronglyNotTaken => SatCounter::StronglyNotTaken,
SatCounter::WeaklyNotTaken => SatCounter::StronglyNotTaken,
SatCounter::WeaklyTaken => SatCounter::WeaklyNotTaken,
SatCounter::StronglyTaken => SatCounter::WeaklyTaken,
}
}
pub fn predict(self) -> bool {
match self {
SatCounter::StronglyNotTaken | SatCounter::WeaklyNotTaken => false,
SatCounter::WeaklyTaken | SatCounter::StronglyTaken => true,
}
}
}
#[derive(Debug, Default, Clone, Copy)]
pub struct Bht {
#[allow(unused)]
entries: Array<SatCounter, BHT_ENTRIES>,
}
impl Bht {
pub fn predict(self, _pc: u32) -> bool {
todo!("assignment 2")
}
pub fn update(self, _pc: u32, _taken: bool) -> Self {
todo!("assignment 2")
}
}