I have an issue where I am trying to pass an array size argument as one of my arguments to the task but it fails.
the code is as follows (not the full version only the important bits):
parameter SIZE_1 = 27;
task task1(input int SIZE, input logic my_array1, input logic my_array2);
logic my_array3 [0:SIZE-1];
//rest of the code
endtask
task1(SIZE_1, array1, array2);
Section 7.4.2 in the LRM states that dimensions for an unpacked array are required to be constant expressions. Using a variable violates this requirement.
You can use a dynamic array instead:
parameter SIZE_1 = 27;
task task1(input int SIZE, input logic my_array1, input logic my_array2);
automatic logic my_array3[] = new[SIZE-1];
//rest of the code
endtask
task1(SIZE_1, array1, array2);
In reply to gabi0307:
Section 7.4.2 in the LRM states that dimensions for an unpacked array are required to be constant expressions. Using a variable violates this requirement.
You can use a dynamic array instead:
parameter SIZE_1 = 27;
task task1(input int SIZE, input logic my_array1, input logic my_array2);
automatic logic my_array3[] = new[SIZE-1];
//rest of the code
endtask
task1(SIZE_1, array1, array2);
the issue is I then need to compare mismatches of 2 arrays and if I define it as dynamic I am comparing between 2 different types of arrays. does it also solve that said issue?
i.e
logic my_array1[27];
//the definition you suggested
for(int i; i < 27; i++) begin
if (my_array1[i] != my_array3[i])
//do logic
end
and I received that I am trying to compare between packed and unpacked array
module testbench();
localparam SIZE_1 = 27;
logic array1[27];
logic array2;
task task1(input int SIZE, input logic my_array1[27], input logic my_array2);
automatic logic my_array3[] = new[SIZE-1];
//rest of the code
for (int i=0; i<SIZE; i++) begin
if (my_array1[i] != my_array3[i]) begin
$display("Mismatch at %0d", i);
end
else begin
$display("Match at %0d", i);
end //do logic
end
endtask
initial begin
task1(SIZE_1, array1, array2);
end
endmodule
If there is something different in your environment, please provide a complete example that fails.