"Memory allocation failure" with FOREACH in the random contraint

I have a sequence_time with a dynamic array diff. And the size of it will be 2170624.

If I put constraint like this:

constraint c_diff_not_neg_max { foreach(diff[i]) { diff[i] != -8192}; };

Then I got this error with QuestaSim 10.2:

# ** Failure: (vsim-4) ****** Memory allocation failure. *****
# Attempting to allocate 18446744071562067984 bytes

Without the FOREACH constraint, the simulation runs fine.

Your foreach iterative constraint gets unrolled into 2170624 individual constraints. Can you do this in a procedural loop inside pre_ or post_randomize()?

In reply to dave_59:

From my understanding, the pre_/post_randomize() is not controlled by constraint.

For my scenario, I have to generate random data sometime even more than 8M data. And I hope to be able to constraint it:

For example (not apply at the same time):

  • data[0] - data[1024] inside [-1024:1024]
  • none of the data equal to a value, like -8000
  • all the data equal to 394

I am not sure if I can do it in pre/post functions.

Or anyone can give me some good suggest about how the sequence_item should look like can do that.

Thanks.

In reply to Enzo Chi:

what you do is create class that represents how to randomize each element

typedef bit [15:0] element_t;

class element_c extends uvm_object;
  `uvm_object_utils(element);
  rand element_t element;
  element_t not_in_list[];
  constraint basic { !(element inside {not_in_list}); }
endclass

Then you construct this class in your main class, using the factory to add and override constraints for each element.

class main extends uvm_sequence_item;
  `uvm_object_utils(packet);
  element_t diff[2170624];
  element_c element_h;
  function new(string name="");
    super.new();
    element_h = element_c::type_id::create("element_h")
  endfunction
  function void post_randomize();
     foreach(diff[i]) begin
              element_h.randomize();
              diff[i] = element_h.element;
         end
   endfunction
endclass

You would use pre_ or post_ randomize based on dependencies with other random variables in your packet.

In reply to dave_59:

Your foreach iterative constraint gets unrolled into 2170624 individual constraints. Can you do this in a procedural loop inside pre_ or post_randomize()?

Hi Dave,
Is it possible to override this iterative value from script.
(example: set SolveArrayResizeMax 0 for dynamic array)
If not means,How can i overcome this issue.

Note:
I have nearly 5,00,000 elements in that queue.

Thanks,
Natarajan.A

In reply to arasupotri.natarajan90:

I can only direct you to the user manual or contact your vendor directly. This public forum is not for tool specific help.