Sign in to follow this  
Followers 0
mramdas

config_db usage: base class versus derived class objects

2 posts in this topic

Is it possible to  do a  uvm_config_db::set()  for an  object of derived class type  using the base class handle  and  later do a   uvm_config_db::get()  of same object  using  the derived class handle

 

Since  a base class handle can be used to point to a derived class object and later typecase, I thought this would work, but doesn't seem to be so.

 

Any  help will be appreciated?

 

 

Here is an example

 

class  BaseA ;

endclass

 

class DerivedA extends BaseA

endclass

 

1) Set config_db

DerivedA a1;

a1 =  DerivedA::create()

uvm_config_db#(DerivedA)::set(this, "" ,  "myobj",  a1);

 

 

2) Get config_db

BaseA  a1;

DerivedA a2;

uvm_config_db#(BaseA)::get(this, "" ,  "myobj", a1);

$cast(a2, a1);

Share this post


Link to post
Share on other sites

Use uvm_config_db#(BaseA)::set() to match the uvm_config_db#(BaseA)::get()

 

Then you need to test the result of the $cast to know if the object was overridden or not.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0