I get a Incompatible type error when I try to instantiate an Environment into a top level file.
The issue (from the error verbiage) is that the type of the Parent parameter of the Environment is different from the type passed into “::create(, this)” . The issue is that the “this” reference
is of (apparently) a different type then the one defined in the “new” function of the Environment in question. In the environment file there is function new (string name == “myName”, uvm_component parent);
In the elaborate step the tool complains that “this” is not actually “just” a uvm_component, but its name also contains the name of the package this top level class is defined in - something like “TOP_PKGNAME.UMV_PKG.uvm_component”. So they don’t match, and the Elaboration fails.
I believe the issue has to do with how we are defining and using packages to organize all the content.
I did inspect this code and it looks very straight forward and correct. We tried many variations of ideas but nothing seemed to work.
The only idea that seemed to get close is to separately defined a uvm_component class member variable, that variable gets the Parent of the top level file, then, we pass this into our environment as the second parm (the “this”). It still failed, but…and this is key, the error was that the “uvm_component” type itself was from a different UVM_PKG. Weird.
Alone, each Environment compiles/runs correctly - the issues is when we try to put them together.
If we don’t pass “this” into the called Environment the build passes. The issue is that NOT passing it breaks the hierarchical UMV path that we’d like to preserve for uvm_config_db’s that make sense.
This has to work, right? The architecture of UVM is to maintain the Parent/Child relationship, but for some reason the compiler doesn’t like the types we’ve passed.
Any help is appreciated…thanks!!
In reply to ljgiordano:
It is a little bit confusing what you are writing.
Do you really instantiate an env in your toplevel module? This is not what we are doing in the UVM. Additionally in the Elaboration your env does not exist. It will be created during runtime 0.
Maybe you can clarify these things.
In reply to chr_sue:
I might have explained this incorrectly. Let me try again:
We’re creating a larger system (UVM Env) from smaller sub systems, themselves UVM Env(s).
The Parent in this case is the place in which the smaller environments are instantiated using “create” in the build step. The sub environments get the parent pointer typically using “this”.
When I speak of “elaboration”, I mean as part of the Build process from another non-Mentor
RTL compiler. The analyze step passes, since there are no syntactical errors.
When the build process enters the “elaboration” step, the error is identified as described.
The parent pointer is said to have a different type then the parameter defined in the child environments.
In reply to ljgiordano:
Elaboration has nothing to do with Mentor tools. This is a step in the buil process of static components.
Dou you have something like this:
//-----------------------------------------------------------------------------
class example_top_env extends uvm_env;
//-----------------------------------------------------------------------------
apb_env apb_env_i;
spi_env spi_env_i;
example_top_config cfg;
//example_top_scoreboard scoreboard;
`uvm_component_utils(example_top_env)
extern function new(string name = "example_top_env", uvm_component parent = null);
extern function void build_phase(uvm_phase phase);
extern function void connect_phase(uvm_phase phase);
extern function void check_phase(uvm_phase phase);
endclass : example_top_env
//-----------------------------------------------------------------------------
// example_top_env implementation
//-----------------------------------------------------------------------------
function example_top_env::new(string name = "example_top_env", uvm_component parent = null);
super.new(name,parent);
endfunction : new
function void example_top_env::build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_type_name(), "In build_phase", UVM_HIGH)
if (!uvm_config_db #(example_top_config)::get(this, "", "example_top_config", cfg))
`uvm_error(get_type_name(), "unable to get example_top_config")
uvm_config_db #(apb_config)::set(this, "*", "apb_config", cfg.apb_cfg);
uvm_config_db #(spi_config)::set(this, "*", "spi_config", cfg.spi_cfg);
apb_env_i = apb_env::type_id::create("apb_env_i", this);
spi_env_i = spi_env::type_id::create("spi_env_i", this);
//scoreboard = example_top_scoreboard::type_id::create("scoreboard", this);
endfunction : build_phase
In reply to chr_sue:
I’m working with a VCS compiler: which has an analysis and elaboration step.
Thanks for pasting the code. Our issue is with similar looking code at these statements:
apb_env_i = apb_env::type_id::create(“apb_env_i”, this);
spi_env_i = spi_env::type_id::create(“spi_env_i”, this);
In the elaboration step of VCS, “this” is said to have a different type than the one
defined in the sub environments “new” function. In this example, “apb_env”
defines:
function new(string name, uvm_component parent);
super.new(name, parent)’
endfunction
When we pass “this” into this in the build step, we get the “type” fail.
BTW - The only reason I continue to mention the elaboration step is to
show that it pass through the analysis step, which indicates there is no syntax errors.
In reply to ljgiordano:
This is probably a tool usage issue, please contact your vendor. You may have two instances of the uvm_pkg compiled
In reply to ljgiordano:
Could you please show me your VCS compile command? Maybe it is caused by this.
Thanks chr_sue and dave_59 : Agreed : The integration issue we see does have to do with
differing UVM packages; we’re headed down that path now to resolve. I’ll post later
with the final solution.