Hi, am trying to run a sequence on a sequencer here is the code below.
class my_sequencer;
int id;
endclass : my_sequencer
class my_sequence;
task start (my_sequencer seqr);
int delay = $urandom_range(1,10);
$display("time: %d, starting sequence on sequencer with id:%d", $time, seqr.id);
#(delay * 1us);
$display("time: %d, finishing sequence on sequencer with id:%d", $time, seqr.id);
endtask : start
endclass : my_sequence
module top;
initial begin
my_sequencer seqr;
my_sequencer seqr_q[$];
static int num_of_seqr = $urandom_range(3,5);
for (int i = 0; i < num_of_seqr; i++) begin
seqr = new;
seqr.id = i;
seqr_q.push_back(seqr);
end
for(int i = 0; i< num_of_seqr; i++) begin
my_sequencer seqr1;
my_sequence seq;
seq = new();
seqr1 = new seqr_q.pop_front();
fork
begin
seq.start(seqr1);
end
join_none
end
wait fork;
$display("time: %d, end reached", $time);
end
endmodule
Result:
time: 0, starting sequence on sequencer with id: 2
time: 0, starting sequence on sequencer with id: 2
time: 0, starting sequence on sequencer with id: 2
time: 6000, finishing sequence on sequencer with id: 2
time: 8000, finishing sequence on sequencer with id: 2
time: 10000, finishing sequence on sequencer with id: 2
time: 10000, end reached
My expectation was sequence should start on different sequencer but all sequences started on the same sequencer. my understanding is because I am allocating memory for sequencer every time it should start on a different sequencer, using automatic is solving the problem but I want to understand why this issue was caused.