From 83eb54ec7e5b4c438b4a83a51b21161b41538bb9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 4 Jul 2026 11:05:34 -0400 Subject: [PATCH] Fix wild compare operators on strings --- src/V3Width.cpp | 6 ++++-- test_regress/t/t_eq_wild.v | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 86d688cc7..a99b293ed 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -9564,9 +9564,11 @@ class WidthVisitor final : public VNVisitor { // No width change on output;... // All below have bool or double outputs switch (nodep->type()) { case VNType::Eq: - case VNType::EqCase: newp = new AstEqN{fl, lhsp, rhsp}; break; + case VNType::EqCase: + case VNType::EqWild: newp = new AstEqN{fl, lhsp, rhsp}; break; case VNType::Neq: - case VNType::NeqCase: newp = new AstNeqN{fl, lhsp, rhsp}; break; + case VNType::NeqCase: + case VNType::NeqWild: newp = new AstNeqN{fl, lhsp, rhsp}; break; case VNType::Gt: case VNType::GtS: newp = new AstGtN{fl, lhsp, rhsp}; break; case VNType::Gte: diff --git a/test_regress/t/t_eq_wild.v b/test_regress/t/t_eq_wild.v index c34463bd1..100726f23 100644 --- a/test_regress/t/t_eq_wild.v +++ b/test_regress/t/t_eq_wild.v @@ -4,7 +4,16 @@ // SPDX-FileCopyrightText: 2026 Antmicro // SPDX-License-Identifier: CC0-1.0 +// verilog_format: off +`define stop $stop +`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); +// verilog_format: on + module t; + localparam string AB = "AB"; + + bit r; + initial begin if (('bxz10 ==? 'bxxx0) !== 1) $stop; if (('bxz10 ==? 'bxxx1) !== 0) $stop; @@ -12,6 +21,16 @@ module t; if (('bxz10 !=? 'bxxx1) !== 1) $stop; if (('bxz10 !=? 'bxxx0) !== 0) $stop; if (('bxz10 !=? 'b1xx0) !== 'x) $stop; + + r = (AB ==? "AA"); + `checkd(r, 0); + r = (AB ==? "AB"); + `checkd(r, 1); + r = (AB !=? "AB"); + `checkd(r, 0); + + // real/shortreal is illegal so not tested here + $write("*-* All Finished *-*\n"); $finish; end