How can I use foreach and fork together to do something in parallel?

Posted by kaushalmodi on Stack Overflow See other posts from Stack Overflow or by kaushalmodi
Published on 2013-11-05T15:45:30Z Indexed on 2013/11/05 15:53 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

This question is not UVM specific but the example that I am working on is UVM related. I have an array of agents in my UVM environment and I would like to launch a sequence on all of them in parallel.

If I do the below:

foreach (env.agt[i])
  begin
    seq.start(env.agt[i].sqr);
  end

, the sequence seq first executes on env.agt[0].sqr. Once that gets over, it then executes on env.agt[1].sqr and so on.

I want to implement a foreach-fork statement so that seq is executed in parallel on all agt[i] sequencers.

No matter how I order the fork-join and foreach, I am not able to achieve that. Can you please help me get that parallel sequence launching behavior?

Thanks.

© Stack Overflow or respective owner

Related posts about foreach

Related posts about fork