Instantiation of interface and dut

hai,
i have to instantiate my dut like this in top testbench

dut DUT(.reset_0(in0.reset[0]),
        .reset_1(in0.reset[1]),
        .intr_0(in0.intr[0]),
        .intr_1(in0.intr[1])
        );

or dut instaniate name different like this

dut DUT(.reset_0(in0.reset[0]),
        .reset_1(in0.reset[1]),
        .intr_0(in1.intr[0]),
        .intr_1(in1.intr[1])
        );

to write like this how should i write inteface and instantiation of interface

i wrote interfac like

interface phy_if (input bit clk);

is it ok or any dynamic array for interface name needed
interface phy_if[1:0] (input bit clk);

and for instantiation of interface i have to use gen var or not
genvar i;
  for(i=0; i< num_dut_instances; i++) begin : dut_inst
    Dut_if dut_if();
    initial uvm_config_db#(virtual Dut_if)::set(uvm_root::get(),"*",$sformatf("dut_if_%0d",i),dut_if);
  end

In reply to nana:

To get the right understanding a few questions:

It looks like you have 2 functional interfaces in your design,one is named (instance names) in0 and the other one in1. Correct?
You have 2 different reset signals?
You have 2 intr signals?

Would be great if you could provide yor definition of the SV interface.
I do not see why you shoule need a dynamic array for the interfaces.

am having intr and reset signals two sets with intr_0,intr_1 reset_0,reset_1 these variables are in one interface
these are 2 set of signals thats why i took as a no of agents 2

mdio, mdc these two signals are in one interfaces these are one set of variables but to intract with above 2 agents i took 2 no of agents

by depending on mdio and mdc that intr,and reset will work i have to process between these two pair of agents

if i want to assign a value two signals are taking same vale thats why i took dynamic array
to differentiate

In reply to nana:

The question is not how many signals for interrupt or reset you have to define the number of interfaces and agents. The question is how many different functional interfaces you have. From your signal naming I guess you are using the mdio-interface (Cypress). Correct? If your design has only one mdio interface you need only one agent.

thanks for reply
am having two interfaces mdio_if,if for if am getting error like
Illegal assignment to type ‘virtual if #(0)’ from type ‘virtual if’: Vir. ‘if’ interface must be assigned a matching interface or virtual interface.

interface :
interface if #(int pm = 1) (input bit clk);
bit [pm:0] intr;
bit [pm:0] rst_n;
bit [1:0] link [0:pm];
clocking wdr_cb @ (posedge clk);
default input #3 output #1;
input rst_n;
output phy_intr;
input link;
endclocking
endinterface

in my top:
virtual interface instantiation:
phy_if #(1) INTF_1(clk);
phy_if #(0) INTF_0(clk);

dut DUT(.reset_0(INTF_0.reset[0]),
.reset_1(INTF_0.reset[1]),
.intr_0(INTF_1.intr[0]),
.intr_1(INTF_1.intr[1])
);
set config:
uvm_config_db #(virtual if#(1))::set(null, “", “INTF_M_MASTER”, INTF_1);
uvm_config_db #(virtual if#(0))::set(null, "
”, “INTF_S_SLAVE”, INTF_0);

