I am trying to do something like this:
module test;
reg [1:0] c [1:0];
reg [1:0] a1 [1:0];
task mem_a;
output reg [1:0] a [1:0];
begin
a[0]=0;
a[1]=1;
a[2]=2;
a[3]=3;
end
endtask
task mem_b;
input reg [1:0] a2 [1:0];
output reg [1:0] b [1:0];
begin
b=a2; // or some other manupulation
end
endtask
initial
begin
mem_a (a1);
mem_b (a1,c);
end
endmodule
When I compile this, I am getting errors as :
- Illegal reference to memory "b"
- Illegal LHS of assignment.
- Illegal reference to memory "a2"
- Illegal task output argument.
- Illegal reference to memory "a1".
So I want to understand how to pass 2-D arrays in tasks.
P.S: I have not used tasks before.
output reg [1:0] b [1:0]. In verilog task, the name of variable is expected after the argument direction. So do it asoutput [1:0] b [1:0]without theregkeyword. This is not the main issue here, just a side comment. :)regorwireas datatype, only two in the main perspective. But, wire is driven by continuous assignmentsassignstatements only, sowireis never expected. As a result, output arguments are implicitly ofregtype. As far as input argument is concerned, it is simply a variable, whose value must be read. As a result, it can beregorwire. Systemverilog having many datatypes requires explicit declaration of datatypes in input/output arguments. Are you looking for a verilog task/function or systemverilog task/function?