arXiv:2512.14762cs.SEcs.AI2025-12

用智能体比固定流程更有效修复代码转换中的语法错误。

Workflows vs Agents for Code Translation

  • 用动态选工具的智能体方法替代固定流程,提升修复能力。
  • 中等规模模型下,模拟成功率提升超20个百分点。
  • 适合资源有限时增强小模型在硬件代码转换中的表现。

将高阶语言(如MATLAB)中的算法翻译为硬件描述语言(HDL)是部署于FPGA和ASIC的必要但耗资源的步骤。尽管大语言模型(LLMs)提供了自动化路径,但其对HDL代码训练不足导致端到端转换易出语法错误。本文对比了两种基于LLM的语法修复方法:一种是专家设计的固定流程,另一种是基于模型上下文协议(MCP)的自主智能体方法,后者可动态选择工具。研究42个信号处理函数,聚焦语法修复阶段。在三个模型规模下,智能体方法更有效解决初始语法错误,使更多函数可通过流水线。上游改进带来下游显著提升,尤其在中等规模模型上,模拟成功率提高超过20个百分点。我们推测优势源于短提示、主动上下文管理与条件性工具调用。8B与30B模型中,条件检索有帮助;235B模型下最终成功提升小,朴素RAG反而最优。结果表明,合理设计的智能体框架最能弥补中小模型的能力局限。

原文摘要 · Abstract (English)

Translating algorithms from high-level languages like MATLAB to hardware description languages (HDLs) is a resource-intensive but necessary step for deployment on FPGAs and ASICs. While large language models (LLMs) offer a path to automation, their limited training on HDL code makes end-to-end transpilation brittle and prone to syntax errors. We compare two LLM-driven methods for syntax repair in a MATLAB-to-HDL pipeline: a structured, expert-designed flow that follows a fixed sequence of operations, and a more autonomous agentic approach that uses the Model Context Protocol (MCP) \cite{anthropic2024mcp} to dynamically select its own tools. We study 42 MATLAB signal-processing functions and isolate the syntax-repair stage. Across three model scales, the agentic approach is more effective at resolving initial syntax errors, unblocking a greater number of candidates to proceed through the pipeline. This upstream improvement yields measurable downstream improvements, most notably on mid-sized models, where it increases the simulation reach rate by over 20 percentage points. We hypothesize the gains come from short prompts, aggressive context management, and conditional tool use. Conditional retrieval helps at 8B and 30B; at 235B final-success gains are small and a naive RAG variant attains the highest final success. Our findings suggest that these agentic frameworks, when properly designed, are most effective at compensating for the capacity limits of small and mid-sized models.

代码生成智能体硬件加速

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。