in test:
get config:
if (!uvm_config_db #(virtual if#(0))::get(this, “”, “INTF_S_SLAVE”, wr_cfg_h[0].phy_vif))
if (!uvm_config_db #(virtual if#(1))::get(this, “”, “INTF_M_MASTER”,wr_cfg_h[1].phy_vif))

What is wrong in this code?? Does anyone know why it isnt working?

Thanks for help

In reply to nana:

Not sure if it’s a typo but you have declared interface name as “interface if” and in top you are using “phy_if”. Try changing phy_if to if and it should work.

thanks for rply
that is typing mistake i used it properly even though it is showing same error.
right now am using model sim tool.
is this tool will work properly for this or am i did anything wrong?

In reply to nana:

Your phy_if is NON-parameterized whereas during get_config you are using parameterized value, hence this error.

Srini
www.verifworks.com

thanks for reply

Illegal assignment to type ‘virtual if #(0)’ from type ‘virtual if’: Vir. ‘if’ interface must be assigned a matching interface or virtual interface.

interface :
interface phy_if #(int pm = 1) (input bit clk);
bit [pm:0] intr;
bit [pm:0] rst_n;
bit [1:0] link [0:pm];
clocking wdr_cb @ (posedge clk);
default input #3 output #1;
input rst_n;
output intr;
input link;
endclocking
endinterface

in my top:
virtual interface instantiation:
phy_if #(1) INTF_1(clk);
phy_if #(0) INTF_0(clk);

dut DUT(.reset_0(INTF_0.reset[0]),
.reset_1(INTF_0.reset[1]),
.intr_0(INTF_1.intr[0]),
.intr_1(INTF_1.intr[1])
);
set config:
uvm_config_db #(virtual phy_if#(1))::set(null, “", “INTF_M_MASTER”, INTF_1);
uvm_config_db #(virtual phy_if#(0))::set(null, "
”, “INTF_S_SLAVE”, INTF_0);

in test:
get config:
if (!uvm_config_db #(virtual phy_if#(0))::get(this, “”, “INTF_S_SLAVE”, wr_cfg_h[0].phy_vif))
if (!uvm_config_db #(virtual phy_if#(1))::get(this, “”, “INTF_M_MASTER”,wr_cfg_h[1].phy_vif))

where i have to change.
Thanks for help

I think Phy_if in wr_cfg is not parameterized, can you post the code of wr_cfg virtual interface declaration.

In reply to nana:

Can you show how phy_vif is declared?

Srini
www.verifworks.com

class wr_agent_config extends uvm_object;
`uvm_object_utils(wr_agent_config)
virtual phy_if phy_vif;
uvm_active_passive_enum is_active = UVM_ACTIVE;
function new(string name = “wr_agent_config”);
super.new(name);
endfunction
endclass

In reply to nana:

There you go, use

virtual phy_if #(int pm = 1) phy_vif

Srini
www.verifworks.com

in driver also i have to use parameterized virtual interface?
class phy_if_wr_driver extends uvm_driver #(phy_if_write_xtn);
`uvm_component_utils (phy_if_wr_driver)
virtual phy_if #(int pm = 1).phy_wdr_cb phy_vif
endclass

In reply to nana:
Actually it’s just

 virtual phy_if #(0).phy_wdr_cb phy_vif

or

 virtual phy_if #(1).phy_wdr_cb phy_vif

The parameters used in the virtual interface variable declaration have to match the parameters used in the interface instance that will be assigned to the variable.

thank for yor reply.

is it possible to get two interface signals in to a single agent.



if (has_wagent)
    begin   
        begin
          wr_cfg_h = new[no_of_mdio_wr_agents];        
            begin 
              wr_cfg_h[0] = wr_agent_config::type_id::create( "wr_cfg_h[0]"); 			
              if (!uvm_config_db #(virtual phy_if #(0))::get(this, "", "INTF_M_MASTER", wr_cfg_h[0].phy_vif_0))
              `uvm_fatal("VIF CONFIG","cannot get()interface vif from uvm_config_db. Have you set() it?")              
              wr_cfg_h[0].is_active   = UVM_ACTIVE;
              env_cfg.wr_cfg_h[0]     = wr_cfg_h[0];  
              $display(" env_cfg.wr_cfg_h[0] %d", env_cfg.wr_cfg_h[0]);

            end  
            
            begin 
              wr_cfg_h[0] = wr_agent_config::type_id::create( "mdio_cfg_h[0]"); 			
              if (!uvm_config_db #(virtual mdio_if )::get(this, "", "mdio_str", wr_cfg_h[0].mdio_vif))
              `uvm_fatal("VIF CONFIG","cannot get()interface vif from uvm_config_db. Have you set() it?")              
              wr_cfg_h[0].is_active   = UVM_ACTIVE;
              env_cfg.wr_cfg_h[0]     = wr_cfg_h[0];  
              $display(" env_cfg.wr_cfg_h[0] %d", env_cfg.wr_cfg_h[0]);

            end    
        end
   end

i need to get two interfaces variables in to a single agent

In reply to nana:

getting two interface in a single component is possible given that they were set using unique identifier and same identifier is used to get them. The code you have posted above doesn’t make sense, you are instantiating wr_cfg_h[0] twice with different name. I think it may be a typo, can you confirm and post correct code of get and set.

Thanks,
Rohit

thank you for ur reply.

if we use same string name is it set and get properly
top:

      
      uvm_config_db #(virtual phy_if #(1))::set(null, "*", "string", INTF_1);
      uvm_config_db #(virtual mdio_if)::set(null,"*","string",in0);   

test:


if (has_wagent)
    begin   
        begin
          wr_cfg_h = new[no_of_mdio_wr_agents];        
            begin 
              wr_cfg_h[0] = wr_agent_config::type_id::create( "wr_cfg_h[0]"); 			
              if (!uvm_config_db #(virtual phy_if #(0))::get(this, "", "string", wr_cfg_h[0].phy_vif_0))
              `uvm_fatal("VIF CONFIG","cannot get()interface vif from uvm_config_db. Have you set() it?")              
              wr_cfg_h[0].is_active   = UVM_ACTIVE;
              env_cfg.wr_cfg_h[0]     = wr_cfg_h[0];  
              $display(" env_cfg.wr_cfg_h[0] %d", env_cfg.wr_cfg_h[0]);
 
            end  
 
            begin 
              wr_cfg_h[0] = wr_agent_config::type_id::create( "mdio_cfg_h[0]"); 			
              if (!uvm_config_db #(virtual mdio_if )::get(this, "", "string", wr_cfg_h[0].mdio_vif))
              `uvm_fatal("VIF CONFIG","cannot get()interface vif from uvm_config_db. Have you set() it?")              
              wr_cfg_h[0].is_active   = UVM_ACTIVE;
              env_cfg.wr_cfg_h[0]     = wr_cfg_h[0];  
              $display(" env_cfg.wr_cfg_h[0] %d", env_cfg.wr_cfg_h[0]);
 
            end    
        end
   end

is it work? 
that second get of env_cfg value will override or not?

In reply to nana:

As long as types are different you can use same name.