Illegal attempt to resize random dynamic array

I have a ethernet transaction in which I have a payload_data; the size of of which is constrained dependin gon the packet type (as in below).

typedef enum {NORMAL,JUMBO} PKT_TYPE;
 typedef enum {GOOD,BAD} CRC_TYPE; 
  
  bit unsigned [6:0] [7:0] preamble; 
  bit [7:0] sfd;
  rand bit [5:0] [7:0] d_addr, s_addr;
  rand bit [1:0] [7:0] data_len;
  randc bit [7:0] payload_data[];
  bit [3:0] [7:0] crc;
  
  rand PKT_TYPE type_pkt;
  rand CRC_TYPE type_crc;

constraint eth_mac_frame_normal 
    {
      if (type_pkt == NORMAL) 
        {payload_data.size() inside {[46:1500]};
        payload_data.size() == data_len;}
    }

  constraint eth_mac_frame_jumbo 
    {
      if (type_pkt == JUMBO) 
      {payload_data.size() inside {[1501:9000]};
	payload_data.size() == data_len;}
    }

When I run the test, (I am using Questa 10.0) It gives me the following error :

** Error: (vsim-7020) eth_SEQ.sv(22): Illegal attempt to resize random dynamic array 'pkt.payload_data' to 8421 elements. (SolveArrayResizeMax=2000)
#    Time: 0 ps  Iteration: 37  Region: /uvm_pkg::uvm_sequence_base::start

eth_SEQ.sv(22) is where I am randomizing the transaction.

Can anyone please help why this error is coming? I searched over the net but i could’nt understand it clearly.

Questa is setting a limit for the array size. You can change the that maximum limit using at least two methods:

  1. Use an attribute on the randomize call:
assert(p.randomize(* solvearrayresizemax = 0 *)() with {type_pkt == JUMBO;});
  1. Use a Tcl variable
vsim -c top -do "set SolveArrayResizeMax 0; run -all; quit -f"

Setting the limit to 0 means the size is unlimited. Please see the Questa User Guide for more information.

In reply to richedelman:

By the way, hitting this limit is usually the indication of an improperly specified constraint. I noticed you had

randc bit [7:0] payload_data[];

I don’t know what you were expecting that to do. It won’t generate an array of unique numbers, and it may be too large an array to have cyclical values for each call to randomize()

In reply to dave_59:

Hi Richedelman,
Thanks for the information, that solved my problem.

In reply to vvs3693:

Hi Dave,

Actually its a typo, I was using rand only.

In reply to vvs3693:

Hi, It worked… But when I am trying to pack this in to a bitstream (uvm_packer), I am not able to do it if there are more than 4095 bytes in total. ie, only a payload of 4070 is allowed. Is there any limit like the above for this also??

In reply to vvs3693:

Got It…
vlog +define+UVM_MAX_STREAMBITS= top.sv