Merge pull request #632 from buncram/cram-dev

absorb changes in test benches and configurations required by the actual results of the tape-out
This commit is contained in:
bunnie 2025-04-20 21:28:24 +08:00 committed by GitHub
commit edd74b61a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 30 deletions

View file

@ -112,8 +112,8 @@ pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {
Some(IoxFunction::AF1), Some(IoxFunction::AF1),
None, None,
None, None,
Some(IoxEnable::Enable), Some(IoxEnable::Disable),
Some(IoxDriveStrength::Drive4mA), Some(IoxDriveStrength::Drive12mA),
); );
// SPIM_SD[0-3]_A[1] // SPIM_SD[0-3]_A[1]
for i in 7..11 { for i in 7..11 {
@ -124,8 +124,8 @@ pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {
Some(IoxFunction::AF1), Some(IoxFunction::AF1),
None, None,
None, None,
Some(IoxEnable::Enable), Some(IoxEnable::Disable),
Some(IoxDriveStrength::Drive2mA), Some(IoxDriveStrength::Drive8mA),
); );
} }
// SPIM_CSN0_A[1] // SPIM_CSN0_A[1]
@ -136,8 +136,8 @@ pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {
Some(IoxFunction::AF1), Some(IoxFunction::AF1),
None, None,
None, None,
Some(IoxEnable::Enable), Some(IoxEnable::Disable),
Some(IoxDriveStrength::Drive2mA), Some(IoxDriveStrength::Drive8mA),
); );
// SPIM_CSN1_A[1] // SPIM_CSN1_A[1]
iox.setup_pin( iox.setup_pin(
@ -147,8 +147,8 @@ pub fn setup_memory_pins(iox: &dyn IoSetup) -> SpimChannel {
Some(IoxFunction::AF1), Some(IoxFunction::AF1),
None, None,
None, None,
Some(IoxEnable::Enable), Some(IoxEnable::Disable),
Some(IoxDriveStrength::Drive2mA), Some(IoxDriveStrength::Drive8mA),
); );
SpimChannel::Channel1 SpimChannel::Channel1
} }

View file

