Verilog wire and reg vs SystemVerilog logic
Compare Verilog wire and reg with SystemVerilog logic, understand drivers, and choose the correct signal declaration.
Verilog wire and reg
In Verilog, a wire is a net: it represents a connection and takes its value from a continuous assignment, module output or primitive. A reg is a procedural variable: it stores the last value assigned by an always or initial block. Despite its name, reg does not necessarily infer a hardware register.
wire sum;
reg parity;
assign sum = a ^ b;
always @* parity = ^data;
parity is combinational because the process is combinational and assigns it completely. Its reg declaration only permits procedural assignment.
SystemVerilog logic
SystemVerilog logic is a four-state variable type that removes most of the old reg terminology. It can be driven by one continuous driver or one procedural process, making it suitable for most RTL ports and internal signals.
logic result;
logic valid_q;
assign result = a & b;
always_ff @(posedge clk) valid_q <= valid_d;
logic does not mean “registered,” and it does not permit multiple procedural drivers. Use a net type such as wire when the design intentionally needs resolved multiple drivers or tri-state connectivity.
Port guidance
- Verilog input ports are nets by default; declare an output
regwhen a procedural block drives it. - In SystemVerilog,
input logicandoutput logicmake variable intent explicit. - A child module output usually connects to a parent net in Verilog. SystemVerilog allows a singly driven variable connection.
- Let lint detect accidental multiple drivers instead of changing every declaration to a net.