always_ff, always_comb, always_latch and final
Plain Verilog has one always block for everything, and it is easy to accidentally describe a latch or mismatch simulation and synthesis. SystemVerilog adds intent-declaring procedural blocks — always_ff, always_comb, always_latch — that let the tools check you got what you meant.
Say what you mean
always_comb is combinational: it has an automatic sensitivity list and the tool errors if the logic implies memory. always_ff is a clocked register and documents the clock/reset. always_latch declares an intentional latch. initial still runs once at time 0; SystemVerilog adds final, which runs once at end of simulation — handy for printing summaries.
module tb;
logic clk=0, rst_n=0;
logic [3:0] d, q, doubled;
always #5 clk = ~clk;
always_comb doubled = d << 1; // pure combinational, checked
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0; // clocked register
else q <= doubled;
initial begin
d = 4'd3; #3 rst_n = 1;
repeat (3) @(posedge clk);
#1 $display("d=%0d doubled=%0d q=%0d", d, doubled, q);
$finish;
end
final $display("final block: simulation finished at t=%0t", $time);
endmoduled=3 doubled=6 q=6 - /var/folders/l0/gs5hnkm56g54bmxg32r6nnwr0000gn/T/tmpa100_inz/tb.sv:16: Verilog $finish final block: simulation finished at t=26
Check yourself
What does <code>always_comb</code> give you that a plain <code>always @(*)</code> does not?
A tool-checked promise of combinational intent: an automatic, complete sensitivity list (including inside called functions) and an error if the body would infer a latch or register. It catches the classic ‘accidental latch’ bug at compile time.
When does a <code>final</code> block execute?
Once, at the very end of simulation (e.g. at $finish), with no delays allowed inside it. It is typically used to print end-of-run summaries or coverage totals.
Share your question in comments or talk to our mentor team for batch guidance.
Compile and simulate this in the browser — no install. Edit the code and re-run instantly.
Learn Verilog with mentors, labs and placement support
This free series is maintained by the ChipXpert training team in Hyderabad & Bengaluru. Go deeper with instructor-led courses on real EDA tools.
Explore VLSI Courses