diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a77cd3fe13a..e1731134b78 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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
@@ -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 != ''
@@ -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
@@ -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.
@@ -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
@@ -959,6 +970,7 @@ jobs:
docs,
lint,
rust-tests,
+ rust-default-tests,
sv-tests,
external-suites,
common-cells,
diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml
index b7113223635..33fdcdb80c7 100644
--- a/.github/workflows/rust-cache.yml
+++ b/.github/workflows/rust-cache.yml
@@ -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
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b178404a8a2..095a0dad575 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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
diff --git a/crates/celox-design/src/lib.rs b/crates/celox-design/src/lib.rs
index 5e45cf13916..5af0b9b685c 100644
--- a/crates/celox-design/src/lib.rs
+++ b/crates/celox-design/src/lib.rs
@@ -86,18 +86,86 @@ pub struct TriggerSet {
pub resets: Vec,
}
-#[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,
+ 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 {
@@ -118,6 +186,11 @@ pub struct RuntimeEventSite {
pub sizing: DisplaySizing,
/// Fully elaborated module-instance scope that emitted this event.
pub scope: Option,
+ #[serde(default)]
+ pub location: Option,
+ /// The assertion whose action issues this report.
+ #[serde(default)]
+ pub assertion: Option,
pub arg_widths: Vec,
pub arg_signed: Vec,
pub arg_is_string: Vec,
@@ -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(),
diff --git a/crates/celox-frontend-core/src/symbolic/assembly.rs b/crates/celox-frontend-core/src/symbolic/assembly.rs
index 7682ec5627d..de8a356d78a 100644
--- a/crates/celox-frontend-core/src/symbolic/assembly.rs
+++ b/crates/celox-frontend-core/src/symbolic/assembly.rs
@@ -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
@@ -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]
@@ -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)
diff --git a/crates/celox-frontend-sv/src/lowering.rs b/crates/celox-frontend-sv/src/lowering.rs
index 8cf8c077ad4..37b7d1f199f 100644
--- a/crates/celox-frontend-sv/src/lowering.rs
+++ b/crates/celox-frontend-sv/src/lowering.rs
@@ -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::{
diff --git a/crates/celox-frontend-sv/src/lowering/comb.rs b/crates/celox-frontend-sv/src/lowering/comb.rs
index c9117dac590..ecaee3626b9 100644
--- a/crates/celox-frontend-sv/src/lowering/comb.rs
+++ b/crates/celox-frontend-sv/src/lowering/comb.rs
@@ -2183,6 +2183,7 @@ impl<'p, 'a> Comb<'p, 'a> {
task: sv::ir::SystemTask::Readmem(format),
args,
site,
+ ..
} => {
self.readmem(&mut store, frames, *format, args, site.as_ref())?;
Ok(store)
@@ -2203,8 +2204,20 @@ impl<'p, 'a> Comb<'p, 'a> {
sv::ir::Stmt::SystemTask { task, .. } if self.initial => Err(unsupported(format!(
"system task `{task}` inside an initial block"
))),
- sv::ir::Stmt::SystemTask { task, args, .. } => {
- self.system_task(&mut store, frames, *task, args)?;
+ sv::ir::Stmt::SystemTask {
+ task,
+ args,
+ site,
+ assertion,
+ } => {
+ self.system_task(
+ &mut store,
+ frames,
+ *task,
+ args,
+ site.as_ref(),
+ assertion.as_ref(),
+ )?;
Ok(store)
}
}
@@ -3456,6 +3469,8 @@ impl<'p, 'a> Comb<'p, 'a> {
frames: &[Frame],
task: sv::ir::SystemTask,
args: &[sv::ir::SystemTaskArg],
+ site: Option<&sv::ir::SourceSpan>,
+ assertion_site: Option<&celox_design::AssertionSite>,
) -> Result<(), sv::AnalyzerError> {
let kind =
system_task_kind(task).ok_or_else(|| unsupported(format!("system task `{task}`")))?;
@@ -3529,13 +3544,7 @@ impl<'p, 'a> Comb<'p, 'a> {
arg_widths.push(self.width(node));
captured.push(self.capture(node)?);
}
- let event_kind = match &kind {
- SystemTaskKind::Print(kind, _) => *kind,
- SystemTaskKind::Control(kind) => *kind,
- SystemTaskKind::Message => RuntimeEventKind::AssertContinue,
- SystemTaskKind::Fatal => RuntimeEventKind::AssertFatal,
- SystemTaskKind::Assertion(kind) => *kind,
- };
+ let event_kind = kind.event_kind();
let condition = self.path_condition()?;
let guard = if let Some(passed) = assertion {
// An assertion fires only on failure and only on the active path.
@@ -3554,10 +3563,10 @@ impl<'p, 'a> Comb<'p, 'a> {
Some(node)
}
// Assertion sites fire when their guard is false.
- (SystemTaskKind::Message | SystemTaskKind::Fatal, None) => {
+ (SystemTaskKind::Message(_) | SystemTaskKind::Fatal, None) => {
Some(self.constant(0, 1)?)
}
- (SystemTaskKind::Message | SystemTaskKind::Fatal, Some((node, sources))) => {
+ (SystemTaskKind::Message(_) | SystemTaskKind::Fatal, Some((node, sources))) => {
observed.extend(sources);
Some(slt_not(self.arena, &mut self.consts, node)?)
}
@@ -3594,6 +3603,8 @@ impl<'p, 'a> Comb<'p, 'a> {
template,
sizing: DisplaySizing::Ieee,
scope: None,
+ location: report_location(site),
+ assertion: assertion_site.cloned(),
arg_widths,
arg_signed,
arg_is_string,
diff --git a/crates/celox-frontend-sv/src/lowering/ff.rs b/crates/celox-frontend-sv/src/lowering/ff.rs
index 5a8236e21a8..0f1d56b9324 100644
--- a/crates/celox-frontend-sv/src/lowering/ff.rs
+++ b/crates/celox-frontend-sv/src/lowering/ff.rs
@@ -2990,9 +2990,12 @@ impl<'p, 'a> Ff<'p, 'a> {
self.eval(expr, None)?;
Ok(true)
}
- sv::ir::Stmt::SystemTask { task, args, site } => {
- self.system_task(*task, args, site.as_ref())
- }
+ sv::ir::Stmt::SystemTask {
+ task,
+ args,
+ site,
+ assertion,
+ } => self.system_task(*task, args, site.as_ref(), assertion.as_ref()),
}
}
@@ -3003,6 +3006,7 @@ impl<'p, 'a> Ff<'p, 'a> {
task: sv::ir::SystemTask,
args: &[sv::ir::SystemTaskArg],
site: Option<&sv::ir::SourceSpan>,
+ assertion_site: Option<&celox_design::AssertionSite>,
) -> Result {
if let sv::ir::SystemTask::Vcd(operation) = task {
self.vcd_task(operation, args)?;
@@ -3161,18 +3165,14 @@ impl<'p, 'a> Ff<'p, 'a> {
}
_ => None,
};
- let event_kind = match &kind {
- SystemTaskKind::Print(kind, _) => *kind,
- SystemTaskKind::Control(kind) => *kind,
- SystemTaskKind::Message => RuntimeEventKind::AssertContinue,
- SystemTaskKind::Fatal => RuntimeEventKind::AssertFatal,
- SystemTaskKind::Assertion(kind) => *kind,
- };
+ let event_kind = kind.event_kind();
let site_id = self.m.event_site(RuntimeEventSite {
kind: event_kind,
template: template.clone(),
sizing: DisplaySizing::Ieee,
scope: None,
+ location: report_location(site),
+ assertion: assertion_site.cloned(),
arg_widths,
arg_signed,
arg_is_string,
diff --git a/crates/celox-frontend-sv/src/lowering/procedural.rs b/crates/celox-frontend-sv/src/lowering/procedural.rs
index 3b750498bf7..c9667da65bc 100644
--- a/crates/celox-frontend-sv/src/lowering/procedural.rs
+++ b/crates/celox-frontend-sv/src/lowering/procedural.rs
@@ -1232,7 +1232,7 @@ pub(super) enum SystemTaskKind {
/// `$finish` and `$stop`, with their event kind.
Control(RuntimeEventKind),
/// `$error`, `$warning`, `$info`: a message, then execution continues.
- Message,
+ Message(Severity),
/// `$fatal`: a message, then the simulation ends with an error.
Fatal,
/// Veryl's assertion calls: eagerly evaluate every argument, then report
@@ -1242,13 +1242,26 @@ pub(super) enum SystemTaskKind {
impl SystemTaskKind {
pub(super) fn is_fatal(&self) -> bool {
- matches!(
- self,
- Self::Fatal | Self::Assertion(RuntimeEventKind::AssertFatal)
- )
+ self.event_kind().is_fatal()
+ }
+
+ pub(super) fn event_kind(&self) -> RuntimeEventKind {
+ match *self {
+ Self::Print(kind, _) | Self::Control(kind) | Self::Assertion(kind) => kind,
+ Self::Message(severity) => RuntimeEventKind::Report(severity),
+ Self::Fatal => RuntimeEventKind::Report(Severity::Fatal),
+ }
}
}
+/// Where a report is written, from the span of its task call.
+pub(super) fn report_location(site: Option<&sv::ir::SourceSpan>) -> Option {
+ site.map(|site| ReportLocation {
+ file: site.logical_path.display().to_string(),
+ line: site.line,
+ })
+}
+
/// How a task reports, for the tasks that report: `$readmemh`/`$readmemb`
/// load memory instead, the analyzer rewrites `$printtimescale` into a
/// `$display`, and `$exit` outside a program block does nothing.
@@ -1261,10 +1274,16 @@ pub(super) fn system_task_kind(task: sv::ir::SystemTask) -> Option SystemTaskKind::Print(RuntimeEventKind::Write, radix.letter()),
SystemTask::Finish => SystemTaskKind::Control(RuntimeEventKind::Finish),
SystemTask::Stop => SystemTaskKind::Control(RuntimeEventKind::Stop),
- SystemTask::Severity(_) => SystemTaskKind::Message,
+ SystemTask::Severity(severity) => SystemTaskKind::Message(match severity {
+ sv::ir::Severity::Error => Severity::Error,
+ sv::ir::Severity::Warning => Severity::Warning,
+ sv::ir::Severity::Info => Severity::Info,
+ }),
SystemTask::Fatal => SystemTaskKind::Fatal,
- SystemTask::Assert => SystemTaskKind::Assertion(RuntimeEventKind::AssertFatal),
- SystemTask::AssertContinue => SystemTaskKind::Assertion(RuntimeEventKind::AssertContinue),
+ SystemTask::Assert => SystemTaskKind::Assertion(RuntimeEventKind::Report(Severity::Fatal)),
+ SystemTask::AssertContinue => {
+ SystemTaskKind::Assertion(RuntimeEventKind::Report(Severity::Error))
+ }
SystemTask::Readmem(_)
| SystemTask::Writemem(_)
| SystemTask::Fclose
diff --git a/crates/celox-frontend-veryl/src/lowering/ff.rs b/crates/celox-frontend-veryl/src/lowering/ff.rs
index f6a42d62974..4570dde39a2 100644
--- a/crates/celox-frontend-veryl/src/lowering/ff.rs
+++ b/crates/celox-frontend-veryl/src/lowering/ff.rs
@@ -9,7 +9,8 @@ use crate::{
use bit_set::BitSet;
use celox_design::{
BinaryOp, BitAccess, DisplaySizing, RuntimeErrorInfo, RuntimeEventKind, RuntimeEventSite,
- SPARSE_WORKING_REGION, STABLE_REGION, TriggerSet, UnaryOp, VarAtomBase, WORKING_REGION,
+ SPARSE_WORKING_REGION, STABLE_REGION, Severity, TriggerSet, UnaryOp, VarAtomBase,
+ WORKING_REGION,
};
use celox_sir::{
BlockId, RegisterId, RegisterType, SIRBuilder, SIRInstruction, SIROffset, SIRTerminator,
@@ -552,6 +553,8 @@ impl<'a> FfParser<'a> {
template,
sizing: DisplaySizing::Veryl,
scope: None,
+ location: None,
+ assertion: None,
arg_widths: value_args
.iter()
.map(|arg| self.get_expression_width(&arg.0))
@@ -769,8 +772,8 @@ impl<'a> FfParser<'a> {
let pass_bb = ir_builder.new_block();
let fail_bb = ir_builder.new_block();
let event_kind = match kind {
- AssertKind::Fatal => RuntimeEventKind::AssertFatal,
- AssertKind::Continue => RuntimeEventKind::AssertContinue,
+ AssertKind::Fatal => RuntimeEventKind::Report(Severity::Fatal),
+ AssertKind::Continue => RuntimeEventKind::Report(Severity::Error),
};
let site_id = self.register_runtime_event_site(event_kind, args);
// Assertion message arguments are observationally eager: any
diff --git a/crates/celox-frontend-veryl/src/lowering/logic_tree/effect.rs b/crates/celox-frontend-veryl/src/lowering/logic_tree/effect.rs
index c4623e4f940..f77095b9bd8 100644
--- a/crates/celox-frontend-veryl/src/lowering/logic_tree/effect.rs
+++ b/crates/celox-frontend-veryl/src/lowering/logic_tree/effect.rs
@@ -1,5 +1,6 @@
use super::state::FunctionLoopControlState;
use super::*;
+use celox_design::Severity;
pub(crate) fn subtract_written_sensitivity(
atoms: impl IntoIterator- >,
@@ -100,6 +101,8 @@ fn register_comb_runtime_event_site<'a>(
template,
sizing: DisplaySizing::Veryl,
scope: None,
+ location: None,
+ assertion: None,
arg_widths: value_args
.iter()
.map(|arg| arg.0.comptime().r#type.total_width().unwrap_or(1))
@@ -156,8 +159,10 @@ fn collect_system_function_effect(
SystemFunctionKind::Finish => (RuntimeEventKind::Finish, None, [].as_slice()),
SystemFunctionKind::Assert { kind, cond, args } => {
let event_kind = match kind {
- veryl_analyzer::ir::AssertKind::Fatal => RuntimeEventKind::AssertFatal,
- veryl_analyzer::ir::AssertKind::Continue => RuntimeEventKind::AssertContinue,
+ veryl_analyzer::ir::AssertKind::Fatal => RuntimeEventKind::Report(Severity::Fatal),
+ veryl_analyzer::ir::AssertKind::Continue => {
+ RuntimeEventKind::Report(Severity::Error)
+ }
};
(event_kind, Some(&cond.0), args.as_slice())
}
@@ -220,20 +225,12 @@ fn collect_system_function_effect(
active,
None,
) => active,
- (RuntimeEventKind::AssertContinue | RuntimeEventKind::AssertFatal, None, explicit) => {
- explicit
- }
- (
- RuntimeEventKind::AssertContinue | RuntimeEventKind::AssertFatal,
- Some(active),
- Some(explicit),
- ) => {
+ (RuntimeEventKind::Report(_), None, explicit) => explicit,
+ (RuntimeEventKind::Report(_), Some(active), Some(explicit)) => {
let inactive = arena.alloc(SLTNode::Unary(UnaryOp::LogicNot, active))?;
Some(arena.alloc(SLTNode::Binary(inactive, BinaryOp::LogicOr, explicit))?)
}
- (RuntimeEventKind::AssertContinue | RuntimeEventKind::AssertFatal, Some(active), None) => {
- Some(active)
- }
+ (RuntimeEventKind::Report(_), Some(active), None) => Some(active),
(
RuntimeEventKind::Display
| RuntimeEventKind::Write
@@ -266,8 +263,7 @@ fn collect_system_function_effect(
| RuntimeEventKind::Stop
),
args: observer_args.clone(),
- fatal_error_code: matches!(kind, RuntimeEventKind::AssertFatal)
- .then_some(1_000_000 + site_id as i64),
+ fatal_error_code: kind.is_fatal().then_some(1_000_000 + site_id as i64),
});
let observed_ids: HashSet<_> = observed_inputs.iter().map(|atom| atom.id).collect();
let position_ids: HashSet<_> = position_inputs.iter().map(|atom| atom.id).collect();
diff --git a/crates/celox-frontend-veryl/src/testbench.rs b/crates/celox-frontend-veryl/src/testbench.rs
index 3ed5e6c4d11..e0a5971e020 100644
--- a/crates/celox-frontend-veryl/src/testbench.rs
+++ b/crates/celox-frontend-veryl/src/testbench.rs
@@ -1,6 +1,6 @@
use celox_design::{
BitAccess, DisplaySizing, InstanceId, PortTypeKind, RuntimeEventKind, RuntimeEventSite,
- StateAddr,
+ Severity, StateAddr,
};
use celox_testbench::{
AssertMessage as GenericAssertMessage, ClockCount as GenericClockCount, ExprBytecode,
@@ -103,12 +103,14 @@ fn runtime_event_site_for_assert(
};
RuntimeEventSite {
kind: match kind {
- AssertKind::Fatal => RuntimeEventKind::AssertFatal,
- AssertKind::Continue => RuntimeEventKind::AssertContinue,
+ AssertKind::Fatal => RuntimeEventKind::Report(Severity::Fatal),
+ AssertKind::Continue => RuntimeEventKind::Report(Severity::Error),
},
template,
sizing: DisplaySizing::Veryl,
scope: None,
+ location: None,
+ assertion: None,
arg_widths: value_args.iter().map(assert_arg_width).collect(),
arg_signed: value_args
.iter()
diff --git a/crates/celox-sv-analyzer/src/ast/procedural.rs b/crates/celox-sv-analyzer/src/ast/procedural.rs
index d47ebdb5f70..adbf305d7f8 100644
--- a/crates/celox-sv-analyzer/src/ast/procedural.rs
+++ b/crates/celox-sv-analyzer/src/ast/procedural.rs
@@ -1297,6 +1297,7 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
let error = Stmt::SystemTask {
task: SystemTask::Severity(system_functions::Severity::Error),
site: source_span(declarations.expression(root).tokens, self.tree),
+ assertion: None,
args: vec![SystemTaskArg::Str(
"$cast of a class handle to an incompatible class".into(),
)],
@@ -1337,6 +1338,7 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
return Ok(vec![Stmt::SystemTask {
task: SystemTask::Display(system_functions::Radix::Decimal),
site: source_span(declarations.expression(root).tokens, self.tree),
+ assertion: None,
args: vec![SystemTaskArg::Str(timescales::print_message(
root,
self.tree,
@@ -1408,6 +1410,7 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
task,
args,
site: source_span(declarations.expression(root).tokens, self.tree),
+ assertion: None,
}])
}
@@ -1609,14 +1612,42 @@ impl<'s, 't, 'a> BodyBuilder<'s, 't, 'a> {
}
/// The default failure action of a native immediate assertion.
-fn assertion_failure(keyword: &str) -> Vec {
+/// The default fail action of an `assert` or `assume`: a call to `$error`
+/// at the assertion (IEEE 1800-2023 20.10).
+fn assertion_failure(keyword: &str, site: Option) -> Vec {
vec![Stmt::SystemTask {
task: SystemTask::Severity(system_functions::Severity::Error),
args: vec![SystemTaskArg::Str(format!("{keyword} failed"))],
- site: None,
+ site,
+ assertion: None,
}]
}
+/// Attribute the severity tasks of an assertion's action block to it. Tasks
+/// in subroutines the block calls are not attributed, and the tasks of a
+/// nested assertion keep its own attribution.
+fn attribute_reports(
+ body: &mut [Stmt],
+ assertion: &celox_design::AssertionSite,
+ outcome: celox_design::AssertionOutcome,
+) {
+ for stmt in body {
+ stmt.walk_mut(&mut |stmt| {
+ if let Stmt::SystemTask {
+ task: SystemTask::Severity(_) | SystemTask::Fatal,
+ assertion: attributed @ None,
+ ..
+ } = stmt
+ {
+ *attributed = Some(celox_design::AssertionSite {
+ outcome,
+ ..assertion.clone()
+ });
+ }
+ });
+ }
+}
+
/// The declared arguments of a task or function: `(name, direction, type,
/// default)`. An argument without a direction takes the previous one's, and
/// one without a type the previous one's type (IEEE 1800-2023 13.3).
@@ -3046,7 +3077,10 @@ pub(super) fn source_span(
current.start = current.start.min(span.start);
current.end = current.end.max(span.end);
} else {
+ let (logical_path, line, _) = native.sources.logical_location(span);
result = Some(crate::procedural::SourceSpan {
+ logical_path: logical_path.to_owned(),
+ line,
path,
start: span.start,
end: span.end,
diff --git a/crates/celox-sv-analyzer/src/ast/procedural/control.rs b/crates/celox-sv-analyzer/src/ast/procedural/control.rs
index 44d2400f926..a2f7748bf8b 100644
--- a/crates/celox-sv-analyzer/src/ast/procedural/control.rs
+++ b/crates/celox-sv-analyzer/src/ast/procedural/control.rs
@@ -63,13 +63,16 @@ enum Job {
AssertionThen {
condition: Expr,
keyword: String,
+ assertion: celox_design::AssertionSite,
+ span: Option,
failure: Option,
start: usize,
},
AssertionFinish {
condition: Expr,
then_body: Vec,
- default_failure: Option,
+ assertion: celox_design::AssertionSite,
+ default_failure: Option<(String, Option)>,
start: usize,
},
}
@@ -238,9 +241,24 @@ impl BodyBuilder<'_, '_, '_> {
failure,
} => {
let condition = self.native_assertion_condition(keyword, header)?;
+ let statement = native.statement(id);
jobs.push(Job::AssertionThen {
condition,
keyword: keyword.clone(),
+ assertion: celox_design::AssertionSite {
+ label: statement
+ .label
+ .as_ref()
+ .map(|label| label.value().to_owned()),
+ directive: match keyword.as_str() {
+ "assume" => celox_design::AssertionDirective::Assume,
+ "cover" => celox_design::AssertionDirective::Cover,
+ _ => celox_design::AssertionDirective::Assert,
+ },
+ deferral: celox_design::AssertionDeferral::None,
+ outcome: celox_design::AssertionOutcome::Fail,
+ },
+ span: super::source_span(statement.tokens, self.tree),
failure: *failure,
start: output.len(),
});
@@ -279,6 +297,8 @@ impl BodyBuilder<'_, '_, '_> {
Job::AssertionThen {
condition,
keyword,
+ assertion,
+ span,
failure,
start,
} => {
@@ -286,8 +306,9 @@ impl BodyBuilder<'_, '_, '_> {
jobs.push(Job::AssertionFinish {
condition,
then_body,
+ assertion,
default_failure: if failure.is_none() && keyword != "cover" {
- Some(keyword)
+ Some((keyword, span))
} else {
None
},
@@ -299,14 +320,25 @@ impl BodyBuilder<'_, '_, '_> {
}
Job::AssertionFinish {
condition,
- then_body,
+ mut then_body,
+ assertion,
default_failure,
start,
} => {
let mut else_body = output.split_off(start);
- if let Some(keyword) = default_failure {
- else_body = assertion_failure(&keyword);
+ if let Some((keyword, span)) = default_failure {
+ else_body = assertion_failure(&keyword, span);
}
+ attribute_reports(
+ &mut then_body,
+ &assertion,
+ celox_design::AssertionOutcome::Pass,
+ );
+ attribute_reports(
+ &mut else_body,
+ &assertion,
+ celox_design::AssertionOutcome::Fail,
+ );
output.push(Stmt::If {
condition,
then_body,
diff --git a/crates/celox-sv-analyzer/src/procedural.rs b/crates/celox-sv-analyzer/src/procedural.rs
index 16d579a9d31..2da16383d4f 100644
--- a/crates/celox-sv-analyzer/src/procedural.rs
+++ b/crates/celox-sv-analyzer/src/procedural.rs
@@ -16,6 +16,11 @@ pub struct SourceSpan {
pub path: std::path::PathBuf,
pub start: usize,
pub end: usize,
+ /// The file and one-based line of the start as `__FILE__` and
+ /// `__LINE__` give them, after `` `line `` directives (IEEE 1800-2023
+ /// 22.12, 22.13).
+ pub logical_path: std::path::PathBuf,
+ pub line: usize,
}
/// Where a process is written, for diagnostics about the process as a
@@ -94,6 +99,9 @@ pub enum StmtBase {
task: SystemTask,
args: Vec>,
site: Option,
+ /// For a severity task in an action block of an assertion, that
+ /// assertion (IEEE 1800-2023 16.3, 20.10).
+ assertion: Option,
},
/// The declaration point of a local variable: it is (re)initialized here,
/// to `init` or to the default value of its type.
@@ -314,9 +322,15 @@ impl StmtBase {
args: args.into_iter().map(|arg| arg.map(&mut *fe)).collect(),
},
StmtBase::Eval(expr) => StmtBase::Eval(fe(expr)),
- StmtBase::SystemTask { task, args, site } => StmtBase::SystemTask {
+ StmtBase::SystemTask {
task,
+ args,
site,
+ assertion,
+ } => StmtBase::SystemTask {
+ task,
+ site,
+ assertion,
args: args
.into_iter()
.map(|arg| match arg {
@@ -466,6 +480,42 @@ impl StmtBase {
}
}
+ /// Visit every statement of this tree in place, outermost first.
+ pub fn walk_mut(&mut self, f: &mut impl FnMut(&mut StmtBase)) {
+ f(self);
+ let mut visit = |stmts: &mut [StmtBase]| {
+ for stmt in stmts {
+ stmt.walk_mut(f);
+ }
+ };
+ match self {
+ StmtBase::If {
+ then_body,
+ else_body,
+ ..
+ } => {
+ visit(then_body);
+ visit(else_body);
+ }
+ StmtBase::Case { items, default, .. } => {
+ for item in items {
+ visit(&mut item.body);
+ }
+ if let Some(default) = default {
+ visit(default);
+ }
+ }
+ StmtBase::Loop {
+ init, step, body, ..
+ } => {
+ visit(init);
+ visit(step);
+ visit(body);
+ }
+ _ => {}
+ }
+ }
+
/// Visit every statement of this tree, outermost first.
pub fn walk<'a>(&'a self, f: &mut impl FnMut(&'a StmtBase)) {
f(self);
diff --git a/crates/celox-vpi/src/bin/celox.rs b/crates/celox-vpi/src/bin/celox.rs
index 78161e8e44f..3ac3ac1a18e 100644
--- a/crates/celox-vpi/src/bin/celox.rs
+++ b/crates/celox-vpi/src/bin/celox.rs
@@ -227,13 +227,14 @@ fn drain_sv_output(
let (message, newline) = match event {
celox::RuntimeEvent::Display { message } => (message, true),
celox::RuntimeEvent::Write { message } => (message, false),
- celox::RuntimeEvent::AssertContinue { message } => {
- *failed = true;
- (message, true)
- }
- celox::RuntimeEvent::AssertFatal { message } => {
- fatal = true;
- (message, true)
+ // Only errors fail the run (IEEE 1800-2023 20.10).
+ celox::RuntimeEvent::Report(report) => {
+ match report.severity {
+ celox::Severity::Fatal => fatal = true,
+ celox::Severity::Error => *failed = true,
+ celox::Severity::Warning | celox::Severity::Info => {}
+ }
+ (report.render(), true)
}
celox::RuntimeEvent::Finish => continue,
celox::RuntimeEvent::Stop => {
@@ -926,6 +927,34 @@ mod tests {
assert!(String::from_utf8(output).unwrap().contains("tick"));
}
+ /// Only `$error` and `$fatal` fail a run; every report is printed with
+ /// its severity and location (IEEE 1800-2023 20.10).
+ #[cfg(feature = "systemverilog")]
+ #[test]
+ fn sv_reports_fail_the_run_only_from_errors() {
+ let run = |task: &str| {
+ let source = format!("module Top; initial {task}(\"note\"); endmodule");
+ let simulation = celox::Simulation::from_sv_sources(
+ vec![(source.as_str(), Path::new("top.sv"))],
+ "Top",
+ )
+ .build()
+ .unwrap();
+ let mut output = Vec::new();
+ let result = simulate_sv(simulation, 10, &mut output);
+ (result, String::from_utf8(output).unwrap())
+ };
+ let (result, output) = run("$info");
+ assert!(result.is_ok());
+ assert!(output.starts_with("Info: top.sv:1: note"), "{output}");
+ let (result, output) = run("$warning");
+ assert!(result.is_ok());
+ assert!(output.starts_with("Warning: top.sv:1: note"), "{output}");
+ let (result, output) = run("$error");
+ assert!(result.is_err());
+ assert!(output.starts_with("Error: top.sv:1: note"), "{output}");
+ }
+
fn state_file(count: u8, stale: u8) -> StateFile {
let object = |path: &str, role, value: u8, mask: u8| StateObject {
path: path.into(),
diff --git a/crates/celox-vpi/src/lib.rs b/crates/celox-vpi/src/lib.rs
index 157fd95dcb2..39fe402c1c4 100644
--- a/crates/celox-vpi/src/lib.rs
+++ b/crates/celox-vpi/src/lib.rs
@@ -21,7 +21,7 @@ use std::{
use celox::{
BigUint, DomainKind, NativeProgramInstance, NativeSignalIdentity, ReflectionScopeId,
- ReflectionSignalId, RuntimeEvent, RuntimeFormatContext, SignalDirection, SimBackend,
+ ReflectionSignalId, RuntimeEvent, RuntimeFormatContext, Severity, SignalDirection, SimBackend,
};
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};
@@ -1851,18 +1851,13 @@ fn process_runtime_events() {
RuntimeEvent::Write { message } => {
let _ = std::io::stdout().lock().write_all(&message);
}
- RuntimeEvent::AssertContinue { message } => {
+ RuntimeEvent::Report(report) => {
let mut output = std::io::stderr().lock();
- let _ = output.write_all(b"assertion failed: ");
- let _ = output.write_all(&message);
- let _ = output.write_all(b"\n");
- }
- RuntimeEvent::AssertFatal { message } => {
- let mut output = std::io::stderr().lock();
- let _ = output.write_all(b"fatal assertion failed: ");
- let _ = output.write_all(&message);
+ let _ = output.write_all(&report.render());
let _ = output.write_all(b"\n");
- callbacks::fail(celox_message_diagnostic(&message));
+ if report.severity == Severity::Fatal {
+ callbacks::fail(celox_message_diagnostic(&report.message));
+ }
}
// Like `vpiStop` in `vpi_control`, `$stop` ends a run that has
// no interactive mode.
diff --git a/crates/celox/examples/sv_tests.rs b/crates/celox/examples/sv_tests.rs
index 9d53159778a..8ff75d497fd 100644
--- a/crates/celox/examples/sv_tests.rs
+++ b/crates/celox/examples/sv_tests.rs
@@ -188,13 +188,11 @@ fn simulate(mut sim: celox::Simulation) -> Result<(), String> {
let mut output = |sim: &mut celox::Simulation| -> Result<(), String> {
for event in sim.drain_runtime_events() {
match event {
- celox::RuntimeEvent::Display { message }
- | celox::RuntimeEvent::AssertContinue { message } => {
- stdout.write_all(&message).unwrap();
- stdout.write_all(b"\n").unwrap();
- }
- celox::RuntimeEvent::Write { message } => stdout.write_all(&message).unwrap(),
- celox::RuntimeEvent::AssertFatal { message } => {
+ celox::RuntimeEvent::Report(celox::Report {
+ severity: celox::Severity::Fatal,
+ message,
+ ..
+ }) => {
stdout.write_all(&message).unwrap();
stdout.write_all(b"\n").unwrap();
return Err(format!(
@@ -204,6 +202,12 @@ fn simulate(mut sim: celox::Simulation) -> Result<(), String> {
.unwrap_or_else(|_| message.escape_ascii().to_string())
));
}
+ celox::RuntimeEvent::Display { message }
+ | celox::RuntimeEvent::Report(celox::Report { message, .. }) => {
+ stdout.write_all(&message).unwrap();
+ stdout.write_all(b"\n").unwrap();
+ }
+ celox::RuntimeEvent::Write { message } => stdout.write_all(&message).unwrap(),
celox::RuntimeEvent::Finish | celox::RuntimeEvent::Stop => {}
celox::RuntimeEvent::Missed { count } => {
return Err(format!("{count} runtime events were lost"));
diff --git a/crates/celox/src/backend/native/image_file.rs b/crates/celox/src/backend/native/image_file.rs
index 0c95b249cc8..7278978181c 100644
--- a/crates/celox/src/backend/native/image_file.rs
+++ b/crates/celox/src/backend/native/image_file.rs
@@ -6,7 +6,7 @@ use std::{fmt, path::Path};
use super::backend::NativeProgramImage;
const TRAILER_MAGIC: &[u8; 8] = b"CELOXNPI";
-const CONTAINER_VERSION: u16 = 34;
+const CONTAINER_VERSION: u16 = 35;
const TRAILER_SIZE: usize = 32;
const FNV_OFFSET_BASIS: u64 = 0xcbf2_9ce4_8422_2325;
const FNV_PRIME: u64 = 0x0000_0100_0000_01b3;
diff --git a/crates/celox/src/backend/native/runtime_image.rs b/crates/celox/src/backend/native/runtime_image.rs
index ff7cbbfbb6e..bcd32cd682b 100644
--- a/crates/celox/src/backend/native/runtime_image.rs
+++ b/crates/celox/src/backend/native/runtime_image.rs
@@ -510,15 +510,15 @@ impl NativeProgramInstance {
context,
);
if let Some(message) = events.into_iter().find_map(|event| match event {
- RuntimeEvent::AssertFatal { message } => {
- Some(crate::simulator::message_diagnostic(&message))
+ RuntimeEvent::Report(report) if report.severity == celox_design::Severity::Fatal => {
+ Some(crate::simulator::message_diagnostic(&report.message))
}
RuntimeEvent::Missed { count } => Some(format!(
"missed {count} runtime events; a fatal assertion may have been overwritten"
)),
RuntimeEvent::Display { .. }
| RuntimeEvent::Write { .. }
- | RuntimeEvent::AssertContinue { .. }
+ | RuntimeEvent::Report(_)
| RuntimeEvent::Finish
| RuntimeEvent::Stop => None,
}) {
diff --git a/crates/celox/src/lib.rs b/crates/celox/src/lib.rs
index 28c216b193e..523993f74d6 100644
--- a/crates/celox/src/lib.rs
+++ b/crates/celox/src/lib.rs
@@ -48,7 +48,10 @@ pub use backend::SimulatorErrorCode as RuntimeErrorCode;
pub use backend::{
EventHandle, LayoutRequirements, MemoryLayout, MemoryLayoutMode, SimBackend, get_byte_size,
};
-pub use celox_design::{DomainKind, ElaboratedDesign, EventTopology, ProcessOrigin, RuntimeSchema};
+pub use celox_design::{
+ AssertionDeferral, AssertionDirective, AssertionOutcome, AssertionSite, DomainKind,
+ ElaboratedDesign, EventTopology, ProcessOrigin, ReportLocation, RuntimeSchema, Severity,
+};
pub use celox_frontend_core::FrontendArtifactError;
pub use celox_frontend_sdk as frontend_sdk;
pub use celox_frontend_sdk::FrontendArtifact;
@@ -117,7 +120,7 @@ mod host_api {
pub use crate::simulator::NativeCompilation;
pub use crate::simulator::{
Checkpoint, CheckpointError, DeadStorePolicy, DumpError, InstanceHierarchy, NamedEvent,
- NamedSignal, RuntimeEvent, RuntimeEventDrain, RuntimeFormatContext, Simulator,
+ NamedSignal, Report, RuntimeEvent, RuntimeEventDrain, RuntimeFormatContext, Simulator,
SimulatorBuilder, SimulatorOptions, StateError, StateImage, StateMismatch, StateSchema,
TierPromotion,
};
diff --git a/crates/celox/src/simulator.rs b/crates/celox/src/simulator.rs
index ffccc1394d2..ca48c93520c 100644
--- a/crates/celox/src/simulator.rs
+++ b/crates/celox/src/simulator.rs
@@ -61,6 +61,7 @@ mod host {
RuntimeEventKind, RuntimeEventSite, RuntimeProgram, SignalRef, VariableInfo,
},
};
+ use celox_design::{AssertionSite, ReportLocation, Severity};
use celox_runtime::backend::EventHandle as _;
use celox_testbench::{
DisplayFormatArg, FieldSpec, format_sv_display_arg, format_veryl_display_arg,
@@ -203,12 +204,9 @@ mod host {
Write {
message: Vec,
},
- AssertContinue {
- message: Vec,
- },
- AssertFatal {
- message: Vec,
- },
+ /// A message of a severity task or of a Veryl assertion. A
+ /// [`Severity::Fatal`] report also ends the simulation with an error.
+ Report(Report),
/// The design executed `$finish`. The host decides whether to stop.
Finish,
/// The design executed `$stop` outside a process kernel. The host
@@ -219,6 +217,65 @@ mod host {
},
}
+ /// What a severity task reports (IEEE 1800-2023 20.10).
+ #[derive(Debug, Clone, PartialEq, Eq)]
+ pub struct Report {
+ pub severity: Severity,
+ /// The formatted message, byte-exact like [`RuntimeEvent::Display`].
+ pub message: Vec,
+ /// The simulation time of the report, when the drain knows it.
+ pub time: Option,
+ /// The hierarchical name of the scope that issued the report.
+ pub scope: Option,
+ /// The file and line of the task call.
+ pub location: Option,
+ /// The assertion whose action block issued the report.
+ pub assertion: Option,
+ }
+
+ impl Report {
+ /// A report with no time, scope, location or assertion.
+ pub fn new(severity: Severity, message: Vec) -> Self {
+ Self {
+ severity,
+ message,
+ time: None,
+ scope: None,
+ location: None,
+ assertion: None,
+ }
+ }
+
+ /// The report as a tool prints it: the severity, the file and line,
+ /// the message, then the time and the scope (IEEE 1800-2023 20.10).
+ pub fn render(&self) -> Vec {
+ let mut out = format!("{:?}", self.severity).into_bytes();
+ if let Some(location) = &self.location {
+ out.extend_from_slice(format!(": {}:{}", location.file, location.line).as_bytes());
+ }
+ out.extend_from_slice(b": ");
+ out.extend_from_slice(&self.message);
+ let mut context = Vec::new();
+ if let Some(time) = self.time {
+ context.push(format!("Time: {time}"));
+ }
+ let name = match (
+ &self.scope,
+ self.assertion.as_ref().and_then(|a| a.label.as_ref()),
+ ) {
+ (Some(scope), Some(label)) => Some(format!("{scope}.{label}")),
+ (scope, label) => scope.clone().or_else(|| label.cloned()),
+ };
+ if let Some(name) = name {
+ context.push(format!("Scope: {name}"));
+ }
+ if !context.is_empty() {
+ out.extend_from_slice(format!("\n {}", context.join(" ")).as_bytes());
+ }
+ out
+ }
+ }
+
#[derive(Debug, Clone, Copy, Default)]
pub struct RuntimeFormatContext<'a> {
pub tb_time: Option,
@@ -490,7 +547,7 @@ mod host {
| RuntimeEventKind::Write
| RuntimeEventKind::Finish
| RuntimeEventKind::Stop => 'd',
- RuntimeEventKind::AssertContinue | RuntimeEventKind::AssertFatal => {
+ RuntimeEventKind::Report(_) => {
if args.is_empty() {
return b"assertion failed".to_vec();
}
@@ -604,8 +661,14 @@ mod host {
match site.kind {
RuntimeEventKind::Display => RuntimeEvent::Display { message },
RuntimeEventKind::Write => RuntimeEvent::Write { message },
- RuntimeEventKind::AssertContinue => RuntimeEvent::AssertContinue { message },
- RuntimeEventKind::AssertFatal => RuntimeEvent::AssertFatal { message },
+ RuntimeEventKind::Report(severity) => RuntimeEvent::Report(Report {
+ severity,
+ message,
+ time: ctx.tb_time,
+ scope: ctx.scope.map(str::to_owned).or_else(|| site.scope.clone()),
+ location: site.location.clone(),
+ assertion: site.assertion.clone(),
+ }),
RuntimeEventKind::Finish => RuntimeEvent::Finish,
RuntimeEventKind::Stop => RuntimeEvent::Stop,
}
@@ -1085,8 +1148,8 @@ mod host {
}
/// Drain runtime events, lazily evaluating dirty combinational logic.
- /// Fatal assertions encountered during evaluation are returned as
- /// [`RuntimeEvent::AssertFatal`] records so the host can handle them.
+ /// Fatal reports encountered during evaluation are returned as
+ /// [`RuntimeEvent::Report`] records so the host can handle them.
pub fn drain_runtime_events(&mut self) -> Vec {
self.drain_runtime_events_with_context(RuntimeFormatContext::default())
}
@@ -1148,7 +1211,7 @@ mod host {
.runtime_schema
.runtime_event_sites
.get(celox_runtime::comb_fatal_site(code)? as usize)?;
- matches!(site.kind, RuntimeEventKind::AssertFatal).then_some(site)
+ site.kind.is_fatal().then_some(site)
}
fn collect_formatted_runtime_events(
@@ -1622,7 +1685,7 @@ mod host {
.runtime_schema
.runtime_event_sites
.get(*site_id)?;
- if !matches!(site.kind, RuntimeEventKind::AssertFatal) {
+ if !site.kind.is_fatal() {
return None;
}
Some(RuntimeErrorCode::Runtime {
diff --git a/crates/celox/src/simulator/host/file_io.rs b/crates/celox/src/simulator/host/file_io.rs
index ef6689303c9..25d04c5ec96 100644
--- a/crates/celox/src/simulator/host/file_io.rs
+++ b/crates/celox/src/simulator/host/file_io.rs
@@ -101,6 +101,8 @@ impl Simulator {
template: site.strings.first().cloned(),
sizing: DisplaySizing::Ieee,
scope,
+ location: None,
+ assertion: None,
arg_widths: Vec::new(),
arg_signed: Vec::new(),
arg_is_string: Vec::new(),
diff --git a/crates/celox/src/testbench.rs b/crates/celox/src/testbench.rs
index 1f60c315077..b01452f8fc2 100644
--- a/crates/celox/src/testbench.rs
+++ b/crates/celox/src/testbench.rs
@@ -15,6 +15,7 @@ use crate::backend::memory_layout::{
use crate::backend::traits::{EventHandle, SimBackend};
use crate::ir::SignalRef;
use crate::simulator::{RuntimeEvent, RuntimeFormatContext, Simulator, message_diagnostic};
+use celox_design::Severity;
pub use celox_testbench::SourceLocation;
use celox_testbench::{
DisplayFormatArg, ExecutableArgument, ExecutableAssertMessage, ExecutableClockCount,
@@ -1499,17 +1500,14 @@ fn drain_runtime_assertions(
};
for event in sim.drain_runtime_events_deferred_with_context(format_ctx) {
match event {
- RuntimeEvent::AssertContinue { message } => {
- last_message = Some(message.clone());
- ctx.assertions.push(AssertionResult {
- passed: false,
- message: Some(message),
- location: location.cloned(),
- });
+ // Only errors fail a test (IEEE 1800-2023 20.10).
+ RuntimeEvent::Report(report) if report.severity < Severity::Error => {
+ forward_display(&report.message, true)
}
- RuntimeEvent::AssertFatal { message } => {
+ RuntimeEvent::Report(report) => {
+ let message = report.message;
last_message = Some(message.clone());
- if fatal_message.is_none() {
+ if report.severity == Severity::Fatal && fatal_message.is_none() {
fatal_message = Some(message.clone());
}
ctx.assertions.push(AssertionResult {
diff --git a/crates/celox/tests/comb_observer.rs b/crates/celox/tests/comb_observer.rs
index 80c84589d55..ae525ef7dbf 100644
--- a/crates/celox/tests/comb_observer.rs
+++ b/crates/celox/tests/comb_observer.rs
@@ -18,9 +18,9 @@ module Top(d: input logic<24>, out: output logic<24>) {
}
"#, "Top").four_state(true);
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, [0x80u8, 0, 0xff])).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Write { message: vec![255, 0, 128, 128] },
celox::RuntimeEvent::Display { message: vec![255, 0, 128] },
]);
@@ -49,12 +49,12 @@ module Top (
let d = sim.signal("d");
let tmp = sim.signal("tmp");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
assert_eq!(sim.get_as::(tmp), 1);
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"before=1 ret=12".to_vec(),
}],
@@ -88,15 +88,15 @@ module Top (
let d = sim.signal("d");
let prior = sim.signal("prior");
let tmp = sim.signal("tmp");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
assert_eq!(sim.get_as::(tmp), 1);
sim.modify(|io| io.set(prior, 7u8)).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"before=1 local=7 ret=12".to_vec(),
}],
@@ -126,11 +126,11 @@ module Top (
"#, "Top");
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"ret=12 out=11".to_vec(),
}],
@@ -169,11 +169,11 @@ module Top (
"#, "Top");
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"first=12 second=11".to_vec(),
}],
@@ -214,11 +214,11 @@ module Top (
"#, "Top");
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"first=1 second=12".to_vec(),
}],
@@ -254,11 +254,11 @@ module Top (
"#, "Top");
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"first=12 module=11".to_vec(),
}],
@@ -284,14 +284,14 @@ module Top (
"#, "Top").four_state(true);
let a = sim.signal("a");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set_four_state(a, celox::BigUint::from(1u8), celox::BigUint::from(1u8));
}).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"x=0".to_vec(),
}],
@@ -343,12 +343,12 @@ module Top (
let d = sim.signal("d");
let tmp_o = sim.signal("tmp_o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 1u8)).unwrap();
assert_eq!(sim.get(tmp_o), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"index=1".to_vec(),
}],
@@ -385,13 +385,13 @@ module Top (
let d = sim.signal("d");
let q = sim.signal("q");
let q_output = sim.signal("q_output");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(sim.get_as::(q), 1);
assert_eq!(sim.get_as::(q_output), 11);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"if=10".to_vec(),
}],
@@ -423,21 +423,21 @@ module Top (
let and_enable = sim.signal("and_enable");
let or_enable = sim.signal("or_enable");
let d = sim.signal("d");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(and_enable, 0u8);
io.set(or_enable, 1u8);
io.set(d, 10u8);
}).unwrap();
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| {
io.set(and_enable, 1u8);
io.set(or_enable, 0u8);
}).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"rhs=10".to_vec(),
@@ -478,7 +478,7 @@ module Top (
let d = sim.signal("d");
let q = sim.signal("q");
let q_output = sim.signal("q_output");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(d, 2u8);
@@ -486,7 +486,7 @@ module Top (
assert_eq!(sim.get_as::(q), 1);
assert_eq!(sim.get_as::(q_output), 12);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"target=2".to_vec(),
}],
@@ -521,13 +521,13 @@ module Top (
let sel = sim.signal("sel");
let data = sim.signal("data");
let tmp = sim.signal("tmp");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(sel, 2u8)).unwrap();
assert_eq!(sim.get_as::(data), 4);
assert_eq!(sim.get_as::(tmp), 12);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"index=2".to_vec(),
}],
@@ -559,12 +559,12 @@ module Top (
let d = sim.signal("d");
let tmp = sim.signal("tmp");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 10u8)).unwrap();
assert_eq!(sim.get_as::(tmp), 11);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"wrapped=10".to_vec(),
}],
@@ -590,12 +590,12 @@ module Top (
"#, "Top");
let sel = sim.signal("sel");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(sel, 1u8)).unwrap();
assert_eq!(sim.get_as::(sim.signal("value")), 11);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"case=11".to_vec(),
}],
@@ -632,13 +632,13 @@ module Top (
let d = sim.signal("d");
let q = sim.signal("q");
let q_output = sim.signal("q_output");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 1u8)).unwrap();
assert_eq!(sim.get_as::(q), 3);
assert_eq!(sim.get_as::(q_output), 2);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"bound=1".to_vec(),
}],
@@ -664,32 +664,32 @@ module Top (
let unrelated = sim.signal("unrelated");
let y = sim.signal("y");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"y=1".to_vec(),
}],
);
assert_eq!(sim.get_as::(y), 1);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(unrelated, 7u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 3u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"y=1".to_vec(),
}],
@@ -721,19 +721,19 @@ module Top (
let unrelated = sim.signal("unrelated");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(sim.get_as::(out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"tmp=5".to_vec(),
}],
);
sim.modify(|io| io.set(unrelated, 7u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
}
fn test_comb_constant_display_runs_on_initial_eval_only(sim) {
@@ -756,7 +756,7 @@ module Top (
// no sensitivity inputs.
sim.eval_comb().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"hi".to_vec(),
}],
@@ -764,7 +764,7 @@ module Top (
sim.modify(|io| io.set(a, 1u8)).unwrap();
sim.eval_comb().unwrap();
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
}
fn test_comb_constant_fatal_assert_runs_on_initial_eval(sim) {
@@ -789,10 +789,8 @@ module Top {
},
);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"constant fail".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"constant fail".to_vec()))],
);
}
@@ -879,7 +877,7 @@ module Top (
// list and the sensitized values have not changed from their defaults.
sim.eval_comb().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=0".to_vec(),
}],
@@ -907,10 +905,8 @@ module Top (
},
);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"a must be set".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"a must be set".to_vec()))],
);
}
@@ -930,11 +926,11 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 7u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=7".to_vec(),
}],
@@ -959,18 +955,18 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("runtime event drain handle");
sim.modify(|io| io.set(a, 11u8)).unwrap();
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![celox::RuntimeEvent::Display {
message: b"a=11".to_vec(),
}],
);
assert_eq!(sim.get_as::(out), 11);
- assert_eq!(drain.drain(), Vec::new());
+ assert_eq!(bare(drain.drain()), Vec::new());
}
fn test_comb_runtime_event_drain_handle_sees_direct_set_capture(sim) {
@@ -990,12 +986,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("runtime event drain handle");
sim.set(a, 12u8);
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![celox::RuntimeEvent::Display {
message: b"a=12".to_vec(),
}],
@@ -1022,17 +1018,17 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=0".to_vec(),
}],
);
let mut drain = sim.runtime_event_drain().expect("runtime event drain handle");
- assert_eq!(drain.drain(), Vec::new());
+ assert_eq!(bare(drain.drain()), Vec::new());
sim.modify(|io| io.set(a, 13u8)).unwrap();
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![celox::RuntimeEvent::Display {
message: b"a=13".to_vec(),
}],
@@ -1068,14 +1064,14 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("runtime event drain handle");
sim.modify(|io| io.set(d, 3u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get_as::(out), 3);
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![
celox::RuntimeEvent::Display {
message: b"ff=3".to_vec(),
@@ -1114,7 +1110,7 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("runtime event drain handle");
sim.modify(|io| io.set(a, 9u8)).unwrap();
@@ -1122,7 +1118,7 @@ module Top (
sim.tick(clk).unwrap();
assert_eq!(sim.get_as::(out), 9);
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![
celox::RuntimeEvent::Display {
message: b"comb=9".to_vec(),
@@ -1151,37 +1147,39 @@ module Top (
let a = sim.signal("a");
let y = sim.signal("y");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 0u8)).unwrap();
assert_eq!(sim.get_as::(y), 0);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"bad y=1".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Error,
+ b"bad y=1".to_vec()
+ ))],
);
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 3u8)).unwrap();
assert_eq!(sim.get_as::(y), 1);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"bad y=1".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Error,
+ b"bad y=1".to_vec()
+ ))],
);
sim.modify(|io| io.set(a, 2u8)).unwrap();
assert_eq!(sim.get_as::(y), 0);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_assert_fatal_stops_comb_eval_and_keeps_event(sim) {
@@ -1201,7 +1199,7 @@ module Top (
let a = sim.signal("a");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
let err = sim.eval_comb().unwrap_err();
@@ -1213,10 +1211,8 @@ module Top (
},
);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"fatal y".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"fatal y".to_vec()))],
);
}
@@ -1243,15 +1239,15 @@ module Top (
let a = sim.signal("a");
let unrelated = sim.signal("unrelated");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert!(sim.eval_comb().is_err());
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(unrelated, 9u8)).unwrap();
sim.eval_comb().unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_pending_events_drain_before_later_ff_events(sim) {
@@ -1280,14 +1276,14 @@ module Top (
let y = sim.signal("y");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(sim.get_as::(y), 5);
sim.modify(|io| io.set(d, 7u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"comb=5".to_vec(),
@@ -1334,20 +1330,20 @@ module Top (
let y = sim.signal("y");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 7u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get_as::(y), 7);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"q=7".to_vec(),
}],
);
sim.tick(clk).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_tracks_downstream_comb_settle_sensitivity(sim) {
@@ -1373,12 +1369,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 9u8)).unwrap();
assert_eq!(sim.get_as::(out), 9);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"x=9".to_vec(),
}],
@@ -1416,7 +1412,7 @@ module Top (
let out_a = sim.signal("out_a");
let out_b = sim.signal("out_b");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(src, 5u8)).unwrap();
assert_eq!(sim.get_as::(out_a), 5);
@@ -1427,7 +1423,7 @@ module Top (
// to coalesce multiple sensitivity changes into one pending process
// execution and emit the side effect once at the settled observation point.
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=5 b=5".to_vec(),
}],
@@ -1460,12 +1456,12 @@ module Top (
let a = sim.signal("a");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"x1=0".to_vec(),
@@ -1500,12 +1496,12 @@ module Top (
let a = sim.signal("a");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"observed=0".to_vec(),
@@ -1542,12 +1538,12 @@ module Top (
let a = sim.signal("a");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"x3=0".to_vec(),
@@ -1583,12 +1579,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 3);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"x1=0 x2=0".to_vec(),
@@ -1632,7 +1628,7 @@ module Top (
let j = sim.signal("j");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(i, 0u8);
@@ -1642,7 +1638,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"xj=0".to_vec(),
@@ -1682,12 +1678,12 @@ module Top (
let a = sim.signal("a");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"hit x1=1".to_vec(),
}],
@@ -1716,7 +1712,7 @@ module Top (
let a = sim.signal("a");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
let err = sim.eval_comb().unwrap_err();
@@ -1728,10 +1724,8 @@ module Top (
},
);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"x1 became 1".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"x1 became 1".to_vec()))],
);
}
@@ -1763,7 +1757,7 @@ module Top (
let b = sim.signal("b");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 1u8);
@@ -1772,7 +1766,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 3);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=0".to_vec(),
@@ -1819,7 +1813,7 @@ module Top (
let count = sim.signal("count");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 2u8);
@@ -1828,7 +1822,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0 x1=0".to_vec(),
@@ -1882,12 +1876,12 @@ module Top (
let a = sim.signal("a");
let o = sim.signal("o");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(o), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"x1=0".to_vec(),
@@ -1926,13 +1920,13 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 3u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get_as::(out), 3);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"ff=3".to_vec(),
@@ -1965,15 +1959,15 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
assert_eq!(
- sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
+ bare(sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
tb_time: Some(42),
scope: Some("tb.top"),
- }),
+ })),
vec![celox::RuntimeEvent::Display {
message: b"loc=tb.top time=42 a=5".to_vec(),
}],
@@ -1996,15 +1990,15 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
assert_eq!(
- sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
+ bare(sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
tb_time: Some(42),
scope: Some("tb.top"),
- }),
+ })),
vec![celox::RuntimeEvent::Display {
message: b"loc=tb.top a=5".to_vec(),
}],
@@ -2039,13 +2033,13 @@ module Top (
let z = sim.signal("z");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 3u8)).unwrap();
assert_eq!(sim.get_as::(y), 3);
assert_eq!(sim.get_as::(z), 0);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"active=3".to_vec(),
}],
@@ -2054,7 +2048,7 @@ module Top (
sim.modify(|io| io.set(a, 4u8)).unwrap();
assert_eq!(sim.get_as::(y), 4);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"active=4".to_vec(),
}],
@@ -2063,14 +2057,12 @@ module Top (
sim.modify(|io| io.set(b, 7u8)).unwrap();
assert_eq!(sim.get_as::(z), 7);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inactive_display=7".to_vec(),
},
- celox::RuntimeEvent::AssertContinue {
- message: b"inactive_assert=7".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"inactive_assert=7".to_vec())),
],
);
}
@@ -2106,13 +2098,13 @@ module Top (
let inactive_out = sim.signal("inactive_out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(sim.get_as::(out), 7);
assert_eq!(sim.get_as::(inactive_out), 0);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=6".to_vec(),
@@ -2126,7 +2118,7 @@ module Top (
sim.modify(|io| io.set(a, 6u8)).unwrap();
assert_eq!(sim.get_as::(out), 8);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=7".to_vec(),
@@ -2163,7 +2155,7 @@ module Top (
let base = sim.signal("base");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 3u8);
@@ -2172,7 +2164,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 16);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"before i=0 sum=10".to_vec(),
@@ -2216,7 +2208,7 @@ module Top (
let b = sim.signal("b");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(sel, 1u8);
@@ -2226,7 +2218,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 21);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"then=20".to_vec(),
}],
@@ -2235,7 +2227,7 @@ module Top (
sim.modify(|io| io.set(sel, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 41);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"else=40".to_vec(),
}],
@@ -2259,7 +2251,7 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set_four_state(
@@ -2271,7 +2263,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_four_state(out).0, num_bigint::BigUint::from(0x1234_5678_9abc_def0u64));
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=000000000000000000010010001101000101011001111000100110101011110011011110xxxx0000"
.to_vec(),
@@ -2303,12 +2295,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 9u8)).unwrap();
assert_eq!(sim.get_as::(out), 10);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"bump=10".to_vec(),
}],
@@ -2361,19 +2353,19 @@ module Top (
let stop = sim.signal("stop");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 5u8);
io.set(stop, 1u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 5);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(stop, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"notify=5".to_vec(),
}],
@@ -2426,7 +2418,7 @@ module Top (
let count = sim.signal("count");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 7u8);
@@ -2435,7 +2427,7 @@ module Top (
}).unwrap();
assert_eq!(sim.get_as::(out), 8);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"notify=7".to_vec(),
}],
@@ -2444,7 +2436,7 @@ module Top (
sim.modify(|io| io.set(stop, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 7);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"notify=7".to_vec(),
@@ -2503,7 +2495,7 @@ module Top (
let count = sim.signal("count");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 7u8);
@@ -2512,7 +2504,7 @@ module Top (
io.set(count, 3u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 7);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_function_loop_with_return_and_break_preserves_effects(sim) {
@@ -2549,7 +2541,7 @@ module Top (
let stop = sim.signal("stop");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 9u8);
@@ -2557,7 +2549,7 @@ module Top (
}).unwrap();
assert_eq!(sim.get_as::(out), 9);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"loop=0".to_vec(),
@@ -2606,7 +2598,7 @@ module Top (
let stop = sim.signal("stop");
let return_early = sim.signal("return_early");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(value, 9u8);
@@ -2614,7 +2606,7 @@ module Top (
}).unwrap();
assert_eq!(sim.get_as::(out), 9);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"after-loop".to_vec(),
}],
@@ -2622,7 +2614,7 @@ module Top (
sim.modify(|io| io.set(return_early, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 10);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_function_packed_array_literal_preserves_source_order(sim) {
@@ -2701,7 +2693,7 @@ module Top (
let q = sim.signal("q");
assert_eq!(sim.get_as::(q), 0xf8);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_named_function_inputs_evaluate_in_source_order(sim) {
@@ -2752,7 +2744,7 @@ module Top (
let inner_count = sim.signal("inner_count");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 11u8);
@@ -2762,7 +2754,7 @@ module Top (
}).unwrap();
assert_eq!(sim.get_as::(out), 11);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inner=0,0".to_vec(),
@@ -2788,7 +2780,7 @@ module Top (
sim.modify(|io| io.set(stop, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 13);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inner=0,0".to_vec(),
@@ -2832,12 +2824,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 6u8)).unwrap();
assert_eq!(sim.get_as::(out), 13);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"arg=6".to_vec(),
}],
@@ -2870,27 +2862,25 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(unrelated, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 0);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 0);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 1);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 0);
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"zero=0".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"zero=0".to_vec()))],
);
}
@@ -2914,12 +2904,12 @@ module Top (
let a = sim.signal("a");
let sum = sim.signal("sum");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 2u8)).unwrap();
assert_eq!(sim.get_as::(sum), 9);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0 sum=2".to_vec(),
@@ -2953,12 +2943,12 @@ module Top (
let a = sim.signal("a");
let seen = sim.signal("seen");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 1u8)).unwrap();
assert_eq!(sim.get_as::(seen), 2);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=1".to_vec(),
@@ -2995,7 +2985,7 @@ module Top (
let b = sim.signal("b");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 1u8);
@@ -3004,7 +2994,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"before=0".to_vec(),
}],
@@ -3012,12 +3002,12 @@ module Top (
sim.modify(|io| io.set(b, 4u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(a, 2u8)).unwrap();
assert_eq!(sim.get_as::(out), 6);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"before=1".to_vec(),
}],
@@ -3050,7 +3040,7 @@ module Top (
let hi = sim.signal("hi");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(idx, 2u8);
@@ -3060,7 +3050,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0xA4);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=4".to_vec(),
}],
@@ -3069,7 +3059,7 @@ module Top (
sim.modify(|io| io.set(hi, 0xBu8)).unwrap();
assert_eq!(sim.get_as::(out), 0xB4);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=4".to_vec(),
}],
@@ -3105,7 +3095,7 @@ module Top (
let tail = sim.signal("tail");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(idx, 2u8);
@@ -3115,7 +3105,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0xAA);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=85".to_vec(),
}],
@@ -3124,7 +3114,7 @@ module Top (
sim.modify(|io| io.set(tail, 0xBBu8)).unwrap();
assert_eq!(sim.get_as::(out), 0xBB);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=85".to_vec(),
}],
@@ -3163,7 +3153,7 @@ module Top (
let y = sim.signal("y");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(base, 0u8);
@@ -3176,7 +3166,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=1".to_vec(),
}],
@@ -3185,7 +3175,7 @@ module Top (
sim.modify(|io| io.set(y, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=1".to_vec(),
}],
@@ -3198,7 +3188,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=0".to_vec(),
}],
@@ -3229,12 +3219,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 3u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=3".to_vec(),
@@ -3281,7 +3271,7 @@ module Top (
let c = sim.signal("c");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(en, 1u8);
@@ -3292,7 +3282,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 19);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"then=7".to_vec(),
}],
@@ -3301,7 +3291,7 @@ module Top (
sim.modify(|io| io.set(en, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 19);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"else=11".to_vec(),
}],
@@ -3331,12 +3321,12 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 2u8)).unwrap();
assert_eq!(sim.get_as::(out), 9);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0 tmp=2".to_vec(),
@@ -3381,7 +3371,7 @@ module Top (
let tail = sim.signal("tail");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 10u8);
@@ -3390,7 +3380,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 99);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"after_f=13".to_vec(),
}],
@@ -3431,7 +3421,7 @@ module Top (
let tail = sim.signal("tail");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(a, 10u8);
@@ -3439,7 +3429,7 @@ module Top (
})
.unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"after_split=11,12".to_vec(),
}],
@@ -3471,7 +3461,7 @@ module Top (
let hi = sim.signal("hi");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(lo, 0x5u8);
@@ -3480,7 +3470,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0xA5);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"mid=133".to_vec(),
}],
@@ -3512,7 +3502,7 @@ module Top (
let base = sim.signal("base");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 4u8);
@@ -3521,7 +3511,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 16);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"sum=16".to_vec(),
}],
@@ -3553,7 +3543,7 @@ module Top (
let base = sim.signal("base");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 4u8);
@@ -3562,7 +3552,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 16);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0 sum=10".to_vec(),
@@ -3611,7 +3601,7 @@ module Top (
let out = sim.signal("out");
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"first=0".to_vec(),
}],
@@ -3624,7 +3614,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 13);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0 sum=10".to_vec(),
@@ -3658,12 +3648,12 @@ module Top (
let count = sim.signal("count");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(count, 2u8)).unwrap();
assert_eq!(sim.get_as::(out), 2);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"same".to_vec(),
@@ -3706,7 +3696,7 @@ module Top (
let out_a = sim.signal("out_a");
let out_b = sim.signal("out_b");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 2u8);
@@ -3716,7 +3706,7 @@ module Top (
assert_eq!(sim.get_as::(out_a), 6);
assert_eq!(sim.get_as::(out_b), 16);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"i=0".to_vec(),
@@ -3755,7 +3745,7 @@ module Top (
let base = sim.signal("base");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(count, 3u8);
@@ -3764,7 +3754,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 13);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"before=10".to_vec(),
@@ -3810,25 +3800,25 @@ module Top (
let unrelated = sim.signal("unrelated");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let value: num_bigint::BigUint = (num_bigint::BigUint::from(0x12u8) << 64)
| num_bigint::BigUint::from(0x34u8);
sim.modify(|io| io.set_wide(a, value.clone())).unwrap();
assert_eq!(sim.get_as::(out), 0x34);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"lo=52 hi=18".to_vec(),
}],
);
sim.modify(|io| io.set_wide(a, value)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(unrelated, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 0x34);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_downstream_dynamic_write_crossing_word_boundary(sim) {
@@ -3857,7 +3847,7 @@ module Top (
let val = sim.signal("val");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(idx, 60u8);
@@ -3866,14 +3856,14 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0xAB);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"slice=171".to_vec(),
}],
);
sim.modify(|io| io.set(val, 0xABu8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_store_coalesce_does_not_enable_unrelated_chunk(sim) {
@@ -3902,7 +3892,7 @@ module Top (
let hi = sim.signal("hi");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(lo, 5u8);
@@ -3911,7 +3901,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 5);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"lo=5".to_vec(),
}],
@@ -3919,7 +3909,7 @@ module Top (
sim.modify(|io| io.set(hi, 2u8)).unwrap();
assert_eq!(sim.get_as::(out), 5);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_ff_to_downstream_comb_store_enables_observer(sim) {
@@ -3953,20 +3943,20 @@ module Top (
let out = sim.signal("out");
sim.eval_comb().unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(d, 11u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get_as::(out), 11);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"x=11".to_vec(),
}],
);
sim.tick(clk).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_port_alias_write_enables_downstream_observer(sim) {
@@ -4002,19 +3992,19 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 21u8)).unwrap();
assert_eq!(sim.get_as::(out), 21);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"internal=21".to_vec(),
}],
);
sim.modify(|io| io.set(a, 21u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_display_four_state_mask_only_input_change_triggers(sim) {
@@ -4034,7 +4024,7 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set_four_state(
@@ -4046,7 +4036,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_four_state(out).0, num_bigint::BigUint::from(0xA0u8));
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=10100000".to_vec(),
}],
@@ -4065,7 +4055,7 @@ module Top (
num_bigint::BigUint::from(0x0Fu8)
);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=1010zzzz".to_vec(),
}],
@@ -4096,13 +4086,13 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set_wide(a, num_bigint::BigUint::from(0x5Au8)))
.unwrap();
assert_eq!(sim.get_as::(out), 0x5A);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"slice=90".to_vec(),
}],
@@ -4132,7 +4122,7 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set_four_state(
@@ -4144,7 +4134,7 @@ module Top (
.unwrap();
assert_eq!(sim.get_as::(out), 0x10);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"lo=00010000".to_vec(),
}],
@@ -4163,7 +4153,7 @@ module Top (
num_bigint::BigUint::from(0x0Fu8)
);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"lo=0001zzzz".to_vec(),
}],
@@ -4203,12 +4193,12 @@ module Top (
let b = sim.signal("b");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(b, 0x33u8)).unwrap();
assert_eq!(sim.get_as::(out), 0x33);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"v=51".to_vec(),
}],
@@ -4241,7 +4231,7 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(sel, 1u8);
@@ -4249,12 +4239,12 @@ module Top (
})
.unwrap();
assert_eq!(sim.get_as::(out), 9);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(sel, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 0);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"tmp=0".to_vec(),
}],
@@ -4287,19 +4277,19 @@ module Top (
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 7u8)).unwrap();
assert_eq!(sim.get_as::(out), 7);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"y=7".to_vec(),
}],
);
sim.modify(|io| io.set(a, 7u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
}
fn test_comb_expression_operands_observe_prior_output_write(sim) {
@@ -4324,10 +4314,10 @@ module Top (a: input logic<8>, out: output logic<8>) {
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 12u8)).unwrap();
assert_eq!(sim.get_as::(out), 13);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"observed=12".to_vec(),
}]);
}
@@ -4354,19 +4344,19 @@ module Top (sel: input logic, a: input logic<8>, b: input logic<8>, out: output
let a = sim.signal("a");
let b = sim.signal("b");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(sel, 1u8);
io.set(a, 7u8);
io.set(b, 9u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 7);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"left=7".to_vec(),
}]);
sim.modify(|io| io.set(sel, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 9);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"right=9".to_vec(),
}]);
}
@@ -4390,10 +4380,10 @@ module Top (a: input logic<8>, out: output logic<8>) {
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 23u8)).unwrap();
assert_eq!(sim.get_as::(out), 23);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"inner=23".to_vec(),
}]);
}
@@ -4430,13 +4420,13 @@ module Top (index: input logic<2>, value: input logic<8>, out: output logic<8>)
let index = sim.signal("index");
let value = sim.signal("value");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(index, 2u8);
io.set(value, 55u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 42);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"index=2".to_vec(),
}]);
}
@@ -4466,18 +4456,18 @@ module Top (sel: input logic, a: input logic<8>, out: output logic<8>) {
let sel = sim.signal("sel");
let a = sim.signal("a");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(sel, 0u8);
io.set(a, 17u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 1);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"after=1".to_vec(),
}]);
sim.modify(|io| io.set(sel, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 17);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"after=17".to_vec(),
}]);
}
@@ -4531,13 +4521,13 @@ module Top (
let value = sim.signal("value");
let first_out = sim.signal("first_out");
let slots_out = sim.signal("slots_out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(value, 10u8)).unwrap();
assert_eq!(sim.get_as::(first_out), 12);
assert_eq!(sim.get_as::(slots_out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"preview=12".to_vec(),
}],
@@ -4584,13 +4574,13 @@ module Top (
let value = sim.signal("value");
let first_out = sim.signal("first_out");
let slots_out = sim.signal("slots_out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(value, 10u8)).unwrap();
assert_eq!(sim.get_as::(first_out), 12);
assert_eq!(sim.get_as::(slots_out), 1);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"preview=12".to_vec(),
}],
@@ -4625,9 +4615,9 @@ module Top (value: input logic<8>, out: output logic<8>) {
let value = sim.signal("value");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(value, 31u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"bound=31".to_vec() },
celox::RuntimeEvent::Display { message: b"body=31".to_vec() },
]);
@@ -4659,10 +4649,10 @@ module Top (value: input logic, out: output logic) {
let value = sim.signal("value");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(value, 1u8)).unwrap();
assert_eq!(sim.get_as::(out), 1);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"index_seen=1".to_vec(),
}]);
}
@@ -4700,17 +4690,17 @@ module Top (
let skip = sim.signal("skip");
let value = sim.signal("value");
let out = sim.signal("out");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| {
io.set(skip, 1u8);
io.set(value, 45u8);
}).unwrap();
assert_eq!(sim.get_as::(out), 0);
- assert_eq!(sim.drain_runtime_events(), vec![]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![]);
sim.modify(|io| io.set(skip, 0u8)).unwrap();
assert_eq!(sim.get_as::(out), 45);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"active_bound=45".to_vec(),
}]);
}
@@ -4741,7 +4731,7 @@ module Top (trigger: input logic, out: output logic<2>) {
let out = sim.signal("out");
assert_eq!(sim.get_as::(out), 2);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"concat_seen=1".to_vec(),
}]);
}
@@ -4775,7 +4765,7 @@ module Top (trigger: input logic, out: output logic<2>) {
let out = sim.signal("out");
assert_eq!(sim.get_as::(out), 2);
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"function_concat_seen=1".to_vec(),
}]);
}
@@ -5515,3 +5505,17 @@ module Top (
"{error}"
);
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/flip_flop.rs b/crates/celox/tests/flip_flop.rs
index 573ade5e492..f845393ee10 100644
--- a/crates/celox/tests/flip_flop.rs
+++ b/crates/celox/tests/flip_flop.rs
@@ -48,16 +48,14 @@ fn test_ff_runtime_display_and_assert_continue(sim) {
sim.modify(|io| io.set(a, 3u8)).unwrap();
sim.tick(clk).unwrap();
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert_eq!(
events,
vec![
celox::RuntimeEvent::Display {
message: b"a=3".to_vec(),
},
- celox::RuntimeEvent::AssertContinue {
- message: b"bad a=3".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"bad a=3".to_vec())),
],
);
}
@@ -94,7 +92,7 @@ fn test_ff_assert_message_runtime_effect_is_eager(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"inside=10".to_vec(),
}],
@@ -107,14 +105,12 @@ fn test_ff_assert_message_runtime_effect_is_eager(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inside=20".to_vec(),
},
- celox::RuntimeEvent::AssertContinue {
- message: b"value=22".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"value=22".to_vec())),
],
);
}
@@ -171,7 +167,7 @@ fn test_ff_unknown_ternary_retains_then_arm_output_state(sim) {
assert_eq!(sim.get(effect), 11u8.into());
assert_eq!(sim.get(q), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"written=11".to_vec(),
}],
@@ -199,7 +195,7 @@ fn test_ff_ternary_runtime_effect_only_evaluates_selected_arm(sim) {
sim.modify(|io| io.set(choose, 1u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"arm=1".to_vec(),
}],
@@ -208,7 +204,7 @@ fn test_ff_ternary_runtime_effect_only_evaluates_selected_arm(sim) {
sim.modify(|io| io.set(choose, 0u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"arm=2".to_vec(),
}],
@@ -243,7 +239,7 @@ fn test_ff_effectful_function_input_is_evaluated_once(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inner=7".to_vec(),
@@ -281,10 +277,8 @@ fn test_ff_assert_message_args_preserve_left_to_right_snapshots(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(effect), 6u8.into());
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"5 6".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"5 6".to_vec()))],
);
}
@@ -317,7 +311,7 @@ fn test_ff_runtime_effect_function_snapshots_input_that_aliases_output(sim) {
assert_eq!(sim.get(effect), 6u8.into());
assert_eq!(sim.get(q), 5u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"x=5".to_vec(),
}],
@@ -357,7 +351,7 @@ fn test_ff_case_pattern_runtime_effect_is_eager(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"pattern=1".to_vec(),
}],
@@ -396,7 +390,7 @@ fn test_ff_statement_function_materializes_effectful_case_controls(sim) {
sim.modify(|io| io.set(d, 1u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"case 1=1".to_vec(),
@@ -460,7 +454,7 @@ fn test_ff_case_controls_apply_nested_output_writes_to_function_state(sim) {
sim.modify(|io| io.set(d, 10u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"state=10 11".to_vec(),
}],
@@ -501,7 +495,7 @@ fn test_ff_case_skips_effectful_patterns_after_matching_arm(sim) {
sim.modify(|io| io.set(d, 1u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"pattern 1=1".to_vec(),
}],
@@ -536,7 +530,7 @@ fn test_ff_assignment_snapshots_dynamic_rhs_access(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"captured=1".to_vec(),
}],
@@ -571,7 +565,7 @@ fn test_ff_assignment_substitutes_through_evaluating_system_function(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 5u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"captured=5".to_vec(),
}],
@@ -609,7 +603,7 @@ fn test_ff_if_snapshots_dynamic_predicate_before_state_merge(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"result=1".to_vec(),
}],
@@ -648,7 +642,7 @@ fn test_ff_case_snapshots_dynamic_target_before_state_merge(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"result=1".to_vec(),
}],
@@ -710,7 +704,7 @@ fn test_ff_case_merges_nested_output_state_from_selected_arm(sim) {
assert_eq!(sim.get(effect), 11u8.into());
assert_eq!(sim.get(q), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"written=11".to_vec(),
}],
@@ -725,7 +719,7 @@ fn test_ff_case_merges_nested_output_state_from_selected_arm(sim) {
assert_eq!(sim.get(effect), 20u8.into());
assert_eq!(sim.get(q), 20u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"written=20".to_vec(),
}],
@@ -781,7 +775,7 @@ fn test_ff_variable_select_captures_nested_output(sim) {
assert_eq!(sim.get(effect), 3u8.into());
assert_eq!(sim.get(q), 3u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"bit=1".to_vec(),
}],
@@ -832,7 +826,7 @@ fn test_ff_effectful_assignment_executes_only_on_selected_if_path(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 6u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| {
io.set(enable, 1u8);
@@ -842,7 +836,7 @@ fn test_ff_effectful_assignment_executes_only_on_selected_if_path(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 8u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"assigned=6".to_vec(),
}],
@@ -887,7 +881,7 @@ fn test_ff_runtime_effect_after_conditional_return_uses_live_path(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 8u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| {
io.set(skip, 0u8);
@@ -897,7 +891,7 @@ fn test_ff_runtime_effect_after_conditional_return_uses_live_path(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 10u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"live=8".to_vec(),
}],
@@ -949,7 +943,7 @@ fn test_ff_case_after_conditional_return_preserves_returned_path(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 11u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| {
io.set(skip, 1u8);
@@ -959,7 +953,7 @@ fn test_ff_case_after_conditional_return_preserves_returned_path(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 21u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| {
io.set(skip, 0u8);
@@ -970,7 +964,7 @@ fn test_ff_case_after_conditional_return_preserves_returned_path(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 32u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"case=0".to_vec(),
}],
@@ -985,7 +979,7 @@ fn test_ff_case_after_conditional_return_preserves_returned_path(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 43u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"case=1".to_vec(),
}],
@@ -1020,7 +1014,7 @@ fn test_ff_statement_call_evaluates_effectful_inputs(sim) {
sim.modify(|io| io.set(d, 9u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"input=9".to_vec(),
}],
@@ -1050,7 +1044,7 @@ fn test_ff_top_level_statement_call_evaluates_discarded_effectful_input(sim) {
sim.modify(|io| io.set(d, 13u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"direct=13".to_vec(),
}],
@@ -1099,7 +1093,7 @@ fn test_ff_nested_runtime_event_output_updates_outer_function_state(sim) {
assert_eq!(sim.get(effect), 8u8.into());
assert_eq!(sim.get(q), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"value=9".to_vec(),
}],
@@ -1147,7 +1141,7 @@ fn test_ff_nested_output_to_module_variable_survives_runtime_function(sim) {
assert_eq!(sim.get(global_value), 8u8.into());
assert_eq!(sim.get(q), 0u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"outer".to_vec(),
}],
@@ -1196,7 +1190,7 @@ fn test_ff_runtime_function_snapshots_nonlocal_read_before_later_write(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"captured=0".to_vec(),
}],
@@ -1255,7 +1249,7 @@ fn test_ff_outputless_nested_nonlocal_write_updates_later_event_argument(sim) {
assert_eq!(sim.get(global_value), 9u8.into());
assert_eq!(sim.get(q), 0u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"values=1,9".to_vec(),
}],
@@ -1347,7 +1341,7 @@ fn test_ff_pure_helper_nonlocal_read_is_snapshotted_before_runtime_write(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 0x5au8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"captured=0".to_vec(),
}],
@@ -1401,7 +1395,7 @@ fn test_ff_guarded_system_task_merges_definition_state(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"update=0".to_vec(),
@@ -1416,7 +1410,7 @@ fn test_ff_guarded_system_task_merges_definition_state(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"global=2".to_vec(),
}],
@@ -1461,7 +1455,7 @@ fn test_ff_statement_helper_dynamic_nonlocal_copyout_is_observable(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 4u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"set".to_vec(),
}],
@@ -1501,7 +1495,7 @@ fn test_ff_nested_dynamic_nonlocal_store_flushes_pending_outer_state(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 4u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"result=0 global=4".to_vec(),
}],
@@ -1541,7 +1535,7 @@ fn test_ff_retained_dynamic_copyout_does_not_repeat_nonlocal_body_write(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 5u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"result=1 global=1".to_vec(),
}],
@@ -1596,7 +1590,7 @@ fn test_ff_guarded_runtime_expression_merges_definition_state(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"global=0".to_vec(),
}],
@@ -1606,7 +1600,7 @@ fn test_ff_guarded_runtime_expression_merges_definition_state(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(global_value), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"global=2".to_vec(),
}],
@@ -1674,7 +1668,7 @@ fn test_ff_short_circuit_nested_output_updates_only_when_rhs_runs(sim) {
assert_eq!(sim.get(and_effect), 10u8.into());
assert_eq!(sim.get(or_effect), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"and=0".to_vec(),
@@ -1694,7 +1688,7 @@ fn test_ff_short_circuit_nested_output_updates_only_when_rhs_runs(sim) {
assert_eq!(sim.get(and_effect), 21u8.into());
assert_eq!(sim.get(or_effect), 20u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"and=1".to_vec(),
@@ -1714,7 +1708,7 @@ fn test_ff_short_circuit_nested_output_updates_only_when_rhs_runs(sim) {
assert_eq!(sim.get(and_effect), 31u8.into());
assert_eq!(sim.get(or_effect), 31u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"and=x".to_vec(),
@@ -1776,7 +1770,7 @@ fn test_ff_pure_predicate_output_updates_outer_function_state(sim) {
assert_eq!(sim.get(effect), 13u8.into());
assert_eq!(sim.get(q), 13u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"predicate=13".to_vec(),
}],
@@ -1834,7 +1828,7 @@ fn test_ff_nested_wrapper_predicate_output_updates_caller_state(sim) {
assert_eq!(sim.get(effect), 13u8.into());
assert_eq!(sim.get(q), 13u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"wrapper=13".to_vec(),
}],
@@ -1894,7 +1888,7 @@ fn test_ff_nested_call_predicate_uses_pre_copyout_input(sim) {
assert_eq!(sim.get(effect), 42u8.into());
assert_eq!(sim.get(q), 42u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"wrapper=42".to_vec(),
}],
@@ -1948,7 +1942,7 @@ fn test_ff_bits_and_size_do_not_evaluate_output_writing_operand(sim) {
assert_eq!(sim.get(effect), 14u8.into());
assert_eq!(sim.get(q), 14u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"bits=8 size=8".to_vec(),
}],
@@ -2014,7 +2008,7 @@ fn test_ff_statement_call_materializes_output_only_input_effect(sim) {
assert_eq!(sim.get(effect), 17u8.into());
assert_eq!(sim.get(q), 17u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"statement=17".to_vec(),
}],
@@ -2058,7 +2052,7 @@ fn test_ff_nested_statement_call_copies_outputs_in_declaration_order(sim) {
assert_eq!(sim.get(effect), 2u8.into());
assert_eq!(sim.get(q), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"written=2".to_vec(),
}],
@@ -2098,7 +2092,7 @@ fn test_ff_nested_statement_call_coerces_output_to_actual_width(sim) {
assert_eq!(sim.get(effect), 1u8.into());
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"written=1".to_vec(),
}],
@@ -2158,7 +2152,7 @@ fn test_ff_state_only_statement_call_materializes_nested_input_output(sim) {
assert_eq!(sim.get(effect), 17u8.into());
assert_eq!(sim.get(q), 17u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"wrapped=17".to_vec(),
}],
@@ -2206,7 +2200,7 @@ fn test_ff_statement_call_copies_outputs_in_declaration_order(sim) {
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"index=0".to_vec(),
@@ -2261,7 +2255,7 @@ fn test_ff_composite_runtime_arg_preserves_left_to_right_snapshot(sim) {
assert_eq!(sim.get(effect), 11u8.into());
assert_eq!(sim.get(q), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"sum=22".to_vec(),
}],
@@ -2329,7 +2323,7 @@ fn test_ff_nested_call_inputs_capture_outputs_in_declaration_order(sim) {
assert_eq!(sim.get(effect), 12u8.into());
assert_eq!(sim.get(q), 12u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"ordered=22".to_vec(),
}],
@@ -2378,7 +2372,7 @@ fn test_ff_nested_call_freezes_all_outputs_before_copy_out(sim) {
assert_eq!(sim.get(first), 9u8.into());
assert_eq!(sim.get(second), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"sum=16".to_vec(),
}],
@@ -2432,7 +2426,7 @@ fn test_ff_nested_call_output_preserves_conditional_early_return_path(sim) {
assert_eq!(sim.get(effect), 1u8.into());
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inner=11".to_vec(),
@@ -2448,7 +2442,7 @@ fn test_ff_nested_call_output_preserves_conditional_early_return_path(sim) {
assert_eq!(sim.get(effect), 2u8.into());
assert_eq!(sim.get(q), 2u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inner=22".to_vec(),
@@ -2521,7 +2515,7 @@ fn test_ff_short_circuit_state_reuses_evaluated_lhs(sim) {
assert_eq!(sim.get(effect), 21u8.into());
assert_eq!(sim.get(q), 21u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"lhs=20".to_vec(),
@@ -2589,7 +2583,7 @@ fn test_ff_concatenation_effects_follow_source_order(sim) {
assert_eq!(sim.get(effect), 12u8.into());
assert_eq!(sim.get(q), 12u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"first=10".to_vec(),
@@ -2631,7 +2625,7 @@ fn test_ff_materialized_formal_slice_uses_expression_context(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0x0010u16.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"inner=175".to_vec(),
}],
@@ -2673,7 +2667,7 @@ fn test_ff_runtime_event_reads_updated_formal_slice(sim) {
assert_eq!(sim.get(effect), 0x1fu8.into());
assert_eq!(sim.get(q), 0x1eu8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"slice=15".to_vec(),
}],
@@ -2723,7 +2717,7 @@ fn test_ff_case_assignment_is_visible_to_later_runtime_event(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(effect), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"case=11".to_vec(),
}],
@@ -2737,7 +2731,7 @@ fn test_ff_case_assignment_is_visible_to_later_runtime_event(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(effect), 22u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"case=22".to_vec(),
}],
@@ -2771,7 +2765,7 @@ fn test_ff_statement_function_with_output_emits_runtime_effect(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(effect), 13u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"statement=12".to_vec(),
}],
@@ -2817,7 +2811,7 @@ fn test_ff_effectful_if_predicate_is_evaluated_once(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"predicate=7".to_vec(),
}],
@@ -2866,7 +2860,7 @@ fn test_ff_nested_output_is_captured_through_signed_cast(sim) {
assert_eq!(sim.get(effect), 8u8.into());
assert_eq!(sim.get(q), 7u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"cast=9".to_vec(),
}],
@@ -2921,7 +2915,7 @@ fn test_ff_effectful_function_inputs_follow_declaration_order(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 24u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"arg=1".to_vec(),
@@ -3000,7 +2994,7 @@ fn test_ff_runtime_event_arguments_use_per_argument_state(sim) {
assert_eq!(sim.get(effect), 11u8.into());
assert_eq!(sim.get(q), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"args=10 12".to_vec(),
}],
@@ -3036,7 +3030,7 @@ fn test_ff_runtime_event_formal_uses_declared_type(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0xffu8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"formal=-1".to_vec(),
}],
@@ -3078,7 +3072,7 @@ fn test_ff_unpacked_input_before_runtime_effect_stays_symbolically_bound(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0xabu8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"observed=17".to_vec(),
}],
@@ -3119,7 +3113,7 @@ fn test_ff_symbolic_runtime_input_uses_declared_formal_type(sim) {
sim.modify(|io| io.set(d, 0x0100u16)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn test_ff_runtime_effectful_return_uses_declared_signed_type(sim) {
@@ -3159,7 +3153,7 @@ fn test_ff_runtime_effectful_return_uses_declared_signed_type(sim) {
(BigUint::from(0xffa0u32), BigUint::from(0u32))
);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"return".to_vec(),
}],
@@ -3207,7 +3201,7 @@ fn test_ff_runtime_effectful_output_uses_declared_formal_type(sim) {
(BigUint::from(0xa0u32), BigUint::from(0u32))
);
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"output".to_vec(),
}],
@@ -3245,7 +3239,7 @@ fn test_ff_runtime_effectful_merge_preserves_signed_return_type(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0xff80u16.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"choose=1".to_vec(),
}],
@@ -3255,7 +3249,7 @@ fn test_ff_runtime_effectful_merge_preserves_signed_return_type(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0xff81u16.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"choose=0".to_vec(),
}],
@@ -3295,7 +3289,7 @@ fn test_ff_runtime_effectful_local_assignment_uses_declared_type(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"temporary=-1".to_vec(),
}],
@@ -3329,7 +3323,7 @@ fn test_ff_rewritten_runtime_event_argument_preserves_signedness(sim) {
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"signed=-1".to_vec(),
}],
@@ -3352,7 +3346,7 @@ fn test_ff_runtime_events_format_verilog_radices(sim) {
sim.modify(|io| io.set(a, 0x2au8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"bin=00101010 hex=2a HEX=2a".to_vec(),
}],
@@ -3386,7 +3380,7 @@ fn test_ff_runtime_events_follow_veryl_field_widths(sim) {
// Veryl's simulator: radices at the argument's width, decimals at their
// minimum, C-style flags, and no truncation to a narrower field.
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"[ 7][7 ][00007][9][00000009][0007]".to_vec(),
@@ -3417,7 +3411,7 @@ fn test_ff_runtime_events_preserve_four_state_args(sim) {
})
.unwrap();
sim.tick(clk).unwrap();
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert_eq!(
events,
vec![
@@ -3430,9 +3424,7 @@ fn test_ff_runtime_events_preserve_four_state_args(sim) {
}
.as_bytes().to_vec(),
},
- celox::RuntimeEvent::AssertContinue {
- message: b"bad=1z10".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"bad=1z10".to_vec())),
],
);
}
@@ -3471,7 +3463,7 @@ fn test_ff_runtime_events_support_design_sized_arg_count(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"1 2 3 4 5".to_vec(),
}],
@@ -3501,7 +3493,7 @@ fn test_ff_runtime_events_support_wide_four_state_args(sim) {
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: match FRONTEND {
test_utils::Frontend::Veryl => "a=123456789abcdef0123X dec=x",
@@ -3533,13 +3525,13 @@ fn test_ff_runtime_event_drain_handle_can_run_during_simulation(sim) {
let drained = std::sync::Arc::clone(&drained);
std::thread::spawn(move || {
while !done.load(std::sync::atomic::Ordering::Acquire) {
- let events = drain.drain();
+ let events = bare(drain.drain());
if !events.is_empty() {
drained.lock().unwrap().extend(events);
}
std::thread::yield_now();
}
- drained.lock().unwrap().extend(drain.drain());
+ drained.lock().unwrap().extend(bare(drain.drain()));
})
};
@@ -3587,11 +3579,11 @@ fn test_runtime_event_drain_handle_is_exclusive(sim) {
sim.modify(|io| io.set(a, 9u8)).unwrap();
sim.tick(clk).unwrap();
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
}));
assert!(result.is_err());
assert_eq!(
- drain.drain(),
+ bare(drain.drain()),
vec![celox::RuntimeEvent::Display {
message: b"a=9".to_vec(),
}],
@@ -3601,7 +3593,7 @@ fn test_runtime_event_drain_handle_is_exclusive(sim) {
sim.modify(|io| io.set(a, 10u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"a=10".to_vec(),
}],
@@ -3623,12 +3615,10 @@ fn test_ff_runtime_fatal_assert_records_event(sim) {
sim.modify(|io| io.set(a, 7u8)).unwrap();
assert!(sim.tick(clk).is_err());
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert_eq!(
events,
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"fatal a=7".to_vec(),
- }],
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"fatal a=7".to_vec()))],
);
}
@@ -3646,12 +3636,10 @@ fn test_ff_message_less_runtime_fatal_assert_uses_default_message(sim) {
let err = sim.tick(clk).unwrap_err();
assert_eq!(err.to_string(), "assertion failed");
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert_eq!(
events,
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"assertion failed".to_vec(),
- }],
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"assertion failed".to_vec()))],
);
}
@@ -4188,13 +4176,13 @@ fn test_ff_case_range_skips_effectful_upper_bound_when_lower_is_false(sim) {
sim.modify(|io| io.set(d, 1u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 0u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| io.set(d, 6u8)).unwrap();
sim.tick(clk).unwrap();
assert_eq!(sim.get(q), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"upper".to_vec(),
}],
@@ -5394,3 +5382,17 @@ fn test_ff_register_gated_clock_rises_after_the_commit(sim) {
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/floating_point_display.rs b/crates/celox/tests/floating_point_display.rs
index eed41c9944f..80a24a37213 100644
--- a/crates/celox/tests/floating_point_display.rs
+++ b/crates/celox/tests/floating_point_display.rs
@@ -1,4 +1,4 @@
-use celox::{RuntimeEvent, Simulator};
+use celox::{Report, RuntimeEvent, Severity, Simulator};
#[path = "test_utils/mod.rs"]
#[macro_use]
@@ -20,10 +20,10 @@ all_backends! {
}
}
"#, "Top");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let a = sim.signal("a");
sim.modify(|io| io.set(a, 3u32)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
RuntimeEvent::Display { message: b"wide=1.500000 narrow=3.00 neg=-1.50".to_vec() },
RuntimeEvent::Write { message: b"fraction=1.50".to_vec() },
]);
@@ -39,10 +39,10 @@ all_backends! {
always_comb { $display((a as f64) / 2.0, a as f32); }
}
"#, "Top");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let a = sim.signal("a");
sim.modify(|io| io.set(a, 3u32)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![RuntimeEvent::Display { message: b"1.5 3".to_vec() }]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![RuntimeEvent::Display { message: b"1.5 3".to_vec() }]);
}
fn rtl_negative_float_constants(sim) {
@@ -58,10 +58,10 @@ all_backends! {
}
"#, "Top");
let clk = sim.event("clk");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.tick(clk).unwrap();
assert_eq!(sim.get(sim.signal("q")), 0xfffffffeu32.into());
- assert_eq!(sim.drain_runtime_events(), vec![RuntimeEvent::Display { message: b"constant=-2.25 wide=-1.50".to_vec() }]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![RuntimeEvent::Display { message: b"constant=-2.25 wide=-1.50".to_vec() }]);
}
fn rtl_ff_float_messages(sim) {
@@ -77,11 +77,11 @@ all_backends! {
let a = sim.signal("a");
let clk = sim.event("clk");
sim.modify(|io| io.set(a, 3u32)).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.tick(clk).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
RuntimeEvent::Display { message: b"ff=1.50 f32=3.00".to_vec() },
- RuntimeEvent::AssertContinue { message: b"value=1.50".to_vec() },
+ RuntimeEvent::Report(Report::new(Severity::Error, b"value=1.50".to_vec())),
]);
}
}
@@ -244,7 +244,7 @@ fn named_float_constants_and_parameters_display_numeric_values() {
let clk = sim.event("clk");
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![RuntimeEvent::Display {
message: expected.as_bytes().to_vec()
}]
@@ -276,7 +276,7 @@ fn hierarchical_float_parameter_overrides_keep_their_own_scope() {
let clk = sim.event("clk");
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![RuntimeEvent::Display {
message: b"P=1.25 C=1.75".to_vec()
}]
@@ -319,7 +319,7 @@ fn package_float_constants_do_not_alias_same_named_parameter_overrides() {
let clk = sim.event("clk");
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![RuntimeEvent::Display {
message: b"local=1.25 package=-2.25".to_vec()
}]
@@ -342,9 +342,23 @@ fn integral_parameter_override_is_used_by_float_constant() {
let clk = sim.event("clk");
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![RuntimeEvent::Display {
message: b"F=3.00 transitive=4.00 direct=4.00".to_vec()
}]
);
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/four_state_expression_semantics.rs b/crates/celox/tests/four_state_expression_semantics.rs
index bb30d875cae..e7d68800b90 100644
--- a/crates/celox/tests/four_state_expression_semantics.rs
+++ b/crates/celox/tests/four_state_expression_semantics.rs
@@ -71,7 +71,7 @@ module Top (
})
.unwrap();
sim.tick(clk).unwrap();
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
for (value, mask, label) in [
(BigUint::from(0u8), BigUint::from(0u8), "0"),
@@ -84,10 +84,8 @@ module Top (
.unwrap();
sim.tick(clk).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"bad condition".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"bad condition".to_vec()))],
"cond={label}",
);
}
@@ -108,7 +106,7 @@ module Top (
let cond = sim.signal("cond");
let known_one = BigUint::from(1u8) << 100usize;
let unknown = BigUint::from(1u8) << 2usize;
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
for (unknown_value, label) in [(1u8, "X"), (0u8, "Z")] {
sim.modify(|io| {
@@ -120,7 +118,7 @@ module Top (
})
.unwrap();
assert!(
- sim.drain_runtime_events().is_empty(),
+ bare(sim.drain_runtime_events()).is_empty(),
"known one plus {label} must pass",
);
@@ -129,10 +127,8 @@ module Top (
})
.unwrap();
assert_eq!(
- sim.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertContinue {
- message: b"bad condition".to_vec(),
- }],
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"bad condition".to_vec()))],
"only {label} must fail",
);
}
@@ -153,3 +149,17 @@ module Top (
@case "four_state_expression_semantics::wide_unaligned_partial_store_and_slice_preserve_four_state_bits";
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/frontends/systemverilog/floating_point.rs b/crates/celox/tests/frontends/systemverilog/floating_point.rs
index fcc1265bd03..7c8ffdbc195 100644
--- a/crates/celox/tests/frontends/systemverilog/floating_point.rs
+++ b/crates/celox/tests/frontends/systemverilog/floating_point.rs
@@ -41,14 +41,28 @@ sv_backends! {
endmodule
"#; }
@build Simulator::from_sv_sources(vec![(source, Path::new("real_comb_display.sv"))], "Top").four_state(true);
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let enabled = sim.signal("enabled");
let bits = sim.signal("bits");
sim.modify(|io| { io.set(bits, 0x3ff8000000000000u64); io.set(enabled, 1u8); }).unwrap();
assert_eq!(sim.get(sim.signal("x")), BigUint::from(0x3ff8000000000000u64));
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert_eq!(events.len(), 2, "{events:?}");
assert!(events.contains(&celox::RuntimeEvent::Display { message: b"comb=1.50 expression=3.0".to_vec() }), "{events:?}");
- assert!(events.contains(&celox::RuntimeEvent::AssertContinue { message: b"assert=1.50".to_vec() }), "{events:?}");
+ assert!(events.contains(&celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"assert=1.50".to_vec()))), "{events:?}");
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/frontends/systemverilog/suite.rs b/crates/celox/tests/frontends/systemverilog/suite.rs
index f10ac99fc15..dacbd92e6f5 100644
--- a/crates/celox/tests/frontends/systemverilog/suite.rs
+++ b/crates/celox/tests/frontends/systemverilog/suite.rs
@@ -48,14 +48,13 @@ impl TimedBackend {
fn capture_events(&mut self) -> Result<()> {
let events = self.sim.drain_runtime_events();
let error = events.iter().find_map(|event| match event {
- RuntimeEvent::AssertFatal { message } => Some(format!(
- "fatal assertion: {}",
- String::from_utf8_lossy(message)
- )),
- RuntimeEvent::AssertContinue { message } => Some(format!(
- "failed assertion: {}",
- String::from_utf8_lossy(message)
- )),
+ RuntimeEvent::Report(report) if report.severity >= celox::Severity::Error => {
+ Some(format!(
+ "{:?}: {}",
+ report.severity,
+ String::from_utf8_lossy(&report.message)
+ ))
+ }
RuntimeEvent::Missed { count } => Some(format!("{count} runtime events were missed")),
_ => None,
});
diff --git a/crates/celox/tests/frontends/systemverilog/system_functions.rs b/crates/celox/tests/frontends/systemverilog/system_functions.rs
index e8d26fe9cd3..28c62e18b39 100644
--- a/crates/celox/tests/frontends/systemverilog/system_functions.rs
+++ b/crates/celox/tests/frontends/systemverilog/system_functions.rs
@@ -22,7 +22,7 @@ fn veryl_assert_unknown_conditions_are_eager_on_interpreter() {
.four_state(true)
.build_interpreter()
.unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let enabled = sim.signal("enabled");
let condition = sim.signal("condition");
sim.modify(|io| {
@@ -34,7 +34,7 @@ fn veryl_assert_unknown_conditions_are_eager_on_interpreter() {
sim.tick(sim.event("clk")).unwrap();
}
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"inside".to_vec()
},]
@@ -47,14 +47,15 @@ fn veryl_assert_unknown_conditions_are_eager_on_interpreter() {
sim.tick(sim.event("clk")).unwrap();
}
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"inside".to_vec()
},
- celox::RuntimeEvent::AssertContinue {
- message: b"value=7".to_vec()
- },
+ celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Error,
+ b"value=7".to_vec()
+ )),
]
);
}
@@ -84,7 +85,7 @@ fn urandom_comb_runs_next_to_an_initial_process_on_interpreter_and_tiered() {
sim.modify(|io| io.set(seed, 17u8)).unwrap();
assert_eq!(sim.get(value), sim.get(sim.signal("reference")));
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"initial".to_vec()
}]
@@ -163,7 +164,7 @@ sv_backends! {
sim.restore(&saved).unwrap();
sim.eval_comb().unwrap();
assert_eq!(sim.get(value), first);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn scope_randomize_fills_arbitrary_packed_widths(sim) {
@@ -325,7 +326,7 @@ sv_backends! {
assert_eq!(sim.get(value), second);
sim.modify(|io| io.set(dead_input, 1u8)).unwrap();
assert_ne!(sim.get(value), second);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn urandom_comb_propagates_all_outputs_and_hierarchical_events(sim) {
@@ -349,24 +350,24 @@ sv_backends! {
endmodule
"#; }
@build Simulator::from_sv_sources(vec![(source, Path::new("random_events.sv"))], "Top").four_state(true);
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let enabled = sim.signal("enabled");
let data = sim.signal("data");
sim.modify(|io| { io.set(enabled, 1u8); io.set(data, 7u8); }).unwrap();
let first = sim.get(sim.signal("q"));
- let messages = sim.drain_runtime_events();
+ let messages = bare(sim.drain_runtime_events());
assert_eq!(messages.len(), 2, "{messages:?}");
assert!(messages.contains(&celox::RuntimeEvent::Display { message: b"inside=8".to_vec() }));
sim.modify(|io| io.set(data, 8u8)).unwrap();
assert_ne!(sim.get(sim.signal("q")), first);
- let messages = sim.drain_runtime_events();
+ let messages = bare(sim.drain_runtime_events());
assert_eq!(messages.len(), 2, "{messages:?}");
assert!(messages.contains(&celox::RuntimeEvent::Display { message: b"inside=9".to_vec() }));
sim.set(sim.signal("unrelated"), 1u8);
sim.eval_comb().unwrap();
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.tick(sim.event("clk")).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display { message: b"clock".to_vec() }]);
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display { message: b"clock".to_vec() }]);
}
fn urandom_comb_notifies_only_observed_bits(sim) {
@@ -402,27 +403,27 @@ sv_backends! {
let high = sim.signal("high");
let index = sim.signal("index");
sim.modify(|io| { io.set(low, 0u8); io.set(high, 0u8); io.set(index, 4u8); }).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(high, 1u8)).unwrap();
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
let array_value = sim.get(sim.signal("q_array"));
assert!(events.is_empty(), "{events:?}; array={array_value:?}");
assert_eq!(array_value, 2u8.into());
sim.modify(|io| io.set(low, 1u8)).unwrap();
- let mut messages: Vec<_> = sim.drain_runtime_events().into_iter().map(|event| match event {
+ let mut messages: Vec<_> = bare(sim.drain_runtime_events()).into_iter().map(|event| match event {
celox::RuntimeEvent::Display { message } => message,
event => panic!("unexpected event: {event:?}"),
}).collect();
messages.sort();
assert_eq!(messages, vec![b"array=1".to_vec(), b"dynamic=1".to_vec(), b"static=1".to_vec()]);
sim.modify(|io| io.set_four_state(high, 1u8.into(), 64u8.into())).unwrap();
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert!(events.is_empty(), "{events:?}");
sim.modify(|io| { io.set(high, 0u8); io.set(index, 5u8); }).unwrap();
- let events = sim.drain_runtime_events();
+ let events = bare(sim.drain_runtime_events());
assert!(events.is_empty(), "{events:?}");
sim.modify(|io| io.set(index, 0u8)).unwrap();
- let mut messages: Vec<_> = sim.drain_runtime_events().into_iter().map(|event| match event {
+ let mut messages: Vec<_> = bare(sim.drain_runtime_events()).into_iter().map(|event| match event {
celox::RuntimeEvent::Display { message } => message,
event => panic!("unexpected event: {event:?}"),
}).collect();
@@ -546,23 +547,23 @@ sv_backends! {
sim.set(enabled, 0u8);
sim.set(ok, 0u8);
sim.tick(clk).unwrap();
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
assert_eq!(sim.get(sim.signal("reached")), 0u8.into());
sim.set(enabled, 1u8);
sim.set(ok, 1u8);
sim.tick(clk).unwrap();
assert_eq!(sim.get(sim.signal("effect")), 0u8.into());
assert_eq!(sim.get(sim.signal("reached")), 1u8.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=1".to_vec() },
]);
sim.set(ok, 0u8);
sim.tick(clk).unwrap();
assert_eq!(sim.get(sim.signal("effect")), 1u8.into());
assert_eq!(sim.get(sim.signal("reached")), 1u8.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=0".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"before=0 value=-2 after=1".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"before=0 value=-2 after=1".to_vec())),
]);
}
@@ -584,23 +585,23 @@ sv_backends! {
"#; }
@build Simulator::from_sv_sources(vec![(source, Path::new("veryl_assert_comb.sv"))], "Top")
.four_state(true);
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let enabled = sim.signal("enabled");
let ok = sim.signal("ok");
sim.modify(|io| { io.set(enabled, 1u8); io.set(ok, 1u8); }).unwrap();
assert_eq!(sim.get(sim.signal("effect")), 0u8.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=1".to_vec() },
]);
sim.modify(|io| io.set(ok, 0u8)).unwrap();
assert_eq!(sim.get(sim.signal("effect")), 1u8.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=0".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"before=0 value=-2 after=1".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"before=0 value=-2 after=1".to_vec())),
]);
sim.modify(|io| io.set(enabled, 0u8)).unwrap();
assert_eq!(sim.get(sim.signal("effect")), 0u8.into());
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn veryl_assert_fatal_ff_evaluates_messages_and_stops_only_on_failure(sim) {
@@ -623,14 +624,14 @@ sv_backends! {
sim.set(ok, 1u8);
sim.tick(clk).unwrap();
assert_eq!(sim.get(sim.signal("reached")), 1u8.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside".to_vec() },
]);
sim.set(ok, 0u8);
assert!(sim.tick(clk).is_err());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside".to_vec() },
- celox::RuntimeEvent::AssertFatal { message: b"value=-2".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"value=-2".to_vec())),
]);
}
@@ -651,21 +652,21 @@ sv_backends! {
endmodule
"#; }
@build Simulator::from_sv_sources(vec![(source, Path::new("veryl_assert_loop.sv"))], "Top");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let ok = sim.signal("ok");
let count = sim.signal("count");
sim.modify(|io| { io.set(ok, 1u8); io.set(count, 2u8); }).unwrap();
assert_eq!(sim.get(sim.signal("q")), 2u32.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=0".to_vec() },
celox::RuntimeEvent::Display { message: b"inside=1".to_vec() },
]);
sim.modify(|io| io.set(ok, 0u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside=0".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"value=1".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"value=1".to_vec())),
celox::RuntimeEvent::Display { message: b"inside=1".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"value=2".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"value=2".to_vec())),
]);
}
@@ -686,11 +687,11 @@ sv_backends! {
"#; }
@build Simulator::from_sv_sources(vec![(source, Path::new("veryl_assert_constant.sv"))], "Top");
sim.tick(sim.event("clk")).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"inside".to_vec() },
celox::RuntimeEvent::Display { message: b"inside".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"assertion failed".to_vec() },
- celox::RuntimeEvent::AssertContinue { message: b"assertion failed".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"assertion failed".to_vec())),
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"assertion failed".to_vec())),
]);
}
@@ -758,7 +759,7 @@ sv_backends! {
@build Simulator::from_sv_sources(vec![(source, Path::new("printtimescale.sv"))], "Top");
sim.set(sim.signal("enabled"), 1u8);
sim.tick(sim.event("clk")).unwrap();
- let mut messages = sim.drain_runtime_events().into_iter().map(|event| match event {
+ let mut messages = bare(sim.drain_runtime_events()).into_iter().map(|event| match event {
celox::RuntimeEvent::Display { message } => String::from_utf8(message).unwrap(),
event => panic!("unexpected event: {event:?}"),
}).collect::>();
@@ -793,7 +794,7 @@ sv_backends! {
sim.set(sim.signal("data"), 7u32);
sim.tick(sim.event("clk")).unwrap();
assert_eq!(sim.get(sim.signal("q")), 7u32.into());
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"Time scale of (Top.info) is 100ns / 10ps".to_vec() },
celox::RuntimeEvent::Display { message: b"Time scale of (Top.child.nested) is 100ns / 10ps".to_vec() },
celox::RuntimeEvent::Display { message: b"Time scale of (Top.info) is 100ns / 10ps".to_vec() },
@@ -824,7 +825,7 @@ sv_backends! {
sim.tick(sim.event("clk")).unwrap();
assert_eq!(sim.get(sim.signal("i_q")), 7u32.into());
assert_eq!(sim.get(sim.signal("j_q")), 7u32.into());
- let mut messages = sim.drain_runtime_events().into_iter().map(|event| match event {
+ let mut messages = bare(sim.drain_runtime_events()).into_iter().map(|event| match event {
celox::RuntimeEvent::Display { message } => String::from_utf8(message).unwrap(),
event => panic!("unexpected event: {event:?}"),
}).collect::>();
@@ -979,7 +980,7 @@ sv_backends! {
for (dimension, expected) in [(1u32, 2u32), (2, 7), (3, 0), (0x0800_0001, 0)] {
sim.set(d, dimension);
assert_eq!(sim.get(y), expected.into());
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Display {
+ assert_eq!(bare(sim.drain_runtime_events()), vec![celox::RuntimeEvent::Display {
message: b"dimension".to_vec(),
}]);
}
@@ -1111,13 +1112,13 @@ sv_backends! {
@build Simulator::from_sv_sources(vec![(source, Path::new("fatal.sv"))], "Top");
let fail = sim.signal("fail");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.set(fail, 1u8);
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"before".to_vec() },
- celox::RuntimeEvent::AssertFatal { message: b"boom 1".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"boom 1".to_vec())),
]);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn display_field_flags(sim) { @case "system_functions::display_field_flags"; }
@@ -1270,8 +1271,7 @@ fn printtimescale_in_interface_array_functions_keeps_each_instance_scope() {
"interface I; function automatic int show(); $printtimescale; return 0; endfunction initial $display(\"%0d\", show()); endinterface module Top(output logic y); I info[2](); assign y=0; endmodule",
);
sim.step().unwrap();
- let mut messages = sim
- .drain_runtime_events()
+ let mut messages = bare(sim.drain_runtime_events())
.into_iter()
.map(|event| match event {
celox::RuntimeEvent::Display { message } => String::from_utf8(message).unwrap(),
@@ -1305,7 +1305,7 @@ fn printtimescale_runs_in_initial_blocks_with_all_time_magnitudes() {
let mut sim = initial_simulation(&source);
sim.step().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: format!("Time scale of (Top) is {expected}").into_bytes()
}]
@@ -1329,8 +1329,7 @@ fn printtimescale_initial_instances_and_interface_arrays_keep_their_names() {
"#;
let mut sim = initial_simulation(source);
sim.step().unwrap();
- let mut messages = sim
- .drain_runtime_events()
+ let mut messages = bare(sim.drain_runtime_events())
.into_iter()
.map(|event| match event {
celox::RuntimeEvent::Display { message } => String::from_utf8(message).unwrap(),
@@ -1364,8 +1363,7 @@ fn printtimescale_interface_arrays_preserve_integer_boundary_indices() {
);
let mut sim = initial_simulation(&source);
sim.step().unwrap();
- let mut messages = sim
- .drain_runtime_events()
+ let mut messages = bare(sim.drain_runtime_events())
.into_iter()
.map(|event| match event {
celox::RuntimeEvent::Display { message } => String::from_utf8(message).unwrap(),
@@ -1456,7 +1454,7 @@ fn stop_suspends_the_simulation_until_it_continues() {
assert_eq!(sim.get(count), expected.into());
assert_eq!(sim.get(other), 0u8.into());
assert_eq!(sim.get(sum), expected.into());
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
// A suspended time step cannot be captured.
assert!(matches!(
sim.checkpoint(),
@@ -1470,7 +1468,7 @@ fn stop_suspends_the_simulation_until_it_continues() {
assert_eq!(sim.get(other), 5u8.into());
assert_eq!(sim.get(sum), 11u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"done 6 13".to_vec(),
}],
@@ -1540,7 +1538,7 @@ fn stop_keeps_the_edges_of_its_time_step() {
assert_eq!(sim.step().unwrap(), Some(0));
assert!(!sim.is_stopped());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"q=0".to_vec(),
}],
@@ -1563,14 +1561,20 @@ fn stop_in_a_clocked_or_combinational_process_is_an_event() {
let mut sim = Simulator::from_sv_sources(vec![(source, Path::new("stop.sv"))], "Top")
.build_cranelift()
.unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.tick(sim.event("clk")).unwrap();
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
let enabled = sim.signal("enabled");
sim.modify(|io| io.set(enabled, 1u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Stop]);
+ assert_eq!(
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Stop]
+ );
sim.tick(sim.event("clk")).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![celox::RuntimeEvent::Stop]);
+ assert_eq!(
+ bare(sim.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Stop]
+ );
}
/// IEEE 1800-2023 24.7: `$exit` outside a program block is ignored.
@@ -1596,7 +1600,7 @@ fn exit_outside_a_program_block_is_ignored() {
assert!(!sim.is_finished());
assert!(!sim.is_stopped());
assert_eq!(sim.get(sim.signal("a")), 3u8.into());
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
// Each call warns once, at its line.
let warned: Vec<_> = sim
.warnings()
@@ -1968,10 +1972,10 @@ fn value_functions_called_as_statements_evaluate_their_operands_once() {
.build_cranelift()
.unwrap();
let a = sim.signal("a");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"g 5".to_vec(),
}],
@@ -2004,11 +2008,11 @@ fn initial_blocks_run_their_system_tasks_at_time_zero() {
let y = sim.signal("y");
// The block runs as a process at time zero, not before it.
assert_eq!(sim.get(y), 0u8.into());
- assert_eq!(sim.drain_runtime_events(), Vec::new());
+ assert_eq!(bare(sim.drain_runtime_events()), Vec::new());
assert_eq!(sim.step().unwrap(), Some(0));
assert_eq!(sim.get(y), 0x34u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"b=34".to_vec(),
@@ -2019,9 +2023,7 @@ fn initial_blocks_run_their_system_tasks_at_time_zero() {
celox::RuntimeEvent::Write {
message: b"1,".to_vec(),
},
- celox::RuntimeEvent::AssertContinue {
- message: b"e4".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Error, b"e4".to_vec())),
],
);
assert!(!sim.is_finished());
@@ -2044,7 +2046,7 @@ fn finish_in_an_initial_block_ends_the_simulation() {
sim.step().unwrap();
assert!(sim.is_finished());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"before".to_vec(),
}],
@@ -2067,14 +2069,15 @@ fn fatal_in_an_initial_block_fails_the_simulation() {
let error = sim.step().unwrap_err();
assert!(error.to_string().contains("boom"), "{error}");
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"before".to_vec(),
},
- celox::RuntimeEvent::AssertFatal {
- message: b"boom 7".to_vec(),
- },
+ celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Fatal,
+ b"boom 7".to_vec()
+ )),
],
);
}
@@ -2098,7 +2101,7 @@ fn initial_blocks_skip_the_operands_short_circuits_skip() {
let mut sim = initial_simulation(source);
sim.step().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"1".to_vec(),
}],
@@ -2122,7 +2125,7 @@ fn initial_blocks_that_read_design_state_run_at_time_zero() {
sim.step().unwrap();
// The initializer runs before the initial block.
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"value=1".to_vec(),
@@ -2152,7 +2155,7 @@ fn nonblocking_assignments_in_initial_processes_update_after_the_display() {
let y = sim.signal("y");
assert_eq!(sim.get(y), 1u8.into());
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"0".to_vec()
}]
@@ -2193,10 +2196,10 @@ fn countbits_called_as_a_statement_evaluates_all_arguments_once() {
.build_cranelift()
.unwrap();
let a = sim.signal("a");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
sim.modify(|io| io.set(a, 5u8)).unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"value 5".to_vec()
@@ -2516,10 +2519,10 @@ fn urandom_comb_starts_after_initial_procedures() {
endmodule
"#;
let mut sim = initial_simulation(source);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.step().unwrap();
assert_eq!(
- sim.drain_runtime_events(),
+ bare(sim.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"initial".to_vec()
@@ -2532,7 +2535,7 @@ fn urandom_comb_starts_after_initial_procedures() {
let value = sim.get(sim.signal("value"));
sim.eval_comb().unwrap();
assert_eq!(sim.get(sim.signal("value")), value);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
#[test]
@@ -2622,7 +2625,7 @@ fn rising_edge_at(sim: &mut celox::Simulation, time: u64) -> Vec Vec {
@@ -2662,7 +2665,7 @@ fn time_counts_the_global_precision_in_the_unit_of_the_caller() {
.unwrap();
let (a, y) = (sim.signal("a"), sim.signal("y"));
sim.run_until(0).unwrap();
- assert_eq!(sim.drain_runtime_events(), displays(&["initial 0"]));
+ assert_eq!(bare(sim.drain_runtime_events()), displays(&["initial 0"]));
// 1.499 ns rounds down, 149.9 x 10 ps up; 1.5 ns, a half, rounds up.
// The package function counts the unit of its package.
assert_eq!(
@@ -2733,9 +2736,9 @@ fn delays_count_the_time_unit_of_their_scope() {
.unwrap();
assert_eq!(sim.step().unwrap(), Some(0));
assert_eq!(sim.step().unwrap(), Some(30));
- assert_eq!(sim.drain_runtime_events(), displays(&["child 3"]));
+ assert_eq!(bare(sim.drain_runtime_events()), displays(&["child 3"]));
assert_eq!(sim.step().unwrap(), Some(3_000));
- assert_eq!(sim.drain_runtime_events(), displays(&["top 3"]));
+ assert_eq!(bare(sim.drain_runtime_events()), displays(&["top 3"]));
}
#[test]
@@ -2923,7 +2926,7 @@ fn state_files_keep_the_time_in_their_schedule() {
untimed.load_state(&file).unwrap();
let clk = untimed.event("clk");
untimed.tick(clk).unwrap();
- assert_eq!(untimed.drain_runtime_events(), displays(&["0"]));
+ assert_eq!(bare(untimed.drain_runtime_events()), displays(&["0"]));
// A Simulation continues at the saved time.
let mut timed = build();
timed.load_state(&file).unwrap();
@@ -2963,7 +2966,7 @@ fn time_is_zero_in_a_simulator_without_time() {
.unwrap();
let clk = sim.event("clk");
sim.tick(clk).unwrap();
- assert_eq!(sim.drain_runtime_events(), displays(&["0 0"]));
+ assert_eq!(bare(sim.drain_runtime_events()), displays(&["0 0"]));
}
#[test]
@@ -3289,3 +3292,17 @@ sv_backends! {
assert_eq!(sim.get(sim.signal("next")), 1196435762u32.into());
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/runtime_api.rs b/crates/celox/tests/runtime_api.rs
index e3dbe91de11..d88637e469c 100644
--- a/crates/celox/tests/runtime_api.rs
+++ b/crates/celox/tests/runtime_api.rs
@@ -1,4 +1,6 @@
-use celox::{AddrLookupError, BigUint, RuntimeErrorCode, RuntimeEvent, Simulator};
+use celox::{
+ AddrLookupError, BigUint, Report, RuntimeErrorCode, RuntimeEvent, Severity, Simulator,
+};
#[path = "test_utils/mod.rs"]
#[macro_use]
@@ -12,8 +14,8 @@ all_backends! {
module Top { always_comb { $assert(1'd0, "site zero"); } }
"#, "Top");
assert!(matches!(sim.eval_comb(), Err(RuntimeErrorCode::Runtime { message, .. }) if message == "site zero"));
- assert_eq!(sim.drain_runtime_events(), vec![RuntimeEvent::AssertFatal { message: b"site zero".to_vec() }]);
- assert!(sim.drain_runtime_events().is_empty());
+ assert_eq!(bare(sim.drain_runtime_events()), vec![RuntimeEvent::Report(Report::new(Severity::Fatal, b"site zero".to_vec()))]);
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn drain_returns_fatal_after_two_display_sites(sim) {
@@ -29,12 +31,12 @@ module Top {
}
"#, "Top");
assert!(matches!(sim.eval_comb(), Err(RuntimeErrorCode::Runtime { message, .. }) if message == "site two"));
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
RuntimeEvent::Display { message: b"first".to_vec() },
RuntimeEvent::Display { message: b"second".to_vec() },
- RuntimeEvent::AssertFatal { message: b"site two".to_vec() },
+ RuntimeEvent::Report(Report::new(Severity::Fatal, b"site two".to_vec())),
]);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn drain_handle_keeps_fatal_records_from_all_input_mutations(sim) {
@@ -49,23 +51,23 @@ module Top (a: input logic<8>, w: input logic<128>) {
let a = sim.signal("a");
let w = sim.signal("w");
sim.modify(|io| { io.set(a, 0u8); io.set(w, 0u8); }).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("drain handle");
- let fatal = vec![RuntimeEvent::AssertFatal { message: b"input fatal".to_vec() }];
+ let fatal = vec![RuntimeEvent::Report(Report::new(Severity::Fatal, b"input fatal".to_vec()))];
sim.set(a, 1u8);
- assert_eq!(drain.drain(), fatal);
- assert!(drain.drain().is_empty());
+ assert_eq!(bare(drain.drain()), fatal);
+ assert!(bare(drain.drain()).is_empty());
sim.set(a, 0u8);
sim.set_wide(w, BigUint::from(1u8));
- assert_eq!(drain.drain(), fatal);
+ assert_eq!(bare(drain.drain()), fatal);
sim.set_wide(w, BigUint::from(0u8));
sim.set_four_state(a, BigUint::from(1u8), BigUint::from(0u8));
- assert_eq!(drain.drain(), fatal);
+ assert_eq!(bare(drain.drain()), fatal);
sim.set(a, 0u8);
sim.modify(|io| io.set(a, 1u8)).unwrap();
- assert_eq!(drain.drain(), fatal);
- assert!(drain.drain().is_empty());
+ assert_eq!(bare(drain.drain()), fatal);
+ assert!(bare(drain.drain()).is_empty());
}
fn drain_handle_keeps_fatal_record_after_checkpoint_restore(sim) {
@@ -78,16 +80,16 @@ module Top (a: input logic<8>) {
"#, "Top");
let a = sim.signal("a");
sim.modify(|io| io.set(a, 0u8)).unwrap();
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
// Save the failing input before lazy evaluation captures its assertion.
sim.set(a, 1u8);
let checkpoint = sim.checkpoint().unwrap();
sim.set(a, 0u8);
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let mut drain = sim.runtime_event_drain().expect("drain handle");
sim.restore(&checkpoint).unwrap();
- assert_eq!(drain.drain(), vec![RuntimeEvent::AssertFatal { message: b"restored fatal".to_vec() }]);
- assert!(drain.drain().is_empty());
+ assert_eq!(bare(drain.drain()), vec![RuntimeEvent::Report(Report::new(Severity::Fatal, b"restored fatal".to_vec()))]);
+ assert!(bare(drain.drain()).is_empty());
}
fn try_event_rejects_signals_without_events(sim) {
@@ -132,11 +134,11 @@ module Top {
}
"#, "Top");
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"before".to_vec() },
- celox::RuntimeEvent::AssertFatal { message: b"initial fatal".to_vec() },
+ celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"initial fatal".to_vec())),
]);
- assert!(sim.drain_runtime_events().is_empty());
+ assert!(bare(sim.drain_runtime_events()).is_empty());
}
fn drain_runtime_events_with_context_returns_comb_fatal_after_modify(sim) {
@@ -151,17 +153,31 @@ module Top (a: input logic<8>, y: output logic<8>) {
}
"#, "Top");
- sim.drain_runtime_events();
+ bare(sim.drain_runtime_events());
let a = sim.signal("a");
sim.modify(|io| io.set(a, 1u8)).unwrap();
- assert_eq!(sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
+ assert_eq!(bare(sim.drain_runtime_events_with_context(celox::RuntimeFormatContext {
scope: Some("host.Top"),
..Default::default()
- }), vec![celox::RuntimeEvent::AssertFatal { message: b"fatal host.Top".to_vec() }]);
- assert!(sim.drain_runtime_events().is_empty());
+ })), vec![celox::RuntimeEvent::Report(celox::Report::new(celox::Severity::Fatal, b"fatal host.Top".to_vec()))]);
+ assert!(bare(sim.drain_runtime_events()).is_empty());
sim.modify(|io| io.set(a, 2u8)).unwrap();
- assert_eq!(sim.drain_runtime_events(), vec![
+ assert_eq!(bare(sim.drain_runtime_events()), vec![
celox::RuntimeEvent::Display { message: b"after".to_vec() },
]);
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/shared_jit_cache.rs b/crates/celox/tests/shared_jit_cache.rs
index fdbee866475..33b47f0c5e0 100644
--- a/crates/celox/tests/shared_jit_cache.rs
+++ b/crates/celox/tests/shared_jit_cache.rs
@@ -346,7 +346,7 @@ fn precompiled_runtime_preserves_comb_runtime_events() {
let mut runtime = trusted_instance(image);
assert_eq!(
- runtime.drain_runtime_events(),
+ bare(runtime.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"y=1".to_vec(),
}]
@@ -356,7 +356,7 @@ fn precompiled_runtime_preserves_comb_runtime_events() {
runtime.backend_mut().set(input, 6u8);
runtime.settle_active_edges(&[]).unwrap();
assert_eq!(
- runtime.drain_runtime_events(),
+ bare(runtime.drain_runtime_events()),
vec![celox::RuntimeEvent::Display {
message: b"y=7".to_vec(),
}]
@@ -424,10 +424,12 @@ fn precompiled_runtime_formats_events_with_the_host_time() {
let mut runtime = trusted_instance(image);
assert_eq!(
- runtime.drain_runtime_events_with_context(celox::RuntimeFormatContext {
- tb_time: Some(37),
- scope: None,
- }),
+ bare(
+ runtime.drain_runtime_events_with_context(celox::RuntimeFormatContext {
+ tb_time: Some(37),
+ scope: None,
+ })
+ ),
vec![celox::RuntimeEvent::Display {
message: b"time=37".to_vec(),
}]
@@ -483,12 +485,12 @@ fn forced_comb_runtime_events_preserve_procedural_order() {
drop(sim);
let mut runtime = trusted_instance(image);
- runtime.drain_runtime_events();
+ bare(runtime.drain_runtime_events());
let input = runtime.reflection().signal_by_name("Top.a").unwrap().0;
assert!(runtime.force_signal(input, 7u8.into(), 0u8.into()));
runtime.eval_comb().unwrap();
assert_eq!(
- runtime.drain_runtime_events(),
+ bare(runtime.drain_runtime_events()),
vec![
celox::RuntimeEvent::Display {
message: b"before=0".to_vec(),
@@ -558,7 +560,7 @@ fn precompiled_runtime_distinguishes_write_from_display() {
let mut runtime = trusted_instance(image);
assert_eq!(
- runtime.drain_runtime_events(),
+ bare(runtime.drain_runtime_events()),
vec![
celox::RuntimeEvent::Write {
message: b"a".to_vec(),
@@ -588,16 +590,17 @@ fn precompiled_runtime_reports_fatal_assertions() {
drop(sim);
let mut runtime = trusted_instance(image);
- runtime.drain_runtime_events();
+ bare(runtime.drain_runtime_events());
let input = runtime.signal_ref("Top.a").unwrap();
runtime.backend_mut().set(input, 1u8);
let error = runtime.settle_active_edges(&[]).unwrap_err();
assert!(error.to_string().contains("fatal a=1"));
assert_eq!(
- runtime.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"fatal a=1".to_vec(),
- }]
+ bare(runtime.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Fatal,
+ b"fatal a=1".to_vec()
+ ))]
);
}
@@ -619,7 +622,7 @@ fn precompiled_runtime_reports_sequential_fatal_assertions() {
drop(sim);
let mut runtime = trusted_instance(image);
- runtime.drain_runtime_events();
+ bare(runtime.drain_runtime_events());
let clock = runtime.signal("Top.clk").unwrap().clone();
runtime.backend_mut().set(clock.signal, 1u8);
let error = runtime
@@ -627,10 +630,11 @@ fn precompiled_runtime_reports_sequential_fatal_assertions() {
.unwrap_err();
assert!(error.to_string().contains("ff fatal"));
assert_eq!(
- runtime.drain_runtime_events(),
- vec![celox::RuntimeEvent::AssertFatal {
- message: b"ff fatal".to_vec(),
- }]
+ bare(runtime.drain_runtime_events()),
+ vec![celox::RuntimeEvent::Report(celox::Report::new(
+ celox::Severity::Fatal,
+ b"ff fatal".to_vec()
+ ))]
);
}
@@ -1041,3 +1045,17 @@ fn shared_code_concurrent_stress() {
t.join().unwrap();
}
}
+
+/// The drained events without the time, scope, location and assertion of
+/// their reports, which these tests do not check.
+fn bare(events: Vec) -> Vec {
+ events
+ .into_iter()
+ .map(|event| match event {
+ celox::RuntimeEvent::Report(report) => {
+ celox::RuntimeEvent::Report(celox::Report::new(report.severity, report.message))
+ }
+ event => event,
+ })
+ .collect()
+}
diff --git a/crates/celox/tests/sv_reports.rs b/crates/celox/tests/sv_reports.rs
new file mode 100644
index 00000000000..d03a96c5735
--- /dev/null
+++ b/crates/celox/tests/sv_reports.rs
@@ -0,0 +1,193 @@
+#![cfg(feature = "systemverilog")]
+//! Severity tasks report their severity, the file and line of the call and
+//! the scope that issued them (IEEE 1800-2023 20.10). A report in an action
+//! block of an assertion names that assertion (16.3).
+use celox::{
+ AssertionDeferral, AssertionDirective, AssertionOutcome, AssertionSite, Report, ReportLocation,
+ Severity,
+};
+use std::path::Path;
+
+/// A report of `reports.sv` without a time.
+fn report(
+ severity: Severity,
+ message: &str,
+ line: usize,
+ assertion: Option<(Option<&str>, AssertionDirective, AssertionOutcome)>,
+) -> Report {
+ Report {
+ severity,
+ message: message.as_bytes().to_vec(),
+ time: None,
+ scope: Some("Top".to_owned()),
+ location: Some(ReportLocation {
+ file: "reports.sv".to_owned(),
+ line,
+ }),
+ assertion: assertion.map(|(label, directive, outcome)| AssertionSite {
+ label: label.map(str::to_owned),
+ directive,
+ deferral: AssertionDeferral::None,
+ outcome,
+ }),
+ }
+}
+
+macro_rules! reports {
+ ($module:ident, $backend:ident) => {
+ mod $module {
+ use super::*;
+
+ /// The reports of `body` in `module Top` until time 1.
+ fn reports(body: &str) -> Vec {
+ let source = format!("`timescale 1ns/1ns\nmodule Top;\n{body}\nendmodule");
+ let mut sim = celox::Simulation::from_sv_sources(
+ vec![(source.as_str(), Path::new("reports.sv"))],
+ "Top",
+ )
+ .$backend()
+ .unwrap();
+ sim.run_until(1).unwrap();
+ sim.drain_runtime_events()
+ .into_iter()
+ .filter_map(|event| match event {
+ celox::RuntimeEvent::Report(report) => Some(report),
+ _ => None,
+ })
+ .collect()
+ }
+
+ #[test]
+ fn severity_tasks_report_their_severity_location_and_scope() {
+ assert_eq!(
+ reports(
+ " initial begin\n \
+ #1;\n \
+ $info(\"i %0d\", 1);\n \
+ $warning(\"w\");\n \
+ $error(\"e\");\n \
+ end"
+ ),
+ vec![
+ report(Severity::Info, "i 1", 5, None),
+ report(Severity::Warning, "w", 6, None),
+ report(Severity::Error, "e", 7, None),
+ ]
+ );
+ }
+
+ #[test]
+ fn action_blocks_report_their_assertion() {
+ use AssertionDirective::{Assert, Assume, Cover};
+ use AssertionOutcome::{Fail, Pass};
+ assert_eq!(
+ reports(
+ " bit a;\n \
+ initial begin\n \
+ #1;\n \
+ a1: assert (a) else $warning(\"a low\");\n \
+ a2: assert (a);\n \
+ c1: cover (!a) $info(\"covered\");\n \
+ assume (!a) $info(\"assumed\");\n \
+ end"
+ ),
+ vec![
+ report(
+ Severity::Warning,
+ "a low",
+ 6,
+ Some((Some("a1"), Assert, Fail))
+ ),
+ report(
+ Severity::Error,
+ "assert failed",
+ 7,
+ Some((Some("a2"), Assert, Fail))
+ ),
+ report(
+ Severity::Info,
+ "covered",
+ 8,
+ Some((Some("c1"), Cover, Pass))
+ ),
+ report(Severity::Info, "assumed", 9, Some((None, Assume, Pass))),
+ ]
+ );
+ }
+
+ /// A report of an assertion in the action block of another
+ /// names the inner one.
+ #[test]
+ fn nested_assertions_keep_their_attribution() {
+ use AssertionDirective::Assert;
+ use AssertionOutcome::Fail;
+ assert_eq!(
+ reports(
+ " bit a;\n \
+ initial begin\n \
+ #1;\n \
+ outer: assert (1) begin\n \
+ inner: assert (a);\n \
+ end\n \
+ end"
+ ),
+ vec![report(
+ Severity::Error,
+ "assert failed",
+ 7,
+ Some((Some("inner"), Assert, Fail))
+ )]
+ );
+ }
+
+ #[test]
+ fn always_comb_reports_keep_their_location() {
+ assert_eq!(
+ reports(" bit a;\n always_comb if (!a) $warning(\"low\");"),
+ vec![report(Severity::Warning, "low", 4, None)]
+ );
+ }
+
+ #[test]
+ fn line_directives_set_the_reported_location() {
+ let reports = reports("`line 40 \"other.sv\" 0\n initial $info(\"moved\");");
+ assert_eq!(
+ reports[0].location,
+ Some(ReportLocation {
+ file: "other.sv".to_owned(),
+ line: 40,
+ })
+ );
+ }
+ }
+ };
+}
+
+reports!(interpreter, build_interpreter);
+reports!(cranelift, build);
+#[cfg(target_arch = "x86_64")]
+reports!(native, build_native);
+reports!(wasm, build_wasm);
+
+#[test]
+fn reports_render_their_location_time_and_scope() {
+ let mut report = report(
+ Severity::Warning,
+ "a low",
+ 6,
+ Some((
+ Some("a1"),
+ AssertionDirective::Assert,
+ AssertionOutcome::Fail,
+ )),
+ );
+ report.time = Some(10);
+ assert_eq!(
+ String::from_utf8(report.render()).unwrap(),
+ "Warning: reports.sv:6: a low\n Time: 10 Scope: Top.a1"
+ );
+ assert_eq!(
+ String::from_utf8(Report::new(Severity::Info, b"bare".to_vec()).render()).unwrap(),
+ "Info: bare"
+ );
+}
diff --git a/crates/celox/tests/sv_update_events.rs b/crates/celox/tests/sv_update_events.rs
index ff14803b6bd..c55243ad908 100644
--- a/crates/celox/tests/sv_update_events.rs
+++ b/crates/celox/tests/sv_update_events.rs
@@ -51,7 +51,7 @@ macro_rules! update_events {
sim.run_until(time).unwrap();
sim.drain_runtime_events()
.into_iter()
- .filter(|event| matches!(event, celox::RuntimeEvent::AssertContinue { .. }))
+ .filter(|event| matches!(event, celox::RuntimeEvent::Report(_)))
.count()
}
diff --git a/docs/guide/systemverilog-reference.md b/docs/guide/systemverilog-reference.md
index 4e45062ed5c..f441828deee 100644
--- a/docs/guide/systemverilog-reference.md
+++ b/docs/guide/systemverilog-reference.md
@@ -553,6 +553,21 @@ Immediate cover executes its pass statement when the condition is true.
Coverage counters and reports are not exposed. Deferred cover (`#0` / `final`)
is rejected because its scheduling is not modeled.
+### Severity tasks and reports
+
+`$info`, `$warning`, `$error` and `$fatal`, including the default `$error` of
+an `assert` or `assume` without a fail action, are reported as
+`RuntimeEvent::Report` (IEEE 1800-2023 20.10). A `Report` carries its
+severity, its message, the file and line of the call as `` `__FILE__ `` and
+`` `__LINE__ `` give them, and the scope that issued it. A report from an
+action block of an immediate assertion also names that assertion: its
+statement label, `assert`, `assume` or `cover`, and whether the pass or the
+fail action issued it. Severity tasks in subroutines the action block calls
+are not attributed. `time` is the time the drain's context gives, as the VPI
+host does at each callback. `Report::render` formats a report as the VPI host
+and the `celox` command print it. Only `$error` and `$fatal` fail a `celox`
+run; `$fatal` also ends the simulation with an error.
+
### Constant functions
Constant functions ignore the display and severity tasks they call.
diff --git a/docs/guide/writing-tests.md b/docs/guide/writing-tests.md
index d82a68852e3..141bb6de910 100644
--- a/docs/guide/writing-tests.md
+++ b/docs/guide/writing-tests.md
@@ -299,7 +299,7 @@ const sim = Simulator.fromSource(SOURCE, "Adder", {
### HDL output bytes
-Rust runtime events (`RuntimeEvent::{Display, Write, AssertContinue, AssertFatal}`)
+Rust runtime events (`RuntimeEvent::{Display, Write}` and the `message` of `RuntimeEvent::Report`)
and detailed testbench assertion messages return `Vec`. JavaScript
`runTest`, `runTestFromProject`, and `runTestWithFrontendArtifact` return
assertion messages as `Uint8Array`. `%s` and `%c` may contain non-UTF-8 bytes or
diff --git a/docs/ja/guide/systemverilog-reference.md b/docs/ja/guide/systemverilog-reference.md
index 29a9a0e11d3..f68584a0e39 100644
--- a/docs/ja/guide/systemverilog-reference.md
+++ b/docs/ja/guide/systemverilog-reference.md
@@ -380,6 +380,18 @@ static な output 引数も、代入しない経路では以前の値を保持
文として呼び出したシステム関数(`$countones(f(a));` など)は、式の中の同じ呼び出しと
同様に検査・評価し、値を捨てます。`$bits` と `$size` は被演算子を評価しません。
+### 重大度タスクと報告
+
+`$info`、`$warning`、`$error`、`$fatal`は、fail アクションのない `assert` / `assume` の既定の
+`$error` も含めて、`RuntimeEvent::Report` として報告します(IEEE 1800-2023 20.10)。`Report`
+は重大度、メッセージ、`` `__FILE__ `` と `` `__LINE__ `` が示す呼び出しのファイルと行、報告した
+スコープを持ちます。即時アサーションのアクションブロックからの報告は、そのアサーションも示します。
+文ラベル、`assert` / `assume` / `cover` の別、pass と fail のどちらのアクションから出たかです。
+アクションブロックが呼ぶサブルーチン内の重大度タスクは、アサーションに結び付けません。`time` は
+drain のコンテキストが与える時刻で、VPI ホストはコールバックごとに与えます。`Report::render` は、
+VPI ホストと `celox` コマンドが表示する形に整形します。`celox` の実行を失敗にするのは `$error` と
+`$fatal` だけで、`$fatal` はさらにシミュレーションをエラーで終了します。
+
### 定数関数
定数関数は、呼び出す表示タスクと重大度タスクを無視します。
diff --git a/docs/ja/guide/writing-tests.md b/docs/ja/guide/writing-tests.md
index 19b1c132a27..42b3607e8e1 100644
--- a/docs/ja/guide/writing-tests.md
+++ b/docs/ja/guide/writing-tests.md
@@ -261,7 +261,7 @@ const sim = Simulator.fromSource(SOURCE, "Adder", {
### HDL出力のバイト列
-Rustの`RuntimeEvent::{Display, Write, AssertContinue, AssertFatal}`と詳細テスト結果の
+Rustの`RuntimeEvent::{Display, Write}`と`RuntimeEvent::Report`の`message`、詳細テスト結果の
assertionメッセージは`Vec`を返します。JavaScriptの`runTest`、
`runTestFromProject`、`runTestWithFrontendArtifact`では`Uint8Array`です。
`%s`と`%c`には非UTF-8やNULが含まれるため、暗黙のデコードは行いません。
diff --git a/lydite/conformance/veryl-proof/README.md b/lydite/conformance/veryl-proof/README.md
index d7dec4c7c86..d9665db5f42 100644
--- a/lydite/conformance/veryl-proof/README.md
+++ b/lydite/conformance/veryl-proof/README.md
@@ -74,8 +74,9 @@ run-status artifact.
Clock payloads and masks are proved unique before selecting an edge;
four-state edges follow IEEE 1800-2023 Table 9-2, including async resets.
General waveform timing outside the Backend's named-event API is not claimed.
- Display/Write/AssertContinue arguments are proved and logged; console delivery
- is outside this Backend API. Activated fatal events fail closed.
+ Display/Write arguments and those of reports below Fatal (assertion messages)
+ are proved and logged; console delivery is outside this Backend API. Activated
+ fatal events fail closed.
6. SSA compaction is allowed only for pure definition relations, after feasibility
and joint uniqueness of every active definition. Extra relational assumptions
prevent compaction; nonunique free variables remain symbolic. Saved snapshots
diff --git a/lydite/conformance/veryl-proof/proof_backend.py b/lydite/conformance/veryl-proof/proof_backend.py
index e0925a5833d..5684d05c8e1 100644
--- a/lydite/conformance/veryl-proof/proof_backend.py
+++ b/lydite/conformance/veryl-proof/proof_backend.py
@@ -412,7 +412,9 @@ def runtime_event(self,operation,args,regs,masks=None):
for site in sites:
if site>=len(metadata):raise Unsupported('missing runtime-event metadata')
kind=metadata[site]['kind']
- if kind not in ('Display','Write','AssertContinue'):
+ # A report other than Fatal ({'Report':'Error'} for an assertion) does not end the simulation.
+ nonfatal=kind in ('Display','Write') or (isinstance(kind,dict) and kind.get('Report') in ('Info','Warning','Error'))
+ if not nonfatal:
raise Unsupported('fatal runtime-event activation requires explicit observer semantics')
if args.get('fatal_error_code') is not None:raise Unsupported('fatal comb capture outside current event model')
values=[]
diff --git a/lydite/conformance/veryl-proof/tests/test_events.py b/lydite/conformance/veryl-proof/tests/test_events.py
index 4176447ee20..285cdb5ecff 100644
--- a/lydite/conformance/veryl-proof/tests/test_events.py
+++ b/lydite/conformance/veryl-proof/tests/test_events.py
@@ -23,6 +23,19 @@ def test_untyped_event_fails_closed(self):
with self.assertRaisesRegex(Unsupported, 'no edge kind'):
backend.event_edge('event', 0, 1)
+ def test_only_nonfatal_runtime_events_are_observed(self):
+ backend = Backend.__new__(Backend)
+ backend.event_log = []
+ for kind in ['Display', 'Write', {'Report': 'Info'}, {'Report': 'Warning'}, {'Report': 'Error'}]:
+ with self.subTest(kind=kind):
+ backend.code = {'runtime_event_sites': [{'kind': kind}]}
+ backend.runtime_event('RuntimeEvent', {'site_id': 0}, {})
+ for kind in [{'Report': 'Fatal'}, 'Finish', 'Stop']:
+ with self.subTest(kind=kind):
+ backend.code = {'runtime_event_sites': [{'kind': kind}]}
+ with self.assertRaisesRegex(Unsupported, 'fatal runtime-event activation'):
+ backend.runtime_event('RuntimeEvent', {'site_id': 0}, {})
+
if __name__ == '__main__':
unittest.main()
diff --git a/scripts/ci-rust-reports.mjs b/scripts/ci-rust-reports.mjs
index ddfb851c8ee..3eb072ba73a 100644
--- a/scripts/ci-rust-reports.mjs
+++ b/scripts/ci-rust-reports.mjs
@@ -15,12 +15,12 @@ export function resetReports(directory, source = currentReport(process.cwd())) {
clearCurrentReport(source);
if (!existsSync(directory)) return;
for (const name of readdirSync(directory)) {
- if (/^nextest-(?:full|\d+)\.xml$/.test(name)) rmSync(resolve(directory, name));
+ if (/^nextest-(?:full|cocotb-\d+|\d+)\.xml$/.test(name)) rmSync(resolve(directory, name));
}
}
export function saveCurrentReport(directory, name, source = currentReport(process.cwd())) {
- if (!/^(?:full|\d+)$/.test(name)) throw new Error("Invalid Rust report name");
+ if (!/^(?:full|cocotb-\d+|\d+)$/.test(name)) throw new Error("Invalid Rust report name");
// A build failure or an empty selection may produce no report. Keep the
// Cargo exit status and any earlier reports; never reuse a previous result.
if (!existsSync(source)) return;
diff --git a/scripts/ci-rust-reports.test.mjs b/scripts/ci-rust-reports.test.mjs
index e0ef8709eef..63cc287a2d5 100644
--- a/scripts/ci-rust-reports.test.mjs
+++ b/scripts/ci-rust-reports.test.mjs
@@ -34,7 +34,7 @@ test("initialization removes only this job's stale reports and creates no target
resetReports(directory, source);
assert.ok(!existsSync(directory));
mkdirSync(directory);
- for (const name of ["nextest-full.xml", "nextest-0.xml", "unrelated.xml"])
+ for (const name of ["nextest-full.xml", "nextest-0.xml", "nextest-cocotb-0.xml", "unrelated.xml"])
writeFileSync(join(directory, name), "old");
writeFileSync(source, "old");
resetReports(directory, source);
@@ -49,3 +49,13 @@ test("full runs use a stable report name and reject invalid paths", (t) => {
assert.ok(existsSync(source));
assert.equal(saveCurrentReport(directory, "full", source), join(directory, "nextest-full.xml"));
});
+
+test("cocotb reports do not overwrite normal test reports", (t) => {
+ const { source, directory } = fixture(t);
+ writeFileSync(source, "normal");
+ saveCurrentReport(directory, "full", source);
+ writeFileSync(source, "cocotb failure");
+ saveCurrentReport(directory, "cocotb-0", source);
+ assert.equal(readFileSync(join(directory, "nextest-full.xml"), "utf8"), "normal");
+ assert.equal(readFileSync(join(directory, "nextest-cocotb-0.xml"), "utf8"), "cocotb failure");
+});
diff --git a/scripts/ci-workflow.test.mjs b/scripts/ci-workflow.test.mjs
index ed9ff3e9e7c..f9122c8d15c 100644
--- a/scripts/ci-workflow.test.mjs
+++ b/scripts/ci-workflow.test.mjs
@@ -23,7 +23,7 @@ test("the required gate rejects failures and only accepts explicitly optional sk
assert.match(gate, /if: \$\{\{ !cancelled\(\)/);
assert.match(
gate,
- /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\]/,
);
assert.match(
gate,
@@ -39,6 +39,8 @@ test("the required gate rejects failures and only accepts explicitly optional sk
CHANGES_RESULT: "success",
RUST_REQUIRED: "true",
RUST_RESULT: "success",
+ DEFAULT_REQUIRED: "true",
+ DEFAULT_RESULT: "success",
SV_TESTS_REQUIRED: "true",
SV_TESTS_RESULT: "success",
ARM64_REQUIRED: "true",
@@ -50,6 +52,9 @@ test("the required gate rejects failures and only accepts explicitly optional sk
EXTERNAL_RESULT: "skipped",
};
const cases = [
+ { env: { ...success, DEFAULT_REQUIRED: "false", DEFAULT_RESULT: "skipped" }, passes: true },
+ { env: { ...success, DEFAULT_REQUIRED: "", DEFAULT_RESULT: "skipped" }, passes: false },
+ { env: { ...success, DEFAULT_REQUIRED: "false", DEFAULT_RESULT: "failure" }, passes: false },
{
env: { ...success, RUST_REQUIRED: "", RUST_RESULT: "skipped" },
passes: false,
@@ -69,6 +74,7 @@ test("the required gate rejects failures and only accepts explicitly optional sk
for (const producer of [
"CHANGES_RESULT",
"RUST_RESULT",
+ "DEFAULT_RESULT",
"SV_TESTS_RESULT",
"ARM64_RESULT",
"NATIVE_RESULT",
@@ -358,7 +364,7 @@ test("PR caches cannot evict the shared default-branch Rust caches", () => {
/ - uses: Swatinem\/rust-cache@v2\n([\s\S]*?)(?=\n -|\n [a-z]|$)/g,
),
];
- assert.equal(cacheSteps.length, 9);
+ assert.equal(cacheSteps.length, 10);
for (const [, step] of cacheSteps) {
assert.match(
step,
@@ -378,7 +384,7 @@ test("cache warming shares the Rust Tests key and builds without running tests",
assert.match(warm, /cancel-in-progress: false/);
assert.doesNotMatch(
warm,
- /pull_request:|cargo nextest run|cargo test|shared-key:/,
+ /pull_request:|cargo nextest run|shared-key:/,
);
assert.match(warm, /steps.cache.outputs.cache-hit != 'true'/);
for (const text of [warm, job("rust-tests")]) {
@@ -389,7 +395,7 @@ test("cache warming shares the Rust Tests key and builds without running tests",
assert.match(warm, /"scripts\/run-vtest.mjs"/);
assert.match(
warm,
- /cargo nextest list --locked --workspace --message-format json/,
+ /cargo nextest list --locked --workspace --exclude 'lydite\*' --message-format json/,
);
const features = job("rust-tests").match(/--features (\S+)/)[1];
assert.ok(warm.includes(`--features ${features}`));
@@ -492,13 +498,55 @@ test("scoped checks preserve full-run fallbacks and use their own package scopes
assert.match(lint, /name: Build the API documentation this pull request can affect\n if: .*outputs\.rust_doc_libraries != ''/);
});
-test("cocotb retains Celox features without enabling unrelated adapter features", () => {
+test("cocotb reuses the original scoped Cargo build", () => {
+ const builds = [{ packages: ["celox", "celox-vpi", "celox-test-suite"], targets: [],
+ features: ["celox/systemverilog", "celox-test-suite/icarus"] }];
const args = cargoArguments("rust-tests", "Run cocotb VPI end-to-end test", {
- FEATURES: "celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus",
+ RUST_FULL: "false", BUILDS: JSON.stringify(builds),
});
- assert.deepEqual(args, ["test", "--locked", "-p", "celox-vpi", "--features", "systemverilog", "--features", "celox/systemverilog", "--test", "cocotb_e2e",
- "cocotb_", "--", "--ignored"]);
- assert.match(job("rust-tests"), /name: Run cocotb VPI end-to-end test\n if: needs.changes.outputs.rust_vpi_e2e != 'false'/);
+ assert.deepEqual(args, ["nextest", "run", "--locked", "--profile", "ci",
+ "-p", "celox", "-p", "celox-vpi", "-p", "celox-test-suite", "--features",
+ "celox/systemverilog,celox-test-suite/icarus,celox-test-suite/runtime-cases",
+ "-E", 'binary_id(celox-vpi::cocotb_e2e) & test(/^cocotb_/)', "--run-ignored", "only"]);
+});
+
+test("full cocotb runs reuse the workspace build and report failures before upload", () => {
+ const rust = job("rust-tests");
+ const full = rust.match(/run: >-\n\s+(cargo nextest run[^\n]*)\n\s+(--features [^\n]*)/);
+ assert.ok(full);
+ const original = `${full[1]} ${full[2]}`.replaceAll("'", "").split(/\s+/).slice(1);
+ const args = cargoArguments("rust-tests", "Run cocotb VPI end-to-end test", { RUST_FULL: "true" });
+ assert.deepEqual(args.slice(0, -4), original);
+ assert.ok(rust.indexOf("Collect Rust test reports") < rust.indexOf("Run cocotb VPI end-to-end test"));
+ assert.ok(rust.indexOf("Run cocotb VPI end-to-end test") < rust.indexOf("Retain Rust test reports"));
+ assert.match(rust, /test_step_outcome: .*steps.cocotb-tests.outcome == 'failure' && 'failure'/);
+});
+
+test("default-feature validation is parallel and mandatory when selected", () => {
+ const defaults = job("rust-default-tests");
+ assert.match(defaults, /needs: changes/);
+ assert.match(defaults, /needs.changes.result != 'success'/);
+ assert.match(defaults, /outputs.rust_full != 'false'/);
+ assert.match(defaults, /outputs.rust_libraries/);
+ assert.match(defaults, /cargo test --locked -p celox --lib/);
+ assert.match(defaults, /cargo test --locked -p celox --doc/);
+ assert.doesNotMatch(defaults, /--features|--no-default-features/);
+ assert.doesNotMatch(job("rust-tests"), /cargo test --locked -p celox --lib/);
+ assert.match(job("rust"), /DEFAULT_RESULT: .*needs.rust-default-tests.result/);
+ assert.match(job("report-full-validation"), /rust-default-tests,/);
+});
+
+test("CI retains the normal test profile and warms each platform's cache", () => {
+ const rust = job("rust-tests");
+ assert.doesNotMatch(rust, /--cargo-profile/);
+ assert.match(rust, /cargo test --locked --workspace/);
+ const warm = readFileSync(new URL("../.github/workflows/rust-cache.yml", import.meta.url), "utf8");
+ const windows = warm.split(" napi-windows:")[1];
+ assert.match(windows, /runs-on: windows-latest/);
+ assert.match(windows, /run: pnpm run build:napi/);
+ assert.match(windows, /steps.cache.outputs.cache-hit != 'true'/);
+ assert.match(windows, /if: github.ref == format/);
+ assert.match(warm, /rust-default-tests:[\s\S]*cargo test --locked -p celox --lib --no-run/);
});
test("full Clippy validation covers every workspace crate", () => {
diff --git a/scripts/run-ci-cocotb.mjs b/scripts/run-ci-cocotb.mjs
new file mode 100644
index 00000000000..30765f798c0
--- /dev/null
+++ b/scripts/run-ci-cocotb.mjs
@@ -0,0 +1,39 @@
+import { spawnSync } from "node:child_process";
+import { pathToFileURL } from "node:url";
+import { clearCurrentReport, saveCurrentReport } from "./ci-rust-reports.mjs";
+import { cargoCommands } from "./run-ci-rust-scope.mjs";
+
+export const cocotbFilter = 'binary_id(celox-vpi::cocotb_e2e) & test(/^cocotb_/)';
+
+// Keep exactly the original packages, features, targets and Cargo profile.
+// Narrowing -p to celox-vpi would resolve a different dependency feature graph.
+export function cocotbCommands(full, builds) {
+ if (full !== "false") return [[
+ "nextest", "run", "--locked", "--workspace", "--exclude", "lydite*",
+ "--profile", "ci",
+ "--features", "celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/runtime-cases",
+ "--run-ignored", "only", "-E", cocotbFilter,
+ ]];
+ // Validate all plans first, including ones we do not need to execute.
+ const commands = cargoCommands("test", builds, cocotbFilter);
+ const selected = commands.filter((_, i) => builds[i].packages.includes("celox-vpi")
+ && (!builds[i].targets.length || builds[i].targets.includes("cocotb_e2e")));
+ if (!selected.length) throw new Error("Cocotb CI requires a VPI test build");
+ return selected.map(args => [
+ ...args.filter(arg => arg !== "--no-tests=pass"), "--run-ignored", "only",
+ ]);
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ if (!process.env.CELOX_COCOTB_PYTHON) throw new Error("Cocotb Python interpreter is required");
+ let reportIndex = 0;
+ for (const args of cocotbCommands(process.env.RUST_FULL,
+ process.env.RUST_FULL === "false" ? JSON.parse(process.env.BUILDS) : null)) {
+ if (process.env.CELOX_CI_REPORT_DIR) clearCurrentReport();
+ const result = spawnSync("cargo", args, { stdio: "inherit" });
+ if (process.env.CELOX_CI_REPORT_DIR)
+ saveCurrentReport(process.env.CELOX_CI_REPORT_DIR, `cocotb-${reportIndex++}`);
+ if (result.error) throw result.error;
+ if (result.status !== 0) process.exit(result.status ?? 1);
+ }
+}
diff --git a/scripts/run-ci-cocotb.test.mjs b/scripts/run-ci-cocotb.test.mjs
new file mode 100644
index 00000000000..a53a46060d6
--- /dev/null
+++ b/scripts/run-ci-cocotb.test.mjs
@@ -0,0 +1,57 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { spawnSync } from "node:child_process";
+import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { cocotbCommands, cocotbFilter } from "./run-ci-cocotb.mjs";
+import { cargoCommands } from "./run-ci-rust-scope.mjs";
+
+test("cocotb preserves build resolution and selects only its ignored tests", () => {
+ const builds = [
+ { packages: ["celox-heap"], targets: [], features: [] },
+ { packages: ["celox", "celox-vpi"], targets: [], features: ["celox/systemverilog"] },
+ ];
+ const original = structuredClone(builds);
+ const expected = cargoCommands("test", builds, cocotbFilter)[1]
+ .filter(arg => arg !== "--no-tests=pass");
+ assert.deepEqual(cocotbCommands("false", builds), [[...expected, "--run-ignored", "only"]]);
+ assert.deepEqual(builds, original);
+ for (const full of ["true", "", undefined]) {
+ const [args] = cocotbCommands(full, null);
+ assert.ok(args.includes("--workspace"));
+ assert.ok(!args.includes("--cargo-profile"));
+ assert.ok(!args.includes("--no-tests=pass"));
+ assert.deepEqual(args.slice(-4), ["--run-ignored", "only", "-E", cocotbFilter]);
+ }
+});
+
+test("missing or wrong VPI targets fail closed", () => {
+ for (const builds of [[], [{ packages: ["celox"], targets: [], features: [] }],
+ [{ packages: ["celox-vpi"], targets: ["other_test"], features: [] }]])
+ assert.throws(() => cocotbCommands("false", builds));
+ const [args] = cocotbCommands("false", [{ packages: ["celox-vpi"], targets: ["cocotb_e2e"], features: [] }]);
+ assert.equal(args[args.indexOf("--test") + 1], "cocotb_e2e");
+});
+
+test("cocotb requires Python and propagates Cargo failures without running later plans", () => {
+ const directory = mkdtempSync(join(tmpdir(), "celox-cocotb-command-"));
+ try {
+ const executable = join(directory, "cargo");
+ const log = join(directory, "calls");
+ writeFileSync(executable, '#!/bin/sh\necho called >> "$COCOTB_CALL_LOG"\nexit 17\n');
+ chmodSync(executable, 0o755);
+ const build = { packages: ["celox-vpi"], targets: [], features: [] };
+ const env = { ...process.env, RUST_FULL: "false", BUILDS: JSON.stringify([build, build]),
+ PATH: `${directory}:${process.env.PATH}`, COCOTB_CALL_LOG: log,
+ CELOX_CI_REPORT_DIR: "", CELOX_COCOTB_PYTHON: "" };
+ const missing = spawnSync(process.execPath, ["scripts/run-ci-cocotb.mjs"], { env, encoding: "utf8" });
+ assert.notEqual(missing.status, 0);
+ assert.match(missing.stderr, /Python interpreter is required/);
+ const failed = spawnSync(process.execPath, ["scripts/run-ci-cocotb.mjs"], {
+ env: { ...env, CELOX_COCOTB_PYTHON: "/test/python" }, encoding: "utf8",
+ });
+ assert.equal(failed.status, 17);
+ assert.equal(readFileSync(log, "utf8"), "called\n");
+ } finally { rmSync(directory, { recursive: true, force: true }); }
+});