SystemVerilog introduced a robust set of data types to bridge the gap between hardware description (Verilog) and high-level verification (C++/Java). Understanding these types is crucial for writing efficient RTL and effective Testbenches.
Unlike standard software programming, hardware simulation requires modeling more than just 0 and 1. SystemVerilog uses a 4-state logic system:
This is the most common interview question in SV.
Can store 0, 1, X, and Z. It is the preferred type for RTL design and connecting modules because it can model X-propagation (bugs) and unconnected ports (Z). It replaces the confusing `reg` vs `wire` distinction in most cases.
Can only store 0 and 1. It is the preferred type for Testbench components, Transaction packets, and C-interface modeling. It is faster to simulate.
Warning: If you assign X or Z to a `bit`, it silently converts to 0!
SystemVerilog adds C-like integer types for ease of verification:
Signed vs Unsigned: Types like `byte` are signed by default. This causes "Overflow" to wrap around to negative numbers (e.g., 127 + 1 = -128). This behavior must be understood to avoid arithmetic bugs.
Select Value to Drive:
> Initial State. Logic=X, Bit=0