I just found that always@(*) does not work as expected when it involve function.
Please see simple sample code below.
http://www.edaplayground.com/x/J7M
module test;
reg a, b, c;
function reg my_func();
if (b==0) begin
$display("DEBUG 0 @%0t", $time);
return a;
end
else if (b==1) begin
$display("DEBUG 1 @%0t", $time);
return ~a;
end
else begin
$display("DEBUG 2 @%0t", $time);
return 0;
end
endfunction
always @(*) begin
//always_comb begin
c = my_func();
end
initial begin
a = 0; #10;
a = 1; #10;
a=0;
end
endmodule
Try to switch between always @(*) and always_comb in simulation. If I use always @(*), nothing will display. But if I use always_comb, it will show expected result as follows:
DEBUG 2 @0
DEBUG 2 @0
DEBUG 2 @10
DEBUG 2 @20
The above code is just simple combinational logic.
Why always @(*) and always_comb show different result? Is it just simulation issue? Further experiment I noticed that it may have something to do with usage of function inside the always block.