add the FIFO basic unit test + todo list of tests

This commit is contained in:
bunnie 2024-03-03 02:39:12 +08:00
parent 0a31875a19
commit 8a7b5e5627
2 changed files with 99 additions and 26 deletions

View file

@ -80,26 +80,29 @@ pub fn bio_tests() {
units::hello_world();
units::hello_multiverse();
units::fifo_basic();
}
// Test plan:
// Unit tests:
// - Basic FIFO stall test. Two cores writing to each other to unlock.
// - Host FIFO stall on empty test. Core stalls until host provides data.
// - Host FIFO stall on full test. Core stall until host reads data.
// - GPIO input path test
// - GPIO direction control test
// - FIFO level trigger test - eq, gt, lt on various channels, at various fullness levels
// - Stall on event - register bit test, between cores
// - Stall on event - register bit test, to host
// - Stall on event - FIFO level test
// - Host IRQ generation test - some combination with event tests above to confirm IRQ generation
// - Core ID read test
// - Core aclk counter test
// -[x] Basic FIFO stall test. Two cores writing to each other to unlock.
// -[ ] Host FIFO stall on empty test. Core stalls until host provides data.
// -[ ] Host FIFO stall on full test. Core stall until host reads data.
// -[ ] GPIO input path test
// -[ ] GPIO direction control test
// -[ ] FIFO level trigger test - eq, gt, lt on various channels, at various fullness levels
// -[ ] Stall on event - register bit test, between cores
// -[ ] Stall on event - register bit test, to host
// -[ ] Stall on event - FIFO level test
// -[ ] Host IRQ generation test - some combination with event tests above to confirm IRQ generation
// -[ ] Extclk as x20 stall source
// -[ ] Check Extclk:gpio pin mapping (make sure bit ordering is not swapped)
// -[ ] Core ID read test
// -[ ] Core aclk counter test
// Application tests:
// - SPI loopback test
// - I2C loopback test
// - IR controller test
// - Arithmetic test, utilizing load/store on core 0
// - Arithmetic test, without store, cores 1-3
// - DMA transfer test -- might have to wait until full-chip integration to get MDMA core?
// -[ ] SPI loopback test - implement using extclk as spi clk for input
// -[ ] I2C loopback test
// -[ ] IR controller test
// -[ ] Arithmetic test, utilizing load/store on core 0
// -[ ] Arithmetic test, without store, cores 1-3
// -[ ] DMA transfer test -- might have to wait until full-chip integration to get MDMA core?

View file

@ -70,16 +70,20 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
// using 'c.j' syntax for the jump causes the assembler to emit an error,
// but the code still compiles, so...avoiding that for now. might be a bug,
// but I am very not interested in fixing that today.
"j 0f",
//
// Also note that labels can only be numbers from 0-99, and, due to an llvm
// bug, labels made exclusively of 0 or 1 should be avoided because they get
// interpreted as binary numbers. dat's some jank in the tank!!
"j 90f",
"nop",
"j 1f",
"j 91f",
"nop",
"j 2f",
"j 92f",
"nop",
"j 3f",
"j 93f",
"nop",
// mach 0 code
"0:",
"90:",
// x26 sets the GPIO mask
"li x2, 0xFF", // load constants into r0-15 bank first
"mv x26, x2", // it's not legal to do anything other than mv to x26
@ -92,7 +96,7 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
"mv x20, zero",
"j 4b",
// mach 1 code
"1:",
"91:",
"li x2, 0xFF00",
"mv x26, x2",
"add x1, zero, 0x20",
@ -102,7 +106,7 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
"mv x20, zero",
"j 5b",
// mach 2 code
"2:",
"92:",
"li x2, 0xFF0000",
"mv x26, x2",
"add x1, zero, 0x30",
@ -112,7 +116,7 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
"mv x20, zero",
"j 6b",
// mach 3 code
"3:",
"93:",
"li x2, 0xFF000000",
"mv x26, x2",
"add x1, zero, 0x40",
@ -122,3 +126,69 @@ bio_code!(multiverse_code, MULTIVERSE_START, MULTIVERSE_END,
"mv x20, zero",
"j 7b"
);
pub fn fifo_basic() {
report_api(0x1310_2000);
report_api(0xf1f0_0000);
let mut bio_ss = BioSharedState::new();
// stop all the machines, so that code can be loaded
bio_ss.bio.wo(utra::bio::SFR_CTRL, 0x0);
let code = fifo_basic_code();
bio_ss.load_code(code, 0);
// configure & run the 0th machine
// / 16. clock
bio_ss.bio.wo(utra::bio::SFR_QDIV0, 0x23_BE00);
bio_ss.bio.wo(utra::bio::SFR_QDIV1, 0x33_1200);
// snap GPIO outputs to the quantum
bio_ss.bio.wo(utra::bio::SFR_CONFIG,
bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_TO_QUANTUM, 1)
| bio_ss.bio.ms(utra::bio::SFR_CONFIG_SNAP_TO_QUANTUM, 2) // arbitrary choice, they should all be the same
);
// start all the machines, all at once
bio_ss.bio.wo(utra::bio::SFR_CTRL, 0xfff);
report_api(0x1310_20FF);
}
bio_code!(fifo_basic_code, FIFO_BASIC_START, FIFO_BASIC_END,
"j 90f",
"nop",
"j 91f",
"nop",
"j 92f",
"nop",
"j 93f",
"nop",
// mach 0 code
"90:",
"li x2, 0xFFFF",
"mv x26, x2",
"li x1, 0x10000000",
"li x2, 0x10000",
"11:",
"mv x16, x1",
"mv x21, x17",
"add x1, x1, x2",
"mv x20, zero",
"j 11b",
// mach 1 code
"91:",
"li x2, 0xFFFF0000",
"mv x26, x2",
"li x1, 0x8000",
"21:",
"mv x17, x1",
"mv x21, x16",
"addi x1, x1, 1",
"mv x20, zero",
"j 21b",
// mach 2 code
"92:",
"j 92b",
// mach 3 code
"93:",
"j 93b",
"nop"
);