I want to assign a hierarchical path to a string variable inside a generate block for N number of instances.
Please let me know if it can work. I'm getting errors for hier assignment.
xmvlog: *E,EXPLPA (testbench.sv,17|9): expecting a left parenthesis ('(') [12.1.2][7.1(IEEE)].
sub.str = `STRINGIFY(`HPATH);
This is the code I have tried:
module test;
`define STRINGIFY(x) `"x`"
`define HPATH top.chip.block
subtest sub[3]();
string hpath;
initial begin
hpath = `STRINGIFY(`HPATH);
$display("HPATH is %s", hpath);
end
genvar r;
generate
for (r=0;r<2;r++)begin
sub[r].str = `STRINGIFY(`HPATH);
end
endgenerate
endmodule
module subtest();
string str;
initial begin
$display("%s",str);
end
endmodule