arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.04933cs.PL
收藏

面向RISC-V的交互树语义:连接编译器与硬件验证

Interaction Tree Semantics for RISC-V: Bridging Compiler and Hardware Verification

Barkhausen Institut(巴克拉森研究所)

Shuanglong Kan, Sebastian Ertel

AI总结:

该研究在Rocq中构建基于ITrees的RISC-V ISA形式化语义,实现编译器IR到硬件的跨层级验证,通过模拟器验证并经三项案例研究证明其有效性。

摘要:

指令集架构(ISA)是编译器与处理器之间的契约,对该契约进行形式化证明需要与现有机械化编译器和硬件实现建立跨层级连接。作为一种在嵌入式、移动及云平台广泛应用的开源模块化ISA,RISC-V的形式化验证ISA规范极具价值。然而,现有RISC-V形式化规范聚焦于硬件工具而非跨层级验证:它们未提供机器检查的指令级属性,也缺乏跨层级验证该契约的支持。我们通过基于交互树(ITrees)的RISC-V ISA形式化语义解决这些局限,该语义在Rocq中构建。利用ITrees的互模拟和精化,我们的语义可在单一框架内实现从编译器IR到硬件的跨层级验证。我们的形式化覆盖了广泛的RISC-V扩展,每条指令语义的正确性由Rocq中的机器检查引理支持。我们进一步通过提取可执行模拟器进行验证,该模拟器通过了所有标准RISC-V测试套件。三项案例研究展示了我们语义在跨层级验证中的有效性:首先,我们通过Vellvm(LLVM ITree语义)证明了数组访问模式下LLVM IR与RISC-V代码之间通过互模拟实现的语义等价性;其次,我们对宏操作融合的特定指令重排序应用翻译验证,区分安全重排序与破坏程序计数器相对寻址的重排序;第三,我们证明Kôika硬件ALU针对我们的ISA契约正确实现了所有R型整数操作(如ADD、SUB、AND)。

英文摘要:

The Instruction Set Architecture (ISA) is the contract between compilers and processors; proving this contract formally demands cross-level connection to existing mechanized compilers and hardware implementations. As an open, modular ISA gaining adoption across embedded, mobile, and cloud platforms, RISC-V makes a formally verified ISA specification particularly valuable. However, existing formal RISC-V specifications focus on hardware tooling rather than cross-level verification: they provide no machine-checked instruction-level properties and lack support for verifying this contract across levels. We address these limitations with a formal semantics of the RISC-V ISA in Rocq, built on Interaction Trees (ITrees). By leveraging ITree bisimulation and refinement, our semantics enables cross-level verification from compiler IR to hardware within a single framework. Our formalization covers a wide spectrum of RISC-V extensions. The correctness of individual instruction semantics is backed by machine-checked lemmas in Rocq. We further validate it by extracting an executable simulator that passes all standard RISC-V test suites. Three case studies demonstrate the effectiveness of our semantics for cross-level verification: first, we prove semantic equivalence via bisimulation between LLVM IR and RISC-V code on an array access pattern via Vellvm (LLVM ITree semantics); second, we apply translation validation to a specific instruction reordering for macro-operation fusion, distinguishing safe reorderings from those that break program-counter-relative addressing; third, we prove that a Kôika hardware ALU correctly implements all R-type integer operations (e.g., ADD, SUB, AND) against our ISA contract.

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

↑