Jump to content

Is there some wrong with the uvm_config_db#::get method?


Recommended Posts

Hi,

I want to get an object (which is created in TB env level) in Test case level, but found assert failed error, seems that uvm_config_db#::get method can not obtain the desired object in TB env, could you help me to point out why? Thanks.

The followings are parts of my codes, item 1 : defined my test_obj, item 2 : created the test_obj in TB env level, item 3: want to obtain the created object in test case level, but failed

1. Define the test_obj class:

class test_obj extends uvm_object;

rand bit test;

`uvm_object_utils(test_obj)

function new(string name="test_obj");

super.new(name);

test = 0;

endfunction

endclass : test_obj

2. in TB env level:

class tb_axi_ovc_self_loop extends uvm_component;

test_obj env_obj; // the object that I want to override

`uvm_component_utils_begin(tb_axi_ovc_self_loop)

`uvm_field_object (env_obj, UVM_ALL_ON)

`uvm_component_utils_end

function new();

env_obj = new("test_obj");

endfunction : new

function void build_phase(uvm_phase phase);

super.build_phase(phase);

endfunction : build_phase

endclass

3.in Test Case level

class test_axi_ovc extends uvm_test;

tb_axi_ovc_self_loop tb_axi_ovc_self_loop_inst;

string seq_name_s;

test_obj tc_obj;

`uvm_component_utils(test_axi_ovc)

function new(string name="test_axi_ovc", uvm_component parent);

super.new(name, parent);

endfunction: new

function void build_phase(uvm_phase phase);

super.build_phase(phase);

tb_axi_ovc_self_loop_inst = tb_axi_ovc_self_loop::type_id::create("tb_axi_ovc_self_loop_inst", this);

endfunction : build_phase

function void connect_phase(uvm_phase phase);

super.connect_phase(phase);

//get the test object

assert(uvm_config_db#(test_obj)::get(this, "tb_axi_ovc_self_loop_inst","env_obj", tc_obj));

//modify the object if needed

tc_obj.test = 1; //but found assert failed here, please help me to point out the reason, thanks.

endfunction : connect_phase

endclass

Edited by hugemx830202
Link to comment
Share on other sites

hi,

it appears that you are mixing field automation and uvm_config_db. if you do use the field macros you have to use uvm_config_db#(uvm_object)::set+get.

this is a common pitfall with the new config_db: the type arg has to be the same! when doing the get() and the set(). (so even base type + derived type doesnt work). this becomes a problem specifically when the field automation is used with the config_db - because the type parameter used to store is not widely known (its documented but ..:).

the ref says:

  
 //| get_config_int(...) => uvm_config_db#(uvm_bitstream_t)::get(cntxt,...)
 //| get_config_string(...) => uvm_config_db#(string)::get(cntxt,...)
 //| get_config_object(...) => uvm_config_db#(uvm_object)::get(cntxt,...)

so for integral types(enums,ints,...) use uvm_bitstream_t, for strings use string and for objects use uvm_object ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...