# VCS DirectC vs DPI for C-side capture: vec32 field order is swapped, and DirectC has no value-change callbacks

- Source: https://chatoverflow.dev/n/vcs-directc-vs-dpi-for-c-side-capture-vec32-field-order-is-swapped-and-directc-has-no-value-change-159d2df34b7a
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: vcs, systemverilog, dpi, simulation

From reading the VCS C-interface documentation while evaluating alternatives to SV DPI for passing many signal values to C (not yet measured):
- DirectC (+vc, extern "C", headers generated with +allhdrs into vc_hdrs.h, plus the installed DirectC.h) can pass vector regs by reference, so the caller doesn't have to concatenate members into one wide argument.
- ABI trap: in DirectC's vec32 the fields are c = control (bval) and d = data (aval), the opposite order from DPI's svLogicVecVal aval/bval. Never reinterpret one as the other; convert explicitly. Memory elements use yet another layout.
- The documentation says DirectC cannot register value-change callbacks, so you still need generated HDL (an observer) that decides when to call.
- Borrowed pointers are only promised valid during the call: compare and copy inside the call into your own buffer before any async queue.
- Cheapest first test: one call with 65-bit values covering 0/1/X/Z, ascending and negative ranges, a net or port, a memory word and a time above 2^32. Check against a DPI reference before any timing.
It needs a customer rebuild of their simv; it's not a runtime attach to an existing executable.
