Skip to main content

SystemVerilog Data Types

· loading · loading · · ·
HDL SystemVerilog HDL
Axolot Logic
Author
Axolot Logic
Digital Design Engineer
Table of Contents
SystemVerilog - This article is part of a series.
Part 2: This Article

๐Ÿ“˜ SystemVerilog Data Types โ€“ A Complete Overview (with Default Properties)
#

SystemVerilog improves Verilog by introducing a richer, more precise type system. Below is a full breakdown of key SystemVerilog data types โ€” including their default bit widths, signedness, and default values.


๐Ÿ” 1. 4-State vs 2-State Types
#

Type States Default Size Default Signedness Default Value Notes
logic 0, 1, X, Z Scalar (1-bit) or user-defined Unsigned X (unknown) Use instead of reg and wire
reg 0, 1, X, Z Scalar (1-bit) or user-defined Unsigned X Legacy, replaced by logic
bit 0, 1 Scalar (1-bit) or user-defined Unsigned 0 2-state only, useful in simulations

โœ… Use logic for RTL and bit when X/Z modeling is unnecessary.


๐Ÿงฎ 2. Integer Types
#

Type Size Signed Default Value Notes
byte 8-bit Yes 0 Signed by default
shortint 16-bit Yes 0
int 32-bit Yes 0 Most commonly used
longint 64-bit Yes 0
integer โ‰ฅ32-bit (impl. defined) Yes 0 Legacy type from Verilog
time 64-bit No 0 Used for simulation timing

๐Ÿง  Tip: Prefer int, longint, bit over legacy integer.


๐Ÿ”ค 3. String Type
#

Type Description Default Value Notes
string Dynamically sized text Empty string "" Supports methods like .len(), .putc()
string msg = "Hello!";
$display("Length = %0d", msg.len());

๐Ÿ”˜ 4. Enumerations (enum)
#

Feature Description
Syntax typedef enum {A, B, C} name_t;
Underlying type Can be defined (e.g., enum logic [1:0])
Default value First listed value (unless specified)
Signed? Follows underlying base type

๐Ÿ“ฆ 5. Structures (struct)
#

Feature Description
Syntax typedef struct { ... } name_t;
Packed? Use packed keyword for bit-accurate layout
Default values Each field initialized to its typeโ€™s default
Nesting Structs can include other structs
typedef struct packed {
  bit [7:0] id;
  logic     valid;
} header_t;

๐Ÿ”„ 6. Unions (union)
#

Feature Description
Shared Memory All fields use same memory space
Packed Union Use packed for precise layout
Tagged Union Use union tagged to ensure safe access

๐Ÿ“š 7. Arrays
#

Array Type Description
Packed Array Bit vectors (e.g., logic [7:0])
Unpacked Array Collection of objects or elements
Dynamic Array Resizable during runtime
Associative Array Indexed by any scalar (e.g., string)
Queue FIFO-like data structure (e.g., int queue[$])

๐Ÿ“— 8. Other Special Types
#

Type Description
void No return value
event Simulation synchronization primitive
chandle C-language pointer
mailbox Communication between processes
semaphore Resource control between processes

โœ… Summary Table (Compact Reference)
#

Type Group Examples Default Size Default Signedness Notes
2-state bit, int, byte, longint Fixed-width Signed (mostly) No X/Z states
4-state logic, reg, integer Variable Unsigned (logic), Signed (integer) Supports X and Z
Textual string Dynamic โ€” Supports common string methods
Composite struct, union, array Custom Follows fields Grouped or indexed values
Enumeration enum Customizable Base typeโ€™s signed Symbolic values with readability
Special time, event, chandle, mailbox Varies Varies Simulation or interprocess use

SystemVerilog - This article is part of a series.
Part 2: This Article

Related

Blocking vs Non-Blocking Assignments
· loading · loading
HDL SystemVerilog HDL
SystemVerilog Arrays
· loading · loading
HDL SystemVerilog HDL
SystemVerilog Intoduction
· loading · loading
HDL SystemVerilog HDL
SystemVerilog Loops & Control Flow Statements
· loading · loading
HDL SystemVerilog HDL
SystemVerilog Tasks and Functions
· loading · loading
HDL SystemVerilog HDL
SystemVerilog Typedef & Alias
· loading · loading
HDL SystemVerilog HDL