verilator icon indicating copy to clipboard operation
verilator copied to clipboard

JSON output does not distinguish between case, casex, and casez statements

Open MrWater98 opened this issue 1 month ago • 3 comments

I'm developing a parser based on Verilator's JSON output and noticed that the generated JSON does not differentiate between case, casex, and casez statements (All display with "type":"CASE").

Environment: Verilator version: 5.029 devel rev v5.028-36-g201e34379

Example Code:

// file: casez_example.v
module casez_example (
    input  [1:0] sel,
    input  [7:0] a,
    input  [7:0] b,
    output reg [7:0] y
);
    always @(*) begin
        casez (sel)
            2'b1?: y = a;  // sel = 10, 11, 1x, 1z 
            default: y = b;
        endcase
    end
endmodule

Example Json:

"stmtsp": [
        {"type":"CASE","name":"","addr":"(N)","loc":"d,9:9,9:14",
         "exprp": [
          {"type":"VARREF","name":"sel","addr":"(O)","loc":"d,9:16,9:19","dtypep":"(G)","access":"RD","varp":"(F)","varScopep":"UNLINKED","classOrPackagep":"UNLINKED"}
        ],

MrWater98 avatar Nov 25 '25 04:11 MrWater98

Might you make a pull to fix this? I suspect there will be others you will need.

Add a AstCase::dumpJson and AstCase::dump methods that print the m_casex->ascii() identifier, you can see examples in other dump methods. You'll then need to update the tests by running with --gold.

wsnyder avatar Nov 25 '25 09:11 wsnyder

Sure, let me check.

MrWater98 avatar Nov 26 '25 05:11 MrWater98

Fix comment above was intended to refer to #6773.

wsnyder avatar Dec 07 '25 18:12 wsnyder