Optimizing register transfer level (RTL) code is of vital importance in hardware design. Large language models (LLMs) provide new methods for the automatic generation and optimization of RTL code, offering the potential to significantly accelerate the design process and reduce human effort. However, existing methods for generating RTL code often focus on model fine-tuning and the use of various expansion techniques to enhance the RTL code generation capabilities, lacking attention to the functional correctness. Ensuring that the generated RTL code not only compiles successfully but also behaves as intended in real hardware implementations remains a critical challenge. To address this issue, we propose EstRTL, an LLM-powered collaborative agent framework for RTL code generation based on static functional score estimation. EstRTL operates a three-stage paradigm: Generation, Estimation and Correction. During the stages, the functional estimation agent statically evaluates the generated code based on score and assessment results, and decides whether to output the code directly, return it for regeneration, or forward it to the code correction agent. This framework can be applied to various LLMs that designed for RTL code generation, further enhancing the correctness of the generated code. By providing quantitative scores and human-readable requirements comparisons, it improves the transparency of AI-assisted RTL code generation. Experiments show that EstRTL significantly improves the correctness of RTL code generation by generic LLM by 3.2\%-9.0\%, demonstrating the practical value of our system. The codes and experimental results are open-sourced at link: https://anonymous.4open.science/status/EstRTL-E200/.
翻译:在硬件设计中,优化寄存器传输级(RTL)代码至关重要。大型语言模型(LLMs)为RTL代码的自动生成与优化提供了新方法,有望显著加速设计流程并减少人工投入。然而,现有RTL代码生成方法通常侧重于模型微调和利用各种扩展技术提升生成能力,缺乏对功能正确性的关注。确保生成的RTL代码不仅成功编译,还能在实际硬件实现中按预期运行,仍是一项关键挑战。为解决此问题,我们提出EstRTL——一个基于静态功能评分评估、由LLM驱动的协作式RTL代码生成智能体框架。EstRTL采用三阶段范式:生成阶段、评估阶段与纠正阶段。在评估阶段,功能评估智能体基于评分和评估结果对生成的代码进行静态分析,并决定是直接输出代码、返回重生成,还是转发至代码纠正智能体。该框架可适用于多种专为RTL代码生成设计的LLM,进一步提升生成代码的正确性。通过提供量化分数和可读的需求对比,它提高了AI辅助RTL代码生成的透明度。实验表明,EstRTL将通用LLM的RTL代码生成正确率显著提升了3.2%至9.0%,验证了系统的实用价值。相关代码与实验结果已在链接https://anonymous.4open.science/status/EstRTL-E200/ 开源。