2

I have defined an interface for my DUT as such:

interface video_input_interface(clk, rst);

   input logic       clk;
   input logic       rst;
         logic[1:0]  x_lsb;
         logic[1:0]  x_msb;
         logic[3:0]  x;

   assign x = {x_msb, x_lsb};
endinterface

The reason I did this is because my DUT has separate ports for x_msb and x_lsb and I want to explicitly show which bits of signal x I am connecting to these ports. For example, when instantiating the DUT:

interface video_input_interface vif;
dut udut(
    .msb(vif.x_msb),
    .lsb(vif.x_lsb),
.............
);

Now the issue is I have 2 drivers in my agent:

Driver A: When driving the interface from Driver A, I would like to drive signal x and not x_lsb, x_msb.

Driver B: When driving the interface from Driver B, I would like to drive signal x_lsb and x_msb individually.

I would think that my solution would split up signal x in my interface into x_lsb and x_msb. In DriverA, I can just drive this signal x. Also, for driver B the interface would be ok with me accessing the bits individually and everything would work just fine... not!

The assign causes signal x to be "X - unknown value". I have to drive x_msb and x_lsb individually for DriverA. Or other option is to

assign x_lsb = x[1:0]
assign x_msb = x[3:2]

This means DriverA would work, but would run into same problem from DriverB (when trying to drive x_lsb and x_msb).

Is there a solution to this? Thanks

4

2 回答 2

3

您可以使用时钟块,每个驱动程序一个:

interface video_input_interface(clk, rst);

   input logic       clk;
   input logic       rst;
         logic[1:0]  x_lsb;
         logic[1:0]  x_msb;

  clocking cb_a @(posedge clk);
    output x = { x_lsb, x_msb };
  endclocking

  clocking cb_b @(posedge clk);
    output x_lsb;
    output x_msb;
  endclocking

endinterface

从驱动程序 A,您将始终引用 cb_a:

@(posedge clk);
video_if.cb_a.x <= 'hA;

从驱动程序 B,您将始终引用 cb_b:

@(posedge clk);
video_if.cb_b.x_msb <= 'h1;
video_if.cb_b.x_lsb <= 'h2;

EDAPlayground 上的完整示例:http ://www.edaplayground.com/x/3hK

你只需要小心不要同时从两个司机那里开车。阅读第 14 节中有关时钟块的更多信息。SV 2012 标准的时钟块。

于 2014-06-04T08:40:58.310 回答
2

你的问题有点不清楚......那么司机A和司机同时B开车x吗?xwhenx_msbx_lsbaredriven byBxisdriven by的值应该是什么A

您已经在界面中分配给 x 。因此,您不能在另一个模块(驱动程序 A)中驱动它,因为 x 不能有多个驱动程序。

如果两个驱动器不是同时驱动的,那么像下面这样的多路复用解决方案呢?

interface video_input_interface(clk, rst);

   input logic       clk;
   input logic       rst;
         logic[1:0]  x_lsb;
         logic[1:0]  x_msb;
         logic[3:0]  x;
         logic       driverIsA;       //Indicates the driver is A
         logic       xValueFromA;     //The x value driven by A

   assign x = driverIsA ? xValueFromA : {x_msb, x_lsb};
endinterface
于 2014-06-03T22:28:43.337 回答