EUVIMEDEUVIMED entdecken
Crossref

HLSRewriter: Efficient Refactoring and Optimization of C/C++ Code with LLMs for High-Level Synthesis

Kangwei Xu, Grace Li Zhang, Xunzhao Yin, Cheng Zhuo, Ulf Schlichtmann, Bing Li

ACM Transactions on Design Automation of Electronic Systems · 31.07.2026 · 31 (4) · 1-21

DOI: 10.1145/3749986 ↗

Kurz gefasst

Fachartikel in der Zeitschrift ACM Transactions on Design Automation of Electronic Systems, online erschienen am 19.03.2026. Verfasst von Kangwei Xu und 5 weiteren Autor:innen. Die Arbeit wurde bisher 6-mal zitiert (Crossref) und nennt 49 Literaturangaben. Gefördert von: Deutsche Forschungsgemeinschaft, NSFC-DFG Sino-German Center for Research Promotion (SGC) Cooperation Project, TUM International Graduate School of Science and Engineering.

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

In High-Level Synthesis (HLS), refactoring a standard C/C++ code into its HLS-compatible version (HLS-C) still requires significant human effort. While various program scripts have been introduced to automate this process, the resulting code still contains many HLS-incompatible issues that need to be manually refactored and optimized by developers. Since Large Language Models (LLMs) have the ability to automate code generation, they can also be used for automated code refactoring and optimization in HLS. However, due to the limited training of LLMs, considering hardware and software simultaneously, hallucinations may occur when using LLMs for HLS, leading to synthesis failures. To address these challenges, we introduce HLSRewriter , an LLM-aided code refactoring and optimization framework that takes regular C/C++ code as input and automatically generates its corresponding optimized HLS-C code for hardware synthesis with minimal human intervention. To mitigate LLM hallucinations, a step-wise reasoning process is employed to analyze and detect HLS-incompatible errors. Afterwards, a repair library containing reference templates is efficiently created by scanning the HLS tool manual, followed by cooperation with a Retrieval-Augmented Generation (RAG) paradigm to guide the LLMs toward correct refactoring. In addition, a pipeline-aware decomposition strategy is introduced to progressively break down complex loop structures into smaller tasks with a balanced trade-off between latency and area, thereby enabling efficient pipelining and parallel execution. To further improve hardware efficiency, a bit width adjuster module is incorporated into this framework to optimize the precision of floating-point variables. Moreover, LLM-aided HLS optimization strategies are introduced to add/tune hardware directives in HLS-C code, thereby enhancing the performance of the final synthesized hardware. Experimental results demonstrate that the proposed LLM-aided framework can achieve higher refactoring pass rates and superior hardware performance in 24 real-world tasks compared with traditional approaches and the direct application of LLMs for code refactoring and optimization. The codes are open-sourced at this link: https://github.com/code-source1/catapult .

Förderung

  • Deutsche Forschungsgemeinschaft
  • NSFC-DFG Sino-German Center for Research Promotion (SGC) Cooperation Project
  • TUM International Graduate School of Science and Engineering

Zitieren

APA

Xu, K., Zhang, G. L., Yin, X., Zhuo, C., Schlichtmann, U., & Li, B. (2026). HLSRewriter: Efficient Refactoring and Optimization of C/C++ Code with LLMs for High-Level Synthesis. ACM Transactions on Design Automation of Electronic Systems, 31(4), 1-21. https://doi.org/10.1145/3749986

Vancouver

Xu K, Zhang GL, Yin X, Zhuo C, Schlichtmann U, Li B. HLSRewriter: Efficient Refactoring and Optimization of C/C++ Code with LLMs for High-Level Synthesis. ACM Transactions on Design Automation of Electronic Systems. 2026;31(4):1-21. doi:10.1145/3749986

BibTeX
@article{Xu2026,
  author = {Xu, Kangwei and Zhang, Grace Li and Yin, Xunzhao and Zhuo, Cheng and Schlichtmann, Ulf and Li, Bing},
  title = {HLSRewriter: Efficient Refactoring and Optimization of C/C++ Code with LLMs for High-Level Synthesis},
  journal = {ACM Transactions on Design Automation of Electronic Systems},
  year = {2026},
  volume = {31},
  number = {4},
  pages = {1--21},
  doi = {10.1145/3749986}
}
Kostenlos starten →