diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5a4a262d569..86607a1b55e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -149,7 +149,7 @@ jobs:
- name: cargo clippy
if: (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') && needs.changes.outputs.rust_full != 'false'
- run: cargo clippy --locked --workspace --exclude lydite-celox --all-targets --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus --no-deps
+ run: cargo clippy --locked --workspace --exclude lydite-celox --all-targets --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/xezim --no-deps
- name: Lint the crates this pull request can affect
if: needs.changes.outputs.rust_full == 'false' && needs.changes.outputs.rust_lint_packages != ''
@@ -259,7 +259,7 @@ jobs:
if: needs.changes.outputs.rust_full != 'false'
run: >-
cargo nextest run --locked --workspace --exclude 'lydite*' --profile ci
- --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/runtime-cases
+ --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/xezim,celox-test-suite/runtime-cases
- name: Run the tests this pull request can affect
id: scoped-tests
@@ -305,7 +305,7 @@ jobs:
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,celox-test-suite/runtime-cases
+ --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/xezim,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 != ''
@@ -348,9 +348,11 @@ jobs:
fail-fast: false
matrix:
suite: [veryl, sv]
- tool: [verilator, icarus]
+ tool: [verilator, icarus, xezim]
env:
VERIFY_TOOL: ${{ matrix.tool }}
+ # xezim builds from source, so only its jobs enter the shell with it.
+ VERIFY_SHELL: ${{ matrix.tool == 'xezim' && '.#xezim' || '.' }}
VERIFY_SUITE: ${{ matrix.suite }}
VERIFY_BIN: ${{ matrix.suite == 'sv' && format('verify-sv-{0}', matrix.tool) || format('verify-{0}', matrix.tool) }}
VERIFY_BASELINE: ${{ matrix.suite == 'sv' && format('crates/celox-test-suite/verification/sv/{0}.json', matrix.tool) || format('crates/celox-test-suite/verification/{0}.json', matrix.tool) }}
@@ -366,7 +368,7 @@ jobs:
- name: Test live simulator adapters
if: matrix.suite == 'veryl'
run: >-
- nix develop --no-update-lock-file --command
+ nix develop "$VERIFY_SHELL" --no-update-lock-file --command
cargo test --locked -p celox-test-suite --features "$VERIFY_TOOL"
--test oracles -- --ignored
@@ -374,7 +376,7 @@ jobs:
if: ${{ !cancelled() }}
run: |
mkdir -p "$RUNNER_TEMP/external-suite"
- nix develop --no-update-lock-file --command \
+ nix develop "$VERIFY_SHELL" --no-update-lock-file --command \
cargo run --locked -p celox-test-suite --features "$VERIFY_TOOL" \
--bin "$VERIFY_BIN" -- --list > "$RUNNER_TEMP/external-suite/catalogue.json"
@@ -385,7 +387,7 @@ jobs:
# The runner returns 1 for retained failures as well as regressions.
# The next step checks the complete fresh report and the exit status.
rm -f "$RUNNER_TEMP/external-suite/logs/results.json"
- if nix develop --no-update-lock-file --command \
+ if nix develop "$VERIFY_SHELL" --no-update-lock-file --command \
cargo run --locked -p celox-test-suite --features "$VERIFY_TOOL" \
--bin "$VERIFY_BIN" -- --fresh --jobs 2 \
--output "$RUNNER_TEMP/external-suite/logs"; then
@@ -400,7 +402,7 @@ jobs:
env:
VERIFY_EXIT_STATUS: ${{ steps.verify.outputs.exit_status }}
run: >-
- nix develop --no-update-lock-file --command
+ nix develop "$VERIFY_SHELL" --no-update-lock-file --command
node scripts/check-external-suite-report.mjs
"$RUNNER_TEMP/external-suite/logs/results.json" "$VERIFY_BASELINE"
"$RUNNER_TEMP/external-suite/catalogue.json" "$VERIFY_EXIT_STATUS" "$VERIFY_SUITE"
diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml
index c7afb638c3f..a5509aebf40 100644
--- a/.github/workflows/codspeed.yml
+++ b/.github/workflows/codspeed.yml
@@ -4,6 +4,11 @@ on:
schedule:
- cron: "17 2 * * *"
workflow_dispatch:
+ inputs:
+ runner_probe:
+ description: Check Macro Runner availability without building or benchmarking
+ type: boolean
+ default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -16,9 +21,20 @@ env:
permissions: {}
jobs:
+ runner-probe:
+ name: Probe CodSpeed runner
+ if: github.event_name == 'workflow_dispatch' && inputs.runner_probe
+ runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04
+ timeout-minutes: 2
+ steps:
+ - name: Verify the ARM64 runner is available
+ run: test "$(uname -m)" = aarch64
+
codspeed:
name: CodSpeed
- runs-on: ubuntu-latest
+ if: inputs.runner_probe != true
+ timeout-minutes: 60
+ runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04
outputs:
run-id: ${{ steps.benchmarks.outputs.run-id }}
permissions:
@@ -39,19 +55,20 @@ jobs:
tool: cargo-codspeed@5.0.1
- name: Build compile-time benchmarks
- run: cargo codspeed build --locked -p celox --bench compilation
+ run: cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation
- name: Run compile-time benchmarks
id: benchmarks
+ timeout-minutes: 15
uses: CodSpeedHQ/action@v5
with:
- mode: simulation
- run: cargo codspeed run -p celox
+ mode: walltime
+ run: cargo codspeed run --measurement-mode walltime -p celox --bench compilation
report:
name: Report CodSpeed
needs: codspeed
- if: always() && (github.ref_name == 'master' || github.ref_name == 'develop')
+ if: always() && inputs.runner_probe != true && (github.ref_name == 'master' || github.ref_name == 'develop')
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml
index 33fdcdb80c7..5bd5f9becc4 100644
--- a/.github/workflows/rust-cache.yml
+++ b/.github/workflows/rust-cache.yml
@@ -54,7 +54,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: >-
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
+ --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus,celox-test-suite/xezim,celox-test-suite/runtime-cases
> /dev/null
rust-default-tests:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9477d10ea5b..4a0f4e9c930 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -120,6 +120,12 @@ interpreter, native and Cranelift backends in both two-state and four-state mode
wide-value latch checks, and a small sorter compilation smoke test.
The 257/512-bit per-bit graph cases and sorter sizes 4/8/16/32 are measured by
`benches/compilation.rs` in the existing daily/manual CodSpeed workflow.
+Compilation benchmarks use CodSpeed walltime measurement on its ARM64 Graviton
+Macro Runner: CPU simulation made
+a single 512-bit case take tens of minutes. The benchmark step has a 15-minute
+timeout and the complete job a 60-minute limit; a timeout is reported as failure.
+The organization runner group must allow this public repository to use CodSpeed
+Macro Runners. Simulation and walltime measurements have separate baselines.
Nested-write benchmarks reuse the same semantic assertions as the small tests.
Scaling cases use one iteration without per-case warmups or adaptive sampling;
a small counter warms process-global analyzer state before measurement.
@@ -130,8 +136,8 @@ CodSpeed reporting workflow.
Build and run them with the same CodSpeed harness as CI:
```sh
-cargo codspeed build --locked -p celox --bench compilation
-cargo codspeed run -p celox
+cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation
+cargo codspeed run --measurement-mode walltime -p celox --bench compilation
```
## Finish validation
diff --git a/conformance/sv-tests/README.md b/conformance/sv-tests/README.md
index 54eb8ebdb3e..24dc1a681cb 100644
--- a/conformance/sv-tests/README.md
+++ b/conformance/sv-tests/README.md
@@ -206,6 +206,14 @@ the assertion. The [reviewed full CI run](https://github.com/celox-sim/celox/act
contains 2054 case/mode verdicts; these are the only two changed rows, and all
verdicts match the updated expectations.
+Accepting undriven nets updates both rows for
+`5.6.4--compiler-directives-pragma` from fail to pass. Its `protected_wire`
+has no driver and now elaborates with the standard net default (IEEE 1800-2023
+6.6 and 6.7.1). The official runner selects elaboration for this probe; runtime
+high-impedance values are checked by the shared undriven-net simulation cases.
+The [reviewed CI run](https://github.com/celox-sim/celox/actions/runs/40112270471)
+changes only these two verdicts across 2,054 mode runs.
+
The report contains each case’s state mode, verdict, selected execution mode,
tags, tool return code and path to the official log. The output directory retains
both the official log and runner diagnostics for each case and state mode.
diff --git a/conformance/sv-tests/expected.tsv b/conformance/sv-tests/expected.tsv
index 5d3d4d4fb63..f2c0fc7c47d 100644
--- a/conformance/sv-tests/expected.tsv
+++ b/conformance/sv-tests/expected.tsv
@@ -979,8 +979,8 @@ chapter-23/23.2--module-definition.sv 2state pass
chapter-23/23.2--module-definition.sv 4state pass
chapter-23/23.2--module-label.sv 2state pass
chapter-23/23.2--module-label.sv 4state pass
-chapter-24/24.3--program.sv 2state fail
-chapter-24/24.3--program.sv 4state fail
+chapter-24/24.3--program.sv 2state pass
+chapter-24/24.3--program.sv 4state pass
chapter-25/25.3-interface.sv 2state pass
chapter-25/25.3-interface.sv 4state pass
chapter-26/26.2--package-decl.sv 2state pass
@@ -1039,8 +1039,8 @@ chapter-5/5.6.4--compiler-directives-define.sv 2state pass
chapter-5/5.6.4--compiler-directives-define.sv 4state pass
chapter-5/5.6.4--compiler-directives-include.sv 2state pass
chapter-5/5.6.4--compiler-directives-include.sv 4state pass
-chapter-5/5.6.4--compiler-directives-pragma.sv 2state fail
-chapter-5/5.6.4--compiler-directives-pragma.sv 4state fail
+chapter-5/5.6.4--compiler-directives-pragma.sv 2state pass
+chapter-5/5.6.4--compiler-directives-pragma.sv 4state pass
chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 2state skip
chapter-5/5.6.4--compiler-directives-preprocessor-macro_0.sv 4state skip
chapter-5/5.6.4--compiler-directives-preprocessor-macro_1.sv 2state pass
diff --git a/crates/celox-design/src/lib.rs b/crates/celox-design/src/lib.rs
index 5e45cf13916..ac20aebb6cb 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,
@@ -291,6 +364,9 @@ pub enum ProcessStatus {
/// A synchronous host operation. The delay slot holds its family and
/// local site index; the same process resumes after the host responds.
HostRequest,
+ /// A program kernel called `$exit` (IEEE 1800-2023 24.7): it and every
+ /// other kernel of its program instance ([`ProcessSlots::program`]) end.
+ Exit,
}
impl ProcessStatus {
@@ -308,6 +384,7 @@ impl ProcessStatus {
Self::Yield => 8,
Self::Stop => 9,
Self::HostRequest => 10,
+ Self::Exit => 11,
}
}
@@ -323,6 +400,7 @@ impl ProcessStatus {
8 => Some(Self::Yield),
9 => Some(Self::Stop),
10 => Some(Self::HostRequest),
+ 11 => Some(Self::Exit),
_ => None,
}
}
@@ -465,6 +543,12 @@ pub struct ProcessSlots {
/// Every delay the kernel suspends for is a constant of at least one
/// time unit.
pub const_delays: bool,
+ /// For an `initial` procedure of a program instance (IEEE 1800-2023
+ /// 24.3), the status slot of that instance's first such kernel, which
+ /// every kernel of the instance names: the kernel runs in the reactive
+ /// region set (24.3.1), and `$exit` and the end of the instance's
+ /// kernels act on them together (24.7). `None` for design code.
+ pub program: Option,
pub resume: A,
pub status: A,
pub delay: A,
@@ -476,6 +560,7 @@ impl ProcessSlots {
is_initializer: self.is_initializer,
requires_timed_simulation: self.requires_timed_simulation,
const_delays: self.const_delays,
+ program: self.program.map(&mut map),
resume: map(self.resume),
status: map(self.status),
delay: map(self.delay),
@@ -1058,6 +1143,9 @@ pub struct SchedulerSchema {
/// The event signals a host periodic clock may drive inside the
/// scheduler's slots, in the order of its clock slots.
pub clocks: Vec,
+ /// Per process kernel, the event signals it writes, as indices into
+ /// [`Self::events`]; empty for a kernel the scheduler does not run.
+ pub kernel_events: Vec>,
}
impl SchedulerSchema {
@@ -1069,6 +1157,7 @@ impl SchedulerSchema {
fallback: self.fallback,
events: self.events.into_iter().map(&mut map).collect(),
clocks: self.clocks.into_iter().map(map).collect(),
+ kernel_events: self.kernel_events,
}
}
}
@@ -1791,6 +1880,7 @@ mod tests {
ProcessStatus::from_code(10),
Some(ProcessStatus::HostRequest)
);
+ assert_eq!(ProcessStatus::from_code(11), Some(ProcessStatus::Exit));
}
#[test]
@@ -1883,10 +1973,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/process.rs b/crates/celox-frontend-core/src/process.rs
index 1931a26203b..b141ad8d532 100644
--- a/crates/celox-frontend-core/src/process.rs
+++ b/crates/celox-frontend-core/src/process.rs
@@ -368,6 +368,13 @@ impl ProcessKernelBuilder {
self.end(ProcessStatus::Finish);
}
+ /// End the kernel and the other kernels of its program instance
+ /// (`$exit`, IEEE 1800-2023 24.7). No block is open afterwards.
+ pub fn exit(&mut self) {
+ self.wait_site = None;
+ self.end(ProcessStatus::Exit);
+ }
+
/// Complete the kernel. If a block is still open, the process ends there.
pub fn build(mut self) -> ExecutionUnit {
if self.builder.has_open_block() {
diff --git a/crates/celox-frontend-core/src/sdk.rs b/crates/celox-frontend-core/src/sdk.rs
index f74172ab2a4..18232d0b2a4 100644
--- a/crates/celox-frontend-core/src/sdk.rs
+++ b/crates/celox-frontend-core/src/sdk.rs
@@ -1732,6 +1732,7 @@ fn lower_processes(
is_initializer: false,
requires_timed_simulation: false,
const_delays: false,
+ program: None,
resume: lowering
.hidden
.declare(name("resume"), PROCESS_RESUME_WIDTH, false),
diff --git a/crates/celox-frontend-core/src/symbolic/assembly.rs b/crates/celox-frontend-core/src/symbolic/assembly.rs
index 7682ec5627d..8c11b502974 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
@@ -2072,6 +2072,7 @@ pub fn schedule_symbolic_rtl_reporting_loops(
fallback: Vec::new(),
events: Vec::new(),
clocks: Vec::new(),
+ kernel_events: Vec::new(),
});
// The runtime reads counters, the signals waits watch and staged
// nonblocking values directly; no unit loads a wait's signal.
@@ -4224,11 +4225,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 +4281,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..23720aafaee 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::{
@@ -592,19 +592,19 @@ fn validate_specialized_instance_net_drivers(
.signals()
.iter()
.filter(|signal| signal.is_net())
- .map(|signal| (signal.name(), true))
+ .map(|signal| signal.name())
.chain(
module
.source
.ports()
.iter()
.filter(|port| port.is_net())
- .map(|port| (port.name(), false)),
+ .map(|port| port.name()),
);
- for (signal_name, require_driver) in net_names {
+ for signal_name in net_names {
let child_driver_ranges =
child_output_driver_ranges(module, signal_name, module_ids, modules);
- validate_net_driver_ranges(module, signal_name, &child_driver_ranges, require_driver)?;
+ validate_net_driver_ranges(module, signal_name, &child_driver_ranges)?;
}
let variable_names = module
@@ -768,7 +768,6 @@ fn validate_net_driver_ranges(
module: &LoweredSvModule,
signal_name: &str,
child_driver_ranges: &[(usize, Option<(i128, i128)>)],
- require_driver: bool,
) -> Result<(), sv::AnalyzerError> {
let local_drivers = local_driver_ranges(
&module.source,
@@ -803,11 +802,6 @@ fn validate_net_driver_ranges(
"multiple net drivers for `{signal_name}`"
)));
}
- if require_driver && child_driver_ranges.is_empty() && local_drivers.is_empty() {
- return Err(sv::AnalyzerError::Unsupported(format!(
- "undriven net declaration `{signal_name}`"
- )));
- }
Ok(())
}
@@ -4457,8 +4451,10 @@ fn lower_initial_processes(
.copied()
.unwrap_or(0x4d59_5df4);
// An `always` process never finishes, so it is never folded into
- // initial state.
- if process.repeats() {
+ // initial state. A program's `initial` procedure runs in the reactive
+ // region set (IEEE 1800-2023 24.3.1), after the design's processes of
+ // time zero, so it is not folded either.
+ if process.repeats() || (module.is_program() && !process.is_initializer()) {
runtime.push((process, random_seed));
continue;
}
@@ -4503,7 +4499,7 @@ fn lower_initial_processes(
.max()
.unwrap_or_default(),
);
- let slots: Vec<_> = runtime
+ let mut slots: Vec<_> = runtime
.iter()
.enumerate()
.map(|(index, (process, _))| {
@@ -4537,12 +4533,28 @@ fn lower_initial_processes(
is_initializer: process.is_initializer(),
requires_timed_simulation: process.is_scheduled_edge(),
const_delays: false,
+ program: None,
resume: declare("resume", PROCESS_RESUME_WIDTH),
status: declare("status", PROCESS_STATUS_WIDTH),
delay: declare("delay", PROCESS_DELAY_WIDTH),
}
})
.collect();
+ // Every `initial` kernel of a program instance names the status slot of
+ // the first, the instance's identity for `$exit` and its end (IEEE
+ // 1800-2023 24.3, 24.7).
+ if module.is_program() {
+ let program = slots
+ .iter()
+ .zip(&runtime)
+ .find(|(_, (process, _))| !process.is_initializer())
+ .map(|(slots, _)| slots.status);
+ for (slots, (process, _)) in slots.iter_mut().zip(&runtime) {
+ if !process.is_initializer() {
+ slots.program = program;
+ }
+ }
+ }
// The kernels add their event sites, runtime errors and extern functions
// after those of the sequential processes. Their hidden variables are
// state the kernels keep.
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..649d4c6c6a1 100644
--- a/crates/celox-frontend-sv/src/lowering/ff.rs
+++ b/crates/celox-frontend-sv/src/lowering/ff.rs
@@ -957,6 +957,7 @@ impl<'p, 'a> Ff<'p, 'a> {
),
],
None,
+ None,
)?;
let (_, name) = self.m.temp("tagged_member", *width, *signed, true);
self.assign(&sv::ir::LValue::Ident(name.clone()), value)?;
@@ -2023,6 +2024,7 @@ impl<'p, 'a> Ff<'p, 'a> {
),
],
None,
+ None,
)?;
}
Ok(())
@@ -2990,9 +2992,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 +3008,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)?;
@@ -3059,9 +3065,14 @@ impl<'p, 'a> Ff<'p, 'a> {
}
return Ok(true);
}
- // IEEE 1800-2023 24.7: `$exit` outside a program block is ignored,
- // with a warning.
+ // IEEE 1800-2023 24.7: `$exit` in a thread of a program's `initial`
+ // procedure ends the program's initial procedures; elsewhere it is
+ // ignored, with a warning.
if task == sv::ir::SystemTask::Exit {
+ if self.m.program && self.kernel.is_some() {
+ self.with_kernel(ProcessKernelBuilder::exit);
+ return Ok(false);
+ }
self.m
.warn(crate::FrontendWarningKind::ExitOutsideProgram, site);
return Ok(true);
@@ -3161,18 +3172,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..242b4f53b89 100644
--- a/crates/celox-frontend-sv/src/lowering/procedural.rs
+++ b/crates/celox-frontend-sv/src/lowering/procedural.rs
@@ -53,6 +53,9 @@ pub(super) struct ProcModule<'a> {
/// Number of extern calls lowered so far.
pub extern_calls: usize,
pub four_state: bool,
+ /// The module is a program (IEEE 1800-2023 24.3): its kernels honour
+ /// `$exit` (24.7).
+ pub program: bool,
pub forceable: HashMap,
/// Hidden variables created while lowering, for the caller to publish.
pub created: Vec,
@@ -244,6 +247,7 @@ impl<'a> ProcModule<'a> {
extern_functions: Vec::new(),
extern_calls: 0,
four_state,
+ program: module.is_program(),
created: Vec::new(),
temp_counter: 0,
capture_counter: 0,
@@ -1232,7 +1236,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 +1246,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 +1278,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-sv/src/warning.rs b/crates/celox-frontend-sv/src/warning.rs
index 851b993d562..4d5752d35ce 100644
--- a/crates/celox-frontend-sv/src/warning.rs
+++ b/crates/celox-frontend-sv/src/warning.rs
@@ -57,8 +57,8 @@ pub enum FrontendWarningKind {
file: String,
detail: String,
},
- /// `$exit` outside a program block, which IEEE 1800-2023 24.7 ignores.
- /// Celox has no program blocks, so every call is ignored.
+ /// `$exit` outside a thread of a program's `initial` procedure, which
+ /// IEEE 1800-2023 24.7 ignores.
#[error("`$exit` outside a program block is ignored")]
ExitOutsideProgram,
}
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-runtime/src/schedule.rs b/crates/celox-runtime/src/schedule.rs
index b9a0e39311b..85be69ad6e6 100644
--- a/crates/celox-runtime/src/schedule.rs
+++ b/crates/celox-runtime/src/schedule.rs
@@ -21,6 +21,8 @@ pub struct ResolvedSchedule {
pub(crate) signal_to_id: FxHashMap,
pub(crate) signal_index_by_id: Vec,
pub(crate) processes: Vec,
+ /// The kernels of program instances, in declaration order.
+ pub(crate) program_processes: Vec,
/// Counted signals and the domains their counters trigger.
pub(crate) counted: Vec,
pub(crate) counted_by_offset: FxHashMap,
@@ -77,6 +79,10 @@ pub(crate) struct SchedulerRefs {
/// The event id and signal of each host clock the scheduler may run,
/// in the order of its clock slots.
pub(crate) clocks: Vec<(usize, SignalRef)>,
+ /// Per process kernel, the bits of `levels` of the events it writes.
+ pub(crate) kernel_events: Vec,
+ /// Per clock slot, the bit of `levels` of its event.
+ pub(crate) clock_events: Vec,
pub(crate) clock_next: SignalRef,
pub(crate) clock_period: SignalRef,
pub(crate) clock_value: SignalRef,
@@ -190,6 +196,7 @@ impl ResolvedSchedule {
.iter()
.map(|process| ProcessRefs {
is_initializer: process.slots.is_initializer,
+ program: process.slots.program.as_ref().map(resolve),
resume: resolve(&process.slots.resume),
starts_with_event_wait: process.slots.requires_timed_simulation,
status: resolve(&process.slots.status),
@@ -299,6 +306,12 @@ impl ResolvedSchedule {
event_info,
signal_to_id,
signal_index_by_id,
+ program_processes: processes
+ .iter()
+ .enumerate()
+ .filter(|(_, process)| process.program.is_some())
+ .map(|(index, _)| index)
+ .collect(),
processes,
counted,
counted_by_offset,
@@ -365,6 +378,24 @@ impl ResolvedSchedule {
.iter()
.map(|event| backend.resolve_event_opt(event).map(|event| event.id()))
.collect::