print the odd numbers in even location and even numbers in odd locations by using constraint

 module test();


class packet;

rand bit [7:0] a;

constraint  a { a inside {[10:20]};}

constraint a2 { foreach(a[i])

if(i%2==0)

a[i]==1;

else

a[i]==0;}

endclass


packet p1=new();

assert(p1.randomize());

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

endmodule

Comments

Popular posts from this blog