write a constraint to generate prime numbers between the range of 1 to 100?
Take a look at this previous question:
https://verificationacademy.com/forums/systemverilog/prime-numbers-constraint
This example also has a scecondary contraint that the number must contain a 7, which you would not need.
class prime_numbers;
rand int unsigned prime[];
constraint const_prime {prime.size inside{100};
foreach(prime[i])
if (i>1 && (!((i%2==0 && i!=2) || (i%3==0 && i!=3) || (i%5==0 && i!=5) || (i%7==0 && i!=7))))
prime[i]==i;
else
prime[i]==2;
}
function void post_randomize;
prime = prime.unique();
endfunction
endclass
module tb();
prime_numbers pm;
initial
begin
pm=new();
assert(pm.randomize());
$display("the prime: %p",pm.prime);
end
endmodule
Check this code.It may help you.