From 35a11d855076ebb3d89d515f40567d02bbff3e5c Mon Sep 17 00:00:00 2001 From: tignear Date: Sat, 17 Oct 2026 04:13:40 +0900 Subject: [PATCH 1/2] test(testbench): cover Veryl string variable semantics --- .../celox-test-suite/src/veryl/cases/mod.rs | 4 + .../src/veryl/cases/tb_string.vtest | 79 +++++++++++++++++++ crates/celox/tests/testbench_string.rs | 31 ++++++++ 3 files changed, 114 insertions(+) create mode 100644 crates/celox-test-suite/src/veryl/cases/tb_string.vtest create mode 100644 crates/celox/tests/testbench_string.rs diff --git a/crates/celox-test-suite/src/veryl/cases/mod.rs b/crates/celox-test-suite/src/veryl/cases/mod.rs index 4d6b0a4a49e..b84278bf228 100644 --- a/crates/celox-test-suite/src/veryl/cases/mod.rs +++ b/crates/celox-test-suite/src/veryl/cases/mod.rs @@ -7,6 +7,10 @@ pub(super) struct Group { } pub(super) const GROUPS: &[Group] = &[ + Group { + file: "src/veryl/cases/tb_string.vtest", + text: include_str!("tb_string.vtest"), + }, Group { file: "src/veryl/cases/partial_word_shift.vtest", text: include_str!("partial_word_shift.vtest"), diff --git a/crates/celox-test-suite/src/veryl/cases/tb_string.vtest b/crates/celox-test-suite/src/veryl/cases/tb_string.vtest new file mode 100644 index 00000000000..39d8d711c12 --- /dev/null +++ b/crates/celox-test-suite/src/veryl/cases/tb_string.vtest @@ -0,0 +1,79 @@ +(group tb_string (category control_flow)) + +(case assignment + (source "test.veryl" #"#[test(Top)] +module Top { + var text: string; + var copy: string; + initial { + text = "short"; + $assert(text == "short"); + copy = text; + text = "a string longer than sixty-four bits"; + $assert(text == "a string longer than sixty-four bits"); + $assert(copy == "short"); + copy = text; + $assert(copy == text); + text = "x"; + $assert(text == "x"); + $assert(copy != text); + text = ""; + $assert(text == ""); + $assert(copy != text); + $finish(); + } +} +"#) + (top Top) + (run_testbench)) + +(case comparison + (source "test.veryl" #"#[test(Top)] +module Top { + var left: string; + var right: string; + initial { + left = "b"; + right = "aa"; + $assert(left >: right); + $assert(left >= right); + $assert(right <: left); + $assert(right <= left); + $assert(left != right); + right = left; + $assert(left == right); + $assert(left <= right); + $assert(left >= right); + left = ""; + $assert(left <: right); + $finish(); + } +} +"#) + (top Top) + (run_testbench)) + +(case control_flow + (source "test.veryl" #"#[test(Top)] +module Top { + var text: string; + var choose: logic; + initial { + text = "before"; + $assert(text == "before"); + choose = 1; + text = if choose ? "longer branch value" : "no"; + $assert(text == "longer branch value"); + choose = 0; + text = if choose ? "no" : ""; + $assert(text == ""); + for i in 0..3 { + if i == 1 { text = "middle"; } + } + $assert(text == "middle"); + $finish(); + } +} +"#) + (top Top) + (run_testbench)) diff --git a/crates/celox/tests/testbench_string.rs b/crates/celox/tests/testbench_string.rs new file mode 100644 index 00000000000..c9c10bdbdd2 --- /dev/null +++ b/crates/celox/tests/testbench_string.rs @@ -0,0 +1,31 @@ +#[path = "test_utils/mod.rs"] +#[macro_use] +#[allow(unused_macros)] +mod test_utils; + +all_backends! { + fn tb_string_assignment(sim) { + @omit_veryl; + // Veryl does not emit #[test] modules into SystemVerilog. + // Celox currently truncates string assignments to the nominal one-bit width. + // All six Celox configurations fail these cases; the support PR enables them. + @ignore_on(native, cranelift, wasm, interp, sv); + @case "tb_string::assignment"; + } + fn tb_string_comparison(sim) { + @omit_veryl; + // Veryl does not emit #[test] modules into SystemVerilog. + // Celox currently truncates string assignments to the nominal one-bit width. + // All six Celox configurations fail these cases; the support PR enables them. + @ignore_on(native, cranelift, wasm, interp, sv); + @case "tb_string::comparison"; + } + fn tb_string_control_flow(sim) { + @omit_veryl; + // Veryl does not emit #[test] modules into SystemVerilog. + // Celox currently truncates string assignments to the nominal one-bit width. + // All six Celox configurations fail these cases; the support PR enables them. + @ignore_on(native, cranelift, wasm, interp, sv); + @case "tb_string::control_flow"; + } +} From 7d433b4275cc9bf423c6e4cdb0421ffc8a8b4884 Mon Sep 17 00:00:00 2001 From: tignear Date: Sat, 17 Oct 2026 05:01:05 +0900 Subject: [PATCH 2/2] test(testbench): update catalogue count for string cases --- crates/celox-test-suite/tests/external_adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/celox-test-suite/tests/external_adapter.rs b/crates/celox-test-suite/tests/external_adapter.rs index cda2b717ee0..effbd8135cd 100644 --- a/crates/celox-test-suite/tests/external_adapter.rs +++ b/crates/celox-test-suite/tests/external_adapter.rs @@ -93,7 +93,7 @@ fn catalogue_has_unique_stable_names_and_categories() { assert!(names.insert(case.name), "duplicate {}", case.name); assert!(case.name.contains("::")); } - assert_eq!(names.len(), 749); + assert_eq!(names.len(), 752); assert_eq!( case("operators::test_bitwise_operations").unwrap().category, Category::Operators