From c9c17c99921b850636bc39af2eaacbfd30359381 Mon Sep 17 00:00:00 2001 From: tignear Date: Tue, 20 Oct 2026 19:14:58 +0900 Subject: [PATCH 1/2] fix(veryl): preserve one-bit struct and union member selects A struct or union containing a single bit has an implicit packed width in Veryl's TypeKind. Retain that dimension when lowering member selects instead of rejecting a valid bit-0 access against zero dimensions. Leave scalar and enum handling unchanged. Add shared regressions for logic/reset fields, nested structs, union aliases and FF reset/capture. These reproduce on stable master independently of the Veryl HEAD dependency roll. Validation: - Standalone master-based struct_constructor harness: 31 passed, including 16 new tests across all eight backend/reference variants. - Frontend units and affected enum/array/language integration tests: 506 passed; 12 existing ignores (reused evidence for identical Rust source and dependencies). - Both new shared cases pass Verilator and Icarus. - NAPI build and JS library's 422 tests pass with this exact Rust implementation. - Affected-crate Clippy, Rust formatting and diff checks pass. Change-Id: Ic316b3194f51bd72406e12e0fbdd64f31073bde7 --- .../src/lowering/bitaccess.rs | 8 +-- .../src/veryl/cases/struct_constructor.vtest | 60 +++++++++++++++++++ crates/celox/tests/struct_constructor.rs | 7 +++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/crates/celox-frontend-veryl/src/lowering/bitaccess.rs b/crates/celox-frontend-veryl/src/lowering/bitaccess.rs index 115e10a14b3..3f6ee374de7 100644 --- a/crates/celox-frontend-veryl/src/lowering/bitaccess.rs +++ b/crates/celox-frontend-veryl/src/lowering/bitaccess.rs @@ -225,12 +225,12 @@ fn collect_dims(module: &Module, var_id: VarId) -> Result, ParserErro "array", &mut dims, )?; - // For enum-typed variables, the width Shape is empty but the actual - // bit width is encoded in the TypeKind. Use kind.width() as the - // base scalar width when the explicit width shape is absent. + // Enums and aggregates encode their packed width in TypeKind rather + // than the width Shape. Even a one-bit struct/union needs that dimension: + // Veryl represents member access as a select into the packed aggregate. if width.is_empty() { if let Some(kind_width) = var_type.kind.width() - && kind_width > 1 + && (kind_width > 1 || (kind_width == 1 && var_type.is_struct_union())) { dims.push(kind_width); } diff --git a/crates/celox-test-suite/src/veryl/cases/struct_constructor.vtest b/crates/celox-test-suite/src/veryl/cases/struct_constructor.vtest index 1ff32fbb1b2..34ceec524bd 100644 --- a/crates/celox-test-suite/src/veryl/cases/struct_constructor.vtest +++ b/crates/celox-test-suite/src/veryl/cases/struct_constructor.vtest @@ -53,3 +53,63 @@ o_cut = Cut'{y: wide}; (assert_eq o_pad 0x0B) ; wide(8bit) -> member logic<4> should keep lower 4 bits. (assert_eq o_cut 0xB)) + +(case test_single_bit_aggregate_members + (source "test.veryl" #" +module Top ( + i: input logic, + rst: input reset_sync_low, + members: output logic<3>, + reset_member: output logic, +) { + struct Single { value: logic, } + struct Nested { inner: Single, } + struct Reset { value: reset_sync_low, } + union Overlay { value: logic, other: logic, } + var single: Single; + var nested: Nested; + var reset_pair: Reset; + var overlay: Overlay; + assign single.value = i; + assign nested.inner.value = i; + assign reset_pair.value = rst; + assign overlay.value = i; + assign members = {single.value, nested.inner.value, overlay.other}; + assign reset_member = reset_pair.value; +} +"#) + (top Top) + (modify (set i 0) (set rst 1)) + (assert_eq members 0) + (assert_eq reset_member 1) + (modify (set i 1) (set rst 0)) + (assert_eq members 7) + (assert_eq reset_member 0)) + +(case test_single_bit_struct_ff + (source "test.veryl" #" +module Top ( + clk: input clock, + rst: input reset, + i: input logic, + o: output logic, +) { + struct Single { value: logic, } + var registered: Single; + always_ff (clk, rst) { + if_reset { registered.value = 1'b0; } + else { registered.value = i; } + } + assign o = registered.value; +} +"#) + (top Top) + (modify (set rst 0) (set i 1)) + (tick clk) + (assert_eq o 0) + (modify (set rst 1)) + (tick clk) + (assert_eq o 1) + (modify (set i 0)) + (tick clk) + (assert_eq o 0)) diff --git a/crates/celox/tests/struct_constructor.rs b/crates/celox/tests/struct_constructor.rs index 359538e8a76..a547523e541 100644 --- a/crates/celox/tests/struct_constructor.rs +++ b/crates/celox/tests/struct_constructor.rs @@ -3,6 +3,13 @@ mod test_utils; all_backends! { + fn test_single_bit_aggregate_members(sim) { + @case "struct_constructor::test_single_bit_aggregate_members"; + } + + fn test_single_bit_struct_ff(sim) { + @case "struct_constructor::test_single_bit_struct_ff"; + } fn test_struct_constructor_comb_assignment(sim) { @case "struct_constructor::test_struct_constructor_comb_assignment"; From 68cf47b92129a37ab5b6b7e5a4c046ddf51ba0f2 Mon Sep 17 00:00:00 2001 From: mergify <37929162+mergify@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:27:00 +0000 Subject: [PATCH 2/2] chore(deps): update mbx to 1.25.0 --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index aad2340f531..a6e0cef588c 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1792195366, - "narHash": "sha256-kqOyKz1zB7CB60DYPWx3fwFnL0R58A6Zzdmgiv15o7Y=", + "lastModified": 1792488653, + "narHash": "sha256-6mDIj7DP6kHQAdT0B7N8QpC3KBrY6W8LEenKg3GGfM0=", "owner": "tignear", "repo": "nix-packages", - "rev": "433f006183bab18dfcaa0a3104ec1c7c9bc907af", + "rev": "683234e1ef474a6fbb653ce7ec11aa4657d49975", "type": "github" }, "original": {