arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.14762cs.SEcs.AI
收藏

工作流与代理在代码翻译中的比较

Workflows vs Agents for Code Translation

Code Metal

Henry Gray, Tom Yotam, Octavian Udrea

AI总结:

研究比较了工作流与代理方法在MATLAB到HDL代码翻译中的效果,发现代理方法在语法修复和提升模拟覆盖率方面表现更优。

摘要:

将算法从高级语言如MATLAB转换为硬件描述语言(HDL)是部署到FPGA和ASIC上的资源密集但必要的步骤。尽管大语言模型(LLMs)提供了自动化路径,但其对HDL代码的有限训练使端到端翻译变得脆弱且容易产生语法错误。我们比较了两种基于LLM的方法用于MATLAB到HDL流程中的语法修复:一种结构化的、由专家设计的流程,遵循固定的运算顺序;另一种更自主的代理方法,使用模型上下文协议(MCP)动态选择其工具。我们研究了42个MATLAB信号处理函数,并隔离了语法修复阶段。在三个模型规模下,代理方法在解决初始语法错误方面更有效,解阻更多候选者继续通过流程。这种上游改进带来了可衡量的下游改进,特别是在中等规模模型中,使模拟覆盖率提高了超过20个百分点。我们假设这些增益来自于简短的提示、积极的上下文管理以及条件工具使用。条件检索在8B和30B模型中有所帮助;在235B模型中,增益较小,而简单的RAG变体达到了最高的最终成功率。我们的发现表明,当正确设计时,这些代理框架在补偿小型和中型模型容量限制方面最有效。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