What you practice
Goodbye wire/reg, Hello logic (0.2). Replace legacy wire/reg with logic in module ports and internal signals to unify net/variable semantics. It is in Hello SystemVerilog — Part 0 · SV Warming Up of the SystemVerilog Masterclass. Move from Verilog to SystemVerilog and get the Verilator simulation flow running.
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 replace legacy wire and reg declarations with the SystemVerilog logic type to eliminate net/variable confusion and unify signal declarations.
Learning objectives
- Understand why
logicsimplifies declarations in modern RTL. - Identify ports and signals that should use
logicinstead ofwire/reg. - Update module port declarations to use
logicexclusively. - Verify correct behavior using a testbench that exercises combinational and sequential logic.
Theory
The logic type in SystemVerilog combines the functionality of wire and reg into a single type. It can be assigned by both continuous assignments (assign) and procedural blocks (always_ff, always_comb). This eliminates the need to choose between wire (for continuous assignments) and reg (for procedural assignments), reducing errors in multi-driven designs.
| Type | Assignment Source | Use Case |
|---|---|---|
wire | Continuous (assign) only | Net connections |
reg | Procedural blocks only | Registers, variables |
logic | Either | Unified, modern replacement |
Note: logic is *not* a flip-flop by itself—it becomes a register only when assigned in a sequential block.
Practice
- Open this chapter in RtlStudio; confirm files appear in Explore.
- Open
student/rtl/design.svand replace each__TODO__withlogicin all port declarations. - Run Simulation and check the Log panel for expected output.
- Open the Waveform tab to verify signal transitions align with stimulus steps.
Summary
You replaced legacy wire and reg declarations with the logic type across the DUT’s port list, eliminating net vs variable confusion in both combinational and sequential logic. The testbench confirmed correct signal propagation for all input combinations, validating that logic behaves as expected under both continuous and procedural assignments. Synthesis confirmed the design maps cleanly to standard cells without unintended multi-drivers or type mismatches. The key takeaway is that logic is the unified, modern data type for all RTL signals, simplifying code and reducing common design errors.
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 Goodbye wire/reg, Hello logic. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.