Casting between varray Types - Casting between varray Types - 2026.2 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-11-11
Version
2026.2 English

cast(obj, 'varray.<type>') reinterprets the values in a different varray type (with the usual numeric conversion rules). Complex ↔ non-complex casts are not supported. Use real() / imag() instead.

data       = varray.int32([1, 2, 3]);
half_data  = cast(data, 'varray.half');      % varray.half
int16_data = cast(data, 'varray.int16');     % varray.int16

typecast(obj, '<type>') reinterprets the underlying bytes as another varray type, without any numeric conversion. Use it when you need to view the same buffer through a different layout (for example, reading back the output of a kernel whose port type was quantized).

bytes     = varray.uint8(hex2dec(['00'; 'C0'; '00'; '3C']));
half_view = typecast(bytes, 'half');          % varray.half, [-2; 1]

% With AXI-Stream sideband:
axis_cfg  = varray.axis_config('tuser_width', 8);
typed     = typecast(bytes, 'half', axis=axis_cfg);

typecast only accepts real scalar or vector inputs.