Hello,
I’m new to the forum (but i did try to find a similar question) and learning SystemVerilog (simulation/verification constructs for this question only).
Coming from software background i have 1 specific question: atomic guarantees. specifically, below is a small reproducer to do an accumulation.
module automatic test;
int sum = 0;
task accum();
sum++;
endtask
initial begin
for (int i=0; i<10; i++) begin
int ii = i;
fork
accum();
join_none
end
wait(sum == 10);
$display("sum = %0d", sum);
$finish;
end
endmodule
question: does SystemVerilog provide a guarantee that when 2 threads reach
sum++
statement, that there will be no side effects.
For instance, take c++, the result will be undefined (at least from the standard point of view). However, I guess (from going over Chris Spear SystemVerilog for Verification 2nd edition) that this is assumed for this (sum++). It is clear that no guarantees on the order, but for this one, i’m not sure.
Any advice on this would be really appreciated.
VK