Hello HLS Kernel - Hello HLS Kernel - 2026.1 English - UG1864

Vitis Functional Simulation User Guide (UG1864)

Document_ID
UG1864
Release_Date
2026-06-23
Version
2026.1 English

This example runs the HLS top function sum_of_four. It reads four int32 values from a stream, sums them, and writes one value. With eight inputs, you get two outputs (for example: [1,2,3,4,5,6,7,8] → [10, 26]).

Layout: Create a working directory with the following files:

hls_example/
├── kernels.h
├── kernels.cpp
└── run_hls_simple.py

kernels.h:

#pragma once
#include "hls_stream.h"
#include <stdint.h>

void sum_of_four(hls::stream<int32_t> &in, hls::stream<int32_t> &out);

kernels.cpp:

#include "kernels.h"

void sum_of_four(hls::stream<int32_t> &in, hls::stream<int32_t> &out)
{
    int32_t sum = 0;
    for (unsigned i = 0; i < 4; ++i) {
        sum += in.read();
    }
    out.write(sum);
}