use crate::uarch::pipeline::rename::vec_prf::VecPhysReg;
use crate::uarch::pipeline::rob::RobTag;
#[derive(Debug, Clone)]
pub struct VecPendingResult {
pub rob_tag: RobTag,
pub vd_phys: [VecPhysReg; 8],
pub vd_count: u8,
pub first_group_ready: u64,
pub full_complete: u64,
pub wakeup_fired: bool,
}
impl VecPendingResult {
#[inline]
pub const fn should_wakeup(&self, now: u64) -> bool {
!self.wakeup_fired && now >= self.first_group_ready
}
#[inline]
pub const fn is_complete(&self, now: u64) -> bool {
now >= self.full_complete
}
}
#[cfg(test)]
mod tests {
use super::*;
fn make_pending(first: u64, full: u64) -> VecPendingResult {
VecPendingResult {
rob_tag: RobTag(1),
vd_phys: [VecPhysReg::ZERO; 8],
vd_count: 1,
first_group_ready: first,
full_complete: full,
wakeup_fired: false,
}
}
#[test]
fn test_wakeup_timing() {
let mut pr = make_pending(10, 15);
assert!(!pr.should_wakeup(9));
assert!(pr.should_wakeup(10));
assert!(pr.should_wakeup(11));
pr.wakeup_fired = true;
assert!(!pr.should_wakeup(11));
}
#[test]
fn test_completion_timing() {
let pr = make_pending(10, 15);
assert!(!pr.is_complete(14));
assert!(pr.is_complete(15));
assert!(pr.is_complete(16));
}
#[test]
fn test_no_chaining() {
let pr = make_pending(15, 15);
assert!(!pr.should_wakeup(14));
assert!(pr.should_wakeup(15));
assert!(pr.is_complete(15));
}
}