Passing array as an argument (packed vs unpacked, dynamic vs fixed)

In reply to dave_59:

Hi Dave, thanks for the quick reply. here is main code for said issue:



class test1 extends base_test;
string array2 [3];
bit [3:0] [31:0] array1;
bit [1:0] [31:0] array3;
bit [15:0] [127:0] data_array_concatenated;

event ev, ev1, ev2, ev3, ev4;

extern task check_values (int num, input bit actual_result_array[][], input string reg_name_array[], input bit expected_result_array[][]);

//somecode


check_values(2, array1, array2, array3)

endclass

task test1::check_values (int num, input bit actual_result_array[][], input string reg_name_array[], input bit expected_result_array[][]);

   //actual_result_array              = new[SIZE1];
   //reg_name_array            = new[SIZE2];
   //expected_result_array      = new[SIZE3];
   //data_array_concatenated    = new[15][127];

   /*
   foreach (actual_result_array[i]) begin
      actual_result_array[i] = new[31];
   end
   foreach (reg_name_array[i]) begin
      reg_name_array[i] = new[31];
   end
   foreach (expected_result_array[i]) begin
      expected_result_array[i] = new[31];
   end
   foreach (data_array_concatenated[i]) begin
      data_array_concatenated[i] = new[127];
   end
   */
   @(negedge internal_vif.done_something)
   for (int i = 0; i < num; i = i + 1) begin // { 
      -> ev;
      //we check if the address is only FF
      if (data_array_concatenated[i][31:0] == 32'hffffffff) 
      begin // {
         writing_flag_addr0 = 0;
      end // }
      if (data_array_concatenated[i][95:64] == 32'hffffffff) 
      begin // {
         writing_flag_addr1 = 0;
      end // }

      reg_name_array[2*i] = api.get_reg_name(data_array_concatenated[i][31:0]);
      functions_vif.read_reg(.reg_name(reg_name_array[2*i]), .reg_rd_data(actual_result_array[2*i]));

      reg_name_array[2*i+1] = api.get_reg_name(data_array_concatenated[i][95:64]);
      functions_vif.read_reg(.reg_name(reg_name_array[2*i+1]), .reg_rd_data(actual_result_array[2*i+1]));
      #1ns
      if (writing_flag_addr0) begin // {
         if (actual_result_array[2*i] != expected_result_array[i][63 -: 32]) begin // {
            `uvm_error(m_name, $sformatf("Mismatch between expected and actual. actual data: %x, expected data: %x", 
            actual_result_array[2*i], expected_result_array[i][63 -: 32]));
            -> ev_1;
         end // }
      end // }
      else begin // {
         if (actual_result_array[2*i] == expected_result_array[i][63 -: 32]) begin // {
            `uvm_error(m_name, $sformatf("Mismatch between expected and actual. actual data: %x, expected data: %x", 
            actual_result_array[2*i], expected_result_array[i][63 -: 32]));
            -> ev_2;
         end // }
      end // }
      if (writing_flag_addr1) begin // {
         if (actual_result_array[2*i+1] != expected_result_array[i][127 -: 96]) begin // {
            `uvm_error(m_name, $sformatf("Mismatch between expected and actual. actual data: %x, expected data: %x", 
            actual_result_array[2*i+1], expected_result_array[i][127 -: 32]));
            -> ev_3;
         end // }
      end // }
      else begin // {
         if (actual_result_array[2*i+1] == expected_result_array[i][127 -: 96]) begin // {
            `uvm_error(m_name, $sformatf("Mismatch between expected and actual. actual data: %x, expected data: %x", 
            actual_result_array[2*i+1], expected_result_array[i][127 -: 32]));
            -> ev_4;
         end // }
      end // }
   end // }
endtask

Short explanation:
we read a slice of data_array_concatenated to get address which we then use to find the register name using an api. we then read the data from that register after a point in time and and after that we compare to the expected array which was created elsewhere.
Error Message: ‘actual_result_array’ of ‘check_values’: Cannot assign a packed type ‘bit[31:0][3:0]’ to an unpacked type ‘bit $’.
*NOTE: you can see also what I was referring to in question 3.