arXiv:2507.02226cs.PLcs.AR2025-07中稿 · the International …被引 12

用运行时策略提升大模型生成硬件代码的准确性和多样性。

DecoRTL: A Run-time Decoding Framework for RTL Code Generation with LLMs

  • 动态调整采样温度,区分语法关键与设计探索区域。
  • 多候选重排序机制提升代码正确率,有效减少错误。
  • 无需微调模型,适合硬件工程师快速生成可靠Verilog代码。

大型语言模型(LLMs)在自动化寄存器传输级(RTL)代码生成中展现出潜力,但传统解码策略因不适应硬件代码的结构与语义要求,常产生幻觉、重复或无效代码。本文通过分析生成过程中的词元级熵,发现模型在结构模糊或语义复杂区域信心不足,标准策略无法区分需确定性的语法关键区与需探索性的设计关键区。为此,提出DecoRTL,一种运行时解码框架,包含两个互补组件:(i) 自一致性采样,生成多个候选并基于词元级一致度重排序,提升正确性同时保持多样性;(ii) 语法感知温度调节,按词元的语法与功能角色动态调整采样温度,对语法关键词使用低温度,对探索性词使用高温度。该方法完全在推理阶段运行,无需额外微调。在VerilogEval基准上对多个开源LLM的评估表明,其显著提升了语法有效性、功能正确性与输出多样性,且执行开销可忽略不计。

原文摘要 · Abstract (English)

As one of their many applications, large language models (LLMs) have recently shown promise in automating register transfer level (RTL) code generation. However, conventional LLM decoding strategies, originally designed for natural language, often fail to meet the structural and semantic demands of RTL, leading to hallucinated, repetitive, or invalid code outputs. In this paper, we first investigate the root causes of these decoding failures through an empirical analysis of token-level entropy during RTL generation. Our findings reveal that LLMs exhibit low confidence in regions of structural ambiguity or semantic complexity, showing that standard decoding strategies fail to differentiate between regions requiring determinism (syntax-critical regions) and those that benefit from creative exploratory variability (design-critical regions). Then, to overcome this, we introduce DecoRTL, a novel run-time decoding strategy, that is both syntax-aware and contrastive for RTL code generation. DecoRTL integrates two complementary components: (i) self-consistency sampling, which generates multiple candidates and re-ranks them based on token-level agreement to promote correctness while maintaining diversity; and (ii) syntax-aware temperature adaptation, which classifies tokens by their syntactical and functional roles and adjusts the sampling temperature accordingly, enforcing low temperature for syntax-critical tokens and higher temperature for exploratory ones. Our approach operates entirely at inference time without requiring any additional model fine-tuning. Through evaluations on multiple open-source LLMs using the VerilogEval benchmark, we demonstrate significant improvements in syntactic validity, functional correctness, and output diversity, while the execution overhead (performance overhead) is imperceptible.

硬件生成大模型解码优化

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