Uvm_config_db

Can i get virtual interface directly to my Driver & Monitor Class from TB_TOP?
Or i need to get in test and after setting from test.

Thanks,
Raja Sekhar

If your test is in a package, which it should be, then you can’t set it from the test. Packages cannot have hierarchical references to any instances of modules or interfaces. So you have to set it from TB_top or some other module instance.

In reply to dave_59:

Example:

TB_TOP:
interface if_h;
uvm_config_db#(virtual interface)::set(null,“*”,“vif”,if_h);

Driver:
virtual interface.drv_modport m_if_h
if(!uvm_config_db#(virtual interface)::get(this,“”,“vif”,m_if_h))
`uvm_fatal(“FATAL”,“You cannot get from Config_db Have you set Properly()?”)

In this example while getting the virtual interface i am getting the error like

ERROR:You cannot assign the interface if_h type to m_if_h.

Please give me the solution.

In reply to raja.kuraku:

How about a more complete example of what you are trying to do. I can only assume this is what you are trying to do

interface my_interface;
//... body
endinterface
module TB_TOP;
my_interface my_interface_inst();

my_DUT my_dut_inst(my_interface_inst);

initial begin
    uvm_config_db#(virtual my_interface)::set(null,"*","vif",my_interface_inst);
    run_test();
    end
endmodule

In reply to dave_59:

Yes exactly i am setting the interface like as above example,
But when i am getting directly on my driver like i have shown in above example,
Then i am facing the problem of type of interface.

In reply to raja.kuraku:

Driver should be

virtual my_interface.drv_modport m_if_h
if(!uvm_config_db#(virtual my_interface)::get(this,"","vif",m_if_h))
`uvm_fatal("FATAL","You cannot get from Config_db Have you set Properly()?")

In reply to dave_59:

Hi Dave,

I cannot see anything wrong in Raja’s code snippet. My doubt is whether instance name should be
same for both set and get methods.

Regards,

Chandan

In reply to chandanc9:

Yes Driver i have written like that only but it is showing that error.
Please give some possible mistakes and errors. For the above example.

And why i am not able to get?

In reply to raja.kuraku:

Hi Raja,
You are setting only the interface into config_db from TB_TOP. I think if you are not setting the modport of the interface you cant get the same in your driver. Also your driver has m_if_h which is an instance of the modport of the interface and not the interface alone. Hence try changing the code in TB_TOP as:
uvm_config_db#(virtual interface.drv_modport)::set(null,“*”,“vif”,if_h);

Let us know if that works…

In reply to myashu:

Then We should set for each modport different.
By setting interface also we can get but here i am facing the problem like

Error for My Example Code:
** Error: (vsim-3978) …/env/m_agent/src/m_driver.sv(71): Illegal assignment to type ‘virtual interface’ from type ‘virtual interface.drv_modport’.

Time: 0 ns Iteration: 0 Region: /my_pkg File: …/env/m_agent/src/my_pkg.sv

** Error: (vsim-8754) …/env/m_agent/src/m_driver.sv(71): Actual inout arg. of type ‘virtual interface.drv_modport’ for formal ‘value’ of ‘get’ is not compatible with the formal’s type ‘virtual interface’.

In reply to :

Sorry I didn’t asked the question properly.

Previously i was using this example.
EX-1:
TB_TOP:
interface vif;
uvm_config_db#(virtual vif)::set(null,“*”,“virtual_if”,vif);

Test:
uvm_config_db#(virtual vif)::get(this,“”,“virtual_if”,agnt_cfg.vif) //Because i have taken the interface handle in agent config class
uvm_config_db#(agnt_cfg)::set(this,“m_agent.*”,“agent_config”,agnt_cfg) // Setting the Agent config

Driver:
agent_config m_cfg_h;
virtual interface.drv_modport m_if_h;
uvm_config_db#(agnt_cfg)::get(this,“”,“agent_config”,m_cfg_h;)
Connect Phase: m_if_h = m_cfg_h.m_if_h;

In this Example1 its working fine.

But i want to get interface directly from top to my Driver class
EX-2:
TB_TOP:
interface vif;
uvm_config_db#(virtual vif)::set(null,“*”,“virtual_if”,vif);

Driver:
virtual interface.drv_modport m_if_h;
uvm_config_db#(virtual vif)::get(this,“”,“virtual_if”,m_if_h;)

When i am doing this i got the error like “You cannot assign the interface(Type mismatching)”.
I have done the same thing in the above example. But there is a handle in agent config through that i am assigning.
But When i am doing directly i am facing the problem.

From the answer of arun kumar i have got that, We cannot assign directly to the drv_modport, We need to get whole interface first after that by taking another handle we can assign the interface to the particular modport.

Am i correct or wrong please give me your Comments/Suggestions.

Thank you very much to all of you for spending your valuable time.

In reply to raja.kuraku:

You code does not make any sense. Please use the code tags and show enough of your code that someone could compile it on their own.

Example:

TB_TOP:
interface if_h;
uvm_config_db#(virtual interface)::set(null,“*”,“vif”,if_h);

Driver:
virtual interface.drv_modport m_if_h // Need to be changed like virtual interface vif_0;
if(!uvm_config_db#(virtual interface)::get(this,“”,“vif”,m_if_h))
`uvm_fatal(“FATAL”,“You cannot get from Config_db Have you set Properly()?”)

In this example while getting the virtual interface i am getting the error like

ERROR:You cannot assign the interface if_h type to m_if_h.

Please give me the solution.

Hello Raja,
Change the declaration of virtual interface in driver class like virtual interface vif_0; and get the whole interface from the config_db and after getting whole interface you can get the modport access like vif_0.mp_if_1.signal1…(first modfort) vif_0.mp_if_2.signal2…(second modport)

Try it once it should work