What you practice
logic and design.sv (0.1). Introduce the unified logic type in SystemVerilog to replace legacy wire/reg in simple combinational logic. 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 unified logic type in SystemVerilog, simplifying combinational and registered signal declarations in your RTL.
Learning objectives
- Understand why
logicreplaceswireandregin modern SystemVerilog. - Declare DUT ports and internal signals using only the
logictype. - Verify a combinational logic module using a simple testbench.
- Run simulation and interpret
$displayoutput in the Log panel.
Theory
SystemVerilog introduced the logic type to unify wire (for continuous assignments) and reg (for procedural assignments) into a single, flexible type.
| Type | Legacy Use Case | logic Compatibility |
|---|---|---|
wire | Continuous assignment (assign) | Yes |
reg | Procedural assignment (always) | Yes |
The logic type works in both contexts and avoids type mismatches between modules. It is the recommended default for all signals in new designs.
Practice
- Open this chapter in RtlStudio — files appear automatically in Explore.
- In
student/rtl/design.sv, replace each__TODO__placeholder with thelogickeyword on the three ports. - Keep the testbench
student/tb/tb.svunchanged — it already useslogicfor all signals. - Run Simulation from the left sidebar and check the Log panel for
INFO:output. - Confirm the four test cases and final
INFO: PASSline appear.
Summary
You practiced replacing legacy wire and reg declarations with the unified logic type in a small combinational DUT. You verified correct behavior through testbench signal dumps and confirmed synthesis success with Yosys. The key takeaway is that logic simplifies RTL coding by unifying net and variable semantics without sacrificing synthesis compatibility.
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 logic and design.sv. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.