In Uvm factory create call, can the instance name be the same as class name?

Hi,
In my uvm env code I have something like

function void build_phase(uvm_phase phase);
35 if (!uvm_config_db #(zt_wi_env_config)::get(this, “”, “zt_wi_env_config”, zt_wi_env_cfg))
36 `uvm_fatal(“CONFIG_LOAD”, “Cannot get() configuration zt_wi_env_config from uvm_config_db. Have you set() it?”)
37
38 uvm_config_db #(pkt_gen_agent_config)::set(this, “pkt_gen_agent_inst*”,
39 “pkt_gen_agent_config”,
40 zt_wi_env_cfg.pkt_gen_agent_cfg);
41 pkt_gen_agent = pkt_gen_agent::type_id::create(“pkt_gen_agent”, this);

However I get the following error…

zt_wi_env_pkg, “pkt_gen_agent::type_id::create”
Target for scope resolution operator does not exist. Token ‘pkt_gen_agent’
is not a class/package. Originating module ‘zt_wi_env_pkg’.
Check that class or package exists with referred token as the name.

Issue seems to be that in the code below, we cannot have instance name same as class name ?

inst_name = type_name::type_id::create(“inst_name”);

Is this true ? Should we always keep instance name different from class names in general ?(most code either prefix m_ or a suffix _inst).

-sanjeev

The problem is you cannot have the same identifier mean two different things in the same scope.

Declaring a class variable name with the same class type name from another scope is legal, but it hides the original type name from the current scope.

So even though the following is legal:

 pkt_gen_agent  pkt_gen_agent;

Using pkt_gen_agent as type to declare another variable, or in the static method reference pkt_gen_agent::type_id::create is no longer legal.