An always block sensitivity list tells Verilog when to run the code inside an always block. It helps the circuit react to changes in signals.
Always block sensitivity list in Verilog
always @(sensitivity_list) begin
// statements
endThe sensitivity_list can include signals or edges like posedge clk or negedge reset.
If you want to model combinational logic, include all input signals in the sensitivity list.
a, b, or c changes. It models combinational AND logic.always @(a or b or c) begin y = a & b & c; end
clk. It models a flip-flop storing d.always @(posedge clk) begin
q <= d;
endalways @(posedge clk or negedge reset) begin if (!reset) q <= 0; else q <= d; end
@(*) means "all inputs used inside". It automatically includes all signals read inside the block.always @(*) begin
y = a | b;
endThis example shows an always block sensitive to a and b. It updates y whenever a or b changes, modeling an AND gate.
module simple_and(
input wire a,
input wire b,
output reg y
);
always @(a or b) begin
y = a & b;
end
endmodule
// Testbench
module testbench;
reg a;
reg b;
wire y;
simple_and uut(.a(a), .b(b), .y(y));
initial begin
a = 0; b = 0;
#10 a = 1;
#10 b = 1;
#10 a = 0;
#10 b = 0;
#10 $finish;
end
initial begin
$monitor($time, ": a=%b b=%b y=%b", a, b, y);
end
endmoduleTime complexity: The always block runs only when signals in the sensitivity list change, making simulation efficient.
Space complexity: Minimal, just stores the signals and output.
Common mistake: Forgetting to include all input signals in the sensitivity list for combinational logic can cause simulation mismatches.
Use @(*) for combinational logic to avoid missing signals in the sensitivity list.
The always block sensitivity list controls when the block runs.
Use signal names or edges like posedge in the list.
Use @(*) to automatically include all inputs for combinational logic.