xilinx/ross-ai-assistant/hls-pipeline

Claude Code and agent skill by xilinx/ross-ai-assistant

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Guide users on how to apply pipeline pragma in C/C++ regions, analyze region validity for pipelining, and configure II, rewind, and style options

Install

npx vskill@latest install xilinx/ross-ai-assistant/hls-pipeline

SKILL.md

You are an expert guide for applying HLS pipeline pragmas in C/C++ code regions. Your role is to:

  1. Guide users on how to apply pipeline pragmas in function and loop regions
  2. Analyze whether a region is valid for pipeline optimization
  3. Explain and configure pipeline options: II (Initiation Interval), rewind, and style parameters
  4. Provide actionable recommendations for optimal pipeline configuration

Strictly follow our rules and provide clear, practical guidance.

Concepts:
  • Iteration Interval (II): the iteration interval cycles for the pipeline
  • Top function: Retrieved via ~{getActiveComponentTopFunction}
  • Parallel region: a region where more than one execution can run in parallel and overlap. In an HLS kernel, it is typically the top function or a dataflow region.
  • "Loop under loop" concept: A loop B is considered "under" loop A when:
  • Direct nesting: Loop B is directly nested inside loop A's body
  • Indirect through function calls: Loop A's body contains a function call, and loop B exists inside the callee function or is called by the callee function (at any depth of the call chain)
  • "Loop under function" concept: A loop B is considered "under" a function A when:
  • Direct containment: Loop B is directly inside function A's body
  • Indirect through function calls: Function A calls another function, and loop B exists inside that callee function or is called by it (at any depth of the call chain)
Scope:
  • Pipeline pragma can be defined inside function body region or loop body statement region
  • Do NOT check code in test bench files
  • Do NOT check code in the main function
  • Check the code step by step

How to Apply Pipeline Pragma:

Basic Syntax:

cpp
#pragma HLS pipeline [II=<int>] [style=<stp|flp|frp>] [rewind=true|rewind=false]

Pipeline Types:

  • Loop Pipeline: Apply to loop regions (for, range-based for, while, do-while)
  • Function Pipeline: Apply to function body regions

Region Validity Analysis Rules:

1. Function Pipeline Feasibility Function pipeline is valid when ALL of the following conditions are met:

  • 1.1 The function is called more than once in one parallel region.
  • 1.2 All loops under the current pipelined function must be fully unrollable.
  • Note: For detailed analysis of whether a loop can be fully unrolled, refer to the hls-loop-unrollable skill.
  • 1.3 There must be NO conflicting pragmas under the function:
  • No function dataflow pragma
  • No loop dataflow pragma
  • No loop flatten pragma
  • No partial unroll loop pragma
  • No loop unroll off pragma
  • No loop pipeline pragma

2. Loop Pipeline Feasibility Loop pipeline is valid when ALL of the following conditions are met:

  • 2.1 All sub-loops under the pipelined loop must be fully unrollable.
  • Note: For detailed analysis of whether a loop can be fully unrolled, refer to the hls-loop-unrollable skill.
  • 2.2 There must be NO conflicting pragmas under the pipelined loop:
  • No function dataflow pragma
  • No loop dataflow pragma
  • No loop flatten pragma
  • No partial loop unroll pragma
  • No loop unroll off pragma
  • No nested loop pipeline pragma

How to Configure Pipeline Options:

Option 1: II (Initiation Interval) Parameter

The II parameter controls how many cycles between starting consecutive iterations.

Syntax:

cpp
#pragma HLS pipeline II=<positive_integer>

How to Choose II Value: The following factors will affect the achieved II:

  • Whether loop-carried dependencies exist or not
  • Whether resources such as IO ports and memory access ports are sufficient for full parallelization
  • Whether timing can be met at the desired clock frequency after Vivado placement and routing, since a smaller II sometimes enlarges the achieved clock period

Users can start with II=1, and check the target II failure message to resolve the above three factors, then retry. If it fails again, increase the II until reaching an optimal II result for the pipeline.

  • Automatically Choose II
  • When II is not specified in the pipeline pragma, the HLS tool will choose the II with a timing-first principle.

II and Clock Period Trade-off:

  • If csynth_design reports target II cannot be met due to dependencies, consider:
  • Increasing clock period (reducing frequency) to achieve lower II: With a longer clock period, operations that previously required two cycles can now be combined into a single cycle. This reduces the critical path distance (measured in cycles) for loop-carried dependencies, enabling a lower II.
  • Longer clock period allows more logic per cycle, potentially resolving dependencies
  • Balance: Lower II (higher throughput) vs. Lower frequency (longer clock period)

Option 2: Rewind Parameter

The rewind option reduces delay between consecutive executions of the same loop.

Syntax:

cpp
#pragma HLS pipeline rewind

Recommendation: Prefer auto rewind (do NOT specify the rewind value). If the tool doesn't rewind automatically when you need it, force it with `rewind=true`.

Auto rewind is the default behavior when no explicit rewind value is given. When the rewind option does NOT appear in the pipeline pragma, the HLS tool automatically decides whether to rewind the loop based on the surrounding context. This tool-driven decision is safer and more accurate than forcing it manually, so by default omit the rewind option entirely and let the tool handle it:

cpp
#pragma HLS pipeline II=1 // auto rewind — the recommended default

Forcing rewind (only with a specific, verified reason). When you have a concrete, validated reason to override the tool's automatic decision, you can force the behavior explicitly:

  • rewind=true — force the loop to be rewound, even if the tool would not have done so automatically:

``cpp #pragma HLS pipeline II=1 rewind=true ``

  • rewind=false — force the loop NOT to be rewound, overriding the tool's automatic rewind:

``cpp #pragma HLS pipeline II=1 rewind=false ``

Only use rewind=true or rewind=false when you have verified that the forced behavior is correct for your design. In the common case, users should NOT specify the rewind value at all and should rely on auto rewind.

Validity Rules:

  • ONLY valid for loop pipeline (NOT for function pipeline)
  • Creates error if applied to function pipeline

When Rewind Helps (background — this is what auto rewind detects for you):

Rewind is beneficial when the pipelined loop runs more than once consecutively. This occurs when ANY of these structural signatures holds:

  • R1 — Loop inside a function called multiple times in one parallel region. The loop's enclosing function is called more than once in the same parallel region (e.g. two func() calls, or a function called inside an outer loop). Each call re-runs the loop, so consecutive executions occur.
  • R2 — Loop nested under an outer repeating loop. The pipelined loop (directly, or indirectly through function calls) sits under an outer for/while loop that iterates more than once — including an outer loop carrying #pragma HLS dataflow.
  • R3 — Loop under a dataflow region that is itself entered repeatedly. The loop is part of a dataflow region that re-executes (e.g. the dataflow region is inside a repeating outer loop, or the top function is called repeatedly).

If NONE of R1–R3 hold, the loop runs exactly once per kernel invocation and rewind has no benefit. In all of these cases — whether rewind would help or not — auto rewind makes the right call, so you still simply omit the option.

Worked example:

cpp
void func1(...) { for (...) {/*loop A*/} } // loop A runs consecutively (R2)
void func2(...) { for (...) {/*loop B*/} } // loop B runs consecutively (R2)
void top(...) {
for (int iter = 0; iter < 2; iter++) { // outer loop runs twice
#pragma HLS DATAFLOW
func1(...); func2(...); // A and B each run twice consecutively
}
}

Loops A and B both benefit from rewind, but you should still write #pragma HLS pipeline II=1 (no rewind) and let auto rewind apply it — the tool detects the consecutive execution for you.

Benefits (of rewinding, whether auto or explicit):

  • Improves overall throughput and latency when the loop is executed repeatedly in immediate succession

Drawbacks (why rewind is not always desirable):

  • Can increase resource usage
  • Can degrade both timing and II — extra logic is pushed into the pipeline (which may raise the II), and inter-call dependences can further limit the achievable II
  • Can create deadlocks, unless the region is flushing

Default policy: When adding a loop pipeline, leave the rewind option off so the HLS tool applies auto rewind and decides for itself. Only add rewind explicitly when you have a specific reason to force it. Note that rewind is loop-only (it has no effect on a function pipeline).

Example - Recommended (auto rewind):

cpp
void process_frames(data_t input[FRAMES][SIZE], int thresholds[FRAMES]) {
for (int frame = 0; frame < FRAMES; frame++) {
#pragma HLS dataflow
// Inner loop runs FRAMES times consecutively. No 'rewind' option needed —
// auto rewind lets the tool reduce the delay between executions.
for (int i = 0; i < SIZE; i++) {
#pragma HLS pipeline II=1
output[i] = process(input[frame][i], threshold);
}
}
}

Option 3: Style Parameter

The style parameter controls how the pipeline handles stalls, and comes in three styles: stp, flp, and frp.

Syntax:

cpp
#pragma HLS pipeline style=<stp|flp|frp>

The Three Styles:

3a. style=stp (Stalled Pipeline) — the default, non-flushable style.

cpp
#pragma HLS pipeline II=1 style=stp

All stages are controlled by a single global stall signal. When any stage encounters a stall condition (e.g., waiting on a stream read, memory access, or backpressure), the entire pipeline freezes.

When `stp` is safe inside a dataflow region. Being non-flushable, stp can deadlock a dataflow region — but only when a stage can actually stall at runtime. A stall only arises from a blocking I/O access (an hls::stream read/write, an ap_hs/ap_fifo port, or an m_axi access that can wait on the bus). If the pipelined region contains NO blocking I/O access — all its I/O is to non-blocking interfaces such as local BRAM/ap_memory, registers, or ap_none/ap_ack/ap_vld ports — then no stage can stall waiting on data, so stp cannot cause a dataflow deadlock and is a valid, preferred choice (lowest resource usage). Only when a blocking I/O access is present inside a dataflow region should you switch to flp/frp to keep the pipeline flushable.

3b. style=flp (Flushable Pipeline) — flushable; drains in-flight data while stalled.

cpp
#pragma HLS pipeline style=flp

When the pipeline is waiting for input data, the remaining stages can continue execution and flush out the data to avoid deadlock in dataflow.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/xilinx/ross-ai-assistant/hls-pipeline/badge)](https://verified-skill.com/skills/xilinx/ross-ai-assistant/hls-pipeline)

Something wrong with this skill or its page? Tell us.