print the power of 2 by using constraint
module test();
class packet;
rand bit [7:0] a;
rand int power;
constraint a1{ a inside {[10:20]};}
constraint a2 { a==power**2;}
endclass
packet p1=new();
assert(p1.ramdomize());
$display("the value is =%p", p1.a);
endmodule
Comments
Post a Comment