I tried to write a testbench using configuration objects, but I am facing an error when I get the object in top_spi_tb_env.
I read a lot of forum but I didn’t find the solution of this error.
I activate +UVM_CONFIG_DB_TRACE and see that the “set” is working. Then when the “get” is called in top_env, it is working too. I have the right value. Here are the lines that I have:
reporter [CFGDB/SET] Configuration ‘uvm_test_top.*.my_spi_env_config’ (type spi_env_config) set by uvm_test_top = (spi_env_config)
When you set the configuration in b_test with wildcard “*”, all child-components of b_test should be able to get it. Please remove the code line above in top_env and try again.
When you set the configuration in b_test with wildcard “*”, all child-components of b_test should be able to get it. Please remove the code line above in top_env and try again.
class spi_env_config extends uvm_object;
`uvm_object_utils(spi_env_config)
bit topcell_env=0;
bit has_scbd=1;
bit has_digital_env=1;
bit active=1;
spi_agent_config agent_config;
function new(string name="spi_env_config_i");
super.new(name);
endfunction : new
endclass
When I create the object in the test before the set, the object has the default values. I verify this with some displays.
Sorry I did not recognize this. It is fine.
Back to your issue. We see only a part of your code. Can you figure out from which get your error message comes from?
if (!uvm_config_db #(spi_env_config)::get( this,"", "my_spi_env_config", my_spi_env_config))
begin
`uvm_fatal(get_type_name(),$psprintf("SPI not configured"))
end
in top_spi_tb_env.
When I follow the config_db trace, I see that the path is correct. For the set it is :
uvm_test_top.*.my_spi_env_config
and for the get it is :
uvm_test_top.top_tb.spi_tb.my_spi_env_config
The code is splited in three files (one for the test, one for top and one for top_spi_tb_env). I tried to use the same lines with an integer instead of the class spi_env_config and it’s working.
If the set()/get() calls work with an integer but not with a class variable, then the issue has to do with the class variables not being type compatible. This is due to compiling spi_env_config multiple times in different scopes.
To fix this, you need to use a package and import the package everywhere that you reference spi_env_config.
The issue was not exactly coming from the package and its importation, but I have an issue during the compilation. The class spi_env_config wasn’t correctly compiled. I thought that a compilation issue like that will come before I run the simulation, but it’s not.