From 5469981e2c0f810453e01679a909414ea6371f71 Mon Sep 17 00:00:00 2001 From: tignear Date: Fri, 23 Oct 2026 11:18:07 +0900 Subject: [PATCH] feat(sv)!: support opt-in interface-array size queries Taxi uses $size(interface_array) in parameters and generate bounds. Resolve these queries from bound interface-array shapes, including formal ports, generated scopes, multiple dimensions and indexed subarrays. Preserve ordinary data-object shadowing and return a signed integer unknown for invalid numeric dimensions. Other interface data queries remain unsupported. Treat this as a compatibility extension: interface_array_query defaults to error and can be enabled with warn or allow through the existing CLI diagnostic option or celox.toml diagnostics table. Preserve located, deduplicated warnings, including when later analysis fails. Document the policy in both guides. Validation: - SystemVerilog suite: 4096 passed, 20 existing ignored. - Analyzer: 791 passed, 3 existing ignored; frontend: 4 passed. - Diagnostic policy: 33 passed; CLI integration: 5 policy combinations passed. - Formatting and affected library/test Clippy checks with -D warnings passed. - Verilator 5.052 passed the reference with assertions enabled. Slang 12 rejects the same interface query, supporting its classification as an extension. A paired frontend-only Taxi audit of 83 configurations on the master base finds that 32 of the 34 affected configurations reach their next blocker; two hit the 120-second limit. The 17 existing frontend passes remain unchanged. No additional configuration completes, and no new cocotb execution is claimed. All 299 resolved upstream source files are unchanged. This PR is independent of the assignment-pattern changes in #1772. BREAKING CHANGE: AnalyzerWarning and FrontendWarningKind gain an InterfaceArrayQuery variant; downstream exhaustive matches must handle it. Change-Id: Ie71c67508b89ab93b4b967e02d5734c7330be136 --- crates/celox-frontend-sv/src/warning.rs | 9 ++ crates/celox-sv-analyzer/src/ast.rs | 63 ++++++---- .../src/ast/const_functions.rs | 2 + .../src/ast/dimensions/query_binding.rs | 88 +++++++++++++ .../src/ast/interface_ast.rs | 1 + crates/celox-sv-analyzer/src/ast/packages.rs | 1 + crates/celox-sv-analyzer/src/ast/warnings.rs | 2 + crates/celox-vpi/tests/run_cli.rs | 61 +++++++++ crates/celox/src/diagnostic_policy.rs | 1 + crates/celox/tests/diagnostic_policy.rs | 119 ++++++++++++++++++ .../frontends/systemverilog/interfaces.rs | 56 +++++++++ docs/guide/celox-toml.md | 13 ++ docs/ja/guide/celox-toml.md | 9 ++ 13 files changed, 404 insertions(+), 21 deletions(-) diff --git a/crates/celox-frontend-sv/src/warning.rs b/crates/celox-frontend-sv/src/warning.rs index 464084d0d44..851b993d562 100644 --- a/crates/celox-frontend-sv/src/warning.rs +++ b/crates/celox-frontend-sv/src/warning.rs @@ -40,6 +40,8 @@ pub enum FrontendWarningKind { /// IEEE 1800-2023 3.14.2.3 requires consistent explicit timing declarations. #[error("mixed explicit and default time units or precisions across design elements")] MixedTimescale, + #[error("`$size` on an interface array is a language extension")] + InterfaceArrayQuery, /// IEEE 1800-2023 9.2.2.4 restricts writes by other processes. #[error("multiple variable drivers for `{signal}` in `{module}` include an always_ff process")] MultipleAlwaysFfDrivers { module: String, signal: String }, @@ -96,6 +98,9 @@ pub(crate) fn analyzer_warnings( found: &[celox_sv_analyzer::ir::AnalyzerWarning], ) -> impl Iterator + '_ { found.iter().map(|warning| match warning { + celox_sv_analyzer::ir::AnalyzerWarning::InterfaceArrayQuery { site } => { + (FrontendWarningKind::InterfaceArrayQuery, site.clone()) + } celox_sv_analyzer::ir::AnalyzerWarning::MixedTimescale => { (FrontendWarningKind::MixedTimescale, None) } @@ -149,6 +154,7 @@ impl miette::Diagnostic for FrontendWarning { fn code<'a>(&'a self) -> Option> { Some(Box::new(match self.kind { FrontendWarningKind::MixedTimescale => "mixed_timescale", + FrontendWarningKind::InterfaceArrayQuery => "interface_array_query", FrontendWarningKind::MultipleAlwaysFfDrivers { .. } => "multiple_always_ff_drivers", FrontendWarningKind::UnpackedPortDefault { .. } => "unpacked_port_default", FrontendWarningKind::InferredLatch => "inferred_latch", @@ -166,6 +172,9 @@ impl miette::Diagnostic for FrontendWarning { FrontendWarningKind::InferredLatch => { "assign every output on every path, or configure diagnostics.inferred_latch as warn or allow" } + FrontendWarningKind::InterfaceArrayQuery => { + "interface arrays are not data arrays in IEEE 1800-2023 20.7; set interface_array_query=warn or allow for compatibility" + } FrontendWarningKind::MixedTimescale => { "declare timeunit/timeprecision consistently; undeclared scopes use 1ns/1ps when this check is relaxed" } diff --git a/crates/celox-sv-analyzer/src/ast.rs b/crates/celox-sv-analyzer/src/ast.rs index 6ab988df73b..4360e0dea28 100644 --- a/crates/celox-sv-analyzer/src/ast.rs +++ b/crates/celox-sv-analyzer/src/ast.rs @@ -27,6 +27,7 @@ pub(super) struct AnalysisState { root_subroutines: std::cell::Cell, next_call_site: std::rc::Rc>, timescales: timescales::State, + diagnostics: RefCell>, /// Classes laid out so far, by name. classes: std::cell::RefCell>>, } @@ -249,6 +250,7 @@ impl InterfaceLookup<'_> { #[derive(Debug, Clone, PartialEq, Eq)] pub struct Source { modules: Vec, + diagnostics: Vec, } /// Overrides supplied by one instantiation. Types have been resolved in its scope. @@ -298,16 +300,21 @@ impl Source { &packages, packages.unit(Path::new("")), )?; - modules.push(Module::from_scope_with_parameter_overrides( - syntax_tree, - module_name, - ¶meter_overrides, - &InterfaceLookup { - local: &interfaces, - extra: &ModuleInterfaces::default(), - }, - Arc::new(imported), - )?); + modules.push( + Module::from_scope_with_parameter_overrides( + syntax_tree, + module_name, + ¶meter_overrides, + &InterfaceLookup { + local: &interfaces, + extra: &ModuleInterfaces::default(), + }, + Arc::new(imported), + ) + .map_err(|error| { + error.with_warnings(context.state.diagnostics.borrow().clone()) + })?, + ); } celox_sv_syntax::PortStyle::NonAnsi => { return Err(AnalyzerError::Unsupported( @@ -318,7 +325,10 @@ impl Source { } } - Ok(Self { modules }) + Ok(Self { + modules, + diagnostics: context.state.diagnostics.borrow().clone(), + }) } pub(crate) fn from_syntax_module_with_parameter_overrides( @@ -426,18 +436,26 @@ impl Source { }, &interfaces, imported.clone(), - )? { + ) + .map_err(|error| { + error.with_warnings(context.state.diagnostics.borrow().clone()) + })? { module.name = module_name.to_string(); modules.push(module); continue; } - modules.push(Module::from_scope_with_parameter_overrides( - syntax_tree, - module_name, - bindings.values, - &interfaces, - Arc::new(imported), - )?); + modules.push( + Module::from_scope_with_parameter_overrides( + syntax_tree, + module_name, + bindings.values, + &interfaces, + Arc::new(imported), + ) + .map_err(|error| { + error.with_warnings(context.state.diagnostics.borrow().clone()) + })?, + ); } celox_sv_syntax::PortStyle::NonAnsi if syntax_tree.root_name()? == module_name => { return Err(AnalyzerError::Unsupported( @@ -447,7 +465,10 @@ impl Source { _ => {} } } - Ok(Self { modules }) + Ok(Self { + modules, + diagnostics: context.state.diagnostics.borrow().clone(), + }) } pub(crate) fn module_names_from_syntax( @@ -492,7 +513,7 @@ impl Source { } pub(crate) fn warnings(&self) -> Vec { - let mut warnings = Vec::new(); + let mut warnings = self.diagnostics.clone(); for module in &self.modules { warnings::append(&mut warnings, module.constant_functions.warnings()); } diff --git a/crates/celox-sv-analyzer/src/ast/const_functions.rs b/crates/celox-sv-analyzer/src/ast/const_functions.rs index 18fe205b6fa..66c9f602e7e 100644 --- a/crates/celox-sv-analyzer/src/ast/const_functions.rs +++ b/crates/celox-sv-analyzer/src/ast/const_functions.rs @@ -175,6 +175,8 @@ impl ConstantFunctions { ) => std::cmp::Ordering::Equal, (super::warnings::AnalyzerWarning::MixedTimescale, _) => std::cmp::Ordering::Less, (_, super::warnings::AnalyzerWarning::MixedTimescale) => std::cmp::Ordering::Greater, + // This collector emits only ExitOutsideProgram warnings. + _ => std::cmp::Ordering::Equal, }); warnings } diff --git a/crates/celox-sv-analyzer/src/ast/dimensions/query_binding.rs b/crates/celox-sv-analyzer/src/ast/dimensions/query_binding.rs index 6778c863882..985c89c846e 100644 --- a/crates/celox-sv-analyzer/src/ast/dimensions/query_binding.rs +++ b/crates/celox-sv-analyzer/src/ast/dimensions/query_binding.rs @@ -88,6 +88,17 @@ pub(in crate::ast) fn query_value( let argument = arguments[0].value.unwrap(); let context = query_context_for_operand(argument, tree, context)?; reject_unbounded(argument, function, tree, &context)?; + if function == SystemFunction::Size + && let Some(value) = interface_array_size( + root, + argument, + arguments.get(1).and_then(|a| a.value), + tree, + &context, + )? + { + return Ok(Some(value)); + } let shape = shape(argument, tree, &context)?; let dimension = if let Some(argument) = arguments.get(1) { Some(expression_binding::bind( @@ -216,6 +227,83 @@ pub(in crate::ast) fn query_value( .ok_or_else(|| unsupported(format!("operand of `{}`", name.spelling))) } +/// Query interface array metadata without admitting interface handles as data +/// expressions. This extension supports `$size` only; it adds no packed rank. +fn interface_array_size( + call: ExprId, + mut argument: ExprId, + dimension: Option, + tree: &AnalysisContext<'_>, + context: &PackedDimensions, +) -> Converted> { + let native = tree.declarations(); + let mut selected = Vec::new(); + loop { + argument = expression_binding::ungroup(argument, native); + match &native.expression(argument).kind { + ExprKind::Select { + expression, + dimension, + } => { + let DimensionKind::Index(index) = dimension.kind else { + return Ok(None); + }; + selected.push(index); + argument = *expression; + } + _ => break, + } + } + let Ok(handle) = interface_binding::actual_handle_key( + argument, + tree, + &context.const_env, + &context.type_aliases, + ) else { + return Ok(None); + }; + let receiver = handle.split(['.', '[']).next().unwrap_or(&handle); + if context.get(receiver).is_some() + || context.const_env.contains_key(receiver) + || context.parameter_values.contains_key(receiver) + { + return Ok(None); + } + let imported = scope::imported(&tree.state); + let Some(array) = imported.interface_arrays.get(&handle) else { + return Ok(None); + }; + let Some(shape) = array + .shape + .get(selected.len()..) + .filter(|shape| !shape.is_empty()) + else { + return Ok(None); + }; + for index in selected { + validate_index(index, tree, context)?; + } + let dimension = match dimension { + Some(id) => constant_binding::bind(id, tree, context)? + .and_then(|value| eval_ast_const_expr(&tree.state, &value, &context.const_env)) + .ok_or_else(|| unsupported("nonconstant interface array query dimension"))?, + None => 1, + }; + let value = usize::try_from(dimension) + .ok() + .and_then(|d| d.checked_sub(1)) + .and_then(|index| shape.get(index)) + .map(|size| integer(*size as i128)) + .unwrap_or_else(|| Expr::Literal("32'sbx".into())); + warnings::append( + &mut tree.state.diagnostics.borrow_mut(), + [warnings::AnalyzerWarning::InterfaceArrayQuery { + site: procedural::source_span(native.expression(call).tokens, tree), + }], + ); + Ok(Some(value)) +} + fn parameter_dimension_count( mut root: ExprId, tree: &AnalysisContext<'_>, diff --git a/crates/celox-sv-analyzer/src/ast/interface_ast.rs b/crates/celox-sv-analyzer/src/ast/interface_ast.rs index cd8bb5e78bd..7ca95f5efca 100644 --- a/crates/celox-sv-analyzer/src/ast/interface_ast.rs +++ b/crates/celox-sv-analyzer/src/ast/interface_ast.rs @@ -216,6 +216,7 @@ pub(super) fn signature( module.instances.clear(); let ir = crate::analyze::analyze_source(Source { modules: vec![module], + diagnostics: Vec::new(), })?; ir.modules() .first() diff --git a/crates/celox-sv-analyzer/src/ast/packages.rs b/crates/celox-sv-analyzer/src/ast/packages.rs index 5f43c0845e1..18b69492bd8 100644 --- a/crates/celox-sv-analyzer/src/ast/packages.rs +++ b/crates/celox-sv-analyzer/src/ast/packages.rs @@ -535,6 +535,7 @@ fn analyze_package_scope( } else { let ir = crate::analyze::analyze_source(Source { modules: vec![module], + diagnostics: Vec::new(), })?; ir.modules().first().cloned() }; diff --git a/crates/celox-sv-analyzer/src/ast/warnings.rs b/crates/celox-sv-analyzer/src/ast/warnings.rs index 20761ddfaef..0b8994bb6e2 100644 --- a/crates/celox-sv-analyzer/src/ast/warnings.rs +++ b/crates/celox-sv-analyzer/src/ast/warnings.rs @@ -8,6 +8,8 @@ use crate::procedural::SourceSpan; pub enum AnalyzerWarning { /// Explicit and implementation-default time scales occur in one design. MixedTimescale, + /// `$size` on an interface array is a compatibility extension to 20.7. + InterfaceArrayQuery { site: Option }, /// An ignored `$exit` in a function outside a program (IEEE 1800-2023 24.7). ExitOutsideProgram { site: Option }, } diff --git a/crates/celox-vpi/tests/run_cli.rs b/crates/celox-vpi/tests/run_cli.rs index 7f180da6475..e68b2bfb196 100644 --- a/crates/celox-vpi/tests/run_cli.rs +++ b/crates/celox-vpi/tests/run_cli.rs @@ -540,3 +540,64 @@ fn source_file_is_relative_to_celox_manifest_from_another_directory() { .unwrap(); assert!(output.status.success(), "{output:?}"); } + +#[cfg(feature = "systemverilog")] +#[test] +fn interface_array_query_policy_flows_through_manifest_and_cli_overrides() { + let project = tempfile::tempdir().unwrap(); + std::fs::write( + project.path().join("top.sv"), + r#" + interface Lane; logic v; endinterface + module Top; + Lane lanes[3:2](); + localparam N=$size(lanes); + initial begin + assert(N==2) else $fatal(1,"size"); + $display("size=%0d",N); + $finish; + end + endmodule + "#, + ) + .unwrap(); + let manifest = project.path().join("celox.toml"); + for (configured, overridden, success, warning) in [ + (None, None, false, false), + (Some("warn"), None, true, true), + (Some("allow"), None, true, false), + (Some("warn"), Some("error"), false, false), + (Some("error"), Some("allow"), true, false), + ] { + let mut config = "sources=['top.sv']\ntop='Top'\n".to_string(); + if let Some(level) = configured { + config.push_str(&format!("[diagnostics]\ninterface_array_query='{level}'\n")); + } + std::fs::write(&manifest, config).unwrap(); + let mut cmd = Command::new(env!("CARGO_BIN_EXE_celox")); + cmd.args(["run", "--project"]) + .arg(&manifest) + .args(["--backend", "interpreter"]) + .env("RUST_LOG", "warn"); + if let Some(level) = overridden { + cmd.args(["--diagnostic", &format!("interface_array_query={level}")]); + } + let output = cmd.output().unwrap(); + let stderr = String::from_utf8_lossy(&output.stderr); + assert_eq!( + output.status.success(), + success, + "{configured:?}/{overridden:?}: {output:?}" + ); + if success { + assert_eq!(output.stdout, b"size=2\n", "{output:?}"); + assert_eq!( + stderr.contains("interface_array_query"), + warning, + "{stderr}" + ); + } else { + assert!(stderr.contains("interface_array_query"), "{stderr}"); + } + } +} diff --git a/crates/celox/src/diagnostic_policy.rs b/crates/celox/src/diagnostic_policy.rs index cf4dac9b34c..dc58a639307 100644 --- a/crates/celox/src/diagnostic_policy.rs +++ b/crates/celox/src/diagnostic_policy.rs @@ -85,6 +85,7 @@ impl DiagnosticPolicy { if matches!( code, "mixed_timescale" + | "interface_array_query" | "unpacked_port_default" | "multiple_always_ff_drivers" | "inferred_latch" diff --git a/crates/celox/tests/diagnostic_policy.rs b/crates/celox/tests/diagnostic_policy.rs index da7893b2a38..49eb9853ce8 100644 --- a/crates/celox/tests/diagnostic_policy.rs +++ b/crates/celox/tests/diagnostic_policy.rs @@ -614,3 +614,122 @@ mod inferred_latch { ); } } + +#[cfg(feature = "systemverilog")] +#[test] +fn interface_array_queries_require_a_recoverable_diagnostic_override() { + use std::path::Path; + let source = "interface Lane; logic v; endinterface module Top(output wire [7:0] y); Lane lanes[3:2](); assign y=$size(lanes); endmodule"; + let build = + || Simulator::from_sv_sources(vec![(source, Path::new("size_extension.sv"))], "Top"); + let error = build().build_cranelift().err().unwrap(); + assert!( + matches!(error.kind(), SimulatorErrorKind::DiagnosticPolicy(_)), + "{error}" + ); + assert!( + error.to_string().contains("interface_array_query"), + "{error}" + ); + for level in [DiagnosticLevel::Warn, DiagnosticLevel::Allow] { + let mut sim = build() + .diagnostic_policy(policy("interface_array_query", level)) + .build_cranelift() + .unwrap(); + assert_eq!(sim.get(sim.signal("y")), 2u8.into()); + assert_eq!( + sim.warnings().len(), + usize::from(level == DiagnosticLevel::Warn) + ); + if let Some(warning) = sim.warnings().first() { + let rendered = celox::render_diagnostic(warning); + assert!(rendered.contains("size_extension.sv"), "{rendered}"); + } + } +} + +#[cfg(feature = "systemverilog")] +#[test] +fn interface_array_extension_keeps_interfaces_out_of_data_expressions() { + use std::path::Path; + for expression in [ + "$bits(lanes)", + "$left(lanes)", + "$size(lanes[0])", + "$size(lanes,missing)", + "$size(lanes,dim)", + "lanes", + ] { + let source = format!( + "interface Lane; logic v; endinterface module Top(input int dim,output wire [31:0] y); Lane lanes[2](); assign y={expression}; endmodule" + ); + assert!( + Simulator::from_sv_sources(vec![(&source, Path::new("bad_interface_query.sv"))], "Top") + .diagnostic_policy(policy("interface_array_query", DiagnosticLevel::Allow)) + .build_cranelift() + .is_err(), + "{expression}" + ); + } +} + +#[cfg(feature = "systemverilog")] +#[test] +fn interface_array_query_warning_survives_a_later_analysis_error() { + use std::path::Path; + let source = "interface Lane; logic v; endinterface module Top(output wire y); Lane lanes[2](); localparam N=$size(lanes); assign y=missing; endmodule"; + let error = Simulator::from_sv_sources(vec![(source, Path::new("later_error.sv"))], "Top") + .diagnostic_policy(policy("interface_array_query", DiagnosticLevel::Warn)) + .build_cranelift() + .err() + .unwrap(); + assert!(error.to_string().contains("missing"), "{error}"); + assert_eq!(error.warnings().len(), 1, "{error}"); +} + +#[cfg(feature = "systemverilog")] +#[test] +fn interface_array_query_policy_covers_formals_and_generated_scopes() { + use std::path::Path; + for source in [ + "interface Lane; logic v; endinterface module Reader(Lane ports[2],output wire [7:0] y); assign y=$size(ports); endmodule module Top(output wire [7:0] y); Lane lanes[2](); Reader r(.ports(lanes),.y(y)); endmodule", + "interface Lane; logic v; endinterface module Top(output wire [7:0] y); if(1) begin: bank Lane lanes[2](); assign y=$size(lanes); end endmodule", + "interface Lane; logic v; endinterface module Top(output wire [7:0] y); Lane lanes[2](); function automatic int count(); return $size(lanes); endfunction assign y=count(); endmodule", + ] { + let error = Simulator::from_sv_sources(vec![(source, Path::new("query_scope.sv"))], "Top") + .build_cranelift() + .err() + .unwrap(); + assert!( + error.to_string().contains("interface_array_query"), + "{error}" + ); + let mut sim = + Simulator::from_sv_sources(vec![(source, Path::new("query_scope.sv"))], "Top") + .diagnostic_policy(policy("interface_array_query", DiagnosticLevel::Allow)) + .build_cranelift() + .unwrap(); + assert_eq!(sim.get(sim.signal("y")), 2u8.into()); + } +} + +#[cfg(feature = "systemverilog")] +#[test] +fn invalid_interface_array_query_dimensions_return_integer_unknowns() { + use std::path::Path; + let source = "interface Lane; logic v; endinterface module Top(output wire [31:0] zero,extra,output wire [63:0] wide); Lane lanes[2](); assign zero=$size(lanes,0); assign extra=$size(lanes,2); assign wide=$size(lanes,2); endmodule"; + let mut sim = Simulator::from_sv_sources(vec![(source, Path::new("query_rank.sv"))], "Top") + .four_state(true) + .diagnostic_policy(policy("interface_array_query", DiagnosticLevel::Allow)) + .build_cranelift() + .unwrap(); + let wide = sim.signal("wide"); + assert_eq!(sim.get_four_state(wide), (u64::MAX.into(), u64::MAX.into())); + for name in ["zero", "extra"] { + let signal = sim.signal(name); + assert_eq!( + sim.get_four_state(signal), + (u32::MAX.into(), u32::MAX.into()) + ); + } +} diff --git a/crates/celox/tests/frontends/systemverilog/interfaces.rs b/crates/celox/tests/frontends/systemverilog/interfaces.rs index 20f54ade184..373ba9c845e 100644 --- a/crates/celox/tests/frontends/systemverilog/interfaces.rs +++ b/crates/celox/tests/frontends/systemverilog/interfaces.rs @@ -141,3 +141,59 @@ sv_backends! { } } } + +// Interface objects are not IEEE 20.7 data arrays. This opt-in compatibility +// behavior belongs to Celox's harness rather than the portable language suite. +sv_backends! { + fn queries_interface_array_sizes_as_an_explicit_extension(sim) { + @setup { + let source = r#" + interface Lane; logic value; endinterface + module Child #(parameter N=1)(output wire [7:0] y); assign y=N; endmodule + module Reader(Lane ports[3:2], output wire [7:0] y); + assign y=$size(ports); + endmodule + module Top(output wire [7:0] local_count, param_count, formal_count, + first_count, second_count, selected_count, generated_count, shadow_count, member_shadow_count, + output wire [1:0] generated); + Lane lanes[3:2](); + Lane matrix[1:0][4:2](); + localparam N=$size(lanes); + assign local_count=N; + Child #(.N($size(lanes))) c(.y(param_count)); + Reader r(.ports(lanes), .y(formal_count)); + assign first_count=$size(matrix,1); + assign second_count=$size(matrix,2); + assign selected_count=$size(matrix[0]); + for(genvar i=0;i<$size(lanes);i=i+1) begin: bits_out + assign generated[i]=1'b1; + end + if(1) begin: bank + Lane local_lanes[5:7](); + assign generated_count=$size(local_lanes); + end + function automatic int shadow(); + int lanes[5]; + return $size(lanes); + endfunction + assign shadow_count=shadow(); + function automatic int shadow_member(); + struct packed {logic [4:0] local_lanes;} bank; + return $size(bank.local_lanes); + endfunction + assign member_shadow_count=shadow_member(); + endmodule + "#; + let mut policy=celox::DiagnosticPolicy::default(); + policy.set("interface_array_query",celox::DiagnosticLevel::Warn); + } + @build Simulator::from_sv_sources(vec![(source,Path::new("interface_array_size.sv"))],"Top") + .diagnostic_policy(policy); + for (name,expected) in [("local_count",2u8),("param_count",2),("formal_count",2), + ("first_count",2),("second_count",3),("selected_count",3), + ("generated_count",3),("shadow_count",5),("member_shadow_count",5),("generated",3)] { + assert_eq!(sim.get(sim.signal(name)),BigUint::from(expected),"{name}"); + } + assert!(!sim.warnings().is_empty()); + } +} diff --git a/docs/guide/celox-toml.md b/docs/guide/celox-toml.md index 4f9069df0d3..3b54313138e 100644 --- a/docs/guide/celox-toml.md +++ b/docs/guide/celox-toml.md @@ -170,6 +170,19 @@ explicit settings remain effective, and the global precision includes default scopes. Syntax errors, unsupported constructs and invalid precision declarations remain errors. +`interface_array_query` defaults to `error`. Set it to `warn` or `allow` to enable +`$size` on fixed-size interface arrays and index-selected subarrays as a compatibility +extension. IEEE 1800-2023 §20.7 specifies queries on data arrays; interface +instances are not data objects. The optional dimension must be a known integer constant. This +extension does not give interface handles a packed width or enable other queries. + +```toml +[diagnostics] +interface_array_query = "warn" +``` + +The CLI uses the same policy: `celox run top.sv --top Top --diagnostic interface_array_query=warn`. + `multiple_always_ff_drivers` defaults to `error` for shared memories written by an `always_ff` and another edge process (IEEE 1800-2023 §9.2.2.4). With `warn` or `allow`, Celox stages their nonblocking writes in sparse next-state storage diff --git a/docs/ja/guide/celox-toml.md b/docs/ja/guide/celox-toml.md index 30be45aabe4..6443f46cdad 100644 --- a/docs/ja/guide/celox-toml.md +++ b/docs/ja/guide/celox-toml.md @@ -155,6 +155,15 @@ memory_file_word_count = "error" Rust の `.allow_inferred_latches(true)` と JavaScript の `allowInferredLatches: true` は、 この診断の明示設定がない場合だけ `allow` を補います。明示した `error`・`warn`・`allow` が優先されます。 +`interface_array_query` の既定値は `error` です。`warn` または `allow` で、固定長の interface 配列と添字で選択した部分配列に対する `$size` を互換拡張として許可します。IEEE 1800-2023 §20.7 の対象はデータ配列であり、interface インスタンスはデータオブジェクトではありません。省略可能な次元引数は既知の整数定数に限ります。この拡張によって interface ハンドルに packed 幅が付いたり、他の配列クエリが使えるようになったりすることはありません。 + +```toml +[diagnostics] +interface_array_query = "warn" +``` + +CLI でも同じ設定を使います: `celox run top.sv --top Top --diagnostic interface_array_query=warn`。 + `multiple_always_ff_drivers` は、`always_ff` と別のエッジプロセスが同じメモリへ書く場合に既定で `error` になります(IEEE 1800-2023 §9.2.2.4)。`warn` または `allow` では、非ブロッキング代入の変更範囲を次状態領域に保持してコミットします。通常の `always` 同士による共有にはこの診断は出ません。異なるプロセスが同時に同じビットへ書く順序は、移植可能な動作として保証されません。 プロジェクトのシミュレータ生成時は `Veryl.toml` と同じ場所の設定を読み込みます。CLI は単独の SystemVerilog プロジェクトにも対応します。