SystemVerilog `string` variables, function arguments and results now
simulate as 32-bit handles into the heap introduced for testbench
strings (IEEE 1800-2023 6.16).
- The analyzer rewrites operators, methods and conversions with a
string operand into string operations: equality stays an integral
comparison of handles, ordering compares contents, and concatenation,
replication with a run-time count, `s[i]`, casts and the `len`,
`getc`, `putc`, `toupper`, `tolower`, `compare`, `icompare`,
`substr`, `atoi` and `itoa` families lower to them. A string literal
or integral value assigned or cast to a string contributes its bytes;
NUL bytes are removed.
- Compiled code reaches the heap through one helper, called as an
`ExternCall` with the reserved `HEAP_HELPER_ID`. Every backend passes
the state pointer first, and the helper finds the heap through a new
state header slot. Buffers build new strings in place and are interned
when frozen, so equal contents keep equal handles.
- Each backend owns its heap, so hosts that keep only the backend, such
as NAPI, keep their strings. `StateImage` captures the heap, so every
checkpoint restores it. Handles are never reused, so a stale copy that
is only compared cannot match a later string.
- The heap is collected after each timed step and each `tick`. Runtime
events still in the backend's buffer are read first, which replaces
string arguments by their contents. Concurrent testbench processes
block the `tick` collection, since their saved temporaries are outside
state memory.
- `%s` and format-less display print string values. Typed `string`
parameters keep their packed text. Unpacked arrays of strings are
rejected, since their element and character selects are not yet told
apart.
Twenty-one sv-tests cases now pass in both state modes; each was
simulated and its values checked. New shared cases pass on Verilator;
Icarus 13.0 lacks the string methods, recorded as a reviewed limitation.
BREAKING CHANGE: `SimBackend` requires `heap` and `heap_mut`. The state
header grows to 48 bytes and the native image container version to 22,
so earlier images must be rebuilt. `StateSchema::capture` and `load` read
the backend's heap; `capture_with_heap` and `load_with_heap` are removed.
Refs #1400
Change-Id: Id79cec4106b91e786ac4517811392d67c4c8ec00
SystemVerilog
stringvariables, function arguments and results nowsimulate as 32-bit handles into the heap introduced for testbench
strings (IEEE 1800-2023 6.16).
string operand into string operations: equality stays an integral
comparison of handles, ordering compares contents, and concatenation,
replication with a run-time count,
s[i], casts and thelen,getc,putc,toupper,tolower,compare,icompare,substr,atoianditoafamilies lower to them. A string literalor integral value assigned or cast to a string contributes its bytes;
NUL bytes are removed.
ExternCallwith the reservedHEAP_HELPER_ID. Every backend passesthe state pointer first, and the helper finds the heap through a new
state header slot. Buffers build new strings in place and are interned
when frozen, so equal contents keep equal handles.
as NAPI, keep their strings.
StateImagecaptures the heap, so everycheckpoint restores it. Handles are never reused, so a stale copy that
is only compared cannot match a later string.
tick. Runtimeevents still in the backend's buffer are read first, which replaces
string arguments by their contents. Concurrent testbench processes
block the
tickcollection, since their saved temporaries are outsidestate memory.
%sand format-less display print string values. Typedstringparameters keep their packed text. Unpacked arrays of strings are
rejected, since their element and character selects are not yet told
apart.
Twenty-one sv-tests cases now pass in both state modes; each was
simulated and its values checked. New shared cases pass on Verilator;
Icarus 13.0 lacks the string methods, recorded as a reviewed limitation.
BREAKING CHANGE:
SimBackendrequiresheapandheap_mut. The stateheader grows to 48 bytes and the native image container version to 22,
so earlier images must be rebuilt.
StateSchema::captureandloadreadthe backend's heap;
capture_with_heapandload_with_heapare removed.Refs #1400