I am observing 2 different outputs for a same piece of code which is called only once, the only difference is that one method is static and other is automatic.
As per my understanding if the method is called only once, then the static or automatic should not have any effect.
Below are the sample codes and output.
Code:
task automatic generateCRC(input bit [31:0] crc_poly, input bit [31:0] crc_seed, input bit [7:0] data_stream[], output [31:0] crc_start_value);
bit [31:0] crc_temp = crc_seed;
bit [7:0] data;
for (int i = 0; i < data_stream.size; i++) // Byte-Stream
begin
data = data_stream[i];
for (int j=0; j < 8; j++) // from LSB to MSB in one byte
begin
if ((crc_temp[31]) != (data[7])) begin
crc_temp = (crc_temp << 1) ^ crc_poly;
end
else begin
crc_temp <<= 1;
end
data <<= 1;
end
end
crc_start_value = crc_temp;
endtask
task generateCRC1(input bit [31:0] crc_poly, input bit [31:0] crc_seed, input bit [7:0] data_stream[], output [31:0] crc_start_value);
//compute the field values from the control_reg value
bit [31:0] crc_temp = crc_seed;
bit [7:0] data;
for (int i = 0; i < data_stream.size; i++) // Byte-Stream
begin
data = data_stream[i];
for (int j=0; j < 8; j++) // from LSB to MSB in one byte
begin
if ((crc_temp[31]) != (data[7])) begin
crc_temp = (crc_temp << 1) ^ crc_poly;
end
else begin
crc_temp <<= 1;
end
data <<= 1;
end
end
crc_start_value = crc_temp;
endtask
module top;
bit [31:0] crc;
bit [31:0] crc1;
logic [7:0] data[] = {'h87, 'h11, 'h55, 'h99, 'h32};
initial begin
generateCRC('hc9d204f5, 'h3, data, crc);
$display("Automatic task output %0h", crc);
generateCRC1('hc9d204f5, 'h3, data, crc1);
$display("Static task output %0h", crc1);
end
endmodule
Output:
Automatic task output 83980f08
Static task output c72cbc03