Is it possible to assign value larger than (2**31 - 1) to array size of new[] operator in dynamic array

Hi all,

I got an error when assign value larger than (231 - 1) to array size of new[] operator in dynamic array.
*** Error: Array size passed to ‘new’ must be an integral value between 0 and 2147483647 (2
31 - 1).


class packet ; 
     
     int unsigned length;
     bit [7:0] payload[];

     constraint len_c {
          length[1:0] == 2'b00
     };
     
     function void post_randomize();
          payload = new[length]; // -> Error here
          /* Create data for payload */
     endfunction 

endclass 

module top; 
    
    packet pkg;
      
    initial begin
       pkg = new();
       
       if (! pkg.randomize() with {
           length == 32'hFFFF_FFFC;
       } ) $display("Cant Randomize!");
    
       /* To do something */               

    end
 
endmodule


Could you please help me for this situation ?
Whether anyone have any solution to solve how to assign a large value to array size in dynamic array ?

Thank you very much for your kindly support.

B.R,
Thien

In reply to thienle:

Typically tools will have some limitations to prevent the user from causing issues by using all of the system memory.

Do you really want a dynamic array of 2 Billion bytes? The storage required for this will be very large and the performance will be extremely poor. You cannot effectively use an array of this size.

In reply to cgales:

Do you know what other type of array to solve this problem ?

Because I want to check toggle for all 32-bit reg, so I need to perform to 2GByte data.

Thank you very much.

B.R,
Thien

In reply to thienle:

I’m not sure what you mean by ‘check toggle for all 32-bit reg’. Do you want to check that each individual bit toggles?

Most simulators will provide toggle coverage so you just need to enable it. You can also use a covergroup.

In reply to cgales:

I strongly recommend cgales advice about use your tool’s coverage capabilities to collect toggle coverage.

Regardless of how you collect coverage, you would want to use an associate array to model a 2GB memory. They only allocate array elements that are explicitly written to. Any test that you could run would only have enough time to use a tiny fraction of the array, and that all you need to toggle a 32-bits of an address register.

In reply to cgales:

Do you want to check that each individual bit toggles
No, I don’t.
Exactly, I want to check toggle for variable length[31:28], so I need to expand array size in dynamic array.

Thank you very much

In reply to dave_59:

I got it.

Do you have any other method to use an associate array to model a 2GB memory ?
If possible, could you please share an code example about that method ?

Thank you very much.

In reply to thienle:

typedef bit [30:0] address_t; // 2GB needs 31 address bits

bit [7:0] memory[address_t] = '{default:0}; // any element you read that has not been written yet
                                            // returns this default value without having to allocate it

In reply to dave_59:

Let me try your code.

Thank you very much for your kindly support.