In reply to dave_59:
In reply to ram007:
The general rule is if one process writes to a variable, and another process reads the same variable synchronized to the same event, you must use a non-blocking assignment to that variable to prevent race conditions.
The process that generates a clock is not synchronized to itself, so you should not be using non-blocking assignments. Reset depends if it is synchronous or asynchronous.
Hi Dave, so to clarify, if I have something like this
module xyz_tb_top();
reg i_local;
reg i_flop;
task abc(input reg i);
i_local = i;
endtask
always @(posedge clk)
begin
i_flop <= i_local;
end
endmodule
Should I use non blocking when assigning i_local to i to avoid race conditions? Because if I use blocking assignment, I see i_flop changing the same cycle as i_local. Is this the race condition you are talking about? Please let me know.