diff --git a/bittide-instances/src/Bittide/Instances/Hitl/Driver/SwitchDemo.hs b/bittide-instances/src/Bittide/Instances/Hitl/Driver/SwitchDemo.hs index 6e28debb0..2dded4252 100644 --- a/bittide-instances/src/Bittide/Instances/Hitl/Driver/SwitchDemo.hs +++ b/bittide-instances/src/Bittide/Instances/Hitl/Driver/SwitchDemo.hs @@ -528,6 +528,16 @@ driver testName targets = do $ \pico -> waitForLine pico.stdoutHandle "[MU] All elastic buffers centered" + liftIO + $ T.tryWithTimeoutOn + T.PrintActionTime + "Wait for calendar to be written" + 60_000_000 + goDumpCcSamples + $ forConcurrently_ picocoms + $ \pico -> + waitForLine pico.stdoutHandle "[MU] Crossbar calendar written" + liftIO $ T.tryWithTimeoutOn T.PrintActionTime diff --git a/bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs b/bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs index bb55c85bc..ae91f7d17 100644 --- a/bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs +++ b/bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs @@ -124,18 +124,18 @@ calendarConfig = -- Active calendar. It will broadcast the PE (node 1) data to all links. Other -- than that we cycle through the other nodes. - ( ValidEntry (2 :> repeat 1) nRepetitions - :> ValidEntry (3 :> repeat 1) nRepetitions - :> ValidEntry (4 :> repeat 1) nRepetitions - :> ValidEntry (5 :> repeat 1) nRepetitions - :> ValidEntry (6 :> repeat 1) nRepetitions - :> ValidEntry (7 :> repeat 1) nRepetitions - :> ValidEntry (8 :> repeat 1) nRepetitions + ( ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions + :> ValidEntry (repeat 0) nRepetitions :> Nil ) -- Don't care about inactive calendar: - (ValidEntry (repeat 0) 0 :> Nil) + (ValidEntry (repeat 0) nRepetitions :> Nil) where -- We want enough time to read _number of FPGAs_ triplets nRepetitions = numConvert (maxBound :: Index (FpgaCount * 3)) diff --git a/firmware-binaries/demos/switch-demo1-mu/src/main.rs b/firmware-binaries/demos/switch-demo1-mu/src/main.rs index 08b788589..9fc18efc4 100644 --- a/firmware-binaries/demos/switch-demo1-mu/src/main.rs +++ b/firmware-binaries/demos/switch-demo1-mu/src/main.rs @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: Apache-2.0 -use bittide_hal::switch_demo_mu::DeviceInstances; +use bittide_hal::{manual_additions::index::IndexTy, switch_demo_mu::DeviceInstances}; use core::panic::PanicInfo; use ufmt::uwriteln; @@ -45,6 +45,56 @@ fn main() -> ! { } uwriteln!(uart, "All elastic buffers centered").unwrap(); + uwriteln!(uart, "Writing crossbar calendar").unwrap(); + let switch_cal = INSTANCES.switch_calendar; + let nreps = { + switch_cal.set_read_addr(const { IndexTy::<7, u8>::min_value() }); + switch_cal.shadow_entry().ve_repeat + }; + uwriteln!(uart, "Using repetition count: {}", nreps).unwrap(); + for (i, n) in (2..=8).enumerate() { + let idx = IndexTy::<7, u8>::new(i as u8).unwrap(); + switch_cal.set_read_addr(idx); + let mut shadow_entry = INSTANCES.switch_calendar.shadow_entry(); + shadow_entry.ve_entry[0] = IndexTy::<9, u8>::new(n).unwrap(); + for elem in &mut shadow_entry.ve_entry[1..] { + *elem = const { unsafe { IndexTy::<9, u8>::new_unchecked(1) } }; + } + shadow_entry.ve_repeat = nreps; + switch_cal.set_shadow_entry(shadow_entry); + switch_cal.set_write_addr(idx); + } + switch_cal.set_shadow_depth_index(IndexTy::<7, u8>::new(6).unwrap()); + switch_cal.set_swap_active(true); + switch_cal.set_end_of_metacycle(true); + // TODO: Figure out why removing this breaks the test. The above `for` loop plus the + // next couple exprs should set the correct shadow calendar and wait for it to swap + // with the active calendar. But if I don't have the section below, and instead + // replace it with a `switch_cal.set_swap_active(false);` then the test breaks. + // We should figure out _WHY_ that is in order to be able to remove this + // (theoretically) useless bit of code. + for (i, n) in (2..=8).enumerate() { + let idx = IndexTy::<7, u8>::new(i as u8).unwrap(); + switch_cal.set_read_addr(idx); + let mut shadow_entry = INSTANCES.switch_calendar.shadow_entry(); + shadow_entry.ve_entry[0] = IndexTy::<9, u8>::new(n).unwrap(); + for elem in &mut shadow_entry.ve_entry[1..] { + *elem = const { unsafe { IndexTy::<9, u8>::new_unchecked(1) } }; + } + shadow_entry.ve_repeat = nreps; + switch_cal.set_shadow_entry(shadow_entry); + switch_cal.set_write_addr(idx); + } + switch_cal.set_shadow_depth_index(IndexTy::<7, u8>::new(6).unwrap()); + switch_cal.set_swap_active(true); + switch_cal.set_end_of_metacycle(true); + for i in 0..=switch_cal.shadow_depth_index().into_underlying() { + let idx = IndexTy::<7, u8>::new(i).unwrap(); + switch_cal.set_read_addr(idx); + uwriteln!(uart, "calendar[{}]: {:?}", i, switch_cal.shadow_entry()).unwrap(); + } + uwriteln!(uart, "Crossbar calendar written").unwrap(); + uwriteln!(uart, "Starting UGN captures").unwrap(); let mut capture_ugns = [ (INSTANCES.capture_ugn, false),