Skip to main content

Module strings

Module strings 

Source
Expand description

SV string values (LRM 1800-2023 §6.16).

A string is stored – in STATE, a frame slot, or a register – as a 64-bit id naming an immutable, interned byte string; id 0 is "". Interning makes equal contents share one id, so ==/!= (and case matching) compare ids; every other operation goes through apply. Interned strings live for the rest of the process (bounded by the number of distinct strings a simulation creates). Each is stored NUL-terminated, so c_str can hand it to C (DPI, %s formatting) without copying.

An SV string never contains a NUL character: storing one is ignored (§6.16), which intern implements by dropping NUL bytes.

Enums§

StrOp
A string operation, by the code codegen passes to sv_rt_str_op.

Functions§

apply
Applies op to (a, b, c) (see StrOp for each operation’s operands and result: a string id or an integer).
bytes
The contents of string id (an unknown id reads as "").
c_str
String id as a NUL-terminated C string.
intern
The id of the string bytes (NUL bytes dropped).
preload
Makes strings (a snapshot) ids 1.. of this process’s table.
snapshot
Every interned string but "", in id order (id 1 first): what a design built ahead of time carries so a fresh process can give each string its build-time id (preload) – ids are baked into machine code and into the initial values of the design’s cells.