Hi,
In the below code, I would like to get the hierarchy into a string m1/m2. only upto module instance. But I am getting some thing extra like “unnamed$$_0” at the end… Can we get the module hierarchy from $sformatf(%m) similar to $display(%m) to store the hierarchy into a string…?
module top;
buff b0 (.buf_in(1'b0), .buf_out());
endmodule
module buff (
input buf_in,
output buf_out
);
wire a;
inv i0 (.in(buf_in), .out(a ));
inv i1 (.in(a ), .out(buf_out));
initial $display("Inside hierarchy %m");
endmodule
module inv (
input in,
output out
);
assign out = ~in;
initial
begin
string m1,m2 ;
m1 = $sformatf("%m");
$sformat(m2,"%m");
$display("string m1 is %s",m1);
$display("string m2 is %s",m2);
end
endmodule
Output :
Inside hierarchy top.b0
string m1 is top.b0.i0.unnamed$$_0
string m2 is top.b0.i0.unnamed$$_0
string m1 is top.b0.i1.unnamed$$_0
string m2 is top.b0.i1.unnamed$$_0