Skip to content
Closed
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
17 changes: 17 additions & 0 deletions crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ pub struct RuntimeEventSite {
/// deferred assertions.
#[serde(default)]
pub deferred: Option<DeferredSite>,
/// The last argument is the simulation time at which the site issued
/// the event, which a report carries (IEEE 1800-2023 20.10). It is not
/// formatted.
#[serde(default)]
pub timestamp_arg: bool,
pub arg_widths: Vec<usize>,
pub arg_signed: Vec<bool>,
pub arg_is_string: Vec<bool>,
Expand Down Expand Up @@ -1105,6 +1110,15 @@ pub struct RuntimeSchema<A> {
/// most one per module instance. Before each round a timed scheduler
/// stores the current time into each, as [`TIME_SLOT_WIDTH`] bits.
pub time_slots: Vec<A>,
/// Variables of `$sampled` operands and their copies, which hold the
/// value of the variable in the Preponed region (IEEE 1800-2023
/// 16.5.1): a host copies each variable into its copy when a time slot
/// is over, and once before the first.
pub sample_shadows: Vec<(A, A)>,
/// Variables and copies that start with the variable's value, such as
/// the `$past` histories (IEEE 1800-2023 16.9.3): a host copies each
/// once before the first time slot.
pub initial_copies: Vec<(A, A)>,
/// The state a compiled scheduler exchanges with the runtime, and the
/// scheduler itself once one is generated. Present when the design has
/// process kernels.
Expand Down Expand Up @@ -1359,6 +1373,8 @@ impl<A> Default for RuntimeSchema<A> {
host_request_sites: Vec::new(),
active_commits: Vec::new(),
time_slots: Vec::new(),
sample_shadows: Vec::new(),
initial_copies: Vec::new(),
scheduler: None,
derived_edges: Vec::new(),
settle_partitions: None,
Expand Down Expand Up @@ -2215,6 +2231,7 @@ mod tests {
location: None,
assertion: None,
deferred: None,
timestamp_arg: false,
arg_widths: Vec::new(),
arg_signed: Vec::new(),
arg_is_string: Vec::new(),
Expand Down
4 changes: 4 additions & 0 deletions crates/celox-design/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pub struct ScheduleModel<A> {
/// Objects the scheduler stores the current time into
/// ([`RuntimeSchema::time_slots`]).
pub time_slots: Vec<A>,
/// Sampled variables and their copies
/// ([`RuntimeSchema::sample_shadows`]).
pub sample_shadows: Vec<(A, A)>,
/// The compiled scheduler, if one was generated
/// ([`RuntimeSchema::scheduler`]).
pub scheduler: Option<crate::SchedulerSchema<A>>,
Expand Down Expand Up @@ -152,6 +155,7 @@ impl<A: Copy + Eq + std::hash::Hash> ScheduleModel<A> {
.any(|site| matches!(site.kind, RuntimeEventKind::Finish)),
active_commits: schema.active_commits.clone(),
time_slots: schema.time_slots.clone(),
sample_shadows: schema.sample_shadows.clone(),
scheduler: schema.scheduler.clone(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/celox-frontend-core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,8 @@ pub fn lower_frontend_artifact(
nba_switches: Vec::new(),
host_request_sites: Vec::new(),
time_slot: None,
sample_shadows: Vec::new(),
initial_copies: Vec::new(),
};
let symbolic = SymbolicRtl {
modules: [(module_id, sim_module.clone())].into_iter().collect(),
Expand Down
6 changes: 6 additions & 0 deletions crates/celox-frontend-core/src/symbolic/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ pub struct SimModule {
/// The variable through which the module's code reads the simulation
/// time; see `RuntimeSchema::time_slots`.
pub time_slot: Option<SourceVarId>,
/// Variables and their sampled copies; see
/// `RuntimeSchema::sample_shadows`.
pub sample_shadows: Vec<(SourceVarId, SourceVarId)>,
/// Variables and copies that start with their value; see
/// `RuntimeSchema::initial_copies`.
pub initial_copies: Vec<(SourceVarId, SourceVarId)>,
}

/// A nonblocking site whose kernel has two paths, as
Expand Down
35 changes: 35 additions & 0 deletions crates/celox-frontend-core/src/symbolic/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,8 @@ pub fn schedule_symbolic_rtl_reporting_loops(
nba_sites,
host_request_sites,
time_slots,
sample_shadows,
initial_copies,
..
} = timing;
let source_sir = SirProgram {
Expand Down Expand Up @@ -2386,6 +2388,14 @@ pub fn schedule_symbolic_rtl_reporting_loops(
.collect();
let active_commits: Vec<StateAddr> = active_commits.into_iter().map(project).collect();
let time_slots: Vec<StateAddr> = time_slots.into_iter().map(project).collect();
let sample_shadows: Vec<(StateAddr, StateAddr)> = sample_shadows
.into_iter()
.map(|(variable, copy)| (project(variable), project(copy)))
.collect();
let initial_copies: Vec<(StateAddr, StateAddr)> = initial_copies
.into_iter()
.map(|(variable, copy)| (project(variable), project(copy)))
.collect();
let root_instance = expanded[&InstancePath(Vec::new())];
let settle_partitions = settle_flags.map(|settle| {
let mut marks: HashMap<StateAddr, BTreeSet<u32>> = HashMap::default();
Expand Down Expand Up @@ -2509,6 +2519,13 @@ pub fn schedule_symbolic_rtl_reporting_loops(
.flat_map(|(source, counter)| [source.id, *counter]),
);
}
// The host copies each sampled variable into its copy.
timing_read_roots.extend(
sample_shadows
.iter()
.chain(&initial_copies)
.flat_map(|&(variable, copy)| [variable, copy]),
);
// A package variable's state object maps back to the package's own
// variable, not to one of its aliases.
let state_to_source = source_to_state
Expand Down Expand Up @@ -2561,6 +2578,8 @@ pub fn schedule_symbolic_rtl_reporting_loops(
host_request_sites,
active_commits,
time_slots,
sample_shadows,
initial_copies,
scheduler,
derived_edges: Vec::new(),
settle_partitions,
Expand Down Expand Up @@ -4113,6 +4132,8 @@ struct TimingMetadata {
nba_sites: Vec<NbaSite<AbsoluteAddr>>,
host_request_sites: Vec<HostRequestSite<AbsoluteAddr>>,
time_slots: Vec<AbsoluteAddr>,
sample_shadows: Vec<(AbsoluteAddr, AbsoluteAddr)>,
initial_copies: Vec<(AbsoluteAddr, AbsoluteAddr)>,
nba_switches: Vec<NbaSwitch<AbsoluteAddr>>,
}

Expand Down Expand Up @@ -4435,6 +4456,8 @@ fn relocate_timing(
nba_sites: Vec::new(),
host_request_sites: Vec::new(),
time_slots: Vec::new(),
sample_shadows: Vec::new(),
initial_copies: Vec::new(),
nba_switches: Vec::new(),
};
for (&instance, module) in instances {
Expand Down Expand Up @@ -4470,6 +4493,18 @@ fn relocate_timing(
}),
);
metadata.time_slots.extend(module.time_slot.map(locate));
metadata.sample_shadows.extend(
module
.sample_shadows
.iter()
.map(|&(variable, copy)| (locate(variable), locate(copy))),
);
metadata.initial_copies.extend(
module
.initial_copies
.iter()
.map(|&(variable, copy)| (locate(variable), locate(copy))),
);
metadata.nba_switches.extend(
module
.nba_switches
Expand Down
Loading
Loading