Organizations: The Hong Kong University of Science and Technology, Hong Kong, Hong Kong · The Hong Kong University of Science and Technology (Guangzhou), Guangzhou, China · Dept of Electronic & Computer Engineering, The Hong Kong University of Science and Technology, Hong Kong, Hong Kong
LLM agents are rapidly shifting software development toward intent-driven vibe coding, yet their effectiveness drops sharply in high-level synthesis (HLS), where code optimization must jointly consider design structure, directive search, and downstream hardware constraints. Existing HLS optimization approaches, including both heuristic-based methods and recent LLM-assisted pipelines, typically operate at fixed abstraction levels or in weakly coupled stages, limiting their ability to leverage the strong interplay between source code restructuring and directive search outcomes. Our key insight is that HLS optimization can be reframed from a fixed, hardwired transformation pipeline into a skill-based agentic control problem: an LLM agent equipped with modular, executable optimization skills and a feedback-driven orchestrator can autonomously navigate the coupled space of code restructuring and directive search. This motivates the design of HLSClaw, the first HLS-specific, skill-based agentic harness for holistic HLS optimization. On real-world HLS benchmarks, HLSClaw achieves a 39.12x geometric-mean latency speedup, outperforming the compiler baseline ScaleHLS by 1.98x, and surpassing the commercial coding agents Claude Code and Codex by 1.86x and 1.70x, respectively, while maintaining strong timing robustness.
Figures & tables
Figure 1. Overview of HLSClaw : an LLM agent coordinates optimization skills in a feedback-driven workflow. An HLS design and a user goal enter a workflow of analysis and planning, code restructuring, differential C simulation, and directive search. A feedback arrow returns from directive search to code restructuring. An LLM agent orchestrates five underlying skills: Profiling, Rewrite, KG-RAG, Fuzzing, and the DSE Engine.
Figure 2. Motivation examples demonstrating the limitations of existing HLS compilers and the opportunity for LLMs. The green arrows show execution time reductions. Circle and pentagon markers highlight the bottlenecks and modified regions. Two rows compare original code, HLSClaw rewrites, and the corresponding hardware structures. For CRS, a loop-carried floating-point accumulation dependency is replaced by four partial sums and a tree reduction. Latency increases from 1,990 to 3,506 cycles, while the clock period decreases from 9.35 to 3.19 nanoseconds, reducing execution time by 40.0 percent. For Conv2D, repeated loading of overlapping windows through a FIFO is replaced by a line buffer and sliding-window registers. At a 5-nanosecond clock period, latency decreases from 4,502 to 1,147 cycles, reducing execution time by 74.5 percent. Numbered circle and pentagon markers connect the bottlenecks with the rewritten code and structures.
Figure 3. Overview of HLSClaw with five optimization skills, a feedback-driven workflow, and context engineering. The architecture combines a context-management layer, a feedback-driven optimization workflow, and five executable skills. An input HLS design and user goal guide analysis and planning, which sends an optimization plan and bottleneck diagnosis to code restructuring. Differential C simulation compares the original design and rewritten candidate; failures return to restructuring, while passing candidates proceed to directive search. Search reports return to analysis, and the best candidate feeds subsequent restructuring. Top States, Artifacts, ScratchPad, and Memory support the workflow, with Profiling, Rewrite, KG-RAG, Fuzzing, and DSE Engine skills below.
Figure 4. Offline construction of the KG-RAG library from multimodal documents for HLS knowledge retrieval. A left-to-right pipeline constructs a retrieval library from PDF files, web pages, and other documents. MinerU parses each document into text, images, tables, and equations. Multimodal embedding encodes the extracted content. The resulting knowledge graph links multimodal content and text representations for retrieval-augmented generation.
Figure 5. Context engineering with Top States, ScratchPad, and Artifacts for orchestration, memory, and outputs. Three connected context layers organize an agent run. Top States holds the system prompt, available-skill information, compact interaction history, and user specifications such as the latency objective, U250 board, and 200-megahertz target. ScratchPad holds the current analysis, commands, and artifact paths and exchanges information with Top States. Artifacts stores reference documents, synthesis reports, original and optimized designs, and scripts, and exchanges information with ScratchPad.
Figure 6. Performance and resource comparison across 12 HLS benchmarks. Top: normalized latency speedup, where higher is better. Bottom: normalized resource score relative to the original design, where lower is better. Two grouped bar charts compare HLSPilot, ScaleHLS, HLSRewriter, Codex, Claude Code, and HLSClaw on Atax, BNN, CNN, CRS, GEMM, GeTanh, GramSchmidt, Matrixmult, Stencil, Substring, VecNormTrans, and Viterbi, followed by geometric means. Both vertical axes are logarithmic. The upper chart shows normalized latency speedup, where higher is better; geometric means in method order are 17.3, 19.7, 14.1, 23.0, 21.0, and 39.1 times. The lower chart shows normalized resource score, where lower is better; geometric means are 14.5, 13.4, 11.3, 21.3, 12.5, and 15.2 times. HLSClaw has the highest geometric-mean speedup, with resource use varying across kernels.
Metric
HLSPilot
ScaleHLS
HLS Rewriter
Codex
Claude Code
HLSClaw
GM
11.89
18.29
14.16
13.34
14.68
30.59
ETS
3.44
6.35
5.35
4.13
5.26
7.48
EWS
4.41
4.46
4.99
4.42
4.68
5.70
Perf/HW Gain
0.82
1.36
1.25
1.18
1.17
2.01
Table 1. Execution time = latency × achieved clock period; For all four metrics, higher is better.
Figure 7. KG-RAG ablation on four kernels: (top) normalized latency speedup; (bottom) normalized resource score. Two grouped bar charts compare No-RAG, Flat-RAG, and KG-RAG on Atax, BNN, CNN, and Substring, followed by geometric means. The logarithmic axes show latency speedup above and normalized resource score below, with the original design marked at one times. Geometric-mean speedups are 3.8, 10.4, and 21.5 times, respectively; corresponding resource scores are 5.71, 14.0, and 15.4 times. KG-RAG provides the highest geometric-mean speedup and speedup per resource score, while resource use varies by kernel.
Configuration
C-sim time (s)
HLS evals
Invalid evals executed
HLS wall time (s)
Total wall time (s)
Without C-sim gate
0
80
15
966.50
966.50
With differential C-sim
94.10
65
0
295.71
389.81
Change
+94.10
−15
−15
−670.79
−576.69
Relative saving
–
18.8%
100%
69.40%
59.70%
Table 2. Impact of differential C simulation on validation and optimization wall-clock time.
Benchmark
eval-1 cycles
eval-1 gain
eval-2 cycles
eval-2 gain
eval-3 cycles
eval-3 gain
eval-4 cycles
eval-4 gain
Substring
24,607
10.65 ×
42,762
6.13 ×
4,122 †
63.59 ׆
4,121
63.61 ×
VecNormTrans
30,729
1.46 ×
6,199
7.26 ×
4,814
9.35 ×
3,127
14.39 ×
CNN
8,115
4.61 ×
14,278
2.62 ×
8,115
4.61 ×
4,105
9.11 ×
Atax
1,259
26.62 ×
977
34.30 ×
1,072 †
31.26 ׆
532
63.00 ×
Table 3. Contribution of eval-1, eval-2, eval-3, and eval-4.
Figure 8. Latency–resource trade-off on CNN. The red curve shows the Pareto frontier obtained by sweeping λ . A scatter plot shows the CNN trade-off between resource score on the horizontal axis and normalized latency on the vertical axis. Gray circles represent explored candidates, and a descending red curve connects the HLSClaw Pareto frontier. A star marks the resource-constrained endpoint at resource score 0.67 and normalized latency 1.00; another star marks a low-latency HLSClaw solution near resource score 11. A magnified inset compares this low-latency region with cross-shaped markers for HLSRewriter, HLSPilot, and ScaleHLS. Moving along the frontier reduces latency at the cost of greater resource use.
Model
NPUs
Tokens
Time (s)
Tokens/s
Qwen2.5-0.5B
1
93
4.57
20.35
openPangu-7B
1
92
7.18
12.81
Qwen2.5-32B
4
128
32.22
3.97
Table 4. Inference results of open-source LLMs on Huawei Ascend 910B1 NPUs.
Figure 9. Cycle-based latency speedup of HLSClaw using openPangu-7B and Qwen2.5-7B-Instruct on five benchmarks.