fastpasta/analyze/validators/its/data_words/
ib.rs

1//! Contains the validator for outer barrel data words
2
3use crate::words::its::status_words::util::is_lane_active;
4
5/// Performs checks on a Data word from Inner Barrel
6#[derive(Debug, Default, Clone, Copy)]
7pub struct IbDataWordValidator;
8
9impl IbDataWordValidator {
10    /// Checks validity of an Inner Barrel data word
11    ///
12    /// If the check fails, returns an [Err] containing the error message
13    // Note: Change return to a vector of String if more checks are added
14    pub fn check(ib_data_word: &[u8], ihw_active_lanes: u32) -> Result<(), Box<str>> {
15        let lane_id = ib_data_word[9] & 0x1F;
16        // lane in active_lanes;
17        if is_lane_active(lane_id, ihw_active_lanes) {
18            Ok(())
19        } else {
20            Err(format!("[E72] IB lane {lane_id} is not active according to IHW active_lanes: {ihw_active_lanes:#X}.").into())
21        }
22    }
23}