-
Notifications
You must be signed in to change notification settings - Fork 2
Write crossbar calendar in software #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Comment on lines
+64
to
+65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you either alter the In that case you should be able to use the OR copy that HAL and adjust it to the switch in |
||
| } | ||
| 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), | ||
|
|
||
There was a problem hiding this comment.
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_repeatof 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.
There was a problem hiding this comment.
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 exfiltratenRepetitionsand 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.