Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bittide-instances/src/Bittide/Instances/Hitl/Driver/SwitchDemo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
52 changes: 51 additions & 1 deletion firmware-binaries/demos/switch-demo1-mu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Comment on lines +51 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this gets the ve_repeat of entry 0 in the shadow calendar which is 0 given the setting of the inactive calendar.

It's probably easiest to just set the inactive calendar to be the same as the active calendar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not 0 anymore (see bittide-instances/src/Bittide/Instances/Hitl/Dut/SwitchDemo.hs:138) - I use it as a hack to exfiltrate nRepetitions and make it useable in the Rust code. Should that value ever change, then the Rust code will still receive the new value through this route.

};
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);
Comment on lines +64 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you either alter the Bittide.Instances.Pnr.Switch's switch and calendar to match the one in SwitchDemo?

In that case you should be able to use the switch_calendar HAL in manual additions.

OR copy that HAL and adjust it to the switch in SwitchDemo. And then use the hal instead of manually ensuring the (error prone) correct order of function calls.

}
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),
Expand Down