RTL Studio Open IDE

1.6 · SYSTEMVERILOG CLASS

always_ff

Model clocked sequential registers with always_ff, asynchronous reset, and non-blocking assignments.

Watch on YouTube

What you practice

always_ff (1.6). Model clocked sequential registers with always_ff, asynchronous reset, and non-blocking assignments. It is in Processes — Part 1 · Design in SV of the SystemVerilog Masterclass. Synthesizable SystemVerilog that removes Verilog ambiguity and cuts boilerplate.

The same IDE is the SystemVerilog simulator. Slang lints the file, Verilator runs it, and the waveform viewer sits next to the source.

What you will learn

Today you will model clocked sequential registers using the always_ff block in SystemVerilog, enforcing single-clock edge sensitivity and non-blocking assignments for reliable hardware behavior.

Learning objectives

  • Understand the purpose of always_ff for synchronous sequential logic.
  • Write correct sensitivity lists with posedge clk and negedge rst_n.
  • Use non-blocking assignment (<=) inside always_ff blocks.
  • Distinguish asynchronous reset behavior from synchronous logic.

Theory

always_ff is a SystemVerilog block specifically for modeling flip-flops and sequential registers. It enforces synthesis tools to infer registers and prevents combinational inference mistakes. Key rules:

  • Sensitivity list must include only one clock edge (e.g., posedge clk) plus optional asynchronous reset edge.
  • Use non-blocking assignment (<=) to avoid race conditions in simulation and synthesis.
  • Asynchronous reset (negedge rst_n) triggers immediately, independent of clock.
KeywordPurpose
always_ffClocked sequential logic (registers)
posedgePositive clock edge trigger
negedgeNegative edge trigger (e.g., active-low reset)
<=Non-blocking assignment (sequential)

Practice

  1. Open RtlStudio and select this chapter — files appear automatically in Explore.
  2. Open student/rtl/design.sv in the editor.
  3. Replace the __TODO__ placeholders to complete the always_ff block: write the sensitivity list and begin/end block header.
  4. Run Simulation from the left sidebar and check the Log panel for INFO: messages.
  5. (Optional) Open the Waveform tab to inspect signal transitions aligned with stimulus steps.

Summary

You practiced modeling sequential logic using the always_ff block with explicit clock edge sensitivity and non-blocking assignments. You implemented a register with asynchronous or synchronous reset, reinforcing disciplined timing behavior. The key takeaway is that always_ff enforces synthesizable, single-clock sequential constructs essential for reliable hardware design. Always ensure reset polarity and assignment style match your intended hardware semantics.

Run it in the Verilog IDE

  1. Open the lesson in the IDE. The SystemVerilog for this topic is already in the editor.
  2. Lint with Slang before you simulate. It covers both Verilog and SystemVerilog in this IDE.
  3. Run Verilator and inspect the VCD. Interfaces, classes, and assertions count only if the simulator agrees.
  4. Run Yosys when the lesson is synthesizable RTL, and keep testbench-only constructs out of that module.

The lesson is done when the simulation matches always_ff. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.