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
50 changes: 31 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ jobs:
if: success() || failure()
run: node scripts/ci-rust-reports.mjs collect

- name: Run cocotb VPI end-to-end test
id: cocotb-tests
if: needs.changes.outputs.rust_vpi_e2e != 'false'
env:
RUST_FULL: ${{ needs.changes.outputs.rust_full }}
BUILDS: ${{ needs.changes.outputs.rust_builds }}
run: |
CELOX_COCOTB_PYTHON="$(command -v python)" node scripts/run-ci-cocotb.mjs

- name: Retain Rust test reports
if: (success() || failure()) && hashFiles('work/ci-reports/rust/*.xml') != ''
uses: actions/upload-artifact@v7
Expand All @@ -289,14 +298,14 @@ jobs:
token: ${{ secrets.MERGIFY_TOKEN }}
report_path: work/ci-reports/rust/*.xml
job_name: rust-tests
test_step_outcome: ${{ steps.workspace-tests.outcome != 'skipped' && steps.workspace-tests.outcome || steps.scoped-tests.outcome }}
test_step_outcome: ${{ steps.cocotb-tests.outcome == 'failure' && 'failure' || steps.workspace-tests.outcome != 'skipped' && steps.workspace-tests.outcome || steps.scoped-tests.outcome }}

# nextest does not run documentation tests.
- name: Run workspace documentation tests with CI features
if: needs.changes.outputs.rust_full != 'false'
run: >-
cargo test --locked --workspace --exclude 'lydite*' --doc
--features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus
--features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/runtime-cases

- name: Run the documentation tests of the changed libraries
if: needs.changes.outputs.rust_full == 'false' && needs.changes.outputs.rust_libraries != ''
Expand All @@ -309,27 +318,24 @@ jobs:
if [ -n "$FEATURES" ]; then args+=(--features "$FEATURES"); fi
cargo test --locked --doc "${args[@]}"

rust-default-tests:
name: Rust default-feature tests
needs: changes
if: ${{ !cancelled() && (needs.changes.result != 'success' || (needs.changes.outputs.rust == 'true' && (needs.changes.outputs.rust_full != 'false' || contains(format(' {0} ', needs.changes.outputs.rust_libraries), ' celox ')))) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- uses: ./.github/actions/setup-rust
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Verify default-feature library and documentation tests
if: needs.changes.outputs.rust_full != 'false' || contains(format(' {0} ', needs.changes.outputs.rust_libraries), ' celox ')
run: |
cargo test --locked -p celox --lib
cargo test --locked -p celox --doc

- name: Run cocotb VPI end-to-end test
if: needs.changes.outputs.rust_vpi_e2e != 'false'
env:
FEATURES: ${{ needs.changes.outputs.rust_full != 'false' && 'celox/systemverilog' || needs.changes.outputs.rust_features }}
run: |
args=()
# Match the feature set of VPI's scoped nextest build. Features of
# other selected packages (such as external adapters) are unrelated.
for feature in ${FEATURES//,/ }; do
case "$feature" in celox/*) args+=(--features "$feature");; esac
done
CELOX_COCOTB_PYTHON="$(command -v python)" \
cargo test --locked -p celox-vpi --features systemverilog "${args[@]}" --test cocotb_e2e \
cocotb_ -- --ignored

external-suites:
name: External suite (${{ matrix.suite }}, ${{ matrix.tool }})
needs: changes
Expand Down Expand Up @@ -630,13 +636,15 @@ jobs:
# into a successful check merely because a downstream job was skipped.
rust:
name: Rust Test & NAPI Build
needs: [changes, rust-tests, sv-tests, arm64-backend, napi-linux, napi-wasm, external-suites]
needs: [changes, rust-tests, rust-default-tests, sv-tests, arm64-backend, napi-linux, napi-wasm, external-suites]
if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true' || needs.changes.outputs.napi == 'true') }}
runs-on: ubuntu-latest
env:
CHANGES_RESULT: ${{ needs.changes.result }}
RUST_REQUIRED: ${{ needs.changes.outputs.rust }}
RUST_RESULT: ${{ needs.rust-tests.result }}
DEFAULT_REQUIRED: ${{ needs.changes.result != 'success' || (needs.changes.outputs.rust == 'true' && (needs.changes.outputs.rust_full != 'false' || contains(format(' {0} ', needs.changes.outputs.rust_libraries), ' celox '))) }}
DEFAULT_RESULT: ${{ needs.rust-default-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.
Expand All @@ -656,6 +664,9 @@ jobs:
if [ "$RUST_REQUIRED" != false ] || [ "$RUST_RESULT" != skipped ]; then
test "$RUST_RESULT" = success
fi
if [ "$DEFAULT_REQUIRED" != false ] || [ "$DEFAULT_RESULT" != skipped ]; then
test "$DEFAULT_RESULT" = success
fi
if [ "$SV_TESTS_REQUIRED" != false ] || [ "$SV_TESTS_RESULT" != skipped ]; then
test "$SV_TESTS_RESULT" = success
fi
Expand Down Expand Up @@ -959,6 +970,7 @@ jobs:
docs,
lint,
rust-tests,
rust-default-tests,
sv-tests,
external-suites,
common-cells,
Expand Down
43 changes: 42 additions & 1 deletion .github/workflows/rust-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,47 @@ jobs:
- name: Build test targets to populate dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: >-
cargo nextest list --locked --workspace --message-format json
cargo nextest list --locked --workspace --exclude 'lydite*' --message-format json
--features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/runtime-cases
> /dev/null

rust-default-tests:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
name: Populate default-feature dependency cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- uses: ./.github/actions/setup-rust
- uses: Swatinem/rust-cache@v2
id: cache
- name: Build default-feature library test dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cargo test --locked -p celox --lib --no-run

napi-windows:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
name: Populate Windows NAPI dependency cache
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- uses: ./.github/actions/setup-rust
- uses: Swatinem/rust-cache@v2
id: cache
- uses: pnpm/action-setup@v6
if: steps.cache.outputs.cache-hit != 'true'
- uses: actions/setup-node@v7
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 24
cache: pnpm
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build NAPI with the CI command
if: steps.cache.outputs.cache-hit != 'true'
run: pnpm run build:napi
27 changes: 20 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,26 @@ ignored registrations deliberately.

With `runtime-cases`, `.vtest` bodies are read from disk instead of embedded in
Rust binaries, so edits to an existing case do not require recompilation. Adding
a test registration or changing Rust still requires a build. The first run builds
both the optimized executor and ordinary test binaries; the executor profile has
its own Cargo cache. Ordinary Cargo test commands retain the embedded, in-process
path. CI's Rust Tests job prepares the executor once and uses it for both full
workspace runs and scoped runs that include Celox. Scopes without Celox skip that
build. The default-branch cache warmer builds both executor and test dependencies
under the same cache key; vtest preparation failures fail the test job.
a test registration or changing Rust still requires a build. Both local commands
and CI build the optimized executor separately from ordinary test binaries.
CI keeps the normal test profile and existing dependency cache: sharing a Cargo
profile alone does not share artifacts when the executor and workspace resolve
different dependency features. Ordinary Cargo test commands retain the embedded,
in-process path. CI's Rust Tests job prepares the executor once and uses it for
full workspace runs and scoped runs that include Celox. Scopes without Celox
skip that build. The default-branch cache warmer builds both executor and test
dependencies under the same cache key; preparation failures fail the test job.
Cocotb runs through nextest with the exact packages, features and targets of its
original build, selecting
only the ignored `cocotb_` cases; an empty selection fails. Its reports are kept
separately and uploaded with the regular test results.

Default-feature library and documentation tests run in a separate parallel job
with no extra features. The required Rust gate still requires this job whenever
Celox libraries or the full workspace are selected, and on detection failure.
The cache warmer also primes this job and Windows NAPI dependencies on master
using their CI job IDs, environments and build commands. Windows builds still
need a first cache fill after a toolchain or dependency change.

The CI nextest profile also emits JUnit results. The Rust Tests job preserves
each scoped invocation separately under `work/ci-reports/rust/`, retains the XML
Expand Down
83 changes: 79 additions & 4 deletions crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,86 @@ pub struct TriggerSet<A> {
pub resets: Vec<A>,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum RuntimeEventKind {
Display,
Write,
AssertContinue,
AssertFatal,
/// A message of a severity task, or of a Veryl assertion
/// (IEEE 1800-2023 20.10). [`Severity::Fatal`] ends the simulation with
/// an error.
Report(Severity),
/// `$finish` executed by the design (IEEE 1800-2023 20.2).
Finish,
/// `$stop` executed by the design (IEEE 1800-2023 20.2).
Stop,
}

impl RuntimeEventKind {
/// A report that ends the simulation with an error.
pub fn is_fatal(self) -> bool {
self == Self::Report(Severity::Fatal)
}
}

/// The severity of a report (IEEE 1800-2023 20.10).
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum Severity {
/// `$info`: a message of no specific severity.
Info,
/// `$warning`.
Warning,
/// `$error`, and the default action of a failed `assert` or `assume`.
Error,
/// `$fatal`.
Fatal,
}

/// Where a report is written: the file and line of `__FILE__` and
/// `__LINE__` at the task call (IEEE 1800-2023 20.10).
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ReportLocation {
pub file: String,
pub line: usize,
}

/// The assertion whose action block issues a report.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct AssertionSite {
/// The statement label, which names the assertion within its scope
/// (IEEE 1800-2023 16.3).
pub label: Option<String>,
pub directive: AssertionDirective,
pub deferral: AssertionDeferral,
pub outcome: AssertionOutcome,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AssertionDirective {
Assert,
Assume,
Cover,
}

/// When an assertion reports (IEEE 1800-2023 16.4).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AssertionDeferral {
/// A simple immediate assertion: at once.
None,
/// `#0`: in the Reactive region.
Observed,
/// `final`: in the Postponed region.
Final,
}

/// Which action block of an assertion issues a report.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AssertionOutcome {
/// The pass action, or the statement of a `cover`.
Pass,
/// The fail action.
Fail,
}

/// How a runtime event site sizes its formatted arguments.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum DisplaySizing {
Expand All @@ -118,6 +186,11 @@ pub struct RuntimeEventSite {
pub sizing: DisplaySizing,
/// Fully elaborated module-instance scope that emitted this event.
pub scope: Option<String>,
#[serde(default)]
pub location: Option<ReportLocation>,
/// The assertion whose action issues this report.
#[serde(default)]
pub assertion: Option<AssertionSite>,
pub arg_widths: Vec<usize>,
pub arg_signed: Vec<bool>,
pub arg_is_string: Vec<bool>,
Expand Down Expand Up @@ -1883,10 +1956,12 @@ mod tests {
let mut runtime = RuntimeSchema::default();
runtime.runtime_errors.insert(1, error.clone());
runtime.runtime_event_sites.push(RuntimeEventSite {
kind: RuntimeEventKind::AssertFatal,
kind: RuntimeEventKind::Report(Severity::Fatal),
template: Some("failed".to_string()),
sizing: DisplaySizing::Veryl,
scope: None,
location: None,
assertion: None,
arg_widths: Vec::new(),
arg_signed: Vec::new(),
arg_is_string: Vec::new(),
Expand Down
20 changes: 9 additions & 11 deletions crates/celox-frontend-core/src/symbolic/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ pub fn schedule_symbolic_rtl_reporting_loops(
&unpacked_element_widths,
)?;
for (site_id, site) in runtime_event_sites.iter().enumerate() {
if !matches!(site.kind, RuntimeEventKind::AssertFatal) {
if !site.kind.is_fatal() {
continue;
}
runtime_errors
Expand Down Expand Up @@ -4224,11 +4224,10 @@ fn build_comb_observer_capture_paths(
| RuntimeEventKind::Finish
| RuntimeEventKind::Stop
);
let fatal_error_code = matches!(
sites[observer.site_id as usize].kind,
RuntimeEventKind::AssertFatal
)
.then_some(observer.site_id as i64);
let fatal_error_code = sites[observer.site_id as usize]
.kind
.is_fatal()
.then_some(observer.site_id as i64);
let pre_lower_nodes = observer_pre_lower_nodes(observer, arena);
for idx in &order_after {
comb_blocks[idx.0]
Expand Down Expand Up @@ -4281,11 +4280,10 @@ fn build_comb_observer_capture_paths(
| RuntimeEventKind::Finish
| RuntimeEventKind::Stop
);
let member_fatal_error_code = matches!(
sites[member.site_id as usize].kind,
RuntimeEventKind::AssertFatal
)
.then_some(member.site_id as i64);
let member_fatal_error_code = sites[member.site_id as usize]
.kind
.is_fatal()
.then_some(member.site_id as i64);
let member_expr = match member
.loop_runner
.or(member.guard)
Expand Down
6 changes: 3 additions & 3 deletions crates/celox-frontend-sv/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::path::Path;
use celox_design::{
BinaryOp, BitAccess, DisplaySizing, DomainKind, ExternFunction, ExternSignature, ExternType,
InitialStateData, InitialStateValue, ModuleId, NbaSite, PROCESS_DELAY_WIDTH,
PROCESS_STATUS_WIDTH, PortTypeKind, ProcessSlots, RegionedVarAddrBase, RuntimeErrorInfo,
RuntimeEventKind, RuntimeEventSite, STABLE_REGION, TIME_SLOT_WIDTH, TriggerSet, UnaryOp,
VarAtomBase, WORKING_REGION, WaitSite,
PROCESS_STATUS_WIDTH, PortTypeKind, ProcessSlots, RegionedVarAddrBase, ReportLocation,
RuntimeErrorInfo, RuntimeEventKind, RuntimeEventSite, STABLE_REGION, Severity, TIME_SLOT_WIDTH,
TriggerSet, UnaryOp, VarAtomBase, WORKING_REGION, WaitSite,
};
use celox_frontend_core::process::PROCESS_RESUME_WIDTH;
use celox_frontend_core::symbolic::artifact::{
Expand Down
Loading
Loading