constraint natural number code and twice odd number code
constraint natural number code:-
/*----------------natural no and twice odd no---------
class b1;
rand int a[];
constraint a1{a.size==(10);}
constraint a2{foreach (a[i])
if(i%2==0)
a[i]==i; // a[i]==i; // a[i]==i+1;
else if(i%2==1)
a[i]==i+1;}
endclass
b1 a3;
module test;
initial
begin
a3=new;
assert(a3.randomize());
$display("the value %p",a3.a);
end
endmodule
*/
constraint twice odd number code:-
/*class b1;
rand bit[7:0] a[];
constraint a1{a.size==(10);}
constraint a2{foreach (a[i])
if(i%2==0)
a[i]==i;}
endclass
b1 a3;
module test;
initial
begin
a3=new;
assert(a3.randomize());
$display("the value %d",a3);
end
endmodule*
Comments
Post a Comment