从不同的测试平台系统调用任务

时间:2019-01-22 19:24:11

标签: task system-verilog

我正在尝试从testbench文件调用接口文件中定义的任务。该任务定义为

task master_monitor(
                   output bit [ADDR_WIDTH-1:0] addr,
                   output bit [DATA_WIDTH-1:0] data,
                   output bit we                    
                  );

          while (!cyc_o) @(posedge clk_i);                                                  
          while (!ack_i) @(posedge clk_i);
          addr = adr_o;
          we = we_o;
          if (we_o) begin
            data = dat_o;
          end else begin
            data = dat_i;
          end
          while (cyc_o) @(posedge clk_i);                                                  
     endtask 

在我的测试台中,该接口被实例化为wb_bus,我正尝试通过以下方式调用该任务:

wire [WB_DATA_WIDTH-1:0] dat_wr_o;
wire [WB_DATA_WIDTH-1:0] adr;
wire we;
initial
begin
    repeat(10) begin
    wb_bus.master_monitor(adr, dat_wr_o, we);

    end
end

当我在modelsim上进行模拟时,最终会出现以下错误:

   ** Error: (vsim-3047) ../testbench/top.sv(52): actual value for formal 'data' of 'master_read' must be assignable.
#    Time: 0 ps  Iteration: 0  Instance: /top File: ../testbench/top.sv
# ** Error: (vsim-3047) ../testbench/top.sv(53): actual value for formal 'we' of 'master_monitor' must be assignable.
#    Time: 0 ps  Iteration: 0  Instance: /top File: ../testbench/top.sv
# ** Error: (vsim-3047) ../testbench/top.sv(53): actual value for formal 'data' of 'master_monitor' must be assignable.
#    Time: 0 ps  Iteration: 0  Instance: /top File: ../testbench/top.sv
# ** Error: (vsim-3047) ../testbench/top.sv(53): actual value for formal 'addr' of 'master_monitor' must be assignable.
#    Time: 0 ps  Iteration: 0  Instance: /top File: ../testbench/top.sv

我是否以正确的方式传递了变量?有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您无法将adr之类的有线信号传递到任务的输出分支。要么将它们更改为logic,要么创建传递给任务参数的中间变量,然后assign将它们传递给连线。