I'm a bit confused about what is considered an input when you use the wildcard @*
in an always
block sensitivity list. For instance, in the following example, which signals are interpreted as inputs that cause the always
block to be reevaluated?
From what I understand, clk and reset aren't included because they don't appear on the right hand side of any procedural statement in the always
block. a and b are included because they both appear on the right hand side of procedural statements in the always
block.
But, where I'm really confused about is en and mux. Because they are used as test conditions in the if and case statements, are they considered inputs? Is the always
block reevaluated each time en and mux change value?
module example
(
input wire clk, reset, en, a, b,
input wire [1:0] mux,
output reg x,y, z
);
always @*
begin
x = a & b;
if (en)
y= a | b;
case(mux)
2'b00: z = 0;
2'b01: z = 1;
2'b10: z = 1;
2'b11: z = 0;
endcase
end
endmodule
Any signal that is read inside a block, and so may cause the result of a block to change if it's value changes, will be included by @*
. Any change on a read signal used must cause the block to be re-evaluated, as it could cause the outputs of the block to change. As I'm sure you know, if you hadn't used @*
you'd be listing those signals out by hand.
In the case of the code you've provided it's any signal that is:
a
and b
)en
and mux
)...but it's any signal that would be evaluated for any reason. (I can't think of any other reasons right now, but maybe someone else can)
clk
and reset
aren't on the sensitivity list because they aren't used. Simple as that. There's nothing special about them; they're signals like any other.