@ -200,7 +200,7 @@ pub fn dma_basic(concurrent: bool, clkmode: u8) -> usize {
const TEST_LEN: usize = 64; const TEST_LEN: usize = 64;
let mut passing = 0; let mut passing = 0;
if !concurrent { if !concurrent {
print!("DMA basic\r"); print!("DMA basic2w\r");
} else { } else {
print!("DMA cpu+dma concurrent\r"); print!("DMA cpu+dma concurrent\r");
} }
@ -211,7 +211,10 @@ pub fn dma_basic(concurrent: bool, clkmode: u8) -> usize {
let mut bio_ss = BioSharedState::new(); let mut bio_ss = BioSharedState::new();
// stop all the machines, so that code can be loaded // stop all the machines, so that code can be loaded
bio_ss.bio.wo(utra::bio_bdma::SFR_CTRL, 0x0); bio_ss.bio.wo(utra::bio_bdma::SFR_CTRL, 0x0);
bio_ss.load_code(dma_basic_code(), 0, BioCore::Core0); bio_ss.load_code(dma_basic_code(), 0, BioCore::Core3);
// setup clocking mode option
bio_ss.bio.rmwf(SFR_CONFIG_CLOCKING_MODE, clkmode as u32);
// setup clocking mode option // setup clocking mode option
bio_ss.bio.rmwf(SFR_CONFIG_CLOCKING_MODE, clkmode as u32); bio_ss.bio.rmwf(SFR_CONFIG_CLOCKING_MODE, clkmode as u32);
@ -223,7 +226,7 @@ pub fn dma_basic(concurrent: bool, clkmode: u8) -> usize {
bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV2, 0x1_0000); bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV2, 0x1_0000);
bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV3, 0x1_0000); bio_ss.bio.wo(utra::bio_bdma::SFR_QDIV3, 0x1_0000);
// start the machine // start the machine
bio_ss.bio.wo(utra::bio_bdma::SFR_CTRL, 0x111); bio_ss.bio.wo(utra::bio_bdma::SFR_CTRL, 0x888);
let mut main_mem_src: [u32; TEST_LEN] = [0u32; TEST_LEN]; let mut main_mem_src: [u32; TEST_LEN] = [0u32; TEST_LEN];
let mut main_mem_dst: [u32; TEST_LEN] = [0u32; TEST_LEN]; let mut main_mem_dst: [u32; TEST_LEN] = [0u32; TEST_LEN];
@ -235,19 +238,19 @@ pub fn dma_basic(concurrent: bool, clkmode: u8) -> usize {
unsafe { core::slice::from_raw_parts_mut((utralib::HW_IFRAM1_MEM + 10000) as *mut u32, TEST_LEN) }; unsafe { core::slice::from_raw_parts_mut((utralib::HW_IFRAM1_MEM + 10000) as *mut u32, TEST_LEN) };
ifram_src.fill(0); ifram_src.fill(0);
ifram_dst.fill(0); ifram_dst.fill(0);
passing += basic_u32(&mut bio_ss, &mut main_mem_src, &mut main_mem_dst, 0, "Main->main", concurrent); passing += basic_u32(&mut bio_ss, &mut main_mem_src, &mut main_mem_dst, 0, "m->m", concurrent);
main_mem_src.fill(0); main_mem_src.fill(0);
main_mem_dst.fill(0); main_mem_dst.fill(0);
passing += basic_u32(&mut bio_ss, ifram_src, &mut main_mem_dst, 0x40, "ifram0->main", concurrent); passing += basic_u32(&mut bio_ss, ifram_src, &mut main_mem_dst, 0x40, "i0->m", concurrent);
ifram_src.fill(0); ifram_src.fill(0);
main_mem_dst.fill(0); main_mem_dst.fill(0);
passing += basic_u32(&mut bio_ss, &mut main_mem_src, ifram_dst, 0x80, "Main->ifram1", concurrent); passing += basic_u32(&mut bio_ss, &mut main_mem_src, ifram_dst, 0x80, "m->i1", concurrent);
main_mem_src.fill(0); main_mem_src.fill(0);
ifram_dst.fill(0); ifram_dst.fill(0);
passing += basic_u32(&mut bio_ss, ifram_src, ifram_dst, 0xC0, "ifram0->ifram1", concurrent); passing += basic_u32(&mut bio_ss, ifram_src, ifram_dst, 0xC0, "i0->i1", concurrent);
if !concurrent { if !concurrent {
print!("DMA basic done.\r"); print!("DMA basic done.\r");
@ -281,13 +284,25 @@ fn basic_u32(
bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, (src.len() * size_of::<u32>()) as u32); // bytes to move bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, (src.len() * size_of::<u32>()) as u32); // bytes to move
while bio_ss.bio.r(utra::bio_bdma::SFR_EVENT_STATUS) & 0x1 == 0 {} while bio_ss.bio.r(utra::bio_bdma::SFR_EVENT_STATUS) & 0x1 == 0 {}
cache_flush(); cache_flush();
let mut errs = 0;
for (i, &d) in src.iter().enumerate() { for (i, &d) in src.iter().enumerate() {
let rbk = unsafe { dst.as_ptr().add(i).read_volatile() }; let rbk = unsafe { dst.as_ptr().add(i).read_volatile() };
if rbk != d { if rbk != d {
print!("{} DMA err @{}, {:x} rbk: {:x}\r", name, i, d, rbk); if errs < 4 {
unsafe {
print!("{} @{:x}/{:x}, {:x} rb:{:x}\r", name, src.as_ptr().add(i) as usize, dst.as_ptr().add(i) as usize, d, rbk);
}
} else {
print!("x");
}
errs += 1;
pass = 0; pass = 0;
} }
} }
if errs > 0 {
print!("\r");
// errs = 0;
}
} else { } else {
// this flushes any read data from the cache, so that the CPU copy is forced to fetch // this flushes any read data from the cache, so that the CPU copy is forced to fetch
// the data from memory // the data from memory
@ -322,12 +337,16 @@ bio_code!(dma_basic_code, DMA_BASIC_START, DMA_BASIC_END,
"li x29, 0x1", // clear event done flag - just before the last parameter arrives "li x29, 0x1", // clear event done flag - just before the last parameter arrives
"mv a1, x16", // wait for # of bytes to move "mv a1, x16", // wait for # of bytes to move
"sw x0, 0(a2)", // make sure write pipeline is in a good state
"sw x0, 0(a2)", // make sure write pipeline is in a good state
"add a4, a1, a3", // a4 <- end condition based on source address increment "add a4, a1, a3", // a4 <- end condition based on source address increment
"30:", "30:",
"lw t0, 0(a3)", // blocks until load responds "lw t0, 0(a3)", // blocks until load responds
"sw t0, 0(a2)", // blocks until store completes "sw t0, 0(a2)", // blocks until store completes
"addi a3, a3, 4", // 3 cycles "addi a3, a3, 4", // 3 cycles
"sw t0, 0(a2)", // blocks until store completes
"addi a2, a2, 4", // 3 cycles "addi a2, a2, 4", // 3 cycles
"bne a3, a4, 30b", // 5 cycles "bne a3, a4, 30b", // 5 cycles
"li x28, 0x1", // flip event done flag "li x28, 0x1", // flip event done flag
@ -687,14 +706,14 @@ pub fn dma_coincident(clkmode: u8) -> usize {
ifram_src.fill(0); ifram_src.fill(0);
ifram_dst.fill(0); ifram_dst.fill(0);
passing += coincident_u32(&mut bio_ss, &mut main_mem_src, &mut main_mem_dst, 0x200, "DMA coincident"); passing += coincident_u32(&mut bio_ss, &mut main_mem_src, &mut main_mem_dst, 0x200, "m->m");
print!("m->m\r"); print!("m->m coincident\r");
// try other memory banks // try other memory banks
passing += coincident_u32(&mut bio_ss, ifram_src, &mut main_mem_dst, 0x300, "ifram0->main"); passing += coincident_u32(&mut bio_ss, ifram_src, &mut main_mem_dst, 0x300, "i0->m");
print!("0->m\r"); print!("0->m\r");
passing += coincident_u32(&mut bio_ss, &mut main_mem_src, ifram_dst, 0x400, "main->ifram1"); passing += coincident_u32(&mut bio_ss, &mut main_mem_src, ifram_dst, 0x400, "m->i1");
print!("m->1\r"); print!("m->1\r");
passing += coincident_u32(&mut bio_ss, ifram_src, ifram_dst, 0x500, "ifram0->ifram1"); passing += coincident_u32(&mut bio_ss, ifram_src, ifram_dst, 0x500, "i0->i1");
print!("0->1\r"); print!("0->1\r");
print!("DMA coincident done.\r"); print!("DMA coincident done.\r");
@ -722,13 +741,22 @@ fn coincident_u32(
while bio_ss.bio.r(utra::bio_bdma::SFR_EVENT_STATUS) & 0xF_0000 != 0xF_0000 {} // one bit per core is set on completion of bits 8:12 while bio_ss.bio.r(utra::bio_bdma::SFR_EVENT_STATUS) & 0xF_0000 != 0xF_0000 {} // one bit per core is set on completion of bits 8:12
cache_flush(); cache_flush();
let mut pass = 1; let mut pass = 1;
let mut errs = 0;
for (i, &d) in src.iter().enumerate() { for (i, &d) in src.iter().enumerate() {
let rbk = unsafe { dst.as_ptr().add(i).read_volatile() }; let rbk = unsafe { dst.as_ptr().add(i).read_volatile() };
if rbk != d { if rbk != d {
if errs < 4 {
print!("{} err @{}, {:x} rbk: {:x}\r", name, i, d, rbk); print!("{} err @{}, {:x} rbk: {:x}\r", name, i, d, rbk);
} else {
print!(".");
}
errs += 1;
pass = 0; pass = 0;
} }
} }
if errs >= 4 {
print!("\r");
}
pass pass
} }
@ -826,7 +854,7 @@ pub fn dmareq_test() -> usize {
bio_ss.bio.wo(utra::bio_bdma::SFR_TXF1, bit as u32); bio_ss.bio.wo(utra::bio_bdma::SFR_TXF1, bit as u32);
print!("starting search \r"); print!("starting search \r");
for i in 1..15 { for i in 1..15 {
print!("search iter {} \r", i); print!("{}\r", i);
// send the bit pattern into the event-set via core 0 // send the bit pattern into the event-set via core 0
bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, i); bio_ss.bio.wo(utra::bio_bdma::SFR_TXF0, i);

View file

@ -88,7 +88,9 @@ pub fn spi_test() -> usize {
print!("dbg pc 2: {:x}\r", bio_ss.bio.r(utra::bio_bdma::SFR_DBG2)); print!("dbg pc 2: {:x}\r", bio_ss.bio.r(utra::bio_bdma::SFR_DBG2));
print!("dbg pc 3: {:x}\r", bio_ss.bio.r(utra::bio_bdma::SFR_DBG3)); print!("dbg pc 3: {:x}\r", bio_ss.bio.r(utra::bio_bdma::SFR_DBG3));
for (index, &val) in retvals.iter().enumerate() { for (index, &val) in retvals.iter().enumerate() {
if index < 4 {
print!("SPI rbk {:x}\r", val); print!("SPI rbk {:x}\r", val);
}
// the XOR to 0xAAAA is just a mask we threw in to test immediate loads // the XOR to 0xAAAA is just a mask we threw in to test immediate loads
assert!(val == ((0xAA00 | index as u32) ^ 0xAAAA)); assert!(val == ((0xAA00 | index as u32) ^ 0xAAAA));
} }

View file

@ -318,13 +318,13 @@ pub fn host_fifo_tests() -> usize {
// //
// finally, we're pegged at 15, because, backpressure caused us to miss the rest of // finally, we're pegged at 15, because, backpressure caused us to miss the rest of
// the entries, and we are stuck at the final written value of the output test // the entries, and we are stuck at the final written value of the output test
print!("rbk: {:x}\r", rbk); print!("r {:x}\r", rbk);
if i <= 9 { if i <= 9 {
assert!(rbk == (0xF1F0_0000 + i)); assert!(rbk == (0xF1F0_0000 + i));
} else { } else {
assert!(rbk == (0xF1F0_0000 + 15)); assert!(rbk == (0xF1F0_0000 + 15));
} }
print!("backpressure {:x}\r", rbk); print!("bp {:x}\r", rbk);
} }
fn get_gpio_via_core(bio_ss: &mut BioSharedState) -> u32 { fn get_gpio_via_core(bio_ss: &mut BioSharedState) -> u32 {
@ -390,7 +390,9 @@ pub fn host_fifo_tests() -> usize {
// fifo2 should have the entire log of all values in it. make sure that's the case // fifo2 should have the entire log of all values in it. make sure that's the case
for i in 0..7 { for i in 0..7 {
let f2_val = bio_ss.bio.r(utra::bio_bdma::SFR_RXF2); let f2_val = bio_ss.bio.r(utra::bio_bdma::SFR_RXF2);
if i > 5 {
print!("f2_val {:x}\r", f2_val); print!("f2_val {:x}\r", f2_val);
}
assert!(f2_val == 0xf1f0_1000 + i); assert!(f2_val == 0xf1f0_1000 + i);
} }
let stop_check = bio_ss.bio.r(utra::bio_bdma::SFR_RXF2); let stop_check = bio_ss.bio.r(utra::bio_bdma::SFR_RXF2);
@ -590,7 +592,7 @@ pub fn fifo_level_tests() -> usize {
// reset all the fifos // reset all the fifos
bio_ss.bio.wo(utra::bio_bdma::SFR_FIFO_CLR, 0xF); bio_ss.bio.wo(utra::bio_bdma::SFR_FIFO_CLR, 0xF);
for test_level in 0..FIFO_MAX { for test_level in 0..FIFO_MAX {
print!("test_level {:x} bank {:x}\r", test_level, bank); // print!("test_level {:x} bank {:x}\r", test_level, bank);
// test eq at level // test eq at level
bio_ss.bio.wfo(level, test_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_EQ_MASK, mask);
@ -886,7 +888,7 @@ pub fn fifo_alias_tests() -> usize {
// reset all the fifos // reset all the fifos
bio_ss.bio.wo(utra::bio_bdma::SFR_FIFO_CLR, 0xF); bio_ss.bio.wo(utra::bio_bdma::SFR_FIFO_CLR, 0xF);
for test_level in 0..FIFO_MAX { for test_level in 0..FIFO_MAX {
print!("test_level {:x} bank {:x}\r", test_level, bank); // print!("test_level {:x} bank {:x}\r", test_level, bank);
// test eq at level // test eq at level
bio_ss.bio.wfo(level, test_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_EQ_MASK, mask);
@ -1106,7 +1108,7 @@ pub fn event_aliases() -> usize {
let mut passing = 1; let mut passing = 1;
for (i, config) in event_test_configs.iter_mut().enumerate() { for (i, config) in event_test_configs.iter_mut().enumerate() {
print!(" Checking bank {}...\r", i); print!(" bnk{}\r", i);
for _ in 0..3 { for _ in 0..3 {
// clear all events // clear all events
bio_ss.bio.wfo(utra::bio_bdma::SFR_EVENT_CLR_SFR_EVENT_CLR, 0xFFFF_FF); bio_ss.bio.wfo(utra::bio_bdma::SFR_EVENT_CLR_SFR_EVENT_CLR, 0xFFFF_FF);