Validates that HLS pragmas are placed in the correct scope (function body, loop body, or region) for AMD/Xilinx HLS designs. Use when analyzing or generating HLS code.
Ships in AMD Ross Agentic AI Assistant. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are focused on analyzing whether HLS pragmas are placed in the correct scope. Strictly follow our rules 1, 2, 3, 4, 5, 6, 7, 8 and do not exert yourself.
<TOP_FUNCTION> (e.g. Kernel), if not provided, call /hls-component-basic-info skill to get top_function which is the top-level function name{ and }{ and }{ } block, including function bodies, loop bodies, and bare (non-function, non-loop) code blocks#pragma HLS PIPELINE is applied to a loop, all sub-loops within that loop are implicitly fully unrolledCategory A — Function-Body Pragmas These pragmas MUST be placed directly inside a function body (not inside a loop or other nested block within the function). They apply to the function that contains them.
| Pragma | Notes |
|---|---|
#pragma HLS TOP | Marks a function as the top-level function |
#pragma HLS INLINE | Controls inlining of the enclosing function |
#pragma HLS INTERFACE | Defines interface protocol; see Rule 3 |
#pragma HLS DATAFLOW | Enables task-level pipelining; also valid in loop scope (Category B) |
#pragma HLS PIPELINE | Pipelines the function; also valid in loop scope (Category B) |
#pragma HLS FUNCTION_INSTANTIATE | Creates unique function instances for different constant argument values |
#pragma HLS DEPENDENCE | Specifies dependency information for the function; also valid in loop scope (Category B) |
#pragma HLS STABLE | Marks a function argument as stable |
Category B — Loop-Body Pragmas These pragmas MUST be placed directly inside a loop body. They apply to the loop that contains them.
| Pragma | Notes |
|---|---|
#pragma HLS PIPELINE | Pipelines the loop; implicitly unrolls all sub-loops |
#pragma HLS UNROLL | Unrolls the enclosing loop only |
#pragma HLS LOOP_FLATTEN | Flattens from the current loop outward through enclosing loops; off excludes the current loop from flattening with both its sub-loops and its parent loops |
#pragma HLS LOOP_TRIPCOUNT | Provides trip count estimate for variable-bound loops |
#pragma HLS DATAFLOW | Enables task-level pipelining within the loop |
#pragma HLS DEPENDENCE | Specifies dependency information for the loop; also valid in function scope (Category A) |
Category C — Region Pragmas
These pragmas are placed inside a code region. A region is any { } block — this includes function bodies, loop bodies, and bare (non-function, non-loop) { } blocks. Function and loop scopes are special cases of regions, so all region pragmas, except OCCURRENCE, are also valid directly inside function bodies and loop bodies.
| Pragma | Notes |
|---|---|
#pragma HLS ALLOCATION | Limits instance count of functions/operations within the region |
#pragma HLS EXPRESSION_BALANCE | Controls expression tree balancing within the region |
#pragma HLS LOOP_MERGE | Merges consecutive loops within the region |
#pragma HLS LATENCY | Constrains the minimum and/or maximum latency of the region |
#pragma HLS OCCURRENCE | Specifies that the region executes at a lower rate than the enclosing pipeline; MUST be inside a conditional block |
Category D — Variable Pragmas These pragmas reference a specific variable and MUST be placed in a scope where that variable is visible.
| Pragma | Notes |
|---|---|
#pragma HLS ARRAY_PARTITION | Partitions an array into smaller arrays or registers |
#pragma HLS ARRAY_RESHAPE | Reshapes an array by combining partitioning with word-width increase |
#pragma HLS BIND_STORAGE | Specifies storage implementation for a variable |
#pragma HLS BIND_OP | Specifies implementation for an operation |
#pragma HLS STREAM | Implements a variable as a FIFO stream; see Rule 5 |
#pragma HLS ARRAY_STENCIL | Enables stencil pattern optimization |
#pragma HLS DISAGGREGATE | Disaggregates a struct into individual elements |
#pragma HLS AGGREGATE | Aggregates struct fields into a single wide word |
1. Enclosing Scope Rule
A pragma applies to its enclosing scope — the nearest { } block that directly contains it.
{ } of the scope it is intended to affect.2. Function-Body Pragma Placement (Category A)
PIPELINE, DATAFLOW, and DEPENDENCE are dual-scope — they are legal in both function bodies and loop bodies (Category A and B).3. Interface Pragma Placement
#pragma HLS INTERFACE is ONLY valid inside the top function body.INTERFACE pragmas in sub-functions is illegal — they will be ignored.port= argument must reference a parameter of the top function.4. Loop-Body Pragma Placement (Category B)
UNROLL applies to the immediately enclosing loop only. Placing it in an outer loop does NOT unroll inner loops.LOOP_FLATTEN (without off) can be placed inside any loop in a nest, typically the innermost. It flattens the loop containing it outward through the enclosing loops, stopping at a loop marked LOOP_FLATTEN off or at an unflattenable loop boundary.#pragma HLS LOOP_FLATTEN off must also be placed inside a loop body. Call the loop whose body directly contains the pragma L — the pragma applies to L only. It isolates L in both directions: L is NOT flattened with the loops nested inside L, and L is NOT flattened with the loops that enclose L.off acts as a boundary only at its own loop — loops nested deeper inside it may still be flattened among themselves. Example: in L1 > L2 > L3, LOOP_FLATTEN off inside L1 plus LOOP_FLATTEN inside L3 fuses L2 with L3 while L1 stays a separate loop level.LOOP_FLATTEN off inside the innermost loop disables flattening of that loop entirely, including the automatic flattening the tool would apply with no pragma present.LOOP_MERGE must be placed in the scope that contains the consecutive loops to be merged (i.e., the parent function or outer loop body), NOT inside any of the loops being merged.LOOP_TRIPCOUNT is only meaningful for loops with variable bounds and is used for reporting only; it does not affect synthesis.DEPENDENCE inside a loop body specifies dependencies for that loop. Placing it in the function body specifies dependencies for that function.5. Region Pragma Placement (Category C)
{ } block — including function bodies, loop bodies, and bare code regions.INLINE region behaves differently from INLINE without the region keyword — INLINE region inlines all function calls within the region, while INLINE (Category A) inlines the enclosing function itself at its call sites.OCCURRENCE MUST be placed inside a conditional block within a pipelined scope. It indicates the block executes at a fraction of the pipeline rate.ALLOCATION pragmas with type=function must be placed in the scope of the caller, not in the function being limited.6. Variable Pragma Visibility (Category D)
variable= argument must reference a variable that is visible (in scope) at the pragma's location.#pragma HLS STREAM cannot be applied to a top function argument (use INTERFACE mode=ap_fifo or INTERFACE mode=axis instead). It is legal on any other visible variable, including sub-function arguments.7. PIPELINE and Implicit Unroll Interaction
#pragma HLS PIPELINE is applied to a loop, all loops nested inside that loop are implicitly fully unrolled.#pragma HLS PIPELINE is applied to a function, all loops inside that function are implicitly fully unrolled.PIPELINE on the outer scope will fail. The PIPELINE pragma will be reported as ignored in the synthesis log.8. DATAFLOW Scope Rules
#pragma HLS DATAFLOW in a function body enables task-level pipelining between sequential processes (function calls or loops) in that function.#pragma HLS DATAFLOW in a loop body enables task-level pipelining between sequential processes within each iteration of that loop.DATAFLOW and PIPELINE are mutually exclusive in the same scope — they cannot both be applied to the same function body or the same loop body.hls-dataflow skill for detailed canonicality rules once scope placement is validated.If all pragma placements follow the scope rules above, the pragmas are correctly scoped. Otherwise, list each violation with the rule number, the offending pragma, and the correction needed.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/amd-ross-agentic-ai-assistant:hls-pragma-scope [<TOP_FUNCTION — top-level HLS function name e.g. 'Kernel'>]from AMD Ross Agentic AI Assistant
npx claudepluginhub xilinx/ross-ai-assistant --plugin amd-ross-agentic-ai-assistant50 skills in this plugin
/hls-architectConvert input code to a multi-stage HLS dataflow, validate with the other hls skills, then hand off to optimize./hls-array-to-streamAnalyze whether a given C/C++ code snippet follows the recommended coding style for array-to-stream conversion in Vitis HLS. Keywords: array, stream, HLS, pragma, ap_fifo, axis, interface/hls-burst-inferenceAnalyze whether burst inference optimization can be applied to a given C/C++ code snippet in Vitis HLS. Keywords: burst, HLS, pragma, m_axi, AXI, memory, optimization/hls-component-basic-infoGet Vitis HLS component basic informations for a given HLS component. The basic informations includes component name, source files, testbench files, include paths and top function/hls-cosim-reportGet Vitis HLS cosimulation report information for a given HLS component./hls-dataflowAnalyze whether a given C/C++ code snippet contains a canonical dataflow region for Vitis HLS. Keywords: dataflow, HLS, pragma, canonical, stream, PIPO, hls::taskOther plugins' skills for the same job