The objective is to randomly insert process1 into process2, while both run parallel. The insertion must be completely random. The behavior should be such that process1 blocks all execution of process2 until process1 is finished.
Here is a sample code, that I’ve been trying to work on:
module check();
initial begin
int count;
fork
begin
repeat(5)
begin
#1;
count++;
$display("displaying%0d",count,$time());
end
end
join_none
for(int i=0;i<=15;i++)
begin
#1;
$display("i incrementing = %0d",i,$time());
end
end
endmodule
What I’ve been trying to achieve is:
- the for loop must execute, and then in some random iteration(say 7), the fork process must execute completely before the next iteration (say 8). Something like:
i=1
i=2
displaying1
displaying2
.
.
displaying5
i=3
- I cannot put any statements inside the for loop, because then the behavior would be determined.
This came up while trying to verify a testcase where a bus reset must occur randomly while an address is being sent across the bus. So, the bus reset task is put inside the fork join_none while the rest of the code executes in the run_phase.