1
votes

I see different examples online of using modports for interfaces when there are port inputs on the interface. Should modports include clk and reset on the modport even though they are interface inputs?

Here's an example with clk not included on modport : https://www.doulos.com/knowhow/sysverilog/tutorial/interfaces/ Section: Modports in Interfaces

Putting clk in the modport gives a Spyglass lint error (undriven variable), here's a general idea of the error:

interface MY_IF (input clk);
signal my_sig;
modport master (input clk, my_sig);
endinterface

MY_IF if (.clk(clk));

MY_MOD (.my_if(if.master)); // claims clk is undriven

Whereas Cadence gives issues if the clk is missing and I pass a virtual interface into a class where I use clk.

Which way is correct? Does a modport have to have ALL of the signals listed, or are port interface signals always available?

2
is clk in the interface instance port driven by anything? your example is missing any driver. - Serge
Yes, I'm just showing a small amount of pseudocode. - nachum
Then this looks like a spyglass issue. Talk to synopsis. - Serge

2 Answers

0
votes

You can include interface ports in modports. But just that the port direction (input, output, inout) can't be changed in modports.

Here is one example.

interface simple_bus (input logic clk);
  logic req, gnt;
  logic [7:0] addr, data;
  logic [1:0] mode;
  logic start, rdy;

  modport slave (input req, addr, mode, start, clk, 
                 output gnt, rdy,
                 ref data);

  modport master(input gnt, rdy, clk,
                 output req, addr, mode, start,
                 ref data);
endinterface: simple_bus
0
votes

Cadence seems to be right according to https://verificationacademy.com/forums/systemverilog/using-modports-restrict-access-interface-signals : "That is the whole point of a modport - they define a subset signals that become ports of the module. The signals that are not part of the modport do not get connected and thus you have no access to them. Once defined, modports are only referenced in the port connection."