write a constraint to get the random no from 0 to 100 such that no repeat

 module test();

class packet;

rand int a;

int b[$];

constraint c1 { ainside {[0:100]};}

constraint c2 {! )a inside {b});}

function void post_randomize();

b.push_front(a);

$display("printnvaluen%od", a);

if(b.size>=101)

b.delete(101);

endfunction

endclass



packet p1=new()

initial

begin

for(int i=0; i<100; i++)

begin

p1.randomize();

end

end

endmodule



p1.randomize();


Comments

Popular posts from this blog