I am trying to setup a simple uvm test bench and i am struggling with setting/getting items from the config_db
Below i have posted code for my top level (testbench_top.sv) where i am setting my interface and my driver (driver.sv) where i am attempting to get my virtual interface.
i am calling set() wit the following arguments:
uvm_config_db #(virtual uvm_csv_depack_in)::set(null,"uvm_test_top", "input_i", input_i);
I am reading the UVM cookbook about how to use this function and it says for the cntxt and inst_name:
• cntxt and inst_name together form a scope that is used to locate the resource within the database; it is formed by
appending the instance name to the full hierarchical name of the context, i.e.
{cntxt.get_full_name(),“.”,inst_name}.
So for the arguments to the function it seems that i have
cntxt = “uvm_test_top”
inst_name = “input_i”
So from my understanding of uvm i should be able to use the cntxt and inst_name to get the virtual interface in my driver with the following function call:
uvm_config_db#(virtual uvm_csv_depack_in)::get(this, "uvm_test_top", "input_i", virtual_interface))
However, the get() always fails.
I have utilized the uvm_config_db #(int)::dump(); function for debugging and i can see that my interface seems to be in the config database…
=== resource pool ===
input_i [/^uvm_test_top$/] : (virtual uvm_csv_depack_in) /top_tb/input_i
-
output_o [/^uvm_test_top$/] : (virtual uvm_csv_depack_in) /top_tb/output_o
-
recording_detail : (reg signed[4095:0]) 0
-
recording_detail : (int) 0
-
=== end of resource pool ===
it even seems that the expected context “uvm_test_top” and the instance name "input_i " are in there…
but the get() still fails?
any ideas?
testbench_top.sv
import uvm_pkg::*;
import uvm_csv_test_pkg::*;
module top_tb;
timeunit 1ns;
timeprecision 1ps;
initial begin
input_i.clk = 0;
forever #10ns input_i.clk = ~input_i.clk;
end
uvm_csv_depack_in input_i ();
uvm_csv_depack_in output_o ();
depacketizer depack (
// input
.data_i(input_i.data),
.data_valid_i(input_i.data_valid),
.x_res_i(13'h0000),
.y_res_i(12'h000),
.clk_i(input_i.clk),
.rst_i(1'b0),
// output
.data_o(output_o.data),
.data_valid_o(output_o.data_valid)
);
initial
begin
uvm_config_db #(virtual uvm_csv_depack_in)::set(null,"uvm_test_top", "input_i", input_i);
uvm_config_db #(virtual uvm_csv_depack_in)::set(null,"uvm_test_top", "output_o", output_o);
run_test(); // run the test
end
endmodule
driver.sv
`ifndef uvm_csv_driver_SV
`define uvm_csv_driver_SV
import uvm_pkg::*;
`include "uvm_macros.svh"
class uvm_csv_driver extends uvm_driver #(uvm_csv_packet_item);
`uvm_component_utils(uvm_csv_driver)
virtual uvm_csv_depack_in virtual_interface;
extern function new(string name, uvm_component parent);
extern task run_phase(uvm_phase phase);
extern function void build_phase(uvm_phase phase);
extern task do_drive();
endclass : uvm_csv_driver
function void uvm_csv_driver::build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db #(int)::dump(); // This prints out a resource pool?
uvm_report_info(get_full_name(),"get_full_name()");
if( !uvm_config_db#(virtual uvm_csv_depack_in)::get(this, "uvm_test_top", "input_i", virtual_interface))
`uvm_fatal(get_type_name(),"cannot get virutal interface")
endfunction: build_phase