Event vs. process

Hi,

I am frequently running into frustration to choose which one of process control methods should be used in which context. Let’s take a kind of example. In my UVM test case, I start a couple of UVM sequences separated with begin-end to invoke data feeding streams inside fork-join. Outside this fork-join block, I would like to wait just one of those sequences to finish before going forward in test execution. To overcome that problem, I have created a couple processes within those sequence start begin-end statements. So, I can just proces.await() in my test to wait until wanted sequence is finish.

Based on that example, I would like ask what is main difference between event and process? Is it a good programming practice to use process in my example or should I replace process with event?

Thanks for you replies!

-Vaino

Hi,

I would be very grateful if someone could answer my initial question on this thread, thanks!

-Vaino

In reply to Vaino:
It would help if you showed some code. Typically people use neither events nor the process.await method. Instead they use some combination of fork/join_any or fork/join_none with wait fork.

In reply to dave_59:

Hi Dave,

See example below from UVM test:



  process proc;

  fork begin
    proc = process::self();
    seq_inst[0] = stimulus_seq::type_id::create("seq_inst[0]");
    seq_inst[0].start(env_inst.agent_inst[0].sequencer, null);
  end
  begin
    seq_inst[1] = stimulus_seq::type_id::create("seq_inst[1]");
    seq_inst[1].start(env_inst.agent_inst[1].sequencer, null);
  end
  join_none
  
  wait (proc != null);
  proc.await();
  
  // Go forward in test execution after "proc" FINISHED

So, did this example open this question more?

-Vaino

In reply to Vaino:

Don’t fork off the process you want to wait for.

fork 
  begin
    seq_inst[1] = stimulus_seq::type_id::create("seq_inst[1]");
    seq_inst[1].start(env_inst.agent_inst[1].sequencer, null);
  end
  join_none
 begin
    seq_inst[0] = stimulus_seq::type_id::create("seq_inst[0]");
    seq_inst[0].start(env_inst.agent_inst[0].sequencer, null);
 end
  // Go forward in test execution after "proc" FINISHED

In reply to dave_59:

Oops, very good! You can definitely start seq_inst[1] first. That probably makes it easier for me to to fork threads parallel.

My opinion is that process and event should be avoided as it causes confusion like this. You just need a new way to think how to place fork-join parallel blocks. Thanks!