Regarding constraints in system verilog

program cov;
class A;
rand int p_vr;
constraint c {p_var inside {[low:high]};}
endclass:A

initial
begin


end

endprogram

Now I want to give the value to low and high then how i have to give the value?

Hi Patel,

‘low’ and ‘high’ should be the members of the class A and you’ll have to set them for the object of A before you randomize it.

-Sharat

Thanks,Sharat
Is it possible to use constraint without using class in program block?

In reply to p_patel:
For your case, it is possible to use $urandom_range(low,high); inside a program block.

You can also provide a constraint using randsequence and randcase inside the program block.

covergroup cg @(posedge en)
coverpoint p_var {bins a=[0:10];
bins b=[11:20];
bins c=[21:30];
bins d=[31:40]}
endgroup

Now i have to cover atleast 2 hit per bins using $urandom function then it is possible?