BitFlow

SystemVerilog vs Verilog: what's the difference?

SystemVerilog is a superset of Verilog. What it adds for RTL design (logic, always_ff, enums, structs, interfaces) and verification (classes, constrained random, assertions), and which to learn first.

By BitFlow · · 7 min read

The short answer

SystemVerilog is Verilog with a lot added. Since 2009 the two have been one standard, IEEE 1800, and every Verilog-2005 design is legal SystemVerilog. The additions fall into two groups:

  • For design (RTL): clearer types and blocks that let the tools catch mistakes, such as logic, always_ff, always_comb, enum, struct, packages and interfaces. These are synthesisable.
  • For verification: object-oriented testbenches, constrained-random stimulus, assertions (SVA) and functional coverage. These run in simulation only, and are the foundation of UVM.

If you are learning digital design, start with Verilog: it is smaller, and everything in it carries over. Then pick up the SystemVerilog design features, which take an afternoon. The verification half is a field of its own.

What SystemVerilog adds for design

VerilogSystemVerilogWhy it helps
wire / reglogicOne type for almost everything; no more guessing which keyword a signal needs
always @(posedge clk)always_ff @(posedge clk)The tool checks that the block really describes flip-flops
always @(*)always_combWarns if the block would infer a latch; sensitivity is automatic
localparam state codesenumNamed states, shown by name in waveforms, with checked assignments
Separate signalsstruct packedGroup related fields, such as a packet header, into one signal
Repeated port listsinterfaceBundle a whole bus (valid, ready, data…) and connect it in one line
include filespackageShare types, constants and functions between modules with proper scoping
// Verilog
localparam IDLE = 2'd0, RUN = 2'd1;
reg [1:0] state;
always @(posedge clk) state <= rst ? IDLE : next;

// SystemVerilog
typedef enum logic [1:0] {IDLE, RUN} state_t;
state_t state;
always_ff @(posedge clk) state <= rst ? IDLE : next;
The same state register in both languages

What SystemVerilog adds for verification

  • Classes: object-oriented testbenches with inheritance, the base of UVM.
  • Constrained random: rand variables and constraint blocks generate legal but unexpected stimulus automatically.
  • Assertions (SVA): properties such as "every request gets a grant within 4 cycles", checked every cycle in simulation and usable by formal tools.
  • Functional coverage: covergroups record which scenarios the tests actually exercised, so you know when you are done.
  • Mailboxes, semaphores, queues and dynamic arrays for building testbench components that talk to each other.
// An assertion: req must be followed by gnt within 1 to 4 cycles
assert property (@(posedge clk) disable iff (rst)
  req |-> ##[1:4] gnt);

Side by side

VerilogSystemVerilog
StandardIEEE 1364 (last revision 2005)IEEE 1800 (absorbed IEEE 1364 in 2009)
RelationshipThe base languageA superset: all Verilog is valid SystemVerilog
Used forRTL design, simple testbenchesRTL design and industrial verification (UVM)
File extension.v.sv
Learning curveSmallDesign part small; verification part large
Jobs that expect itFPGA and RTL designRTL design, and nearly every verification role

Which should you learn first?

  1. Verilog first, for the hardware concepts: modules, always blocks, blocking vs nonblocking, FSMs, testbenches.
  2. SystemVerilog design features next: logic, always_ff, always_comb, enum, struct. Use them in all new RTL.
  3. SystemVerilog verification if you are heading for a verification role: classes, constrained random, SVA, coverage, then UVM.
TipBitFlow's Verilog generators can emit either language for the same block (FIFOs, UART, SPI, arbiters, CDC synchronisers), which is a quick way to compare the two styles on real designs.

Questions

Is SystemVerilog the same as Verilog?

No, but it contains it. SystemVerilog (IEEE 1800) is a superset of Verilog: every Verilog design is valid SystemVerilog, and SystemVerilog adds design features such as logic, always_ff and enum, plus verification features such as classes, constrained random, assertions and coverage.

Should I learn Verilog or SystemVerilog first?

Learn Verilog first for the core hardware concepts, then add SystemVerilog's design features. Learn SystemVerilog's verification features and UVM if you are aiming for a verification role.

Is SystemVerilog synthesisable?

Its design subset is: logic, always_ff, always_comb, enum, struct, packages and interfaces are supported by synthesis tools. Classes, randomisation and coverage are for simulation only.

Is Verilog still used?

Yes. Much RTL is still written in Verilog-2005 style, and the language lives on inside SystemVerilog, which is what most new design and verification code uses.

Was this article helpful?

Keep going