In reply to dave_59:
In reply to rgarcia07:
Do you mean to run the 4 producers in series (which is what you have written), or do you want them executing in parallel? If in parallel, you may need some sort of arbitration scheme to keep one of the producers from being greedy.
Hi Dave,
I meant to act in parallel, any hint on how to achieve this is really appreciated, I thought that putting the prod[i].run() methods inside the fork-join I will get the each producer’s put() task running in parallel and blocking the mailbox.
module env();
producer prod[];
consumer cons;
packet pkt;
mailbox #(packet)channel;
initial begin
channel= new(); //creating mailbox
prod= new[4]; // create dynamic array of producers
foreach(prod[i]) begin
prod[i] = new(channel); //passing mailbox handle to each producer
end
cons= new(channel); //passing mailbox handle
fork
foreach(prod[i]) begin
fork
prod.run();
join
end
cons.run();
join
end
endmodule
Cheers,
-Ronald