print the odd numbers by using constraints code
module test();
class packet;
rand bit [7:0] a;
initial
begin
constraint a{ a inside [10:20];}}
constraint a2 ( foreach(a[i])
if(i%2==0)
a[i]==0;
else
a[i]==1;
}
endclass
packet p1=new();
assert(p1.randomize());
$display("the value of a is =%p", p1.a);
endmodule
Comments
Post a Comment