Hi,
I have created a environment config db as below:
---------------------------------------------------------------
class env_cfg extends uvm_object;
`uvm_object_utils(env_cfg)
rand bit slave_address;
virtual spi_if spi_if;
---------------------------------------------------------------
i am setting the virtual interface for my spi interface from the top module with the below command:
---------------------------------------------------------------
uvm_config_db#(virtual spi_if)::set(null,“*”,“spi_if”,spi_if);
---------------------------------------------------------------
in my test I have created an object for config db and I get the config db details
I randomize the config db and set it back as below:
---------------------------------------------------------------
function void build_phase(uvm_phase phase);
super.build_phase(phase);
env_config = new;
if (!uvm_config_db #(virtual spi_if)::get(this,"","spi_if",env_config.spi_if)) begin
`uvm_error(get_type_name,"Cannot find SPI_IF configuration!")
end
//env_config.spi_if = spi_if;
assert(this.randomize()) else `uvm_error("BASE_TEST", "Randomization Failed");
uvm_config_db #(env_cfg)::set(this,"*","env_config",env_config );
endfunction
---------------------------------------------------------------
In my driver i get the interface and drive to the dut as below:
---------------------------------------------------------------
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual spi_if)::get(this, "", "spi_if", spi_if))
`uvm_fatal("NOVIF",{"virtual interface must be set for: ",get_full_name(),"spi_if"});
endfunction: build_phase
task run_phase(uvm_phase phase);
`uvm_info(block,"IDLE", UVM_MEDIUM);
spi_if.SPI_MODE = 0;
spi_if.SS_N = 1'b1;
spi_if.SCLK = 1'b1;
spi_if.MOSI = 1'b1;
endtask
---------------------------------------------------------------
I get a null reference error as below, i am not able to understand why:
---------------------------------------------------------------
UVM_ERROR testbenches/testcases/base_test.sv(230) @ 0: uvm_test_top [base_test] Cannot find SPI_IF configuration!
UVM_FATAL testbenches/spi_agent/spi_driver.sv(26) @ 0: uvm_test_top.env.spi_ag.spi_drvr [NOVIF] virtual interface must be set for:
uvm_test_top.env.spi_ag.spi_drvrspi_if
---------------------------------------------------------------
also since i set the value again in test, will my previous value of spi_if get overridden?
Can someone please help me with this?