I need to run a sequence on all the sequencers in parallel at the same time.
I did try something like below but i know i will be ending up in running the “sequence” sequentially on all the sequencers one after the other.
task body(); uvm_info("SEQ",$sformatf("Starting %s sequence",get_full_name()),UVM_MEDIUM); fork begin for (int i = 0; i < p_sequencer.cfg.a_devices; i = i + 1) begin a_seq[i] = wr_rd_random_v_seq::type_id::create($psprintf("SEQ[%0d]",i)); a_seq[i].start(p_sequencer.a_vseqr[i]); fork begin uvm_do_on(a_seq[i],p_sequencer.a_vseqr[i]);
end
join_none
end
end
begin
if (p_sequencer.cfg.b_devices > 0) begin // {
`uvm_do_on(b_seq,p_sequencer.b_vseqr);
end
end
The issue is that you are calling the for loop inside the fork, which means that the for loop is one branch of the fork.
I am not sure if you can call a “forked for loop” in SystemVerilog like you are trying to. This is something that I think I saw either in Cuda or OpenCL.
You will have to modify the code so that each call of the for loop is a fork branch such as:
for (int i = 0; i < p_sequencer.cfg.a_devices; i = i + 1) begin
fork begin
a_seq[i] = wr_rd_random_v_seq::type_id::create($psprintf(“SEQ[%0d]”,i));
a_seq[i].start(p_sequencer.a_vseqr[i]);
end
join_none
end
for (int i = 0; i < p_sequencer.cfg.a_devices; i = i + 1)
begin
automatic int j = i;
fork
begin
a_seq[j] = wr_rd_random_v_seq::type_id::create($psprintf(“SEQ[%0d]”,j));
a_seq[j].start(p_sequencer.a_vseqr[j]);
end
join_none
end
The automatic variable declaration needs to go inside the fork/join_none. See the last example in section 9.3.2 Parallel blocks of the IEEE 1800-2012 LRM
I did Try something like below, as automatic variable needs to be declatred inside fork…jone_none.
According to the below print msgs it looks like the things are happening in parallel but I got FATAL errors something like below.
Can you help me in resolving this.
fork
begin
for (int i = 0; i < p_sequencer.cfg.a_devices; i = i + 1) begin
$display(" 11 SAN_@@ a_devices %0d iteration %0d at time %0t",p_sequencer.cfg.a_devices,i,$time);
ram_seq[i] = wr_rd_random_v_seq::type_id::create($psprintf("SEQ[%0d]",i));
fork
begin
automatic int j =i;
`uvm_do_on(a_seq[j],p_sequencer.a_vseqr[j]);
end
join_none
end
end
11 SAN_@@ a_devices 2 iteration 0 at time 0
11 SAN_@@ a_devices 2 iteration 1 at time 0
UVM_FATAL ramb_wr_rd_v_seq.sv(3) @ 0: ********.a_seq[j] [DCLPSQ] *****.a_seq[j] Error casting p_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer
UVM_FATAL ramb_wr_rd_v_seq.sv(3) @ 0: ********.a_seq[j] [DCLPSQ] *****.a_seq[j] Error casting p_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer
where i have defined “wr_rd_random_v_seq” as below
Now It is working fine, after changing the code to like below
fork
begin
for (int i = 0; i < p_sequencer.cfg.a_devices; i = i + 1) begin
$display(" 11 SAN_@@ a_devices %0d iteration %0d at time %0t",p_sequencer.cfg.a_devices,i,$time);
ram_seq[i] = wr_rd_random_v_seq::type_id::create($psprintf(“SEQ[%0d]”,i));
fork
automatic int j =i;
begin
$display(" 22 SAN_@@ a_devices %0d iteration %0d at time %0t",a_devices,j,$time);
`uvm_do_on(a_seq[j],p_sequencer.a_vseqr[j]);
end
join_none
end
end
I could see the above display messages in the irun.log file as
11 SAN_@@ a_devices 2 iteration 0 at time 0
11 SAN_@@ a_devices 2 iteration 1 at time 0
22 SAN_@@ a_devices 2 iteration 1 at time 0
22 SAN_@@ a_devices 2 iteration 0 at time 0