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?
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.
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
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
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!