print the pattern 10101010 by using constraint

 code:-


module test();

class packet;

rand bit [7:0] a;

constraint a1 (a inside {[0:10]};}

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