arXiv:2611.07324cs.ARNov 2026

Manuscript Offprint

arXiv:2611.07324

Rule-Guided and Trajectory-Aware Repair for LLM-Based HLS Generation

Xianjing Zhu, Wenqi Lou, Yuanbo Wen, Teng Wang, Lei Gong, Chao Wang, Xuehai Zhou

Abstract

Large language models (LLMs) offer a promising path for directly generating functionally correct and synthesizable HLS-C from natural-language specifications. However, existing approaches often struggle to turn multi-round tool feedback and reusable HLS knowledge into effective revisions, limiting end-to-end generation success. We propose MementoHLS¹, an agentic HLS generation framework built around executable and falsifiable dual-memory-guided repair. MementoHLS combines an Executable Repair Contract Library (ERCL), which converts cross-task HLS knowledge into evidence-gated repair actions, with a Reviewer-Grounded Falsification Ledger (RFL), which converts task-local repair history into trajectory evidence to suppress ineffective routes and preserve validated progress. To ensure reliable outcome attribution, a Same-Candidate Reviewer binds Parse, Compile, Testbench (TB), and Synthesis (Synth) outcomes to the corresponding candidate, while a Single-Commit Arbiter commits at most one candidate per round. Evaluated on 94 HLS-Eval and 170 Bench4HLS tasks, MementoHLS improves same-candidate TB∧Synth pass@1/pass@5 from 41.7%/57.4% to 58.9%/68.1% on HLS-Eval, and from 15.5%/32.9% to 32.4%/50.6% on Bench4HLS, demonstrating substantial improvements in end-to-end HLS generation reliability.

1 Introduction

High-Level Synthesis (HLS) translates C/C++ descriptions into RTL, lowering the barrier for accelerator and FPGA design [2, 8, 16]. Recent advances in LLMs further enable AI-assisted HLS automation. As illustrated in Fig. 1, existing LLM-based HLS workflows can be broadly divided into two stages: generating a functionally correct and synthesizable HLS-C implementation, and optimizing valid designs for latency, throughput, or resource efficiency. Methods such as C2HLSC [3] and HLSRewriter [15] focus on C/C++-to-HLS transformation and repair, while HLSPilot [13] and related approaches [7, 9] mainly target downstream QoR optimization. These two stages are complementary, as optimization relies on a correct and synthesizable HLS implementation.

Early LLM-based HLS generation methods typically start from existing algorithmic C/C++ programs and transform them into HLS-compatible code. With improved LLM reasoning and code generation capabilities [18], recent studies [4, 6, 17, 19] directly generate HLS-C implementations from natural-language specifications. However, obtaining a functionally correct and synthesizable design still requires iterative feedback from Parse, Compile, Testbench (TB), and Synthesis (Synth) stages.

Existing approaches improve HLS generation through prompting, retrieval, tool feedback, fine-tuning, or iterative refinement.

Figure

Figure 1: Overview of the Two-Stage LLM-Assisted HLS Automation Workflow.

However, during multi-round generation, simply returning tool logs, retrieved knowledge, and previous interactions to the LLM does not provide sufficient control over how repair knowledge should be applied or how previous repair outcomes should influence subsequent generation. We identify two key limitations in current tool-guided HLS generation: (1) a knowledge-to-action gap, (2) a history-to-evidence gap.

First, reusable HLS knowledge does not directly translate into reliable repair actions. HLS-specific knowledge may describe synthesis restrictions, interface requirements, or numerical issues, but its applicability depends on the current candidate, task interface, data types, dimensions, tool feedback, and algorithmic constraints. Such a context-dependent applicability issue has also been observed in retrieval-augmented reasoning for hardware design specifications [12]. A reliable repair mechanism must explicitly encode applicability evidence, prohibited conditions, permissible edits, design invariants, and validation obligations. To address this challenge, we introduce the Executable Repair Contract Library (ERCL), which converts reusable cross-task HLS knowledge into evidence-gated and executable repair contracts.

Second, raw interaction history does not provide reliable evidence about whether previous generation attempts have actually improved the design. Across multiple rounds, superficial changes in logs may correspond to the same failure, while apparently different repairs may regress previously satisfied validation stages or revisit ineffective routes. Simply storing previous tool logs or model interactions cannot distinguish genuine progress from repeated failures, regression, or oscillation [10]. Reliable iterative repair requires attributing each observed outcome to the repair route that produced it, normalizing unstable tool feedback, and using this evidence to suppress ineffective actions while preserving validated progress. To address this challenge, we introduce the Reviewer-Grounded Falsification Ledger (RFL), which converts task-local generation history into normalized trajectory evidence and uses actual tool outcomes to assign repair credit, suppress ineffective

¹Code is available at: https://github.com/ZD-zhu/MementoHLS.

routes, preserve validated progress, and trigger recovery under stagnation.

We integrate ERCL and RFL into MementoHLS, an agentic framework for reliable LLM-based HLS generation. ERCL determines which reusable repair knowledge is applicable and authorized for the current generation failure, whereas RFL determines how the observed outcomes of previous repair attempts should constrain subsequent generation. For this dual-memory mechanism to operate reliably, however, every tool outcome must be unambiguously attributable to the exact candidate and repair action that produced it. We therefore introduce a Same-Candidate Reviewer to bind Parse, Compile, Testbench, and Synthesis outcomes to a unique candidate, together with a Single-Commit Arbiter that commits at most one candidate per round. These mechanisms provide reliable attribution for ERCL and RFL, forming a closed loop where reusable knowledge guides repair actions and trajectory evidence shapes subsequent generation.

In summary, this work makes the following contributions:

  • We propose MementoHLS, an agentic framework for reliable LLM-based HLS generation that closes the loop among generation, tool feedback, and repair under a fixed LLM, while ensuring reliable outcome attribution through candidate-bound review and single-commit execution.
  • We introduce the ERCL, which transforms reusable cross-task HLS knowledge into evidence-gated, executable repair contracts with explicit applicability and validation constraints.
  • We introduce the RFL, which converts task-local multi-round repair history into tool-grounded trajectory evidence for repair credit assignment and adaptive trajectory control.
  • We evaluate MementoHLS on HLS-Eval [1] and Bench4HLS [5], where it consistently achieves state-of-the-art same-candidate TB\ASynth success rates across multiple LLM backbones and model scales.