diff --git a/crates/celox-sv-analyzer/src/ast/interface_binding.rs b/crates/celox-sv-analyzer/src/ast/interface_binding.rs index 29a0ebcec0a..83c101df185 100644 --- a/crates/celox-sv-analyzer/src/ast/interface_binding.rs +++ b/crates/celox-sv-analyzer/src/ast/interface_binding.rs @@ -268,6 +268,7 @@ pub(super) fn analyze_module( true, Some(&header_ports), )?; + let mut caller_ports = caller.ports.clone(); let mut caller_symbols = caller.symbols.as_ref().unwrap().clone(); let _caller_scope = scope::install(&tree.state, Arc::new(caller_symbols.clone())); let _functions = const_functions::install(&tree.state, caller.constant_functions.clone()); @@ -295,6 +296,7 @@ pub(super) fn analyze_module( true, Some(&header_ports), )?; + caller_ports = caller.ports.clone(); caller_symbols = caller.symbols.unwrap(); generated = true; let mut current = caller_symbols.clone(); @@ -324,7 +326,7 @@ pub(super) fn analyze_module( binding_declaration_view(&view_ports, &instantiations, tree, &imported)?; let mut header_imports = imported.clone(); header_imports.declarations_only = true; - caller_symbols = Module::from_selected_scope( + let caller = Module::from_selected_scope( &tree.child(&header_tree, &overrides), &name, &overrides, @@ -332,9 +334,9 @@ pub(super) fn analyze_module( Arc::new(header_imports), true, Some(&header_ports), - )? - .symbols - .unwrap(); + )?; + caller_ports = caller.ports.clone(); + caller_symbols = caller.symbols.unwrap(); } let mut current = caller_symbols.clone(); current.extend(&imported); @@ -345,8 +347,12 @@ pub(super) fn analyze_module( } let _scope = scope::install(&tree.state, Arc::new(current.clone())); let _functions = const_functions::install(&tree.state, current.constant_functions.clone()); + // Exported scope symbols omit ordinary module ports. Keep the + // selected caller header available for connection width discovery. + let mut connection_ports = caller_ports.clone(); + connection_ports.extend(current.ports.iter().cloned()); let mut dimensions = packed_dimensions_from_ports_and_signals( - ¤t.ports, + &connection_ports, ¤t.signals, ¤t.const_env, ¤t.type_aliases, @@ -416,10 +422,10 @@ pub(super) fn analyze_module( .insert(handle.clone(), elements.clone()); } } - for local_handle in elements.elements { + for (ordinal, local_handle) in elements.elements.iter().enumerate() { let handle = generated_item.as_ref().map_or_else( || local_handle.clone(), - |item| item.instance_name(&local_handle), + |item| item.instance_name(local_handle), ); imported .interface_types @@ -443,6 +449,14 @@ pub(super) fn analyze_module( imported.declarations_only, ) })?; + let port_state = module.constant_function_state(); + let port_symbols = module.symbols.as_ref().unwrap(); + let port_dimensions = packed_dimensions_from_ports_and_signals( + &module.ports, + &module.signals, + &port_symbols.const_env, + &port_symbols.type_aliases, + ); for port in &module.ports { let signal = Signal { name: port.name.clone(), @@ -460,6 +474,70 @@ pub(super) fn analyze_module( let Some(actual) = connection.actual_expr.clone() else { continue; }; + let actual = if elements.shape.is_empty() { + actual + } else { + let port_shape = port_dimensions.get(&port.name).unwrap(); + let port_width = lvalue_expr_type( + &port_state, + &LValue::Ident(port.name.clone()), + &port_dimensions, + ) + .ok_or_else(|| unsupported("interface array port width"))? + .width; + let actual_width = expr_static_width(&tree.state, &actual, &dimensions) + .ok_or_else(|| unsupported("interface array connection width"))?; + let actual_shape = if let Some(root) = + connection_expression(authored, &port.name, Some(&interface))? + { + dimensions::operand_shape(root, tree, &dimensions)? + } else if let Expr::Ident(name) = &actual { + dimensions.get(name).cloned() + } else { + None + }; + let unpacked_sizes = + |shape: &VariableDimensions, + state: &AnalysisState, + env: &HashMap| { + shape + .unpacked + .iter() + .map(|dimension| { + usize::try_from(eval_ast_const_expr( + state, + &dimension.width, + env, + )?) + .ok() + }) + .collect::>>() + }; + let actual_shape = actual_shape + .as_ref() + .map(|shape| unpacked_sizes(shape, &tree.state, &dimensions.const_env)) + .unwrap_or_else(|| Some(Vec::new())) + .ok_or_else(|| unsupported("interface array actual shape"))?; + let port_shape = + unpacked_sizes(port_shape, &port_state, &port_dimensions.const_env) + .ok_or_else(|| unsupported("interface array port shape"))?; + let (origin, ascending) = + connection_slice_origin(&actual, &tree.state, &dimensions)?; + let shape = ConnectionShape { + unpacked: actual_shape, + width: actual_width, + origin, + ascending, + }; + distribute_port_connection( + actual, + &shape, + &port_shape, + port_width, + &elements, + ordinal, + )? + }; let bound = format!("{handle}${}", port.name); let assignment = match port.direction { PortDirection::Input => Assignment::new(LValue::Ident(bound), actual), @@ -849,6 +927,111 @@ fn formal_dimensions( .ok_or_else(|| unsupported(format!("missing interface port `{port_name}`"))) } +struct ConnectionShape { + unpacked: Vec, + width: usize, + origin: ConstExpr, + ascending: bool, +} + +/// Single packed dimensions retain authored indices in analyzer expressions; +/// unpacked and multi-packed selections already use flat storage coordinates. +fn connection_slice_origin( + actual: &Expr, + state: &AnalysisState, + dimensions: &PackedDimensions, +) -> Converted<(ConstExpr, bool)> { + let (name, selected_origin) = match actual { + Expr::Ident(name) => (name, None), + Expr::Select { expr, lsb, .. } => { + let Expr::Ident(name) = expr.as_ref() else { + return Ok((ConstExpr::Literal("0".into()), false)); + }; + (name, Some(lsb.clone())) + } + _ => return Ok((ConstExpr::Literal("0".into()), false)), + }; + if let Some(shape) = dimensions.get(name) + && shape.unpacked.is_empty() + && let [dimension] = shape.packed.as_slice() + && !dimension.normalize_single + { + let left = eval_ast_const_expr(state, &dimension.left, &dimensions.const_env) + .ok_or_else(|| unsupported("interface connection packed bound"))?; + let right = eval_ast_const_expr(state, &dimension.right, &dimensions.const_env) + .ok_or_else(|| unsupported("interface connection packed bound"))?; + return Ok(( + selected_origin.unwrap_or_else(|| dimension.right.clone()), + left < right, + )); + } + Ok(( + selected_origin.unwrap_or_else(|| ConstExpr::Literal("0".into())), + false, + )) +} + +/// IEEE 1800-2023 23.3.3.5. Packed actuals distribute MSB-first; +/// unpacked actuals use the compiler's declaration-order element layout. +fn distribute_port_connection( + actual: Expr, + shape: &ConnectionShape, + port_shape: &[usize], + port_width: usize, + elements: &ArrayBinding, + ordinal: usize, +) -> Converted { + let actual_shape = shape.unpacked.as_slice(); + let actual_width = shape.width; + if actual_shape == port_shape && actual_width == port_width { + return Ok(actual); + } + let packed = actual_shape.is_empty() && port_shape.is_empty(); + let distributed_shape = elements + .shape + .iter() + .chain(port_shape) + .copied() + .collect::>(); + if (!packed && actual_shape != distributed_shape) + || port_width.checked_mul(elements.elements.len()) != Some(actual_width) + { + return Err(unsupported(format!( + "interface array connection shape/width: {actual_width} bits {actual_shape:?} for {} ports of {port_width} bits {port_shape:?}", + elements.elements.len(), + ))); + } + let offset = if packed { + elements.elements.len() - ordinal - 1 + } else { + ordinal + } * port_width; + let coordinate = |offset: usize| { + let offset = const_expr_from_i128(offset as i128); + if shape.ascending { + ConstExpr::Binary { + left: Box::new(shape.origin.clone()), + op: BinaryOp::Sub, + right: Box::new(offset), + } + } else { + add_expr(shape.origin.clone(), offset) + } + }; + let msb = coordinate(offset + port_width - 1); + let lsb = coordinate(offset); + let expr = match actual { + Expr::Select { expr, .. } if matches!(expr.as_ref(), Expr::Ident(_)) => expr, + value => Box::new(value), + }; + Ok(Expr::Select { + expr, + msb, + lsb, + signed: false, + }) +} + fn connection_lvalue(expr: Expr) -> Converted { match expr { Expr::Ident(name) => Ok(LValue::Ident(name)), diff --git a/crates/celox-sv-analyzer/src/ast/interfaces.rs b/crates/celox-sv-analyzer/src/ast/interfaces.rs index a57b12356e5..fabbf9e9a25 100644 --- a/crates/celox-sv-analyzer/src/ast/interfaces.rs +++ b/crates/celox-sv-analyzer/src/ast/interfaces.rs @@ -3118,7 +3118,63 @@ pub fn plan_interfaces_with_member_paths( .iter() .map(|(code, path)| File::new(code, path)) .collect::>>()?; - let design = Design::collect(&files)?; + // Local interface instances are bound from their original declarations by + // interface_binding. A structural plan is needed only for module interface + // ports; collecting full contracts here rejects ordinary interface ports. + let mut interface_names = HashSet::default(); + let mut contract_names = HashSet::default(); + let mut module_names = HashSet::default(); + for file in &files { + let native = file.syntax_tree.declarations(); + for (_, unit) in roots(&file.syntax_tree)? { + let name = native_name(&unit.name); + match unit.kind { + native::UnitKind::Interface => { + if unit.ports.is_empty() { + contract_names.insert(name.clone()); + } + if !interface_names.insert(name.clone()) || module_names.contains(&name) { + return Err(AnalyzerError::DuplicateModule { name }); + } + } + native::UnitKind::Module => { + if interface_names.contains(&name) { + return Err(AnalyzerError::DuplicateModule { name }); + } + module_names.insert(name); + for port in &unit.ports { + if port.direction.is_some() || port.net_type.is_some() || port.variable { + continue; + } + if let Some(id) = port.data_type { + match &native.data_type(id).kind { + native::DataTypeKind::Interface { + name: Some(name), .. + } => { + contract_names.insert(native_name(name)); + } + native::DataTypeKind::Named(path) if path.len() == 1 => { + contract_names.insert(native_name(&path[0].name)); + } + _ => {} + } + } + } + } + _ => {} + } + } + } + for (_, _, supplied) in bindings { + contract_names.extend(supplied.iter().map(|(_, interface)| interface.clone())); + } + let design = if !module_names.is_empty() { + // Ordinary module contracts still need planning when local interfaces + // have ports. Collect those contracts independently of native locals. + Design::collect_selected(&files, Some(&contract_names))? + } else { + Design::collect(&files)? + }; let mut result = NativeInterfacePlan::default(); let mut reflected_paths = HashMap::default(); if design.interfaces.is_empty() { diff --git a/crates/celox-sv-analyzer/src/tests.rs b/crates/celox-sv-analyzer/src/tests.rs index 24d99e7046f..2c5241294ed 100644 --- a/crates/celox-sv-analyzer/src/tests.rs +++ b/crates/celox-sv-analyzer/src/tests.rs @@ -5265,6 +5265,38 @@ fn native_interface_array_ports_reject_incompatible_shapes() { ); } +#[test] +fn rejects_mismatched_interface_array_connection_widths_and_shapes() { + for declaration in [ + "logic [2:0] value; I lanes[1:0](.value(value));", + "logic [0:0] value [3]; I lanes[1:0](.value(value));", + "logic value [1][2]; I lanes[1:0](.value(value));", + ] { + let text = format!( + "interface I(input logic value); endinterface module Top; {declaration} endmodule" + ); + let parsed = + ParsedSource::parse(&text, Path::new("invalid-interface-array-connection.sv")).unwrap(); + let packages = ParsedSource::analyze_packages(&[&parsed]).unwrap(); + let error = parsed + .analyze_module( + "Top", + &HashMap::default(), + &[], + &[], + &ModuleInterfaces::default(), + &packages, + ) + .unwrap_err(); + assert!( + error + .to_string() + .contains("interface array connection shape/width"), + "{declaration}: {error}" + ); + } +} + #[test] fn native_interface_port_views_do_not_repeat_instance_initializers() { let module = native_interface_module( diff --git a/crates/celox-test-suite/LIMITATIONS.md b/crates/celox-test-suite/LIMITATIONS.md index d4a759ab0b7..baf27d6f58d 100644 --- a/crates/celox-test-suite/LIMITATIONS.md +++ b/crates/celox-test-suite/LIMITATIONS.md @@ -354,6 +354,17 @@ backends; the source and observed failures are retained in The SystemVerilog suite's exclusions are listed in [`verification/sv/limitations.json`](verification/sv/limitations.json), with the failures observed before them in [`verification/sv/limitations/`](verification/sv/limitations). A case is excluded for a tool only when the expected value follows IEEE 1800 and the tool either cannot run the design or disagrees with the standard; where the two tools disagree with each other, the entry says so. +The interface-array connection cases cover packed distribution, unpacked +connections and array ports, and multidimensional instance arrays (IEEE +1800-2023 23.3.3.5). Verilator 5.052 passes the three one-dimensional cases, +but counts only the inner instance dimension when validating the packed +connection width of a 2x2 array. Icarus 13.0 passes the packed case; it rejects +unpacked actuals, aborts on interface array ports, and explicitly rejects +multidimensional instance arrays. The exact case exclusions retain the +[Verilator diagnostics](verification/repros/sv_interface_array_connections_verilator.json) +and [Icarus diagnostics](verification/repros/sv_interface_array_connections_icarus.json). +Celox runs all four unchanged cases on every backend. + The `indexed_select::constant_part_select_indices_of_concatenations` case also uses these standard concatenation and replication selections as array indices (IEEE 1800-2023 11.4.12). Icarus 13.0 rejects them with syntax errors before @@ -397,7 +408,9 @@ four-state expectations; the assertions remain enabled on all Celox variants. | `sv_icarus_mixed_state_struct_members` | execute | icarus | 1 | Icarus 13.0 does not convert a 2-state member of a packed struct with 4-state members from four state when reading it, so a compound assignment to the member keeps X; IEEE 1800-2023 7.2.1 converts it. Verilator cannot check four-state values. | | `sv_icarus_unary_plus_unknown` | execute | icarus | 1 | Icarus 13.0 returns the operand of a unary plus unchanged when it has X or Z bits; IEEE 1800-2023 11.4.3 makes the result of an arithmetic operator all X. Verilator cannot check four-state values. | | `sv_icarus_runtime_packed_subselect` | compile | icarus | 3 | Icarus 13.0 rejects a further select after a runtime index into a multidimensional packed array, or after runtime indices into an unpacked array of them (t[k][j], t[k][2:1], u[j][k][i]: "Array index expressions must be constant here"). Verilator passes the two-state case; the four-state one is outside what it checks. | -| `sv_icarus_interfaces` | compile | icarus | 14 | Icarus 13.0 rejects interface port declarations (syntax error in port declarations), modport function imports ("sorry: modport task/function ports are not yet supported") and multidimensional interface instance arrays ("sorry: Multi-dimensional arrays of instances are not yet supported"). Verilator passes these cases. The implicit named interface cases have [focused pre-exclusion evidence](verification/sv/limitations/implicit-interface-ports-icarus.json). | +| `sv_verilator_multidimensional_interface_connections` | compile | verilator | 1 | Verilator 5.052 validates a 2x2 scalar interface array against a two-bit connection instead of four bits. See the focused interface-array evidence above. | +| `sv_icarus_interface_array_connections` | compile | icarus | 3 | Icarus 13.0 rejects distributed unpacked actuals and multidimensional instances, and aborts on interface array ports. See the focused interface-array evidence above. | +| `sv_icarus_interfaces` | compile | icarus | 15 | Icarus 13.0 rejects interface port declarations (syntax error in port declarations), modport function imports ("sorry: modport task/function ports are not yet supported") and multidimensional interface instance arrays ("sorry: Multi-dimensional arrays of instances are not yet supported"). Verilator passes these cases. The implicit named interface cases have [focused pre-exclusion evidence](verification/sv/limitations/implicit-interface-ports-icarus.json). The mixed module-contract/local-interface case retains its [port-declaration diagnostics](verification/repros/sv_mixed_interface_connections_icarus.json). | | `sv_icarus_packed_inner_index_range` | execute | icarus | 1 | Icarus 13.0 flattens an out-of-range inner index of a multidimensional packed array into the neighbouring element: a read gives a known value instead of X, and a write lands in that element; IEEE 1800-2023 7.4.6 and 11.5.1 make the select out of range. Verilator cannot check four-state values, and it truncates out-of-range packed indices. | | `sv_icarus_unpacked_subroutine_ports` | compile | icarus | 2 | Icarus 13.0 reports that subroutine ports with unpacked dimensions are not yet supported. Verilator passes the valid case. | | `sv_icarus_unpacked_array_patterns` | compile | icarus | 1 | Icarus 13.0 reports that an assignment pattern with unpacked array items assigned to a multidimensional unpacked array is not yet supported ("Procedural assignment of array or array slice"), so the run cannot count it as a language rejection. The design is invalid (IEEE 1800-2023 7.6, 10.8). | diff --git a/crates/celox-test-suite/src/sv/cases/interfaces.vtest b/crates/celox-test-suite/src/sv/cases/interfaces.vtest index 5c7cf68c682..44f83a53f50 100644 --- a/crates/celox-test-suite/src/sv/cases/interfaces.vtest +++ b/crates/celox-test-suite/src/sv/cases/interfaces.vtest @@ -693,3 +693,147 @@ (modify (set x value)) (assert_eq y (^ value (trunc 8 (+ value 1)))) (assert_eq z (^ (trunc 8 (~ value)) (trunc 8 (+ (trunc 8 (~ value)) 1)))))) + +(case distributes_packed_connections_to_interface_arrays + ; IEEE 1800-2023 23.3.3.5: declaration-order leftmost instances + ; receive the most significant packed slices; scalar values broadcast. + (source "interface_array_distribution.sv" #" + interface Wire(input logic value, output wire result); + assign result = value; + endinterface + interface Pair #(parameter int W = 2)(input logic [W-1:0] value, output wire [W-1:0] result); + assign result = value; + endinterface + module Top(input logic [1:0] bits_in, input logic [3:0] words_in, input logic shared, + output wire [1:0] descending, ascending, broadcast_bits, + output wire [3:0] words, + output wire [1:0] desc_members, asc_members, + output wire [3:0] selected_words, broadcast_words, generated_bits, ascending_members); + Wire down [3:2](.value(bits_in), .result(descending)); + Wire up [5:6](bits_in, ascending); + Wire same [1:0](.value(shared), .result(broadcast_bits)); + Pair #(.W(2)) pairs [1:0](.value(words_in), .result(words)); + wire [7:0] selected_bus; + logic [0:3] ascending_input; + assign ascending_input = words_in; + Pair selected_pairs [0:1](.value(ascending_input), .result(selected_bus[5:2])); + assign selected_words = selected_bus[5:2]; + assign ascending_members = {selected_pairs[0].value, selected_pairs[1].value}; + Pair shared_pairs [1:0](.value(words_in[1:0]), .result(broadcast_words)); + for (genvar k = 0; k < 2; k++) begin:g + Wire local_wires [0:1](.value(bits_in), .result(generated_bits[k*2 +: 2])); + end + assign desc_members = {down[3].value, down[2].value}; + assign asc_members = {up[5].value, up[6].value}; + endmodule + "#) + (top Top) + (for value (list 0 1 2 3) + (modify (set bits_in value) (set words_in (+ (* value 4) (- 3 value))) (set shared (% value 2))) + (assert_eq descending value) + (assert_eq ascending value) + (assert_eq desc_members value) + (assert_eq asc_members value) + (assert_eq broadcast_bits (* (% value 2) 3)) + (assert_eq words (+ (* value 4) (- 3 value))) + (assert_eq selected_words (+ (* value 4) (- 3 value))) + (assert_eq ascending_members (+ (* value 4) (- 3 value))) + (assert_eq broadcast_words (* (- 3 value) 5)) + (assert_eq generated_bits (* value 5)))) + +(case distributes_unpacked_connections_to_interface_arrays + (source "interface_unpacked_distribution.sv" #" + interface Pair(input logic [1:0] value, output wire [1:0] result); + assign result = value; + endinterface + module Top(input logic [3:0] data, output logic [3:0] y, members); + logic [1:0] inputs [7:6]; + wire [1:0] results [2:3]; + assign inputs[7] = data[3:2]; + assign inputs[6] = data[1:0]; + Pair pairs [4:5](.value(inputs), .result(results)); + assign y = {results[2], results[3]}; + assign members = {pairs[4].value, pairs[5].value}; + endmodule + "#) + (top Top) + (for value (list 0 1 6 9 14 15) + (modify (set data value)) + (assert_eq y value) + (assert_eq members value))) + +(case distributes_array_port_connections_to_interface_arrays + (source "interface_array_port_distribution.sv" #" + interface Block(input logic [1:0] value [2], output wire [1:0] result [2]); + assign result = value; + endinterface + module Top(input logic [7:0] data, output logic [7:0] y, members, + output logic [3:0] broadcast_values); + logic [1:0] inputs [2][2]; + wire [1:0] results [2][2]; + assign inputs[0][0] = data[7:6]; + assign inputs[0][1] = data[5:4]; + assign inputs[1][0] = data[3:2]; + assign inputs[1][1] = data[1:0]; + Block blocks [1:0](.value(inputs), .result(results)); + Block shared_blocks [1:0](.value(inputs[0])); + assign y = {results[0][0], results[0][1], results[1][0], results[1][1]}; + assign members = {blocks[1].value[0], blocks[1].value[1], blocks[0].value[0], blocks[0].value[1]}; + assign broadcast_values = {shared_blocks[1].value[0], shared_blocks[0].value[1]}; + endmodule + "#) + (top Top) + (for value (list 0 0x1b 0xe4 0xa5 0xff) + (modify (set data value)) + (assert_eq y value) + (assert_eq members value) + (assert_eq broadcast_values (slice value 7 4)))) + +(case distributes_multidimensional_connections_to_interface_arrays + ; IEEE 1800-2023 23.3.3.5: the rightmost dimension varies first. + (source "interface_multidimensional_distribution.sv" #" + interface Wire(input logic value, output wire result); + assign result = value; + endinterface + module Top(input logic [3:0] data, output wire [3:0] y, output logic [3:0] members); + Wire grid [2:1][4:3](.value(data), .result(y)); + assign members = {grid[2][4].value, grid[2][3].value, grid[1][4].value, grid[1][3].value}; + endmodule + "#) + (top Top) + (for value (list 0 3 5 10 15) + (modify (set data value)) + (assert_eq y value) + (assert_eq members value))) + +(case mixes_module_contracts_with_local_interface_connections + (source "mixed_interface_connections.sv" #" + interface Bus; + logic [1:0] data; + endinterface + interface Wire(input logic value, output wire result); + assign result = value; + endinterface + module Child(Bus b, output wire [1:0] y); + assign y = b.data; + endmodule + module GenericChild(interface b, output wire [1:0] y); + assign y = b.data; + endmodule + module Top(input logic [1:0] data, output wire [1:0] named_value, generic_value, array_value, + output wire single_value); + Bus bus(); + assign bus.data = data; + Child child(bus, named_value); + GenericChild generic_child(bus, generic_value); + Wire wires[1:0](data, array_value); + Wire single_wire(data[0], single_value); + endmodule + "#) + (top Top) + (for value (list 0 1 2 3) + (modify (set data value)) + (assert_eq named_value value) + (assert_eq generic_value value) + (assert_eq array_value value) + (assert_eq single_value (% value 2)))) diff --git a/crates/celox-test-suite/verification/repros/sv_interface_array_connections_icarus.json b/crates/celox-test-suite/verification/repros/sv_interface_array_connections_icarus.json new file mode 100644 index 00000000000..bbe20831092 --- /dev/null +++ b/crates/celox-test-suite/verification/repros/sv_interface_array_connections_icarus.json @@ -0,0 +1,55 @@ +{ + "schema_version": 3, + "suite": "sv", + "suite_version": "0.11.0", + "tool": "icarus", + "version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "include_ignored": false, + "note": "Focused pre-exclusion compile failures for interface array connections (IEEE 1800-2023 23.3.3.5). Shared sources and assertions remain in src/sv/cases/interfaces.vtest; no failure was converted to a pass.", + "counts": { + "passed": 0, + "rejected": 0, + "unexpected_accept": 0, + "mismatch": 0, + "emission_error": 0, + "compile_error": 3, + "runtime_error": 0, + "unsupported": 0, + "ignored": 0 + }, + "cases": [ + { + "category": "Hierarchy", + "detail": "Icarus build exit status: 134; see /build.log\n/source_0.sv:13: assert: elaborate.cc:1574: failed assertion prts.size()==1\nAborted (core dumped)\n", + "expectation": "Simulation", + "name": "interfaces::distributes_array_port_connections_to_interface_arrays", + "phase": "compile", + "status": "compile_error", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus build exit status: 1; see /build.log\n/source_0.sv:6: sorry: Multi-dimensional arrays of instances are not yet supported.\n1 error(s) during elaboration.\n", + "expectation": "Simulation", + "name": "interfaces::distributes_multidimensional_connections_to_interface_arrays", + "phase": "compile", + "status": "compile_error", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus build exit status: 2; see /build.log\n/source_0.sv:10: error: Array inputs needs an array index here.\n/source_0.sv:10: error: Failed to elaborate input port 'value' expression (inputs) in instance dut.pairs of module: Pair.\n2 error(s) during elaboration.\n", + "expectation": "Simulation", + "name": "interfaces::distributes_unpacked_connections_to_interface_arrays", + "phase": "compile", + "status": "compile_error", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + } + ] +} diff --git a/crates/celox-test-suite/verification/repros/sv_interface_array_connections_verilator.json b/crates/celox-test-suite/verification/repros/sv_interface_array_connections_verilator.json new file mode 100644 index 00000000000..f6a96094799 --- /dev/null +++ b/crates/celox-test-suite/verification/repros/sv_interface_array_connections_verilator.json @@ -0,0 +1,33 @@ +{ + "schema_version": 3, + "suite": "sv", + "suite_version": "0.11.0", + "tool": "verilator", + "version": "Verilator 5.052 2026-09-05 rev v5.052", + "include_ignored": false, + "note": "Focused pre-exclusion compile failures for interface array connections (IEEE 1800-2023 23.3.3.5). Shared sources and assertions remain in src/sv/cases/interfaces.vtest; no failure was converted to a pass.", + "counts": { + "passed": 0, + "rejected": 0, + "unexpected_accept": 0, + "mismatch": 0, + "emission_error": 0, + "compile_error": 1, + "runtime_error": 0, + "unsupported": 0, + "ignored": 0 + }, + "cases": [ + { + "category": "Hierarchy", + "detail": "Verilator build exit status: 1; see /build.log\n%Error: /source_0.sv:6:29: Input port connection 'value' as part of a module instance array requires 1 or 2 bits, but connection's VARREF 'data' generates 4 bits. (IEEE 1800-2023 23.3.3)\n : ... note: In instance 'celox_suite_tb.dut'\n 6 | Wire grid [2:1][4:3](.value(data), .result(y));\n | ^~~~~\n ... See the manual at https://verilator.org/verilator_doc.html?v=5.052 for more assistance.\n%Error: /source_0.sv:6:43: Output port connection 'result' as part of a module instance array requires 1 or 2 bits, but connection's VARREF 'y' generates 4 bits. (IEEE 1800-2023 23.3.3)\n : ... note: In instance 'celox_suite_tb.dut'\n 6 | Wire grid [2:1][4:3](.value(data), .result(y));\n | ^~~~~~\n%Error: Exiting due to 2 error(s)\n", + "expectation": "Simulation", + "name": "interfaces::distributes_multidimensional_connections_to_interface_arrays", + "phase": "compile", + "status": "compile_error", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + } + ] +} diff --git a/crates/celox-test-suite/verification/repros/sv_mixed_interface_connections_icarus.json b/crates/celox-test-suite/verification/repros/sv_mixed_interface_connections_icarus.json new file mode 100644 index 00000000000..cb3ccb5ed9e --- /dev/null +++ b/crates/celox-test-suite/verification/repros/sv_mixed_interface_connections_icarus.json @@ -0,0 +1,33 @@ +{ + "schema_version": 3, + "suite": "sv", + "suite_version": "0.11.0", + "tool": "icarus", + "version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "include_ignored": false, + "counts": { + "compile_error": 1, + "emission_error": 0, + "ignored": 0, + "mismatch": 0, + "passed": 0, + "rejected": 0, + "runtime_error": 0, + "unexpected_accept": 0, + "unsupported": 0 + }, + "cases": [ + { + "category": "Hierarchy", + "detail": "Icarus build exit status: 4; see /build.log\n/source_0.sv:8: syntax error\n/source_0.sv:8: Errors in port declarations.\n/source_0.sv:11: syntax error\n/source_0.sv:11: Errors in port declarations.\n", + "expectation": "Simulation", + "name": "interfaces::mixes_module_contracts_with_local_interface_connections", + "phase": "compile", + "status": "compile_error", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + } + ], + "note": "Focused pre-exclusion failure: Icarus rejects the typed and generic module interface port declarations in the mixed local-interface connection regression. Celox and Verilator pass the unchanged source and assertions." +} diff --git a/crates/celox-test-suite/verification/sv/icarus/interfaces.json b/crates/celox-test-suite/verification/sv/icarus/interfaces.json index 857a898b77f..5ed546a6a29 100644 --- a/crates/celox-test-suite/verification/sv/icarus/interfaces.json +++ b/crates/celox-test-suite/verification/sv/icarus/interfaces.json @@ -10,6 +10,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -35,6 +36,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -60,6 +62,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -85,6 +88,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -110,6 +114,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -135,6 +140,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -160,6 +166,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -196,6 +203,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -221,6 +229,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -246,6 +255,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -271,6 +281,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -305,6 +316,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ] }, @@ -413,6 +425,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -438,6 +451,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "id": "sv_icarus_interfaces", @@ -452,6 +466,101 @@ "stronger_than_sv": false, "tag_reasons": {}, "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_compile_limitation", + "evidence": [ + "verification/repros/sv_interface_array_connections_icarus.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_interface_array_connections", + "observed_version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "phase": "compile", + "reason": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "upstream": [] + }, + "name": "interfaces::distributes_array_port_connections_to_interface_arrays", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_compile_limitation", + "evidence": [ + "verification/repros/sv_interface_array_connections_icarus.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_interface_array_connections", + "observed_version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "phase": "compile", + "reason": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "upstream": [] + }, + "name": "interfaces::distributes_multidimensional_connections_to_interface_arrays", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_compile_limitation", + "evidence": [ + "verification/repros/sv_interface_array_connections_icarus.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_interface_array_connections", + "observed_version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "phase": "compile", + "reason": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "upstream": [] + }, + "name": "interfaces::distributes_unpacked_connections_to_interface_arrays", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Icarus 13.0 rejects interface port declarations (syntax error in port declarations), modport function imports (\"sorry: modport task/function ports are not yet supported\") and multidimensional interface instance arrays (\"sorry: Multi-dimensional arrays of instances are not yet supported\"). Verilator passes these cases.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_compile_limitation", + "evidence": [ + "verification/sv/limitations/icarus.json", + "verification/sv/limitations/interface-array-ports-icarus.json", + "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_icarus_interfaces", + "observed_version": "Celox SV frontend; Verilator 5.052 / Icarus 13.0", + "phase": "compile", + "reason": "Icarus 13.0 rejects interface port declarations (syntax error in port declarations), modport function imports (\"sorry: modport task/function ports are not yet supported\") and multidimensional interface instance arrays (\"sorry: Multi-dimensional arrays of instances are not yet supported\"). Verilator passes these cases.", + "upstream": [] + }, + "name": "interfaces::mixes_module_contracts_with_local_interface_connections", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] } ] } diff --git a/crates/celox-test-suite/verification/sv/limitations.json b/crates/celox-test-suite/verification/sv/limitations.json index 40f8787d4b0..35d0da4feb3 100644 --- a/crates/celox-test-suite/verification/sv/limitations.json +++ b/crates/celox-test-suite/verification/sv/limitations.json @@ -605,6 +605,7 @@ "verification/sv/limitations/icarus.json", "verification/sv/limitations/interface-array-ports-icarus.json", "verification/sv/limitations/implicit-interface-ports-icarus.json", + "verification/repros/sv_mixed_interface_connections_icarus.json", "LIMITATIONS.md#systemverilog-suite" ], "cases": { @@ -619,6 +620,7 @@ "interfaces::drives_members_through_child_outputs_and_array_generate_regions", "interfaces::elaborates_net_members_typedefs_and_localparams", "interfaces::infers_directions_of_ports_without_modport", + "interfaces::mixes_module_contracts_with_local_interface_connections", "interfaces::overrides_body_parameters_and_drives_members_from_imported_functions", "interfaces::reads_undriven_interface_members_as_unknown", "interfaces::rewrites_nested_references_and_keeps_declaration_functions", @@ -626,6 +628,42 @@ ] } }, + { + "id": "sv_verilator_multidimensional_interface_connections", + "category": "simulator_compile_limitation", + "phase": "compile", + "observed_version": "Verilator 5.052 2026-09-05 rev v5.052", + "reason": "Verilator 5.052 rejects a four-bit actual connected to a 2x2 interface instance array with scalar ports, requiring only 1 or 2 bits instead of 1 or 4. IEEE 1800-2023 23.3.3.5 distributes packed actuals across all instance dimensions, rightmost dimension first. Celox passes the unchanged shared assertions; Icarus separately rejects multidimensional instance arrays.", + "upstream": [], + "evidence": [ + "verification/repros/sv_interface_array_connections_verilator.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "cases": { + "verilator": [ + "interfaces::distributes_multidimensional_connections_to_interface_arrays" + ] + } + }, + { + "id": "sv_icarus_interface_array_connections", + "category": "simulator_compile_limitation", + "phase": "compile", + "observed_version": "Icarus Verilog version 13.0 (stable) (v13_0)", + "reason": "Icarus 13.0 rejects unpacked actuals distributed across interface instances (Array inputs needs an array index), aborts on interface array ports (assertion prts.size()==1), and rejects multidimensional instance arrays explicitly. IEEE 1800-2023 23.3.3.5 permits these connections. Verilator passes both unpacked cases; Celox passes all three.", + "upstream": [], + "evidence": [ + "verification/repros/sv_interface_array_connections_icarus.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "cases": { + "icarus": [ + "interfaces::distributes_array_port_connections_to_interface_arrays", + "interfaces::distributes_multidimensional_connections_to_interface_arrays", + "interfaces::distributes_unpacked_connections_to_interface_arrays" + ] + } + }, { "id": "sv_icarus_dimensions_type_queries", "category": "simulator_compile_limitation", diff --git a/crates/celox-test-suite/verification/sv/verilator/interfaces.json b/crates/celox-test-suite/verification/sv/verilator/interfaces.json index ac71a506b90..4ec712f8799 100644 --- a/crates/celox-test-suite/verification/sv/verilator/interfaces.json +++ b/crates/celox-test-suite/verification/sv/verilator/interfaces.json @@ -131,6 +131,29 @@ "stronger_than_sv": false, "tag_reasons": {}, "tags": [] + }, + { + "category": "Hierarchy", + "detail": "Verilator 5.052 rejects a four-bit actual connected to a 2x2 interface instance array with scalar ports, requiring only 1 or 2 bits instead of 1 or 4. IEEE 1800-2023 23.3.3.5 distributes packed actuals across all instance dimensions, rightmost dimension first. Celox passes the unchanged shared assertions; Icarus separately rejects multidimensional instance arrays.", + "expectation": "Simulation", + "known_issue": { + "category": "simulator_compile_limitation", + "evidence": [ + "verification/repros/sv_interface_array_connections_verilator.json", + "LIMITATIONS.md#systemverilog-suite" + ], + "id": "sv_verilator_multidimensional_interface_connections", + "observed_version": "Verilator 5.052 2026-09-05 rev v5.052", + "phase": "compile", + "reason": "Verilator 5.052 rejects a four-bit actual connected to a 2x2 interface instance array with scalar ports, requiring only 1 or 2 bits instead of 1 or 4. IEEE 1800-2023 23.3.3.5 distributes packed actuals across all instance dimensions, rightmost dimension first. Celox passes the unchanged shared assertions; Icarus separately rejects multidimensional instance arrays.", + "upstream": [] + }, + "name": "interfaces::distributes_multidimensional_connections_to_interface_arrays", + "phase": "skip", + "status": "ignored", + "stronger_than_sv": false, + "tag_reasons": {}, + "tags": [] } ] } diff --git a/crates/celox/tests/frontends/systemverilog/interfaces.rs b/crates/celox/tests/frontends/systemverilog/interfaces.rs index 30d336fbbf4..20f54ade184 100644 --- a/crates/celox/tests/frontends/systemverilog/interfaces.rs +++ b/crates/celox/tests/frontends/systemverilog/interfaces.rs @@ -1,6 +1,25 @@ use super::*; sv_backends! { + fn distributes_multidimensional_connections_to_interface_arrays(sim) { + @case "interfaces::distributes_multidimensional_connections_to_interface_arrays"; + } + + fn distributes_array_port_connections_to_interface_arrays(sim) { + @case "interfaces::distributes_array_port_connections_to_interface_arrays"; + } + + fn distributes_unpacked_connections_to_interface_arrays(sim) { + @case "interfaces::distributes_unpacked_connections_to_interface_arrays"; + } + + fn mixes_module_contracts_with_local_interface_connections(sim) { + @case "interfaces::mixes_module_contracts_with_local_interface_connections"; + } + fn distributes_packed_connections_to_interface_arrays(sim) { + @case "interfaces::distributes_packed_connections_to_interface_arrays"; + } + fn binds_implicit_named_interface_ports(sim) { @case "interfaces::binds_implicit_named_interface_ports"; }