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
46 changes: 42 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
rust: ${{ steps.classify.outputs.rust }}
rust_full: ${{ steps.classify.outputs.rust_full }}
rust_packages: ${{ steps.classify.outputs.rust_packages }}
rust_targets: ${{ steps.classify.outputs.rust_targets }}
rust_lint_packages: ${{ steps.classify.outputs.rust_lint_packages }}
rust_lint_features: ${{ steps.classify.outputs.rust_lint_features }}
rust_lint_targets: ${{ steps.classify.outputs.rust_lint_targets }}
rust_doc_libraries: ${{ steps.classify.outputs.rust_doc_libraries }}
rust_sv_tests: ${{ steps.classify.outputs.rust_sv_tests }}
rust_features: ${{ steps.classify.outputs.rust_features }}
rust_filter: ${{ steps.classify.outputs.rust_filter }}
rust_libraries: ${{ steps.classify.outputs.rust_libraries }}
Expand Down Expand Up @@ -139,15 +145,42 @@ jobs:
fi

- name: cargo clippy
if: needs.changes.result != 'success' || needs.changes.outputs.rust == 'true'
if: (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') && needs.changes.outputs.rust_full != 'false'
run: cargo clippy --locked -p celox-test-suite -p celox -p celox-frontend-core -p celox-frontend-sv -p celox-frontend-veryl -p celox-macros -p celox-napi -p celox-sv-analyzer -p celox-ts-gen -p celox-vpi -p lydite-ir -p lydite -p lydite-celox -p lydite-solver -p lydite-syntax -p lydite-verify --all-targets --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus --no-deps

- name: Lint the crates this pull request can affect
if: needs.changes.outputs.rust_full == 'false' && needs.changes.outputs.rust_lint_packages != ''
env:
PACKAGES: ${{ needs.changes.outputs.rust_lint_packages }}
FEATURES: ${{ needs.changes.outputs.rust_lint_features }}
TARGETS: ${{ needs.changes.outputs.rust_lint_targets }}
run: |
args=()
for package in $PACKAGES; do args+=(-p "$package"); done
if [ -n "$FEATURES" ]; then args+=(--features "$FEATURES"); fi
if [ -n "$TARGETS" ]; then
for target in $TARGETS; do args+=(--test "$target"); done
else
args+=(--all-targets)
fi
cargo clippy --locked "${args[@]}" --no-deps

- name: Build Rust API documentation
if: needs.changes.result != 'success' || needs.changes.outputs.rust == 'true'
if: (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') && needs.changes.outputs.rust_full != 'false'
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --locked --workspace --no-deps

- name: Build the API documentation this pull request can affect
if: needs.changes.outputs.rust_full == 'false' && needs.changes.outputs.rust_doc_libraries != ''
env:
RUSTDOCFLAGS: -D warnings
LIBRARIES: ${{ needs.changes.outputs.rust_doc_libraries }}
run: |
args=()
for package in $LIBRARIES; do args+=(-p "$package"); done
cargo doc --locked --no-deps "${args[@]}"

- uses: pnpm/action-setup@v6
if: needs.changes.result != 'success' || needs.changes.outputs.javascript == 'true'

Expand Down Expand Up @@ -197,10 +230,12 @@ jobs:
save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}

- uses: actions/setup-python@v7
if: needs.changes.outputs.rust_full != 'false' || contains(format(' {0} ', needs.changes.outputs.rust_packages), ' celox-vpi ')
with:
python-version: "3.14"

- name: Install cocotb
if: needs.changes.outputs.rust_full != 'false' || contains(format(' {0} ', needs.changes.outputs.rust_packages), ' celox-vpi ')
run: python -m pip install cocotb==2.1.0

- name: Install cargo-nextest
Expand All @@ -227,12 +262,14 @@ jobs:
PACKAGES: ${{ needs.changes.outputs.rust_packages }}
FEATURES: ${{ needs.changes.outputs.rust_features }}
FILTER: ${{ needs.changes.outputs.rust_filter }}
TARGETS: ${{ needs.changes.outputs.rust_targets }}
run: |
echo "Packages: $PACKAGES"
echo "Filter: $FILTER"
args=()
for package in $PACKAGES; do args+=(-p "$package"); done
if [ -n "$FEATURES" ]; then args+=(--features "$FEATURES"); fi
for target in $TARGETS; do args+=(--test "$target"); done
cargo nextest run --locked --profile ci \
--no-tests=pass "${args[@]}" -E "$FILTER"

Expand Down Expand Up @@ -359,7 +396,7 @@ jobs:
sv-tests:
name: sv-tests conformance
needs: changes
if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') }}
if: ${{ !cancelled() && (needs.changes.result != 'success' || (needs.changes.outputs.rust == 'true' && needs.changes.outputs.rust_sv_tests != 'false')) }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -506,6 +543,7 @@ jobs:
CHANGES_RESULT: ${{ needs.changes.result }}
RUST_REQUIRED: ${{ needs.changes.outputs.rust }}
RUST_RESULT: ${{ needs.rust-tests.result }}
SV_TESTS_REQUIRED: ${{ needs.changes.outputs.rust != 'false' && needs.changes.outputs.rust_sv_tests != 'false' }}
SV_TESTS_RESULT: ${{ needs.sv-tests.result }}
# Platform coverage is mandatory in queue and full validation runs.
ARM64_REQUIRED: ${{ needs.changes.outputs.queue != 'false' && needs.changes.outputs.rust != 'false' }}
Expand All @@ -524,7 +562,7 @@ jobs:
if [ "$RUST_REQUIRED" != false ] || [ "$RUST_RESULT" != skipped ]; then
test "$RUST_RESULT" = success
fi
if [ "$RUST_REQUIRED" != false ] || [ "$SV_TESTS_RESULT" != skipped ]; then
if [ "$SV_TESTS_REQUIRED" != false ] || [ "$SV_TESTS_RESULT" != skipped ]; then
test "$SV_TESTS_RESULT" = success
fi
if [ "$ARM64_REQUIRED" != false ] || [ "$ARM64_RESULT" != skipped ]; then
Expand Down
28 changes: 24 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,30 @@ Lydite has its own test cadence (`scripts/ci-lydite-changes.mjs`):
excludes them, and fails on selected-job failures or cancellations. Repository
branch protection must require this check to make it a merge gate.

The classifier selects CI jobs, not individual Rust tests. Selected Rust CI
still runs the Celox workspace suite with CI features, doctests, default-feature
checks, ARM64 backend checks, and the explicit cocotb test. Local validation
uses the finer behavior-based matrix above.
Ordinary PRs also scope Rust compilation and execution:

- Library changes select the crate and its transitive consumers. Backend and
SV frontend changes narrow Celox integration tests to the affected variants;
shared implementation changes retain all affected variants.
- A single package's integration test or recognized Insta snapshot changes
select only the corresponding test binaries, using Cargo `--test` as well
as a nextest filter. Shared helpers and fixtures retain the package's tests;
mixed library/test changes combine their requirements.
- Clippy selects affected crates and test targets, including Lydite. Rust API
documentation and doctests select libraries reached through runtime/build
dependencies; dev-only consumers still run tests but do not rebuild their
API documentation. Test-only changes skip API documentation and doctests.
- sv-tests conformance runs when the Celox library or its runtime/build
dependencies change, or its runner/expectations change. Test infrastructure
and downstream consumers do not select this separate release-mode build.
- Python/cocotb setup runs only when VPI tests are selected.

Queue drafts, merge groups, releases, `ci:full`, and daily/manual full runs
retain the existing workspace tests, lint, documentation, sv-tests and platform
coverage. Cargo manifest, lockfile, toolchain, unknown-path and failed scope
analysis changes fall back to broad validation. Required checks permit skips
only when explicitly unneeded and still reject failures and cancellations.
Local validation uses the behavior-based matrix above.

| Cadence | Coverage |
| --- | --- |
Expand Down
6 changes: 3 additions & 3 deletions conformance/sv-tests/expected.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ chapter-8/8.8--typed_constructor.sv fail
chapter-8/8.8--typed_constructor_param.sv fail
chapter-8/8.9--static_properties.sv fail
chapter-9/9.2.1--initial.sv pass
chapter-9/9.2.2.1--always.sv fail
chapter-9/9.2.2.1--always.sv pass
chapter-9/9.2.2.2--always_comb.sv pass
chapter-9/9.2.2.3--always_latch.sv fail
chapter-9/9.2.2.4--always_ff.sv pass
Expand All @@ -732,8 +732,8 @@ chapter-9/9.4.2--event_control_negedge.sv pass
chapter-9/9.4.2--event_control_posedge.sv pass
chapter-9/9.4.2--event_control_sim.sv fail
chapter-9/9.4.2--event_control_sim_minimal.sv fail
chapter-9/9.4.2.1--event_comma_op.sv fail
chapter-9/9.4.2.1--event_or_op.sv fail
chapter-9/9.4.2.1--event_comma_op.sv pass
chapter-9/9.4.2.1--event_or_op.sv pass
chapter-9/9.4.2.2--event_implicit.sv pass
chapter-9/9.4.2.3--event_conditional.sv fail
chapter-9/9.4.2.4--event_sequence.sv fail
Expand Down
6 changes: 6 additions & 0 deletions crates/celox-frontend-sv/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,12 @@ fn lower_initial_processes(
.get(&(1, index))
.copied()
.unwrap_or(0x4d59_5df4);
// An `always` process never finishes, so it is never folded into
// initial state.
if process.repeats() {
runtime.push((process, random_seed));
continue;
}
let mut comb = comb::Comb::new(&mut pm, &mut arena);
match comb.lower_initial(process.body(), process.is_initializer(), &seed) {
Ok((written, store)) => {
Expand Down
9 changes: 9 additions & 0 deletions crates/celox-sv-analyzer/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ impl Module {
body: static_initializers,
initializer: true,
synthetic: false,
repeats: false,
},
);
}
Expand Down Expand Up @@ -2062,6 +2063,8 @@ pub struct InitialProcess {
body: Vec<Stmt>,
initializer: bool,
synthetic: bool,
/// An `always` process: its body runs forever.
repeats: bool,
}

impl InitialProcess {
Expand All @@ -2084,6 +2087,12 @@ impl InitialProcess {
self.initializer
}

/// Whether this is an `always` process, which runs its body forever and
/// never finishes on its own.
pub fn repeats(&self) -> bool {
self.repeats
}

pub fn body(&self) -> &[Stmt] {
&self.body
}
Expand Down
1 change: 1 addition & 0 deletions crates/celox-sv-analyzer/src/ast/array_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ impl ArrayParameter<'_> {
}],
initializer: false,
synthetic: true,
repeats: false,
})
}
}
47 changes: 37 additions & 10 deletions crates/celox-sv-analyzer/src/ast/procedural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,17 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
}
}

