用语法驱动方法生成可调控粒度的硬件代码补全测试集。
RuC: HDL-Agnostic Rule Completion Benchmark Generation

- 基于HDL语法自动掩蔽代码区域,实现细粒度补全任务生成。
- 使用FIM提示策略时模型表现最佳,不同语法结构影响显著。
- 适合评估LLM在RTL开发中的代码理解能力,尤其适用于开源模型对比。
大型语言模型(LLMs)在代码相关任务中性能迅速提升,使其在寄存器传输级(RTL)开发中的集成日益吸引人。现有基准多模仿内联代码助手,评估模型生成完整硬件模块或单行代码补全的能力,但缺乏对补全粒度和语法范围的控制。为此,我们提出一种语言无关的规则补全框架(RuC),基于语法驱动、可选择规则的基准生成器,从输入的硬件描述源自动生成RTL代码补全任务。RuC利用目标硬件描述语言(HDL)的语法,掩蔽语义明确的代码区域,并以周围未掩蔽代码为上下文,引导模型重生成这些区域,从而实现对领域特定模型代码理解能力的可控、可扩展评估,涵盖赋值到整个逻辑块的重建。我们使用RuC从Tiny Tapeout shuttle TT07和CVE2 RISC-V核心生成两个SystemVerilog规则补全基准,验证其在多种设计中的适用性,并对现代开源LLMs在不同设置下的代码补全能力进行对比研究。结果表明,补全性能强烈依赖于模型类型、被掩蔽区域的语法结构及提示策略。特别是,采用填空中间(Fill-in-the-Middle, FIM)提示策略时得分最高。这些发现凸显了语法驱动、任意粒度基准在有意义评估LLM在RTL开发工作流中能力方面的价值。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have rapidly improved in performance across code-related tasks, making their integration into Register Transfer Level (RTL) development increasingly attractive. Mimicking the behavior of inline code assistants, many benchmarks evaluate LLMs' capabilities in code completion, either assessing the generation of entire hardware modules or the completion of a single line within a module. However both of these approaches lack the ability to control the granularity of the code-completion sample size and the syntactic range of completions. To overcome these limitations, we present a framework for language-agnostic rule completion (RuC), a grammar-driven, rule-selectable benchmark generator that automatically produces RTL code-completion tasks from a set of input hardware description sources. RuC uses the target Hardware Description Language (HDL) grammar to mask syntactically defined code regions and prompts a model to regenerate them using the surrounding unmasked code as context, enabling a controlled and scalable evaluation of the domain-specific model's code-understanding capabilities, ranging from assignments to the reconstruction of entire logic blocks. We use RuC to generate two SystemVerilog rule-completion benchmarks from the Tiny Tapeout shuttle TT07 and the CVE2 RISC-V core to demonstrate RuC's applicability to a broad range of designs, and conduct a comparative study of the code completion capabilities of modern open-source LLMs across diverse settings. Results indicate that completion performance strongly depends on the model type, the grammatical structure of the masked region, and the prompting strategy. Specifically, the highest scores are obtained with Fill-in-the-Middle (FIM) prompting. These findings highlight the value of grammar-driven, arbitrarily granular benchmarks for meaningful evaluation of LLM capabilities in RTL development workflows.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。