write a constraint for prime numbers in between 0 to 500

 module test();

class packet;

bit rand [7:0] a;

constraint c1 { a inside {[0:500]};}

constraint c2 { foreach (a[i])

if(i>1)

a[i]==prime(i);}

endclass

packet p1=new();

assert(p1.randomize());

$display("the value is =%p", p1.a);

endmodule


Comments

Popular posts from this blog