// Declarations
bit[31:0] dw0_full_list[$];
rand bit [15:0] src_size_sg;
// Lets assume src_size_sg having value of 2^16 after randomization.
std::randomize(dw0_full_list) with {
dw0_full_list.size == src_size_sg;
unique {dw0_full_list};
};
So resolving the unique { dw0_full_list }; related it is taking a lot of time. The MAX Size of the dw0_full_list is 2^16.
Can you please suggest, The best replacement code for this unique keyword?
I want to generate unique 32-bit data values in a queue or array, where the size is determined dynamically after randomization. Using std::randomize, I aim to fill the queue/array with a dynamically decided size, ensuring all elements are unique.
Although your current code works, it takes a significant amount of time to resolve the constraint. I need suggestions to modify the code to improve performance without using the unique keyword.
You still haven’t explained your requirements clearly.
What is dw0_full_list? A queue of addresses?
What is dw0_start and dw0_end? If dw0_end is assigned to dw0_full_list.size(), why is it part of the constraint instead of being assigned after?
Is there a constraint on dw0_start?
What is sg_data_list_size and src_size_sg? What are the constraints on these variables? Can sg_data_list_size have an unlimited number of 16 bit values? If so, then there is no real constraint on the size of dw0_fill_list.
If you have an a queue with 65,536 elements, applying the ‘unique’ constraint will likely result in excessive solve times. This is because the solver will generate all 65,536 values and then check that they are all unique.
Perhaps a better implementation would be to:
Start with an empty queue
Randomize a single value with the constraint that it doesn’t exist in the queue
Add it to the queue
Repeat until the desired queue size is obtained
While this would be efficient early on, as the queue size grows, the randomization time will likely increase, but I haven’t done any calculations.