In reply to sylvainb:
In reply to UVM_LOVE:
You have to pass the interface using the uvm_config_db (using set) directly from your test bench, where you instantiate the DUT and connect it to a real instance of an apb_interface (not virtual!).
Then in the build_phase of your apb_basic_test after you create the m_cfg you can assign m_cfg.apb_if using the get method of the uvm_config_db
Basically, My testbench.sv looks like as the below
`include "uvm_macros.svh"
import uvm_pkg::*;
`include "apb_master_agent.sv"
`include "apb_scoreboard.sv"
`include "apb_master_environment.sv"
...
`include "apb_basic_test.sv"
module top;
int i;
apb_interface apb_intf();
assign apb_intf.pready=apb_intf.pselect&apb_intf.penable;
always
#5 apb_intf.pclk=!apb_intf.pclk;
DUT u_DUT(
.a(apb_intf.paddress), //[9:0]
.b(apb_intf.pwdata), //[31:0]
//output
.c(apb_intf.preaddata) //[31:0]
);
initial
begin
apb_intf.presetn=1'b1;
end
initial
begin
i=3;
uvm_config_db#(virtual apb_interface)::set(null,"*","apb_master_intf",apb_intf);
run_test("apb_basic_test");
end
endmodule
As your answer, I declared uvm_config_db#(virtual apb_interface)::set(null,“*”,“apb_master_intf”,apb_intf);
then in the build_phase of apb_basic_test.sv
I declared as the below.
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
m_cfg=apb_master_config::type_id::create("m_cfg",this);
uvm_config_db #(apb_master_config)::set(this, "*", "apb_master_config", m_cfg);
But still I got NULL point ERROR
In apb_monitor.sv
class apb_monitor extends uvm_monitor;
`uvm_component_utils(apb_monitor)
virtual apb_interface vapb_intf;
apb_sequence_item apb_rx;
apb_master_config m_cfg;
function new(string name="apb_monitor", uvm_component parent = null);
super.new(name, parent);
endfunction
uvm_analysis_port #(apb_sequence_item) my_mon_port;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
my_mon_port = new ("my_mon_port", this);
/*
if (! uvm_config_db #(virtual apb_interface) :: get (this, "", "apb_master_intf", vapb_intf)) begin
`uvm_fatal (get_type_name (), "Monitor Didn't get handle to virtual interface virtualapb_intf")
end
*/
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
if(!uvm_config_db #(apb_master_config)::get(this, "*", "apb_master_config", m_cfg))
`uvm_fatal("FATAL MSG", "Configuration object is not set properly")
vapb_intf = m_cfg.apb_if;
`uvm_info(get_type_name(), $psprintf("!!!!!!t is: %p", m_cfg.apb_if),UVM_LOW)
endfunction