Large Language Models (LLMs) show great promise in RTL code generation and optimization. However, real-world RTL designs are typically long, entangled, and poorly modularized, posing a major challenge due to context-length limitations and lack of structure. To overcome these obstacles, we propose a scalable LLM-based RTL optimization framework guided by graph similarity. Our method introduces three collaborative agents: (1) a Partition Agent that decomposes RTL designs into semantically meaningful AST subtrees, guided by AST graph similarity to reusable design templates; (2) an Optimization Agent that generates RTL submodule code based on partitioned subtrees using multi-modal Retrieval-Augmented Generation (RAG) with both AST and RTL guidance; and (3) a Reconstruction Agent that reassembles optimized submodules based on logic-aware ordering and Graph-RAG prompting, ensuring global functional equivalence. Together, these components enable robust, structure-aware optimization of long-context RTL designs, bridging the gap between toy examples and industrial-scale hardware codebases.
翻译:大语言模型在RTL代码生成与优化方面展现出巨大潜力。然而,真实世界的RTL设计通常冗长、结构耦合且模块化程度低,受上下文长度限制及缺乏结构化特性,这构成了重大挑战。为克服这些障碍,我们提出了一种基于图相似性引导的可扩展大语言模型RTL优化框架。该方法引入三类协作智能体:(1)分区智能体,通过AST图相似性引导,将RTL设计分解为语义可解读的AST子树,进而复用至可重用设计模板;(2)优化智能体,基于已分区子树,采用融合AST与RTL指导的多模态检索增强生成技术,生成RTL子模块代码;(3)重构智能体,依据逻辑感知排序与Graph-RAG提示机制重组优化后的子模块,确保全局功能等价性。这些组件协同作用,实现了对长上下文RTL设计的鲁棒、结构感知优化,弥合了玩具级示例与工业级硬件代码库之间的差距。