1
votes

I was intended to use a customized task in an always @* block, like:

input [31:0] a;
input b;
output reg [31:0] c;

task mytask;
begin
    if (b) begin
        c = a;
    end
end
endtask

always @* begin
    // ... (b is not included)
    mytask;
    // ... (b is not included)
end

What I think is that when signal b changes from 0 to 1, c will be set to the content of a. Then I found the always block is not sensitive to signal b (using ISim 14.7).

Is this a bug or designed to behave like this?

3

3 Answers

1
votes

That is the defined behavior in Verilog. If you wan to make the task sensitive to the signals you have to put them in the I/O list:

task mytask(input b);

(And the reason I know is that I also made that error and looked it up)

1
votes

The language is specified to behave like this. Always @* (or always_comb) blocks are not sensitive to changes in values used in tasks that are not included in the argument list. Use a function here since your body in not consuming time.

1
votes

Just to add to the answers: Your original always @* procedure will never execute because it has an empty trigger list. @ * means: Hey tool (simulator which relies on this list), build the sensitivity list for me. always @ * (by the lang spec) is only sensitive to changes on the arguments of a function/task (alongside other triggers)(in your case - no arguments thus empty sensitivity list), not to changes in signals within the function/task contents.

Side note: I think SystemVerilog's always_comb would work here (2012 std 9.2.2.2.2). Dave, thanks for the clarification.