TL;DR
Large language models (LLMs) are remarkably good at autocompleting Python or Java, but hardware description languages (HDLs)—the code that defines actual silicon circuits—play by completely different rules. MHRC-Bench is the first multilingual, repository-level benchmark for hardware code completion with functional testing. The authors show that fine-tuning smaller open-weight models on hardware repositories lets them beat giants like GPT-5, while revealing four ways hardware code breaks standard software-AI assumptions.
What Problem Does This Paper Address?
If you ask an LLM to autocomplete a Python function, it’s reasoning about sequential execution: do A, then B, then C. Hardware description languages don’t work like that. They describe parallel circuits, physical signal connectivity, and strict timing constraints.
Despite this, almost all repository-level code completion benchmarks focus exclusively on software. Existing hardware benchmarks either test isolated, single-module generation from natural language prompts (like VerilogEval) or stick to a single language and single-line completions (like RTL-Repo). We haven't had a realistic way to test whether LLMs can navigate multi-file hardware projects—where a module in one file depends on parameters, interfaces, and pragmas defined in another—across the diverse languages hardware engineers actually use.
Methods
The researchers built an evaluation pipeline that mirrors real-world hardware development. Instead of slicing out random character spans (which can break syntax), they parse each source file into a Concrete Syntax Tree (CST) using tree-sitter and select syntactically complete nodes as completion targets.
They evaluate two families of models:
- Open-weight code LLMs: Qwen2.5-Coder (3B, 7B, 14B) and DeepSeek-Coder (5.7B, 6.7B), tested both out-of-the-box and after supervised fine-tuning (LoRA) on the benchmark's training split.
- Commercial general-purpose models: GPT-5, Gemini 2.5 Pro, Grok-4, and DeepSeek-V3.2.
Models are tested under two prompting modes—preceding-context-only and full-context (fill-in-the-middle)—within a matched 2,048-token window. To see how well models use cross-file information, they also test three repository-level retrieval methods: RepoCoder, GraphCoder, and RLCoder. Performance is measured via Exact Match (EM), Edit Similarity (ES), and functional pass rate (pass@1) using real testbenches and I/O vectors.
Datasets
The authors introduce MHRC-Bench, comprising MHRC-Bench-Train and MHRC-Bench-Eval. It contains 47,200 source files drawn from 583 distinct, deduplicated GitHub repositories (created after 2000, with >5 stars), split at the repository level to prevent data leakage.
MHRC-Bench spans three major hardware paradigms:
- RTL-based HDLs: Verilog/SystemVerilog (grouped as V/SV) and VHDL.
- High-Level Synthesis (HLS): Xilinx HLS C/C++.
- Domain-Specific Languages (DSLs): Chisel.
At least 40% of the completion targets span two to five lines. Every target is annotated at two levels: code structure (5 depth buckets based on its CST depth) and hardware semantics (9 categories covering both design—like Storage Block and Interface—and verification—like Testbench Stimulus).
Key Insights and Ideas
Beyond raw scores, the paper uncovers four "aha moments" that separate hardware from software code completion:
- Language matters—a lot: Across almost every setting, HLS is the easiest (benefiting from LLMs' massive C/C++ pretraining) and VHDL is the hardest (suffering from a smaller public footprint, verbose syntax, and strict typing where tiny width or cast errors are fatal). Uniquely, VHDL is the only language where giving the model both preceding and succeeding code (fill-in-the-middle) fails to beat preceding-context-only.
- Deeper structure doesn't mean easier: In software, deeper CST nodes monotonically correlate with higher LLM accuracy. In hardware, accuracy fluctuates non-monotonically with structural depth.
- More context hits a wall: Software completion generally keeps improving as you feed it longer context windows. On hardware code, fine-tuned models peak at 2,048 tokens and actually degrade when pushed to 4,096 or 8,192 tokens, as extra context introduces noise.
- Software retrievers break on hardware: GraphCoder—a retriever tuned for Python and Java—frequently underperforms a no-retrieval baseline on HDLs. Its CST helpers and dependency-graph builders simply miss hardware-specific constructs like function declarations and HLS pragmas.
Key Results
- Fine-tuning smaller models pays off: Out of the box, open-weight code LLMs score near-zero Exact Match in preceding-context-only hardware tasks. After fine-tuning on MHRC-Bench-Train, Qwen2.5-Coder-14B outperforms GPT-5, Grok-4, and DeepSeek-V3.2 across all four HDLs in EM and ES under matched 2,048-token windows, and beats Gemini 2.5 Pro on everything except Chisel.
- Functional pass rates (
pass@1): On HLS, LoRA-tuned Qwen-14B hits 71.9%, edging out GPT-5 (68.0%). On VHDL, every proprietary model stays below 11%, while fine-tuned DS-5.7B and Qwen-7B reach 18.3%. On SystemVerilog, fine-tuned DS-5.7B and Qwen-14B tie Gemini 2.5 Pro at 40.0%. On Chisel, Gemini 2.5 Pro leads at 56.7% (with Qwen-14B at 33.4%). - Agents vs. local models: Evaluating the Aider coding agent yields a 6.0 percentage-point EM boost over the best fine-tuned local model, but at 10x the token cost.
Limitations and Future Work
The authors note several limitations: MHRC-Bench is built from open-source GitHub repositories, which may not reflect proprietary industry HDL practices. Its rule-based semantic labels can miss ambiguous design intent, and it currently excludes analog/mixed-signal design and physical-design scripts. Finally, while train/test splits are strictly separated, closed-source commercial models may have seen some public test repositories during pretraining. Looking ahead, the failure of software-tuned retrievers highlights a clear need for HDL-native retrievers built around hardware dependencies.
Summary updated