Hi All,
I have a class that generates 10 random numbers. And in the test program, I create two instances c1 and c2. I wonder if it is possible to let c1 and c2 generate the same sequence of number? That’s to say, if c1 generates 7,8,3,2,5,1,4,0,9,6, I wonder if it is possible to let c2 also generates 7,8,3,2,5,1,4,0,9,6?
I tried to use srandom() to set the initial seed, but it seems to have no effect on the result.
class c_rng;
int i;
task gen_print();
repeat(10)begin
i=$urandom;
$display("i=%0d",i);
end
endtask
endclass
module test;
c_rng c1,c2;
initial begin
c1=new();
c2=new();
c1.srandom(1);
c2.srandom(1);
$display("c1 generates");
c1.gen_print();
$display("c2 generates");
c2.gen_print();
end
endmodule
Thanks in advance for your help!
Hao