What you practice
always_comb (1.5). Use always_comb blocks for safe, explicit combinational logic — no sensitivity list required. 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
You will learn how to use always_comb to enforce explicit combinational intent in SystemVerilog, eliminating risks from incomplete sensitivity lists and unintended latches.
Learning objectives
- Understand why
always_combis safer thanalways @*for combinational logic. - Recognize how
always_combautomatically infers a complete sensitivity list. - Use
always_combwith a fullcasestatement to avoid latch inference. - Verify combinational behavior by testing all input combinations.
Theory
always_comb is a SystemVerilog procedural block that guarantees combinational behavior. It automatically includes all signals read inside the block in the sensitivity list, preventing accidental latches from incomplete lists. Unlike always @*, always_comb also triggers lint-time checks for unintended memory elements.
| Block Type | Sensitivity List | Latch Check | Combinational Guarantee |
|---|---|---|---|
always @* | Manual inference | None | Not enforced |
always_comb | Automatic | Yes | Enforced |
Practice
- Open this chapter in RtlStudio; confirm
student/rtl/design.svandstudent/tb/tb.svappear in Explore. - In
student/rtl/design.sv, replace__TODO__ beginwithalways_comb begin. - In the same file, replace
case (__TODO__)withcase ({a, b, c}). - Run Simulation and check the Log panel for expected
INFO:messages. - (Optional) Open the Waveform tab to inspect signal transitions.
Summary
You practiced implementing a pure combinational circuit using an always_comb block with a complete case structure, ensuring explicit intent and preventing unintended latch inference. You verified full input coverage by driving all eight minterms in the testbench and confirmed correct output behavior through simulation and synthesis. This reinforced how always_comb enforces single-driver semantics and enables robust tool analysis for combinational logic correctness.
Run it in the Verilog IDE
- Open the lesson in the IDE. The SystemVerilog for this topic is already in the editor.
- Lint with Slang before you simulate. It covers both Verilog and SystemVerilog in this IDE.
- Run Verilator and inspect the VCD. Interfaces, classes, and assertions count only if the simulator agrees.
- 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_comb. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.