Add support for localparam of packed struct types
Problem to solve
Add SV support of tmrg for typedef struct packed{}
initialized as localparam
.
Target audience
TMRG version
Commit 854b369f
Further details
I am in the process of applying tmrg
to a popular open-source RISC-V core written in SystemVerilog. In that process I have encountered following issue, described by a passing and failing minimum example:
TMRG PASSES:
module top ();
typedef struct packed {
bit [3:0] lo;
bit [3:0] hi;
} p1_t;
p1_t p1 = '{4'h5, 4'hA};
initial begin
$display(":assert: ('%h' == '5a')", p1);
$display(":assert: (('%h' == 'a') and ('%h' == '5'))", p1.hi, p1.lo);
end
endmodule
TMRG FAILS:
module top ();
typedef struct packed {
bit [3:0] lo;
bit [3:0] hi;
} p1_t;
localparam p1_t p1 = '{4'h5, 4'hA};
initial begin
$display(":assert: ('%h' == '5a')", p1);
$display(":assert: (('%h' == 'a') and ('%h' == '5'))", p1.hi, p1.lo);
end
endmodule
Proposal
What does success look like, and how can we measure that?
TMRG accepts above failing case.
Links / references
Example file where this is used in the Ibex https://github.com/lowRISC/ibex/blob/master/rtl/ibex_pkg.sv.
Edited by Anvesh Nookala