Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions conformance/sv-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ strict by default. The `9.2.2.3--always_latch` probe still fails because it uses
an unsupported nonblocking latch assignment (`<=`). The full pinned run reviewed
all 2054 case/mode rows; no other expectation rows changed.

The integral file-input extension updates six expectation rows: `21.3--feof`,
`21.3--fflush` and `21.3--fpos` now pass simulation in both state modes. The
remaining file-input probes retain their measured verdicts; several still use
unsupported `final` constructs.

The six Annex N distribution probes (`20.15--dist_normal`, `dist_exponential`,
`dist_poisson`, `dist_chi_square`, `dist_t` and `dist_erlang`) now pass simulation
in both state modes, updating twelve more expectation rows. The scanner probes
retain failures caused by unsupported `final` constructs or internal data types;
no scanner expectation is changed.

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.
Expand Down
36 changes: 18 additions & 18 deletions conformance/sv-tests/expected.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -681,18 +681,18 @@ chapter-20/20.10--warning.sv 2state pass
chapter-20/20.10--warning.sv 4state pass
chapter-20/20.14--coverage.sv 2state fail
chapter-20/20.14--coverage.sv 4state fail
chapter-20/20.15--dist_chi_square.sv 2state fail
chapter-20/20.15--dist_chi_square.sv 4state fail
chapter-20/20.15--dist_erlang.sv 2state fail
chapter-20/20.15--dist_erlang.sv 4state fail
chapter-20/20.15--dist_exponential.sv 2state fail
chapter-20/20.15--dist_exponential.sv 4state fail
chapter-20/20.15--dist_normal.sv 2state fail
chapter-20/20.15--dist_normal.sv 4state fail
chapter-20/20.15--dist_poisson.sv 2state fail
chapter-20/20.15--dist_poisson.sv 4state fail
chapter-20/20.15--dist_t.sv 2state fail
chapter-20/20.15--dist_t.sv 4state fail
chapter-20/20.15--dist_chi_square.sv 2state pass
chapter-20/20.15--dist_chi_square.sv 4state pass
chapter-20/20.15--dist_erlang.sv 2state pass
chapter-20/20.15--dist_erlang.sv 4state pass
chapter-20/20.15--dist_exponential.sv 2state pass
chapter-20/20.15--dist_exponential.sv 4state pass
chapter-20/20.15--dist_normal.sv 2state pass
chapter-20/20.15--dist_normal.sv 4state pass
chapter-20/20.15--dist_poisson.sv 2state pass
chapter-20/20.15--dist_poisson.sv 4state pass
chapter-20/20.15--dist_t.sv 2state pass
chapter-20/20.15--dist_t.sv 4state pass
chapter-20/20.15--dist_uniform.sv 2state pass
chapter-20/20.15--dist_uniform.sv 4state pass
chapter-20/20.15--random.sv 2state pass
Expand Down Expand Up @@ -781,12 +781,12 @@ chapter-21/21.3--fdisplay-boh.sv 2state fail
chapter-21/21.3--fdisplay-boh.sv 4state fail
chapter-21/21.3--fdisplay.sv 2state fail
chapter-21/21.3--fdisplay.sv 4state fail
chapter-21/21.3--feof.sv 2state fail
chapter-21/21.3--feof.sv 4state fail
chapter-21/21.3--feof.sv 2state pass
chapter-21/21.3--feof.sv 4state pass
chapter-21/21.3--ferror.sv 2state fail
chapter-21/21.3--ferror.sv 4state fail
chapter-21/21.3--fflush.sv 2state fail
chapter-21/21.3--fflush.sv 4state fail
chapter-21/21.3--fflush.sv 2state pass
chapter-21/21.3--fflush.sv 4state pass
chapter-21/21.3--fgetc.sv 2state fail
chapter-21/21.3--fgetc.sv 4state fail
chapter-21/21.3--fgets.sv 2state fail
Expand All @@ -795,8 +795,8 @@ chapter-21/21.3--file.sv 2state pass
chapter-21/21.3--file.sv 4state pass
chapter-21/21.3--fmonitor.sv 2state fail
chapter-21/21.3--fmonitor.sv 4state fail
chapter-21/21.3--fpos.sv 2state fail
chapter-21/21.3--fpos.sv 4state fail
chapter-21/21.3--fpos.sv 2state pass
chapter-21/21.3--fpos.sv 4state pass
chapter-21/21.3--fread.sv 2state fail
chapter-21/21.3--fread.sv 4state fail
chapter-21/21.3--fscanf.sv 2state fail
Expand Down
10 changes: 9 additions & 1 deletion crates/celox-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ pub enum HostRequestKind {
Plusargs,
FileIo,
Vcd,
Scan,
Distribution,
}

