Skip to content
Merged
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
5 changes: 5 additions & 0 deletions crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,10 @@ pub struct RuntimeSchema<A> {
/// 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 @@ -1365,6 +1369,7 @@ impl<A> Default for RuntimeSchema<A> {
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
1 change: 1 addition & 0 deletions crates/celox-frontend-core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,7 @@ pub fn lower_frontend_artifact(
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
3 changes: 3 additions & 0 deletions crates/celox-frontend-core/src/symbolic/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ pub struct SimModule {
/// 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
15 changes: 15 additions & 0 deletions crates/celox-frontend-core/src/symbolic/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,7 @@ pub fn schedule_symbolic_rtl_reporting_loops(
host_request_sites,
time_slots,
sample_shadows,
initial_copies,
..
} = timing;
let source_sir = SirProgram {
Expand Down Expand Up @@ -2391,6 +2392,10 @@ pub fn schedule_symbolic_rtl_reporting_loops(
.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 @@ -2518,6 +2523,7 @@ pub fn schedule_symbolic_rtl_reporting_loops(
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
Expand Down Expand Up @@ -2573,6 +2579,7 @@ pub fn schedule_symbolic_rtl_reporting_loops(
active_commits,
time_slots,
sample_shadows,
initial_copies,
scheduler,
derived_edges: Vec::new(),
settle_partitions,
Expand Down Expand Up @@ -4126,6 +4133,7 @@ struct TimingMetadata {
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 @@ -4449,6 +4457,7 @@ fn relocate_timing(
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 @@ -4490,6 +4499,12 @@ fn relocate_timing(
.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
28 changes: 26 additions & 2 deletions crates/celox-frontend-sv/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ struct SvVariable {
/// The variable whose sampled value this hidden copy holds
/// (`SimModule::sample_shadows`).
sampled_from: Option<SourceVarId>,
/// The variable whose past sampled values this hidden register holds;
/// it starts with the variable's value (`SimModule::initial_copies`).
history_of: Option<SourceVarId>,
}

/// Whether `expr` reads a string variable: after its calls are hoisted, a
Expand Down Expand Up @@ -130,13 +133,15 @@ impl SvVariable {

/// A hidden variable other than the time slot, whose value the lowered
/// code computes. The time slot and the sampled copies are state the
/// scheduler writes, and an event expression's variables are state its
/// process and its continuous assignment share.
/// scheduler writes, `$past` histories are state their process keeps,
/// and an event expression's variables are state its process and its
/// continuous assignment share.
fn is_scratch(&self) -> bool {
self.hidden
&& self.path != [TIME_SLOT]
&& self.force_control.is_none()
&& self.sampled_from.is_none()
&& self.history_of.is_none()
&& !self.path[0].starts_with(EVENT_PREFIX)
}
}
Expand Down Expand Up @@ -2203,6 +2208,7 @@ fn prepare_external_hierarchy_collecting(
hidden: !variable.module_affiliated,
force_control: None,
sampled_from: None,
history_of: None,
},
)
})
Expand Down Expand Up @@ -3635,6 +3641,7 @@ fn lower_module_with_overrides(
hidden: false,
force_control: None,
sampled_from: None,
history_of: None,
};
name_to_id.insert(port.name().to_string(), id);
port_order.push(id);
Expand Down Expand Up @@ -3720,6 +3727,7 @@ fn lower_module_with_overrides(
hidden: false,
force_control: None,
sampled_from: None,
history_of: None,
};
name_to_id.insert(signal.name().to_string(), id);
// The package's object, or the other instance's, has its own
Expand Down Expand Up @@ -3801,6 +3809,7 @@ fn lower_module_with_overrides(
hidden: false,
force_control: None,
sampled_from: None,
history_of: None,
},
);
}
Expand Down Expand Up @@ -4014,6 +4023,7 @@ fn lower_module_with_overrides(
host_request_sites,
time_slot: name_to_id.get(TIME_SLOT).copied(),
sample_shadows: Vec::new(),
initial_copies: Vec::new(),
},
variables,
port_order,
Expand Down Expand Up @@ -4808,6 +4818,12 @@ pub(crate) fn attach_instance_glue(
.collect();
sample_shadows.sort_by_key(|&(variable, copy)| (variable.0, copy.0));
module.sample_shadows = sample_shadows;
let mut initial_copies: Vec<_> = parent_variables
.iter()
.filter_map(|(&copy, variable)| variable.history_of.map(|variable| (variable, copy)))
.collect();
initial_copies.sort_by_key(|&(variable, copy)| (variable.0, copy.0));
module.initial_copies = initial_copies;
for (instance, child_id, child, connections) in resolved_instances {
let glue = build_instance_glue(
&parent_variables,
Expand Down Expand Up @@ -5203,6 +5219,7 @@ fn lower_initial_processes(
hidden: true,
force_control: None,
sampled_from: None,
history_of: None,
},
);
id
Expand Down Expand Up @@ -5848,6 +5865,7 @@ fn ensure_parent_output_signals(
hidden: false,
force_control: None,
sampled_from: None,
history_of: None,
};
parent
.variables
Expand Down Expand Up @@ -7731,6 +7749,11 @@ fn lower_bit_vector_function_slt<A: std::hash::Hash + Eq + Clone>(
| SystemFunction::Signed
| SystemFunction::Unsigned
| SystemFunction::Sampled
| SystemFunction::Past
| SystemFunction::Rose
| SystemFunction::Fell
| SystemFunction::Stable
| SystemFunction::Changed
| SystemFunction::Bits
| SystemFunction::Size
| SystemFunction::Dimensions
Expand Down Expand Up @@ -9721,6 +9744,7 @@ fn lower_ff_processes(
.with_shared_variables(shared_variables)
.with_sparse_candidates(&edge_memories)
.with_window_writes(&window_writes)
.with_inferred_clock(trigger_set.resets.is_empty())
.lower_process(process.body())?;
repeated_writes.extend(repeated_ff_writes(&eval_only, &staged));
// A process without writes still runs for its runtime events and
Expand Down
Loading
Loading