Hi Everyone,
I’m facing an issue with my code
Following is the piece of code
for(int i=0; i<10; i++)
fork
int j = i;
schedule_data_on_if(j);
join_none
task schedule_data_on_if(input int index) ;
forever begin
wait(q_in[index] !=0); // Input queue
$display(“Before delay in thread %0d”, index); // All these prints are happening in order
repeat(50) @(posedge clk); // DELAY
$display(“After delay in thread %0d”, index); // How to control this statement execution ??
end
endtask
Input Description:
I have an array of input queue(q_in). From my sequence I will fill this queue with indexes 2 7 4 in order (at 0 time)
Output Expected
Before delay in thread 2
Before delay in thread 7
Before delay in thread 4
After delay in thread 2 // (PROBLEM STARTS HERE)
After delay in thread 7
After delay in thread 4
Output Coming:
Before delay in thread 2
Before delay in thread 7
Before delay in thread 4
After delay in thread 4 // WHY IS IT HAPPENING EXACTLY OPPOSITE ??
After delay in thread 7
After delay in thread 2
Question:
Here 10 threads are running parallel and the statements before the delay (repeat stat) are executing in the same order, the way I’ve given input.
Why are the statements executed after the delay statement are happening exactly opposite.
Requirement
My requirement is to control the execution of statement after the delay, in the same order, the way I’ve given the input at 0 time. How can this be done?
P.S: Please do ignore the typos and syntaxes