always, always_comb and always_ff explained

Compare Verilog always with SystemVerilog always_comb and always_ff, including sensitivity, assignment and single-driver rules.

always

Verilog always is general purpose. The sensitivity list and body determine whether it models combinational logic, a latch or sequential logic.

always @* y = (sel) ? a : b;
always @(posedge clk) q <= d;

@* automatically includes signals read by the block and is safer than a hand-maintained combinational sensitivity list.

always_comb

SystemVerilog always_comb expresses combinational intent. Tools build the sensitivity set, execute the block once at time zero, and can diagnose variables written by another process. Every output still needs an assignment on every path.

always_comb begin
  next_state = state;
  if (advance) next_state = state + 1'b1;
end

Do not use nonblocking assignments or intentional storage in always_comb. A missing branch can still imply a latch and should be reported by lint.

always_ff

always_ff states that a process models flip-flops or other event-controlled state. A variable written in it must not be written by another process.

always_ff @(posedge clk or negedge rst_n) begin
  if (!rst_n) q <= '0;
  else        q <= d;
end

Use nonblocking assignments for state. Keep combinational next-state calculation in always_comb and state updates in always_ff.

Choosing the construct

  • Existing Verilog: always @* for combinational logic and edge-sensitive always for registers.
  • SystemVerilog RTL: prefer always_comb and always_ff because they communicate intent and enable stronger checks.
  • Use always_latch only when a level-sensitive latch is deliberate and documented.

Continue into the complete lesson

Use the course lesson for the surrounding design rules, exercises, labs and knowledge check.

Open supporting lesson →
Related answers

Continue exploring this topic

SystemVerilog constraint examples

Use SystemVerilog inside, dist, implication, solve-before, soft and foreach constraints with practical examples and debugging guidance.