0
\$\begingroup\$
task xyz(output op, output bit [width-1:0] write_data []);

I have my task xyz definiton in an interface. I want to call this task from my testbench.sv.

How should I call it? I am trying to call it in this manner, but I am getting an error:

xyz(1'b0, bit[width-1:0] write_data [])

What's the correct way of passing an unpacked array of packed array as task arguments?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

There are 2 types of errors in your task call line.

You should not use the variable type (bit) or any dimensions. These are only used in the task definition. Instead of passing:

bit[width-1:0] write_data []

simply pass the variable name:

write_data

You must not connect a constant (1'b0) to the op output.

Here is a complete code example which has no compile errors:

module tb;
  parameter width = 4;
  bit [width-1:0] write_data [];
  bit op;
  
  task xyz(output op, output bit [width-1:0] write_data []);
  endtask
  
  initial begin
    xyz(op, write_data);
  end
endmodule

Here is the code on EDA playground.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.