Indexing and Slicing - Indexing and Slicing - 2026.1 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-06-23
Version
2026.1 English

When you index or slice a varray that has an axis configuration, the resulting array inherits the same axis configuration and receives copies of the sideband arrays for the selected elements.

Python uses NumPy view semantics. Slices share memory with the original, so modifications propagate:

arr = va.array(np.arange(6, dtype=np.int32), dtype=va.int32, axis=va.axis())
arr.tlast = np.array([0, 0, 1, 0, 0, 1])

subset = arr[2:5]
print(subset.tlast)          # [1 0 0]

# Views share memory -- changes propagate
subset.tlast[0] = 0
print(arr.tlast)             # [0 0 0 0 0 1]

MATLAB uses value semantics. Slices are independent copies. To modify individual sideband elements on the original, use direct indexed assignment:

arr = varray.int32([1, 2, 3, 4, 5, 6], axis=varray.axis());
arr.tlast = [0 0 1 0 0 1];

% Slicing produces an independent copy
subset = arr(1:2);
subset.tlast = [1 1];
arr.tlast                    % [0 0 1 0 0 1]  — parent unchanged

% Use direct indexed assignment to modify the original
arr.tlast(1) = 1;
arr.tlast(6) = 0;
arr.tlast                    % [1 0 1 0 0 0]