Using get_type_name in an interface

Hello,

I have an interface with some assertions,
In case assertion failed I report a `uvm_error

since I have this interface instanced multiple times in my environment,
I would like to use get_type_name in the error message, for easier debug.

But, when I add get_type_name I get a compile error:
"
Hierarchical name component lookup failed for ‘get_type_name’ at <interface-file & get_type_name location in the file>

should I include uvm_macros or import uvm_pkg ?
Or get_type_name can’t be used in an interface, only in object and component ?

who can I solve my dilemma ?

Thanks, Aidy

In reply to AL_verif:

Hi,

Get_type_name can be used with the objects of the classes that are registered with the factory. It won’t work with interfaces. If you want to print the complete hierarchical path, then, you can use %m.

You can find the below example for the usage of %m.

$display("in %m, @time t = %t, start signal is %0d", $time, start);

Hope this helps.

Putta Satish

In reply to puttasatish:

In reply to AL_verif:
Hi,
Get_type_name can be used with the objects of the classes that are registered with the factory. It won’t work with interfaces. If you want to print the complete hierarchical path, then, you can use %m.
You can find the below example for the usage of %m.

$display("in %m, @time t = %t, start signal is %0d", $time, start);

Hope this helps.
Putta Satish

I tried %m,
but I get the output “%m” himself :
[in %m] Failed …

what can be the reason that %m don’t print the module name ?

In reply to AL_verif:

Can we see the exact code you used to print the message?

In reply to dave_59:

This is my error message, It comes in an assertion in an interface:
`uvm_error(“in %m”, $sformatf(“Failed. address=%0h, data=%0h” adrr, data))

In reply to AL_verif:

Only certain strings to certain system functions get interpreted as formatting strings. Try:

`uvm_error($sformatf("in %m"), $sformatf("Failed. address=%0h, data=%0h" adrr, data))

In reply to dave_59:

Working for me now.

Thank you all !