impl HostRequestKind {
Expand All @@ -311,6 +313,8 @@ impl HostRequestKind {
Self::Plusargs => 1u64,
Self::FileIo => 2,
Self::Vcd => 3,
Self::Scan => 4,
Self::Distribution => 5,
};
(family << 32) | site as u64
}
Expand All @@ -321,6 +325,8 @@ impl HostRequestKind {
1 => Self::Plusargs,
2 => Self::FileIo,
3 => Self::Vcd,
4 => Self::Scan,
5 => Self::Distribution,
_ => return None,
};
Some((family, request as u32))
Expand Down Expand Up @@ -1452,6 +1458,8 @@ mod tests {
HostRequestKind::Plusargs,
HostRequestKind::FileIo,
HostRequestKind::Vcd,
HostRequestKind::Scan,
HostRequestKind::Distribution,
] {
for site in [0, 1, u32::MAX] {
assert_eq!(
Expand All @@ -1460,7 +1468,7 @@ mod tests {
);
}
}
for invalid in [0, u32::MAX as u64, 4u64 << 32, 1u64 << 63] {
for invalid in [0, u32::MAX as u64, 6u64 << 32, 1u64 << 63] {
assert_eq!(HostRequestKind::decode(invalid), None);
}
assert_eq!(
Expand Down
15 changes: 15 additions & 0 deletions crates/celox-frontend-sv/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5975,12 +5975,27 @@ fn lower_bit_vector_function_slt<A: std::hash::Hash + Eq + Clone>(
| SystemFunction::Stime
| SystemFunction::Random
| SystemFunction::DistUniform
| SystemFunction::DistNormal
| SystemFunction::DistExponential
| SystemFunction::DistPoisson
| SystemFunction::DistChiSquare
| SystemFunction::DistT
| SystemFunction::DistErlang
| SystemFunction::TestPlusargs
| SystemFunction::ValuePlusargs
| SystemFunction::Urandom
| SystemFunction::UrandomRange
| SystemFunction::Fopen
| SystemFunction::ScopeRandomize
| SystemFunction::Fread
| SystemFunction::Ftell
| SystemFunction::Fseek
| SystemFunction::Rewind
| SystemFunction::Fgetc
| SystemFunction::Ungetc
| SystemFunction::Feof
| SystemFunction::Sscanf
| SystemFunction::Fscanf
| SystemFunction::Timeunit
| SystemFunction::Timeprecision
| SystemFunction::Isunbounded
Expand Down
116 changes: 116 additions & 0 deletions crates/celox-frontend-sv/src/lowering/ff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//! four-state semantics identical to the combinational lowering.

mod file_io;
mod fread;
mod scan;

use super::procedural::*;
use super::*;
Expand Down Expand Up @@ -835,6 +837,33 @@ impl<'p, 'a> Ff<'p, 'a> {
return Ok(expr.clone());
}
Ok(match expr {
Expr::Call {
callee: sv::ir::Callee::System(sv::ir::SystemFunction::Fread),
args,
..
} => self.fread(args)?,
Expr::Call {
callee:
sv::ir::Callee::System(
function @ (sv::ir::SystemFunction::Ftell
| sv::ir::SystemFunction::Fseek
| sv::ir::SystemFunction::Rewind
| sv::ir::SystemFunction::Fgetc
| sv::ir::SystemFunction::Ungetc
| sv::ir::SystemFunction::Feof),
),
args,
..
} => self.file_function(*function, args)?,
Expr::Call {
callee:
sv::ir::Callee::System(
function
@ (sv::ir::SystemFunction::Sscanf | sv::ir::SystemFunction::Fscanf),
),
args,
..
} => self.scan_function(*function, args)?,
Expr::Call {
callee: sv::ir::Callee::System(sv::ir::SystemFunction::Fopen),
args,
Expand Down Expand Up @@ -889,6 +918,19 @@ impl<'p, 'a> Ff<'p, 'a> {
args,
..
} => self.plusargs(*function, args)?,
Expr::Call {
callee:
sv::ir::Callee::System(
function @ (sv::ir::SystemFunction::DistNormal
| sv::ir::SystemFunction::DistExponential
| sv::ir::SystemFunction::DistPoisson
| sv::ir::SystemFunction::DistChiSquare
| sv::ir::SystemFunction::DistT
| sv::ir::SystemFunction::DistErlang),
),
args,
..
} => self.distribution(*function, args)?,
Expr::Call {
callee: sv::ir::Callee::System(sv::ir::SystemFunction::DistUniform),
args,
Expand Down Expand Up @@ -1793,6 +1835,79 @@ impl<'p, 'a> Ff<'p, 'a> {
Ok((id, sv::ir::Expr::Ident(name)))
}

fn distribution(
&mut self,
function: sv::ir::SystemFunction,
args: &[Option<sv::ir::Expr>],
) -> Result<sv::ir::Expr, sv::AnalyzerError> {
use celox_design::{HostRequestKind, HostRequestSite, HostRequestValue};
use sv::ir::{Expr, SystemFunction as F};
if self.kernel.is_none() {
return Err(unsupported(format!(
"{} outside a timed process",
function.name()
)));
}
let operation = match function {
F::DistNormal => 0,
F::DistExponential => 1,
F::DistPoisson => 2,
F::DistChiSquare => 3,
F::DistT => 4,
F::DistErlang => 5,
_ => unreachable!(),
};
let seed = args
.first()
.and_then(Option::as_ref)
.ok_or_else(|| unsupported("distribution seed"))?;
// Capture selectors once before evaluating the other actuals, and
// suspend with an int formal rather than writing the caller's storage.
let (lvalues, captured) = self.capture_system_actual(seed)?;
let formal = self.int_formal(captured);
let (seed_id, seed_result) =
self.host_hidden("distribution_seed", &formal, 32, true, true)?;
let value = |id| HostRequestValue {
float_precision: None,
id,
width: 32,
signed: true,
is_string: false,
};
let mut operands = vec![value(seed_id)];
for arg in args.iter().skip(1) {
let arg = self.hoist(
arg.as_ref()
.ok_or_else(|| unsupported("distribution argument"))?,
)?;
let formal = self.int_formal(arg);
let (id, _) = self.host_hidden("distribution_arg", &formal, 32, true, true)?;
operands.push(value(id));
}
let (ret_id, ret_name) = self.m.temp("distribution_result", 32, true, false);
let site = self
.host_request_sites
.iter()
.filter(|site| site.kind == HostRequestKind::Distribution)
.count() as u32;
self.host_request_sites.push(HostRequestSite {
process: 0,
kind: HostRequestKind::Distribution,
requires_timed_simulation: false,
operation,
args: operands,
results: vec![value(ret_id), value(seed_id)],
strings: Vec::new(),
});
self.with_kernel(|kernel| kernel.host_request(HostRequestKind::Distribution, site))
.map_err(kernel_error)?;
match lvalues.as_slice() {
[lvalue] => self.assign(lvalue, &seed_result)?,
parts => self.assign_concat(parts, &seed_result)?,
}
Ok(Expr::Ident(ret_name))
}

fn plusargs(
&mut self,
function: sv::ir::SystemFunction,
Expand Down Expand Up @@ -2631,6 +2746,7 @@ impl<'p, 'a> Ff<'p, 'a> {
if matches!(
task,
sv::ir::SystemTask::Fclose
| sv::ir::SystemTask::Fflush
| sv::ir::SystemTask::Fdisplay(_)
| sv::ir::SystemTask::Fwrite(_)
| sv::ir::SystemTask::Writemem(_)
Expand Down
Loading
Loading