0
votes

Here I have a simple example below.

module A(o,clk,rst,i);
  output o;
  input i,clk,rst;
  ...
endmodule

and here is an interface class definition below.

interface my_if(input bit clk);
  logic o,rst,i;
  wire clk;

  clocking cb@(posedge clk);
    input o;         // why input here ?
    output i,rst;    // why output here ?
  endclocking
  ...
endinterface

My question is how to decide the signal inside cb is input or output ??

Thank you !

1
I mean if I may understand in this way that the direction of signal is just opposite between the module and interface ? - Rocky Zheng
usually to define inputs and output views for an interface, modports are used. clocking block can be used to construct modports. The IO views are used to connect interface to different modules with different IO ports. - Serge
Thanks Serge. So the input/output view for each signals defined in interface class could be alternative, which depends on the modules we want to connect - Rocky Zheng
yes, you got it. - Serge

1 Answers

1
votes

There are many uses of input/output in SystemVerilog, which can be confusing.

For ports, they the flow of data across a boundary. For a clocking block, they represent whether a signal is passively being sampled, or actively driven. Depending on the situation, it is perfectly reasonable to have a port declared as an output, and the same signal declared as a clocking block input.