I was trying text substitution feature in SV
module Text_Substitution ;
`define HI Hello
`define H(x) "Hello , x"
`define LO "`HI, world"
initial begin
$display("`HI, world");
$display(`LO);
$display(`H(world));
end
endmodule
I get Output ::
HI, world
HI, world
Hello , x
Since LRM doesn’t allow text substitution within String literals we observe `HI in first 2 lines of output
So I changed the code to ::
module Text_Substitution2 ;
`define HI Hello
`define H(x) "Hello , x"
`define LO { `"HI`", " world" } // [X]
initial begin
$display( { `"HI`" , " world" } ); // [Y]
$display(`LO);
$display(`H(world));
end
endmodule
I get different Output across simulators . What should the actual O/P be ?
My understanding is via string concatenation ( via and [Y] ) I should be able to achieve text substitution
I expect the Output to be ::
Hello, world
Hello, world
Hello , world
via each of 3 defines at Top .