End-to-End HLS Kernel Example - End-to-End HLS Kernel Example - 2026.1 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-06-23
Version
2026.1 English

This example shows a complete workflow where an HLS kernel uses hls::axis streams and the host-side simulation code uses varray with axis.

HLS Kernel (example.cpp):

#include "hls_stream.h"
#include "ap_axi_sdata.h"
#include "ap_int.h"

void example_float(hls::stream<hls::axis<float>> &in,
                   hls::stream<hls::axis<float>> &out) {
    #pragma HLS INTERFACE mode=axis port=in
    #pragma HLS INTERFACE mode=axis port=out

    hls::axis<float> word;
    do {
        #pragma HLS PIPELINE II=1
        in.read(word);
        word.data += 5.0f;
        out.write(word);
    } while (!word.last);
}

Python:

import vfs
import varray as va
import numpy as np

kernel = vfs.hlsKernel(input_files="example.cpp", hls_function="example_float")

in_vals = np.array([1.5, -2.25, 3.125, -4.0, 5.75], dtype=np.float32)
in_arr = va.array(in_vals, dtype=va.float, axis=va.axis())
in_arr.tlast[-1] = 1

result = kernel.run(in_arr)
print(np.asarray(result))
# [ 6.5   2.75  8.125  1.   10.75 ]

MATLAB:

kernel = vfs.hlsKernel( ...
    input_files  = "example.cpp", ...
    hls_function = "example_float");

in_vals = single([1.5, -2.25, 3.125, -4.0, 5.75]);
in_arr = varray.float(in_vals, axis=varray.axis());
in_arr.tlast(5) = 1;

result = kernel.run(in_arr);
out = single(double(result));
disp(out)
% [6.5; 2.75; 8.125; 1.0; 10.75]