mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add comprehensive host fifo test
This commit is contained in:
parent
5911808611
commit
62b2567ade
3 changed files with 249 additions and 3 deletions
|
|
@ -88,12 +88,12 @@ pub fn report_api(d: u32) {
|
||||||
pub fn bio_tests() {
|
pub fn bio_tests() {
|
||||||
report_api(crate::get_id());
|
report_api(crate::get_id());
|
||||||
|
|
||||||
|
units::fifo_level_tests();
|
||||||
spi::spi_test();
|
spi::spi_test();
|
||||||
units::hello_world();
|
units::hello_world();
|
||||||
units::hello_multiverse();
|
units::hello_multiverse();
|
||||||
units::fifo_basic();
|
units::fifo_basic();
|
||||||
units::host_fifo_tests();
|
units::host_fifo_tests();
|
||||||
units::fifo_level_tests();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test plan:
|
// Test plan:
|
||||||
|
|
@ -105,11 +105,11 @@ pub fn bio_tests() {
|
||||||
// -[x] Extclk as x20 stall source
|
// -[x] Extclk as x20 stall source
|
||||||
// -[x] Check Extclk:gpio pin mapping (make sure bit ordering is not swapped)
|
// -[x] Check Extclk:gpio pin mapping (make sure bit ordering is not swapped)
|
||||||
// -[ ] GPIO direction control test
|
// -[ ] GPIO direction control test
|
||||||
// -[ ] FIFO level trigger test - eq, gt, lt on various channels, at various fullness levels
|
// -[x] FIFO level trigger test - eq, gt, lt on various channels, at various fullness levels
|
||||||
// -[x] Stall on event - register bit test, between cores
|
// -[x] Stall on event - register bit test, between cores
|
||||||
// -[x] Stall on event - register bit test, to host
|
// -[x] Stall on event - register bit test, to host
|
||||||
// -[x] Stall on event - FIFO level test
|
// -[x] Stall on event - FIFO level test
|
||||||
// -[ ] Host IRQ generation test - some combination with event tests above to confirm IRQ generation
|
// -[x] Host IRQ generation test - some combination with event tests above to confirm IRQ generation
|
||||||
// -[x] Core ID read test
|
// -[x] Core ID read test
|
||||||
// -[ ] Core aclk counter test
|
// -[ ] Core aclk counter test
|
||||||
// Application tests:
|
// Application tests:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use utralib::utra::bio::{SFR_ETYPE_FIFO_EVENT_EQ_MASK, SFR_ETYPE_FIFO_EVENT_GT_MASK, SFR_ETYPE_FIFO_EVENT_LT_MASK};
|
||||||
|
|
||||||
use super::{report_api, TEST_INVERT_MASK};
|
use super::{report_api, TEST_INVERT_MASK};
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
|
@ -430,6 +432,14 @@ bio_code!(
|
||||||
"j 22b"
|
"j 22b"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
struct FifoLevelTestConfig {
|
||||||
|
tx_reg: crate::Register,
|
||||||
|
rx_reg: crate::Register,
|
||||||
|
levels: [crate::Field; 2],
|
||||||
|
event_masks: [u32; 2],
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: i think this can be done without any code running on the machines; the host can
|
// TODO: i think this can be done without any code running on the machines; the host can
|
||||||
// set and observe all fifo levels and triggers directly.
|
// set and observe all fifo levels and triggers directly.
|
||||||
pub fn fifo_level_tests() {
|
pub fn fifo_level_tests() {
|
||||||
|
|
@ -459,5 +469,233 @@ pub fn fifo_level_tests() {
|
||||||
bio_ss.bio.rmwf(utra::bio::SFR_ETYPE_FIFO_EVENT_LT_MASK, 0b11_01_01_00);
|
bio_ss.bio.rmwf(utra::bio::SFR_ETYPE_FIFO_EVENT_LT_MASK, 0b11_01_01_00);
|
||||||
bio_ss.bio.rmwf(utra::bio::SFR_ETYPE_FIFO_EVENT_GT_MASK, 0b10_10_10_00);
|
bio_ss.bio.rmwf(utra::bio::SFR_ETYPE_FIFO_EVENT_GT_MASK, 0b10_10_10_00);
|
||||||
|
|
||||||
|
/*
|
||||||
|
The structure of the FIFO events is that there are two event level configurations
|
||||||
|
per FIFO, structured as fifo [N] gets event level [N*2, N*2+1].
|
||||||
|
|
||||||
|
Each event level could trigger on equals, less than, greater than, or any combination
|
||||||
|
of the three.
|
||||||
|
*/
|
||||||
|
let fifo_test_configs: [FifoLevelTestConfig; 4] = [
|
||||||
|
FifoLevelTestConfig {
|
||||||
|
tx_reg: utra::bio::SFR_TXF0,
|
||||||
|
rx_reg: utra::bio::SFR_RXF0,
|
||||||
|
levels: [utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL0, utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL1],
|
||||||
|
event_masks: [0x1, 0x2],
|
||||||
|
},
|
||||||
|
FifoLevelTestConfig {
|
||||||
|
tx_reg: utra::bio::SFR_TXF1,
|
||||||
|
rx_reg: utra::bio::SFR_RXF1,
|
||||||
|
levels: [utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL2, utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL3],
|
||||||
|
event_masks: [0x4, 0x8],
|
||||||
|
},
|
||||||
|
FifoLevelTestConfig {
|
||||||
|
tx_reg: utra::bio::SFR_TXF2,
|
||||||
|
rx_reg: utra::bio::SFR_RXF2,
|
||||||
|
levels: [utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL4, utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL5],
|
||||||
|
event_masks: [0x10, 0x20],
|
||||||
|
},
|
||||||
|
FifoLevelTestConfig {
|
||||||
|
tx_reg: utra::bio::SFR_TXF3,
|
||||||
|
rx_reg: utra::bio::SFR_RXF3,
|
||||||
|
levels: [utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL6, utra::bio::SFR_ELEVEL_FIFO_EVENT_LEVEL7],
|
||||||
|
event_masks: [0x40, 0x80],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const FIFO_MAX: u32 = 9;
|
||||||
|
let mut rx_checks = [0u32; FIFO_MAX as usize];
|
||||||
|
let mut tx_state = 0x1;
|
||||||
|
let irq_masks: [Register; 4] = [
|
||||||
|
utra::bio::SFR_IRQMASK_0, utra::bio::SFR_IRQMASK_1, utra::bio::SFR_IRQMASK_2, utra::bio::SFR_IRQMASK_3
|
||||||
|
];
|
||||||
|
let irqarray18 = CSR::new(utra::irqarray18::HW_IRQARRAY18_BASE as *mut u32);
|
||||||
|
|
||||||
|
for (bank, config) in fifo_test_configs.iter().enumerate() {
|
||||||
|
let irq_mask_reg = irq_masks[bank];
|
||||||
|
let irq_mask = (1 << bank) as u32;
|
||||||
|
report_api(0xf1f0_f1f0 + irq_mask);
|
||||||
|
// we want to check that less than, equals, and greater than triggers work individually
|
||||||
|
// then we want to check that lt+eq and gt+eq work together
|
||||||
|
// lt+gt trigger doesn't make sense, we just don't check that
|
||||||
|
for (&level, &mask) in config.levels.iter().zip(config.event_masks.iter()) {
|
||||||
|
bio_ss.bio.wo(irq_mask_reg, mask << 24);
|
||||||
|
// reset all the fifos
|
||||||
|
bio_ss.bio.wo(utra::bio::SFR_FIFO_CLR, 0xF);
|
||||||
|
for test_level in 0..FIFO_MAX {
|
||||||
|
report_api(0xf1f0_4000 + test_level + ((bank as u32) << 8));
|
||||||
|
// test eq at level
|
||||||
|
bio_ss.bio.wfo(level, test_level);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_EQ_MASK, mask);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_LT_MASK, 0);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_GT_MASK, 0);
|
||||||
|
// fill
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
// report_api(ev_check);
|
||||||
|
if check_level == test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
// report_api(irqarray18.r(utra::irqarray18::EV_STATUS));
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
// report_api(irqarray18.r(utra::irqarray18::EV_STATUS));
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(config.tx_reg, tx_state);
|
||||||
|
// report_api(tx_state);
|
||||||
|
rx_checks[check_level as usize] = tx_state;
|
||||||
|
tx_state = crate::lfsr_next_u32(tx_state);
|
||||||
|
}
|
||||||
|
// drain
|
||||||
|
// report_api(0xdddd_dddd);
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let rx = bio_ss.bio.r(config.rx_reg);
|
||||||
|
// report_api(rx);
|
||||||
|
assert!(rx == rx_checks[check_level as usize]);
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if FIFO_MAX - check_level - 1 == test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test lt at level
|
||||||
|
bio_ss.bio.wfo(level, test_level);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_EQ_MASK, 0);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_LT_MASK, mask);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_GT_MASK, 0);
|
||||||
|
// fill
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if check_level < test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(config.tx_reg, tx_state);
|
||||||
|
rx_checks[check_level as usize] = tx_state;
|
||||||
|
tx_state = crate::lfsr_next_u32(tx_state);
|
||||||
|
}
|
||||||
|
// drain
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let rx = bio_ss.bio.r(config.rx_reg);
|
||||||
|
assert!(rx == rx_checks[check_level as usize]);
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if FIFO_MAX - check_level - 1 < test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test gt at level
|
||||||
|
bio_ss.bio.wfo(level, test_level);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_EQ_MASK, 0);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_LT_MASK, 0);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_GT_MASK, mask);
|
||||||
|
// fill
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if check_level > test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(config.tx_reg, tx_state);
|
||||||
|
rx_checks[check_level as usize] = tx_state;
|
||||||
|
tx_state = crate::lfsr_next_u32(tx_state);
|
||||||
|
}
|
||||||
|
// drain
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let rx = bio_ss.bio.r(config.rx_reg);
|
||||||
|
assert!(rx == rx_checks[check_level as usize]);
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if FIFO_MAX - check_level - 1 > test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test lt eq at level
|
||||||
|
bio_ss.bio.wfo(level, test_level);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_EQ_MASK, mask);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_LT_MASK, mask);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_GT_MASK, 0);
|
||||||
|
// fill
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if check_level <= test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(config.tx_reg, tx_state);
|
||||||
|
rx_checks[check_level as usize] = tx_state;
|
||||||
|
tx_state = crate::lfsr_next_u32(tx_state);
|
||||||
|
}
|
||||||
|
// drain
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let rx = bio_ss.bio.r(config.rx_reg);
|
||||||
|
assert!(rx == rx_checks[check_level as usize]);
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if FIFO_MAX - check_level - 1 <= test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test gt eq at level
|
||||||
|
bio_ss.bio.wfo(level, test_level);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_EQ_MASK, mask);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_LT_MASK, 0);
|
||||||
|
bio_ss.bio.rmwf(SFR_ETYPE_FIFO_EVENT_GT_MASK, mask);
|
||||||
|
// fill
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if check_level >= test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(config.tx_reg, tx_state);
|
||||||
|
rx_checks[check_level as usize] = tx_state;
|
||||||
|
tx_state = crate::lfsr_next_u32(tx_state);
|
||||||
|
}
|
||||||
|
// drain
|
||||||
|
for check_level in 0..FIFO_MAX {
|
||||||
|
let rx = bio_ss.bio.r(config.rx_reg);
|
||||||
|
assert!(rx == rx_checks[check_level as usize]);
|
||||||
|
let ev_check = bio_ss.bio.r(utra::bio::SFR_EVENT_STATUS) >> 24;
|
||||||
|
if FIFO_MAX - check_level - 1 >= test_level {
|
||||||
|
assert!(ev_check & mask == mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask == irq_mask);
|
||||||
|
} else {
|
||||||
|
assert!(ev_check & mask != mask);
|
||||||
|
assert!(irqarray18.r(utra::irqarray18::EV_STATUS) & irq_mask != irq_mask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bio_ss.bio.wo(irq_mask_reg, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
report_api(0x1314_600D);
|
report_api(0x1314_600D);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,14 @@ pub fn lfsr_next(state: u16) -> u16 {
|
||||||
|
|
||||||
((state << 1) + bit) & 0x1_FF
|
((state << 1) + bit) & 0x1_FF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// used to generate some test vectors
|
||||||
|
pub fn lfsr_next_u32(state: u32) -> u32 {
|
||||||
|
let bit = ((state >> 31) ^ (state >> 21) ^ (state >> 1) ^ (state >> 0)) & 1;
|
||||||
|
|
||||||
|
(state << 1) + bit
|
||||||
|
}
|
||||||
|
|
||||||
pub struct BioSharedState {
|
pub struct BioSharedState {
|
||||||
pub bio: CSR<u32>,
|
pub bio: CSR<u32>,
|
||||||
pub imem_slice: &'static mut [u32],
|
pub imem_slice: &'static mut [u32],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue