How do I get my head around HLS pragmas for NPU work?

Nov 29, 2026 Last reply: 1 day ago 2 Replies

First reply

tom.ortiz

The mindset shift that made it click for me was quitting the memorization approach entirely and starting to picture the actual circuit each pragma builds. Once you think in terms of registers, multiplexers and memory ports instead of C code, the pragmas stop being a list to…

Read the full reply

I've been working through HLS lately, mostly because I want to do NPU development with it. The syntax and the flow of writing C code that gets synthesized is one thing, but the part that keeps tripping me up is the pragmas. I know names like pipeline, unroll, array partition, dataflow and interface, but I honestly don't have a solid feel for when each one applies or what it actually does to the hardware underneath. Right now I'm mostly just trying to memorize them, which feels like the wrong approach. I keep wondering if there's a better way to internalize this stuff, like a mental model that makes it click instead of brute-forcing a list. So, how did the rest of you learn AMD HLS? Any advice, or resources that helped you get past this same wall, would be a big help.


The mindset shift that made it click for me was quitting the memorization approach entirely and starting to picture the actual circuit each pragma builds. Once you think in terms of registers, multiplexers and memory ports instead of C code, the pragmas stop being a list to remember and start being obvious choices. A pipelined loop is a schedule where a new iteration starts every cycle. An unrolled loop is copies of hardware working side by side. Array partitioning is the difference between one memory with limited ports and several memories or individual registers. Dataflow is parallel blocks connected by FIFOs. Once you see it that way, you stop asking 'which pragma do I use' and start asking 'what hardware do I want', and the pragma picks itself. For NPU work you genuinely only need a small handful anyway. Pipeline, unroll, array partition, dataflow and interface will cover nearly everything, so learn those five deeply rather than skimming the whole catalog.

Watch out for the classic mistake though: adding unroll or pipeline to a loop that reads an array and seeing zero speedup. A BRAM only has two ports, so if you unroll to do several multiply-accumulates per cycle without partitioning the array, everything just queues up on memory. And be careful with false dependencies when pipelining. Plain C++ thinking will mislead you here, because the scheduler sometimes sees two accesses to the same array as a dependency even when they never conflict in practice. You have to reason like the hardware would.

Resources that helped me: read the intro and pragma sections of UG1399, then go browse the Vitis repo examples to see how the data types and pragmas are actually used. There's also a good paper on code transformation from ETH that's well worth a read. On video, check out Young Kyu Choi's channel on YouTube, and this one:

formatting link
. And if budget allows, AMD's paid HLS training is solid, it breaks down exactly what each main pragma does and when to reach for it.

Old habits die hard here, but the picture-in-circuits advice is the one thing that's stayed true through every toolchain change I've seen. Back when I started we drew the datapath on paper before writing a line, and that habit transfers straight over to HLS. What helped me internalize the big five was taking one small kernel and rewriting it three ways, once pipelined, once unrolled, once dataflow, then asking myself what hardware I just asked for before checking the reports. Doing it by hand a few times beats memorizing. Curious wheather your NPU work is mostly MAC arrays, since that's where the memory port limit relly bites.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required