Grace90
Grace90

Reputation: 227

How can I randomize value of a variable between -5 to 21 without using constraints in systemverilog?

I am trying to randomize a variable which can take values from -5 to 21, $urandom_range generates only positive values and $random generates signed values but not a range

Upvotes: 1

Views: 658

Answers (1)

dave_59
dave_59

Reputation: 42788

int value;

value = $urandom_range(26)-5;

Upvotes: 5

Related Questions