Setting and getting config class objects

Hi,

My tb architecture consists of xtn item,sequence,agent,agent_cfg,agent_top,scoreboard,env_cfg ,env,test.

I have got struck with respect to setting and getting config class objects.

Firstly i was having doubt with respect to usage of config class object.
1.Is it like good to have config class for each agent or single config is enough.
Yes i am aware that ,by keeping config class as dynamic it adds on to more flexibility like which agent is being active or dynamic and even for different virtual interface.
What are the other advantages and disadvantages?

2.If i have kept it as dynamic ,then how to set them and get them.
As of now i am trying with this method



//in agent_top
foreach(m_agent[i]) 
uvm_config_db #(master_agent_cfg)::set(this,$sformatf("m_agent[%0d]",i),"master_agent_cfg",e_cfg.m_cfg[i]);


//in agent
foreach(m_cfg[i])
(!uvm_config_db #(master_agent_cfg)::get(this,"","master_agent_cfg",m_cfg[i]))




The errors are as follows-
a.Getting errors here like null object access.
I cross checked this error as i had declared m_cfg as dynamic,but dint assign it using new operator.It got resolved.
Even after this,I am not getting the handle.

b.After debugging the above error,again i am getting error in the connect phase of agent.
drv_h.seq_item_port.connect(seqr_h.seq_item_export) //in this line
again the same error of null object access.

So the error does mean that .driver and sequencer are not created.I feel somewhere its related to m_cfg only.

Can anyone please help me on this issue?

Thanks & regards,
Shubham

In reply to shubham_03:
Shubham, What is the error exactly? Can you please post the very first error as shown in your simulation? And the line at which it is occurring?

Hi Yasaswi,

I have declared m_cfg as dynamic array i.e master_agent_cfg m_cfg and i need to get handle in agent.
Setting up of handle is fine ,but not getting the handle in agent.
Now,with respect to error message,null object access is the error message which is popping up.
and w.r.t line no,As i had mentioned earlier,i.e in the connect phase of an agent.

Can you please give any simple example where i can set and get the handles for multiple config class object?
I have looked for online content ,but wasn’t able to find anything specific.

And also ,can you please let me know regarding any major advantages and disadvantages of using multiple config class objects

Thanks & regards,
Shubham

In reply to shubham_03:
For me it is unclear which data you have in your config objects. I’d assume you need only 2 cfg objects, 1 for the master agents and another 1 for the slave agents.
And you do not need to define an dynamic array, because when starting your simulation you know how many master agents and slave agents you have.

The error messages you get is an indication the config obejct does not exist or you used wrong arguments in set/get

Hi chr_sue,

Thanks for the reply.

My config_class looks like this




class master_agent_cfg extends uvm_object;
    
  `uvm_object_utils(master_agent_cfg)
  
  virtual connect_if vif; //interface,name changed
  
  uvm_active_passive_enum active=UVM_ACTIVE; //agent status
  
  bit has_functional_coverage=0;
  
  
  extern function new();
  extern function void build_phase();  
  
endclass


Yes ,i need only two config objects in this case.One for master & one for slave.
What if i am having multiple agents ?
My intention over here is ,its better to have more flexibility if in case in future any
more agents are added.
Is no of agents proportional to no of agent_cfg ?
As we can set the status of an agent .i.e active or passive by the help of m_cfg handle.
So in that way ,if i am having dynamic array of m_cfg ,then it will be flexible right ?

FYI,

env_cfg looks like this



 class master_env_cfg extends uvm_object;

  `uvm_object_utils(master_env_config)
  
  
  bit has_scoreboard=1;
  bit has_m_agent=1;
  bit has_s_agent=1;
  bit has_m_top=1;
  bit has_s_top=1;
  
  
  
  master_agent_cfg m_cfg[]; //config_object is dynamic,as config info for particular agent might change
  
  
  
  //These are the flexible parameters,when declared can be reused accordingly
  int no_of_scoreboard=1;
  int no_of_m_agent=1;
  int no_of_s_agent=1;
  int no_of_m_top=1;
  int no_of_s_top=1;


  extern function new(string name="master_env_cfg");
 
 endclass
    

 

With respect to the error message ,error line is not pointing to get method of config_db.
If there was some sort of argument mismatch in get method ,ten it will point to it right ?

Its just that i am not getting the m_cfg handle into my agent,by which i can make my agent
or passive.

Any simple example pointed w.r.t to set and get handle would also be great.
I had explored the forum and i had found info about setting the handles ,but not how to get
the handles .

Can you please help me on this ?

Thanks & regards,
Shubham

In reply to shubham_03:

//in agent_top
foreach(m_agent[i])
uvm_config_db #(master_agent_cfg)::set(this,$sformatf(“m_agent[%0d]”,i),“master_agent_cfg”,e_cfg.m_cfg[i]);
//in agent
foreach(m_cfg[i])
(!uvm_config_db #(master_agent_cfg)::get(this,“”,“master_agent_cfg”,m_cfg[i]))





Hi,

first of all I don't understand why you initiate config dynamic array, It's good to avoid dynamic array if we don't have actual use of that, i assumed that you have 2 instance of agent now each agent want only one config for configuration , so you have to pass config class to each agent using hair name , and inside agent we only have to get one cfg


``` verilog

//agt
class agent .....
  master_agent_cfg m_master_agent_cfg
  //some code....
  if(!uvm_config_db #(master_agent_cfg)::get(this,"","master_agent_cfg",m_master_agent_cfg)
    fatal....
  //some code...
endclass

class env .....
  master_agent_cfg m_master_agent_cfg[2];
  agent m_agent[2];
  //some code ...
  foreach(m_agent_[i]) 
    uvm_config_db#(master_agent_cfg)::set(this,{$sformatf("m_agent[%0d]",i),".*"},"master_agent_cfg",m_master_agent_cfg[i]);
   //some code ...
endclass

you can also do this with dynamic arry but for that you can create instance in new method



cfg m_cfg[];
agt m_sgt[];

function new....
  m_cfg = new[no_of_instance];
  m_agt = new[no_of_instance];

Hi,

Thank you dhaval for the reply.

I was able to resolve the error as of now.
Actually i was not creating agent_top,so thats why agent was not created and handles were not passed.
But i am having few follow up questions.
1.The way you have suggested to get config handle,how would we know whether that config handles belongs to master or slave?i think by using dynamic array we can differentiate by the help of index.

2.May i know the usage of declaring virtual interface in config class?
Whats the actual use of it from the larger perspective and what help it does?

3.Where do we need to assign this “vif=m_cfg.vif” in respective driver and monitor or in agent ?
Why do we need this ? Is it like in case of multiple interfaces ,by declaring multiple virtual interface in config class,we can replace one by another when driving,sampling to and from the dut?

Thanks & regards,
Shubham

1.The way you have suggested to get config handle,how would we know whether that config handles belongs to master or slave?i think by using dynamic array we can differentiate by the help of index.

==> In any organization, they have his own coding guide line, I am use conman config class method we have one top_cfg, that contain all information like how many agent is present run time add remove support is present or not and also contain all other sub config class instance that is peasant with dynamic array, and best on slave number we are get config data inside component.

2.May i know the usage of declaring virtual interface in config class?
Whats the actual use of it from the larger perspective and what help it does?

==> Our tb architecture is set of well defined component so what happen our some component has dependency on other component, like driver creation is depend on agent active passive, so for driver we have to set get that creation from agent configure, but in interface case we only have limited interface and in interface is entity that not add or remove run time , and interface is almost use by every component, and all component has config class handle , so we take instance of interface in config class apart from get interface individually, it very easy to maintain when any modification come later and also you code looks clean, also they has many more advantages based on your architecture.

3.Where do we need to assign this “vif=m_cfg.vif” in respective driver and monitor or in agent ?
Why do we need this ? Is it like in case of multiple interfaces ,by declaring multiple virtual interface in config class,we can replace one by another when driving,sampling to and from the dut?

==> I don’t understand this, but I assuming you want how we can get require interface in each agent , for that we have agent_id or flow_id based on that we get interface from conman config class vif = cfg.master_vif[agent_id/flow_id], we aslo some code in that we have interface individual from config , at the end every thing is based on requirement and architecture.

Hi dhaval,

I sincerely appreciate for your time and efforts for the answer.
Thank you for the reply.

Yes ,you said it right.It depends on the requirements and respective organisations guidelines.
But i am not yet clear with the usage of interface in config class.

If possible ,please suggest me some resource or any example w.r.t. usage of interface in config class.

Regards,
Shubham

In reply to shubham_03:

Hi,

Our organisation, verify RTL and also developed VIP,
When we verify RTL we don’t care any thing we set VIF from any part,
But when we developed VIP We collect all entity that user have to provide, make instance in
configure class so when any consumer have to use VIP , consumer only have access of configure class, consumer have to set every thing in config class so VIP work as expected and not dependent on any hair and also take multi instance in his top.

In most of case VIF found in config class in purchased VIP.(so user don’t need to do any thing other then configure class)

In reply to shubham_03:

Hi dhaval,
I sincerely appreciate for your time and efforts for the answer.
Thank you for the reply.
Yes ,you said it right.It depends on the requirements and respective organisations guidelines.
But i am not yet clear with the usage of interface in config class.
If possible ,please suggest me some resource or any example w.r.t. usage of interface in config class.
Regards,
Shubham

It is a good common practice to put the virtual interface to a configuration object class whic is then put to the config_db.
See the details here:
https://verificationacademy.com/cookbook/usingtheuvmconfigdb

Because the configuration object is specific to each test it is specified in the test class. Setting the config object from the toplevel module of your UVM testbench is not useful, because configurations are not specific to this module.

Hi,

Thanks for the reply dhaval & chr_sue.

First of all ,i got a bit of clarity w.r.t this line.
“Where do we need to assign this “vif=m_cfg.vif” in respective driver and monitor or in agent ?”
→ Actually the example which i was referring, was not getting the interface from module tb_top.It was more like through the config object.
a.create the cfg_object in agent_top and set it.
b.now get the cfg_object in driver and monitor.
c.in connect phase of driver & monitor,assign “vif=m_cfg.vif”

chr_sue,yes i have gone through the link.I found it useful.

but config object is specific to agent right ?
Seems like there are alternate ways to make use of config object and mostly depends on the application.
And rather than using wildcard as an argument in config_db,if we are passing it lower components specifically ,overhead can be avoided.

I was like more of curious and was thinking like,if we are declaring the interface in config object which is specific to agent,we can replace one interface with the other and the flexible nature of tb_architecture remains true.

Regards,
Shubham