Generate the array of unique values without using random and constraints

Without using Random variable and constraint, you can generate array of random unique values using below code, but it is not fully random.

int unsigned data[10];
initial begin
foreach (data[i]) begin
data[i] = i;
// or data[i] = i * i;
end
data.shuffle();
end

About the author

The Art of Verification

Hi, I’m Hardik, and welcome to The Art of Verification.

I’m a Verification Engineer who loves to crack complex designs and here to help others commit to mastering Verification Skills through self-learning, System Verilog, UVM, and most important to develop that thought process that every verification engineer should have.

I’ve made it my mission to give back and serve others beyond myself.

I will NEVER settle for less than I can be, do, give, or create.

View all posts

Leave a Reply

Your email address will not be published.