/// Timing controls suspend the process that executes them. An `initial`
/// body runs as a process; `always` bodies with timing controls and
/// subroutines with them are not lowered yet.
fn allow_timing(&self, construct: &str) -> Result<(), AnalyzerError> {
/// Timing controls suspend the process that executes them: an
/// `initial` or `always` process. An `always_comb` or `always_ff` body
/// and a function may not suspend; subroutines with timing controls are
/// not lowered yet.
fn allow_timing(&self, construct: &'static str) -> Result<(), AnalyzerError> {
match self.body {
system_functions::Body::Initial => Ok(()),
system_functions::Body::Always => Err(unsupported(format!(
"always and always_latch processes with a {construct}"
))),
system_functions::Body::Always => Err(AnalyzerError::TimingControlOutsideProcess {
construct,
context: "an always_comb or always_ff body",
}),
system_functions::Body::Subroutine => {
Err(unsupported(format!("{construct} in a subroutine")))
}
Expand Down Expand Up @@ -2214,6 +2216,7 @@ pub(super) fn initial_processes_from_module_node(
body,
initializer: true,
synthetic: false,
repeats: false,
});
}
continue;
Expand All @@ -2222,17 +2225,40 @@ pub(super) fn initial_processes_from_module_node(
else {
continue;
};
let sv_parser::ModuleCommonItem::InitialConstruct(initial) = &module_item.nodes.1 else {
continue;
let (statement, repeats) = match &module_item.nodes.1 {
sv_parser::ModuleCommonItem::InitialConstruct(initial) => {
(Some(&initial.nodes.1), false)
}
sv_parser::ModuleCommonItem::AlwaysConstruct(always)
if validation::always_kind(always) == validation::AlwaysKind::Process =>
{
(None, true)
}
_ => continue,
};
let (item_dimensions, literals) = views.get(item);
// A process statement runs in the body kind of an `initial` block:
// it may suspend and call any task.
let mut builder = BodyBuilder::new(
tree,
item_dimensions,
state,
system_functions::Body::Initial,
);
let mut body = builder.statement_or_null(&initial.nodes.1)?;
let mut body = match (statement, &module_item.nodes.1) {
(Some(statement), _) => builder.statement_or_null(statement)?,
(None, sv_parser::ModuleCommonItem::AlwaysConstruct(always)) => {
// `always statement` repeats the statement forever.
vec![Stmt::Loop {
kind: LoopKind::Forever,
init: Vec::new(),
condition: None,
step: Vec::new(),
body: builder.statement(&always.nodes.1)?,
}]
}
_ => unreachable!("only initial and always constructs are collected"),
};
for stmt in &mut body {
substitute_stmt_constants(stmt, &item.env, literals);
qualify_stmt(item, stmt);
Expand All @@ -2244,6 +2270,7 @@ pub(super) fn initial_processes_from_module_node(
body,
initializer: false,
synthetic: false,
repeats,
});
}
initializers.extend(processes);
Expand Down
2 changes: 2 additions & 0 deletions crates/celox-sv-analyzer/src/ast/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ impl ScopeSymbols {
.collect(),
initializer: process.initializer,
synthetic: process.synthetic,
repeats: process.repeats,
})
.collect();
self.signals.push(signal);
Expand Down Expand Up @@ -505,6 +506,7 @@ impl ScopeSymbols {
.collect(),
initializer: process.initializer,
synthetic: process.synthetic,
repeats: process.repeats,
})
.collect(),
aliases: HashMap::default(),
Expand Down
31 changes: 23 additions & 8 deletions crates/celox-sv-analyzer/src/ast/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ pub(super) fn reject_unsupported_multidimensional_packed_bounds(
pub(super) enum AlwaysKind {
Comb,
Ff,
/// A process that runs its statement forever, suspending at its timing
/// controls (IEEE 1800-2023 9.2.2.1).
Process,
Unsupported,
}

/// `always_comb` and `always @*` are combinational; `always_ff` and an
/// `always` sensitive to clock edges are sequential. Other sensitivity lists
/// (incomplete level-sensitive lists, `always_latch`) are not supported.
/// `always` sensitive to clock edges are sequential, as long as their body
/// has no timing control of its own. Every other `always` is a process.
/// `always_latch` is not supported.
pub(super) fn always_kind(always: &sv_parser::AlwaysConstruct) -> AlwaysKind {
match always.nodes.0 {
sv_parser::AlwaysKeyword::AlwaysComb(_) => AlwaysKind::Comb,
Expand All @@ -53,11 +57,14 @@ pub(super) fn always_kind(always: &sv_parser::AlwaysConstruct) -> AlwaysKind {
let sv_parser::StatementItem::ProceduralTimingControlStatement(timing) =
&always.nodes.1.nodes.2
else {
return AlwaysKind::Unsupported;
return AlwaysKind::Process;
};
let sv_parser::ProceduralTimingControl::EventControl(control) = &timing.nodes.0 else {
return AlwaysKind::Unsupported;
return AlwaysKind::Process;
};
if has_timing_control(RefNode::StatementOrNull(&timing.nodes.1)) {
return AlwaysKind::Process;
}
match &**control {
sv_parser::EventControl::Asterisk(_)
| sv_parser::EventControl::ParenAsterisk(_) => AlwaysKind::Comb,
Expand All @@ -68,12 +75,22 @@ pub(super) fn always_kind(always: &sv_parser::AlwaysConstruct) -> AlwaysKind {
{
AlwaysKind::Ff
}
_ => AlwaysKind::Unsupported,
_ => AlwaysKind::Process,
}
}
}
}

/// Whether a statement contains a delay, an event control or a `wait`.
fn has_timing_control(node: RefNode<'_>) -> bool {
node.into_iter().any(|node| {
matches!(
node,
RefNode::ProceduralTimingControlStatement(_) | RefNode::WaitStatement(_)
)
})
}

/// The statement an combinational `always` evaluates, without its event control.
pub(super) fn always_comb_body(
always: &sv_parser::AlwaysConstruct,
Expand Down Expand Up @@ -551,9 +568,7 @@ fn reject_silently_ignored_constructs_with_dimensions(
}
RefNode::AlwaysConstruct(always) => {
if always_kind(always) == AlwaysKind::Unsupported {
return Err(AnalyzerError::Unsupported(
"always and always_latch processes".to_string(),
));
return Err(AnalyzerError::Unsupported("always_latch process".to_string()));
}
let body = RefNode::Statement(&always.nodes.1);
if always_kind(always) == AlwaysKind::Comb
Expand Down
Loading
Loading