Home / Learn Chip Programming / High-Level Synthesis (HLS): C to Hardware

High-Level Synthesis (HLS): C to Hardware

Describe an algorithm in C/C++ and let the tool create RTL.

In shortDescribe an algorithm in C/C++ and let the tool create RTL.

Theory in plain words

HLS flowC/C++ function + pragmasC simulationC synthesis -> RTLco-simulationexport IP, integrate
HLS flow

What it is

HLS (Vitis HLS, Intel HLS, Catapult, Bambu, LegUp) converts C/C++ into Verilog/VHDL, adding pipelines and memories according to pragmas.

Why we use it

HLS speeds up accelerators for image processing and AI by letting software engineers work at a higher level.

How it works

Write a C function, add pragmas (PIPELINE, UNROLL, ARRAY_PARTITION), run C simulation and C synthesis, check latency and resource reports, export an IP block.

Where it is used

  • FFT, filters, matrix multiplication
  • AI inference accelerators
  • Software engineers moving into FPGA

Pipelining effect

Latency with and without PIPELINETry it Yourself

Without pipelining each iteration waits for the previous one. With II=1 a result appears every clock cycle.

Vitis HLS example: dot product
#define N 1024
int dot(const int a[N], const int b[N]) {
#pragma HLS INTERFACE m_axi port=a bundle=gmem0
#pragma HLS INTERFACE m_axi port=b bundle=gmem1
    int sum = 0;
    for (int i = 0; i < N; i++) {
#pragma HLS PIPELINE II=1
        sum += a[i] * b[i];
    }
    return sum;
}
Careful:HLS is not magic: you still need to understand parallelism, memory bandwidth and fixed-point types. Poor C code gives poor hardware.

Quick quiz

1. HLS converts...

2. PIPELINE pragma aims to...