HDLFORGE: A Two-Stage Multi-Agent Framework for Efficient Verilog Code Generation with Adaptive Model Escalation

HDLFORGE is a two-stage multi-agent framework that optimizes the trade-off between Verilog generation speed and accuracy by defaulting to a medium-sized LLM and escalating to a stronger model only when necessary, while leveraging a counterexample-guided formal agent to efficiently detect and repair bugs.

Armin Abdollahi, Saeid Shokoufa, Negin Ashrafi, Mehdi Kamal, Massoud Pedram

Published 2026-03-06
📖 4 min read☕ Coffee break read

Imagine you are trying to build a complex Lego castle based on a vague description from a friend. You have two types of builders available:

  1. The Fast Apprentice: A quick, cheap, and energetic builder who can throw together ideas fast but sometimes makes small mistakes or misses details.
  2. The Master Architect: A brilliant, highly experienced expert who builds perfect structures but is slow, expensive, and only available for a short time.

HDLFORGE is a smart management system that figures out how to use these two builders to get the best castle possible without wasting money or time.

Here is how the system works, broken down into simple steps:

1. The Two-Stage Strategy (The "Apprentice First" Rule)

Most systems either hire the Master Architect for every job (which is too slow and expensive) or stick with the Fast Apprentice forever (which leads to a wobbly castle).

HDLFORGE uses a Two-Stage Approach:

  • Stage A (The Apprentice): The system starts by asking the Fast Apprentice (a medium-sized AI) to build the Verilog code (the "blueprint" for a computer chip). It tries to fix its own mistakes using quick, cheap checks.
  • Stage B (The Master Architect): The system only calls in the Master Architect (a huge, powerful AI) if the Apprentice is clearly stuck or if the blueprint looks too dangerous. This ensures you only pay the "Master's fee" when absolutely necessary.

2. The "Smell Test" (The Escalation Controller)

How does the system know when to call the Master? It doesn't just guess. It uses a Calibrated Score, like a dashboard in a car.

Before asking for help, the system runs a series of quick "smoke tests" (like checking if the engine starts, if the lights work, and if there are any weird noises).

  • If the score is good, the Apprentice keeps working.
  • If the score is bad (e.g., the code won't compile or has too many errors), the system says, "Okay, the Apprentice is stuck. Time to call the Master."

This is the "Adaptive Escalation." It's like a manager who lets a junior employee try to solve a problem first, but immediately steps in with a senior expert if the junior is spinning their wheels.

3. The "Bug Hunter" (The Formal Agent)

This is the paper's coolest trick. When the Apprentice makes a mistake, the system doesn't just say "Fix it." It uses a special tool called a Counterexample-Guided Formal Agent.

Think of this as a Time-Traveling Detective:

  • When the Apprentice builds a wall that falls down, the Detective looks at exactly why it fell.
  • Instead of just fixing that one wall, the Detective writes a tiny, reusable "trap" (a micro-test) that catches that specific type of falling wall forever.
  • If the Apprentice tries to build the same bad wall again later, the trap snaps shut immediately, saving time.

This turns a single failure into a permanent lesson, so the system learns faster and makes fewer mistakes over time.

4. The Results: Fast, Cheap, and Accurate

The researchers tested this on three major benchmarks (like standardized tests for chip design). Here is what they found:

  • Speed vs. Accuracy: They got the best of both worlds. They were almost as accurate as using the Master Architect for every single task, but they finished the job 50% faster on average.
  • Portability: The "Manager" (the escalation controller) is so smart it can be attached to any existing AI coding system. It's like a universal remote control that can upgrade any old TV to a smart TV without needing to rebuild the TV itself.
  • Bug Detection: Because of the "Time-Traveling Detective" (the micro-tests), the system found and fixed bugs much faster than other methods, especially tricky ones like reset errors or logic loops.

The Big Picture

HDLFORGE is like a smart factory manager. It knows that not every problem requires a PhD-level engineer. It lets the junior staff try first, uses quick checks to see if they are struggling, and only brings in the expensive experts when needed. Plus, it keeps a "lesson learned" book for every mistake so the team gets smarter with every single project.

The result? We get high-quality computer chip designs faster and cheaper than ever before.