Modport in UVM

Hi,

Is it possible to use modports in testbenches along with virtual interfaces ?

Thanks

In reply to sri205:

Yes you can do this, but you have to be careful when passing the virtual interface to the config_db. Consider always the right modport.

In reply to sri205:

You can, but they have little verification value for all the effort they take to create. The main advantage of modports is for synthesis to indicate direction. Most simulation tools fail to enforce directions, especially when used in virtual interfaces.

Thanks a lot Chris & Dave.

Dave, is there anything wrong in passing the exact direction through the modport while it is being used in a driver ? If I do use a specific modport which specifies the directions as output from TB to the DUT, I guess there’s no harm in doing it. Why won’t it add any value ?
that part i don’t understand :-)

For instance, if there’s an input to TB from DUT, as it’s used in reactive slaves or as responses, won’t it add any value in the drivers ?

Or, as explained in this link,

Your text to link here…

usage of modports in TB is a moot point as clocking blocks are used ?

In reply to chr_sue:

Chris, i’m not sure of passing on the exact modport in the exact location while using the config_db. If you could help me out, it’ll be really useful.

interface apb_if;

logic pclk,penable, pwrite;
logic [7:0] pwdata,prdata;

modport TB(output pclk, output penable, 
           output pwrite, 
           output [7:0] pwdata,
           input [7:0] prdata);
endinterface

module top_tb();

apb_if.TB apb_tb_if;

initial
begin
        uvm_config_db#(virtual apb_if.TB)::set(null,"*","apb_TB_if",apb_tb_if);
end

endmodule

the uvm_config_db code, will this work out right ? or don’t i need to mention the usage of modport while using the uvm_config_db ?

In reply to sri205:

You might want to connect your DUT directly to your DUT, i.e. you need the instance of the interface without the modport like this

module top_tb();
 
apb_if apb_tb_if;

DUT dut(apb_tb_if);

For the virtual interface you might want to use the TB modport. It is correct what you are doing here:

initial
begin
        uvm_config_db#(virtual apb_if.TB)::set(null,"*","apb_TB_if",apb_tb_if);
end

But you should have in mind the modport adds only the checking of the data direction and nothing else.
I have nether used it in my industrial projects.

In the driver/monitor you have to use the modport TB like this

my_driver extends uvm_driver #(my_item);

virtual apb_if.TB vif;

endmodule