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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@ jobs:
cargo test --locked -p celox-test-suite --features "$VERIFY_TOOL"
--test oracles -- --ignored

# The VPI host's time-step regions against Icarus, through the same
# cocotb test module, with the locked cocotb and Icarus versions.
- name: Cross-check cocotb time-step regions against Icarus
if: matrix.suite == 'sv' && matrix.tool == 'icarus'
run: >-
nix develop "$VERIFY_SHELL" --no-update-lock-file --command
cargo test --locked -p celox-vpi --features systemverilog
--test cocotb_e2e icarus_and_celox_agree_on_dut_processes -- --ignored --exact

- name: Catalogue every shared case
if: ${{ !cancelled() }}
run: |
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ GCC-style optimization level presets with per-pass overrides.
| `IdentityStoreBypass` | Detects identity copies and registers address aliases |
| `TailCallSplit` | Splits large functions into tail-call chains (enabled even at O0) |
| `DerivedEdgeUnits` | Runs edges of gated/divided clocks in generated units instead of the Rust plan walk (not a SIR transform; costs build time, `-sir:derived_edge_units` to opt out) |
| `PartitionedSettle` | Splits the combinational settle into partitions that run only when state they read changed (not a SIR transform; off unless enabled, `+sir:partitioned_settle`; `SimulatorBuilder::settle_check` cross-checks it) |

### Cranelift Backend Optimization

Expand Down
280 changes: 140 additions & 140 deletions conformance/sv-tests/expected.tsv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/celox-backend-arm64/src/isel/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fn layout_for(address: AbsoluteAddr, width: usize, four_state: bool) -> MemoryLa
let total_size = plane_size * if four_state { 2 } else { 1 };
MemoryLayout {
trace: None,
settle: None,
four_state,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
1 change: 1 addition & 0 deletions crates/celox-backend-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6488,6 +6488,7 @@ mod bit_count_tests {

MemoryLayout {
trace: None,
settle: None,
four_state,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
1 change: 1 addition & 0 deletions crates/celox-backend-x86/src/backend/native/isel/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use num_bigint::BigUint;
fn empty_layout() -> MemoryLayout {
MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ fn compile_bit_count(op: UnaryOp, source_width: usize, four_state: bool) -> Comp

let layout = MemoryLayout {
trace: None,
settle: None,
four_state,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ fn narrowed_wide_binary_store_does_not_write_source_width() {

let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down Expand Up @@ -1130,6 +1131,7 @@ fn execute_unaligned_64_bit_load(dynamic: bool) -> u64 {

let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down Expand Up @@ -1295,6 +1297,7 @@ fn verify_scalar_alignment_matrix(dynamic: bool, four_state: bool) {
eu.verify();
let layout = MemoryLayout {
trace: None,
settle: None,
four_state,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down Expand Up @@ -1511,6 +1514,7 @@ fn verify_wide_alignment_matrix(dynamic: bool) {
eu.verify();
let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ fn lowers_shared_selector_roots_to_cached_indexed_table_loads() {

let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ fn narrow_wide_shift_uses_only_chunks_covered_by_the_result() {

let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down Expand Up @@ -836,6 +837,7 @@ fn wide_shift_result_is_canonical_before_mux_condition() {

let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ mod tests {
.collect();
MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: MemoryLayoutMode::Packed,
unpacked_arrays: HashMap::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pub fn compile(recover: bool) -> CompiledUpdate {
)];
let layout = MemoryLayout {
trace: None,
settle: None,
four_state: false,
mode: celox_state_layout::MemoryLayoutMode::Packed,
offsets: [
Expand Down
41 changes: 37 additions & 4 deletions crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,17 @@ impl std::fmt::Display for ProcessOrigin {
}
}

/// When a procedural kernel is invoked by the runtime.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ProcessKind {
/// Static declarations run before ordinary HDL procedures.
Initializer,
#[default]
Regular,
/// A final procedure runs only when simulation ends (IEEE 1800-2023 9.2.3).
Final,
}

/// State through which one process kernel exchanges control with the runtime.
///
/// A process kernel is a resumable function. On entry it reads `resume` to
Expand All @@ -625,9 +636,9 @@ impl std::fmt::Display for ProcessOrigin {
/// checkpoints capture a suspended process.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ProcessSlots<A> {
/// A static declaration initializer, executed before all HDL procedures.
pub is_initializer: bool,
/// This kernel originated from an edge procedure and must execute in Simulation.
/// The phase in which the runtime invokes this kernel.
pub kind: ProcessKind,
/// This kernel requires Simulation's process scheduler rather than Simulator.
pub requires_timed_simulation: bool,
/// Every delay the kernel suspends for is a constant of at least one
/// time unit.
Expand All @@ -646,7 +657,7 @@ pub struct ProcessSlots<A> {
impl<A> ProcessSlots<A> {
pub fn map<B>(self, mut map: impl FnMut(A) -> B) -> ProcessSlots<B> {
ProcessSlots {
is_initializer: self.is_initializer,
kind: self.kind,
requires_timed_simulation: self.requires_timed_simulation,
const_delays: self.const_delays,
program: self.program.map(&mut map),
Expand Down Expand Up @@ -1053,6 +1064,27 @@ pub struct RuntimeSchema<A> {
/// Generated units that run an edge of an event with every derived
/// clock domain it reaches, for the events that have them.
pub derived_edges: Vec<DerivedEdgeUnits<A>>,
/// The partitions of a partitioned combinational settle, when it is
/// partitioned.
pub settle_partitions: Option<SettlePartitions<A>>,
}

/// A combinational settle split into partitions that run only when state
/// they read changed since they last ran.
///
/// Byte `p` of `flags` is partition `p`'s dirty flag; the byte after the
/// last partition's is the untracked byte, set once state may change
/// without anyone setting flags (a retained raw view), after which every
/// partition always runs.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SettlePartitions<A> {
pub flags: A,
pub partitions: u32,
/// State the settle reads or writes, with the partitions to mark when
/// something other than the settle writes it. A written object lists
/// its writers as well, so that, as in a single pass, the settle
/// recomputes it.
pub marks: Vec<(A, Vec<u32>)>,
}

/// The process units that run the edges of one event together with its
Expand Down Expand Up @@ -1279,6 +1311,7 @@ impl<A> Default for RuntimeSchema<A> {
time_slots: Vec::new(),
scheduler: None,
derived_edges: Vec::new(),
settle_partitions: None,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/celox-frontend-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use shared::{
pub use trace::{FrontendTrace, FrontendTraceOptions, TraceSimModule};

pub use symbolic::flattening;
pub use symbolic::parallel::ParallelScheduleOptions;
pub use symbolic::parallel::{ParallelScheduleOptions, SettlePartitionMode};

pub(crate) type HashMap<K, V> = fxhash::FxHashMap<K, V>;
pub(crate) type HashSet<T> = fxhash::FxHashSet<T>;
2 changes: 1 addition & 1 deletion crates/celox-frontend-core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ fn lower_processes(
for (index, process) in artifact.processes().iter().enumerate() {
let name = |slot: &str| vec![format!("$process[{index}]"), slot.to_string()];
let slots = ProcessSlots {
is_initializer: false,
kind: celox_design::ProcessKind::Regular,
requires_timed_simulation: false,
const_delays: false,
program: None,
Expand Down
Loading
Loading