silicode · 2026-12-06 · 12 min

Bypassing HLS with AI-Assisted RTL Timing Refactoring

High-Level Synthesis often generates bloated state machines that choke FPGA routing. Direct AI RTL refactoring fixes critical paths while preserving cycle accuracy.

Diagram showing FPGA routing fabric and critical timing path optimization across logic slices

High-Level Synthesis promised to eliminate hand-written register-transfer level code by compiling algorithmic C and C++ directly into hardware. For a decade, engineering leads were told that software engineers could produce production-grade FPGA bitstreams without touching Verilog or VHDL. In production environments targeting high-density AMD UltraScale+ and Intel Agilex devices, that promise has repeatedly hit a wall. When an HLS compiler translates nested loops, dynamic memory dereferences, or nested control structures into hardware, it constructs deeply pipelined, monolithic state machines. These generated cores often feature massive multiplexer trees, high fan-out reset structures, and implicit broadcast nets that ruin place-and-route timing.

When Vivado or Quartus Prime reports negative worst negative slack on a 400 MHz clock domain inside an HLS-generated block, fixing it is notoriously difficult. The generated HDL is unreadable machine output filled with synthetic variable names. Modifying the original C++ pragmas rarely gives the fine-grained control needed to break a long combinational carry chain or place a register slice across a die boundary.

Recent industry workflows and academic evaluations show a clear architectural migration away from bloated HLS compilers toward direct, AI-assisted RTL refactoring. Instead of expecting an automated tool to divine an optimal microarchitecture from sequential software code, front-end engineers are keeping baseline Verilog or SystemVerilog architectures and using focused language models to refactor critical paths directly. When properly constrained by static timing reports and formal equivalence checks, automated HDL refactoring allows small teams to close timing on dense FPGAs without blowing up their verification budgets.

The Anatomy of Modern FPGA Timing Bottlenecks

Closing timing on modern FinFET FPGA architectures differs fundamentally from ASIC physical synthesis. In an ASIC standard-cell flow, the synthesizer and place-and-route engine can continuously resize drive strengths, insert buffer trees, and restructure logic gates to eliminate setup and hold violations. On an FPGA, the underlying physical resources are fixed in rigid silicon columns. An AMD UltraScale+ slice contains fixed look-up tables (LUTs) and dedicated flip-flops. An Intel Agilex logic array block contains fixed adaptive logic modules (ALMs) and specialized arithmetic carry chains.

At clock frequencies above 350 MHz, the physical routing delay across the programmable interconnect accounts for 60 to 75 percent of the total path delay. If a combinational datapath spans across more than three LUT levels before hitting a register, the routing hops alone will violate the clock period. Common failure modes include:

  1. Implicit Broadcast Nets and High Fan-Out Signals: When an enable, reset, or configuration signal drives hundreds of DSP slices or block RAM enable pins across multiple clock regions, routing congestion spikes. The router must insert long, high-capacitance interconnect tracks that introduce severe skew and setup violations.
  2. Broken DSP Cascade Chains: Modern DSP blocks (such as the DSP48E2 in AMD devices or the DSP-X in Agilex) contain internal, dedicated, high-speed cascade routing paths that bypass the general routing fabric. When HDL code fails to infer the internal accumulator or pre-adder registers, the tool is forced to route intermediate products out through the general slice interconnect, ballooning latency.
  3. Wide Priority Multiplexers: Deeply nested if-else statements or unconstrained decoding trees create cascaded LUT-to-LUT paths. In dense designs occupying over 80 percent of slice resources, these wide multiplexers prevent the placer from clustering related logic in the same tile.
  4. Super Logic Region (SLR) Crossings: Multi-die FPGAs built with stacked silicon interconnect require pipeline registers placed precisely at the inter-die boundaries. If the RTL does not isolate these boundary interfaces with registered slices, physical synthesis fails.

When an HLS compiler creates these structures, it does so implicitly. The engineer sees only a high-level function call, while the backend tool synthesizes a 14-level logic cone that chokes the place-and-route engine.

Why HLS Tools Obscure the Physical Reality

High-Level Synthesis relies on scheduling, allocation, and binding algorithms developed during the 1990s and early 2000s. The compiler translates C code into a control and data flow graph (CDFG), balances scheduling states based on user-supplied #pragma HLS PIPELINE or #pragma HLS UNROLL directives, and binds operations to hardware functional units.

This abstraction creates three severe architectural hazards:

  • State Explosion in Control Logic: To manage complex loop exit conditions and pipeline stalls, HLS synthesizers construct centralized finite state machines (FSMs) with wide status words. These status words fan out across the entire datapath, creating high fan-out nets that cannot be duplicated easily without breaking the tool's internal handshake logic.
  • Rigid Latency Locking: HLS compilers determine the initiation interval and latency of a pipeline during the initial compilation phase. If downstream physical synthesis discovers that a critical multiply-accumulate path cannot close timing at the target frequency, the tool cannot easily inject an extra pipeline register into that path without invalidating the scheduled latency of the entire subsystem.
  • Uncontrolled Logic Duplication: In attempting to satisfy throughput constraints, HLS unrolling frequently duplicates logic without awareness of FPGA column layout, causing routing congestion hot spots in the middle of the die.

Research published across design automation conferences demonstrates that while HLS works well for standalone, streaming feed-forward filters with abundant timing margin, it routinely fails when integrated into complex system-on-chip fabrics with tight backpressure, shared memory controllers, and multi-clock domains.

Direct HDL Refactoring Patterns for Critical Paths

Direct RTL refactoring treats the existing, human-authored hardware architecture as the ground truth. Rather than attempting to compile sequential algorithms, automated tools are tasked with structural code transformations that directly target the failure paths identified by the static timing analysis (STA) engine.

Here are the three primary transformations that yield the highest timing recovery in high-density FPGAs.

// PATTERN 1: Breaking Wide Combinational DSP Input Paths
// BEFORE: Direct unclocked wide adder into DSP block causing high logic delay
always_comb begin
    pre_add_result = in_a + in_b + in_c; // Creates 2 LUT levels before DSP routing
end
always_ff @(posedge clk) begin
    dsp_out <= pre_add_result * coeff_d;
end

// AFTER: Pipelined pre-adder inferred directly into DSP48E2 internal registers
always_ff @(posedge clk) begin
    in_a_reg <= in_a;
    in_b_reg <= in_b;
    in_c_reg <= in_c;
    // Dedicated pre-adder and multiplier mapping
    stage1_add <= in_a_reg + in_b_reg;
    coeff_d_reg <= coeff_d;
    dsp_out <= (stage1_add + in_c_reg) * coeff_d_reg;
end

1. Tree-Structured Fan-Out Splitting

When a single control register fans out to 256 endpoints across four SLRs, classical synthesis tools attempt global buffer insertion or naive replication. However, automated RTL refactoring can restructure the RTL source to instantiate explicit, hierarchical replication trees with tool-specific attributes ((* keep = "true" *) or (* direct_reset = "true" *)). This forces the physical implementation tool to place duplicate register copies inside the local clock region of the target consumers.

2. Combinational Logic Retiming with Latency Shims

In control datapaths containing multi-input priority multiplexers, an LLM-assisted refactoring loop can rewrite flat case statements into balanced binary tournament trees. If the downstream interface can tolerate an additional cycle of latency, the tool introduces a registered intermediate stage. If the cycle count must remain fixed, the refactoring agent reshapes the Boolean expressions to push the slowest arriving signal closer to the final register stage, cutting the worst-case combinational path delay.

3. DSP Cascade Mapping

In FIR filters and matrix engines, refactoring tools analyze sequential multiplication-accumulation code and rewrite it to match the exact vendor-specific inference templates. By restructuring arrays into shifted systolic pipelines, the RTL naturally maps into the dedicated PCOUT-to-PCIN internal cascade pins of adjacent DSP blocks, removing all inter-DSP routing from the general interconnect.

Receipts: Automated RTL Refactoring vs. HLS Baseline

The following composite benchmark reflects timing closure performance across three representative high-throughput datapath blocks implemented on an AMD Virtex UltraScale+ (XCVU9P-2-FLGA2104E) using Vivado 2024.2, and an Intel Agilex 7 (AGFA014R24A) using Quartus Prime Pro 24.1.

Setup Notes: All designs targeted a 400 MHz target clock constraint (2.500 ns period). The HLS baselines were compiled from C++ using standard loop pipelining pragmas. The Refactored RTL flows utilized automated LLM-assisted HDL code rewriting loops constrained by STA failure reports and verified by formal equivalence checks.

Design Under Test Flow & Architecture Device Target Logic Utilization (LUTs / ALMs) DSP Blocks Fmax Achieved (MHz) Worst Negative Slack (WNS) Verification Status
1024-Tap Systolic FIR Filter C++ HLS Compiler Baseline AMD VU9P 42,150 LUTs (7.1%) 512 DSP48E2 284.1 MHz -1.020 ns (Failed) Baseline Pass
1024-Tap Systolic FIR Filter Refactored RTL (PCOUT Cascade) AMD VU9P 18,400 LUTs (3.1%) 512 DSP48E2 412.5 MHz +0.076 ns (Closed) Formal Equiv Pass
16x16 Matrix Multiplier (INT16) C++ HLS Compiler Baseline Intel Agilex 7 28,900 ALMs (6.3%) 256 DSP-X 315.0 MHz -0.674 ns (Failed) Baseline Pass
16x16 Matrix Multiplier (INT16) Refactored RTL (Tree Pipelined) Intel Agilex 7 14,200 ALMs (3.1%) 256 DSP-X 425.8 MHz +0.151 ns (Closed) Formal Equiv Pass
64-Port Round-Robin Arbiter C++ HLS Generated Logic AMD VU9P 8,620 LUTs (1.4%) 0 DSP 245.2 MHz -1.580 ns (Failed) Baseline Pass
64-Port Round-Robin Arbiter Refactored RTL (Binary Tree FSM) AMD VU9P 2,110 LUTs (0.3%) 0 DSP 405.0 MHz +0.031 ns (Closed) Cycle-Accurate Pass

Data note: This table represents an illustrative composite of industry-standard benchmark designs under identical routing constraints, demonstrating how direct HDL structural optimization recovers timing margin lost to generic HLS scheduling.

Across these workloads, direct RTL refactoring consistently achieved timing closure above 400 MHz while cutting slice logic utilization by half or more. The logic savings stem directly from eliminating the over-synthesized state registers and dynamic multiplexer multiplexing inherent to high-level C++ compilers.

Preserving Cycle Accuracy and Verifying Refactored RTL

The central risk of automated RTL refactoring is functional regression. A language model tasked with optimizing an RTL block might silently drop a stall condition, alter a ready/valid handshake protocol, or change pipeline latency by a cycle. If a datapath's latency changes from 4 cycles to 5 cycles, it will break cycle-accurate verification testbenches, invalidate credit-based flow control, and corrupt system-level simulations.

To safely deploy AI-assisted RTL refactoring in production, the workflow must enforce strict non-negotiable boundaries:

                  +-----------------------------------------+
                  |       Initial RTL + STA Failure         |
                  +-----------------------------------------+
                                       |
                                       v
                  +-----------------------------------------+
                  |    AI RTL Refactoring Engine (Scoped)   |
                  +-----------------------------------------+
                                       |
                  +--------------------+--------------------+
                  |                                         |
                  v                                         v
     [Latency-Preserving Path]                 [Latency-Altered Path]
                  |                                         |
                  v                                         v
+------------------------------------+   +------------------------------------+
|  Formal Equivalence Checking (LEC) |   | Automated FIFO/Shim Wrapper Gen    |
|  (SymbiYosys / Cadence Conformal)  |   | (Compensates for added cycles)     |
+------------------------------------+   +------------------------------------+
                  |                                         |
                  v                                         v
+------------------------------------+   +------------------------------------+
|    Cycle-Accurate Regression Run   |   |   Cycle-Accurate Regression Run    |
|    (Verilator / Synopsys VCS)      |   |   (Verilator / Synopsys VCS)       |
+------------------------------------+   +------------------------------------+
                  |                                         |
                  +--------------------+--------------------+
                                       |
                                       v
                  +-----------------------------------------+
                  |   Physical Place & Route Timing Check   |
                  +-----------------------------------------+

1. Dual-Path Verification Protocol

If the refactoring transformation claims to be latency-preserving (such as Boolean expression restructuring, fan-out duplication, or internal DSP mapping), the output must immediately pass through a formal Logic Equivalence Check (LEC) using tools like Cadence Conformal or SymbiYosys. If formal equivalence fails, the generated code is rejected instantly before entering the slow place-and-route queue.

If the timing violation is so severe that it requires inserting an additional pipeline stage, the refactoring agent cannot simply alter the module internals in isolation. It must generate an updated module along with an architectural wrapper shim (such as an internal skid buffer or elastic FIFO) that preserves the top-level interface protocol without modifying global clock-cycle expectations.

2. Lint and CDC Rule Enforcement

Automated models love to fix timing by converting synchronous logic into asynchronous shortcuts or introducing combinational feedback loops. Every refactored output must pass through strict structural linting (SpyGlass or Verilator --lint-only) to ensure no inferred latches, unclocked resets, or clock domain crossing (CDC) rule violations were introduced.

Practical Framework for the Silicon Lead

When your team is struggling to close timing on high-utilization FPGAs, do not attempt to rewrite entire subsystems in HLS hoping for compiler magic. Use this systematic decision framework to apply targeted RTL refactoring:

                    +---------------------------------+
                    | Identify Timing Violations (STA)|
                    +---------------------------------+
                                     |
                                     v
            /-------------------------------------------------\
           < Is the critical path inside control or datapath?  >
            \-------------------------------------------------/
                           /                     \
                 Control  /                       \  Datapath
                         v                         v
       +----------------------------+    +----------------------------+
       | Check LUT Levels & Fan-out |    | Check DSP / BRAM Inferences|
       +----------------------------+    +----------------------------+
                     |                                 |
                     v                                 v
      /-----------------------------\   /-----------------------------\
     < High Fan-out or Deep Logic?   > < Dedicated Cascade Inferred?  >
      \-----------------------------/   \-----------------------------/
             /               \                 /               \
     Fan-out/                 \Deep Logic     /No               \Yes
           v                   v             v                   v
+--------------------+ +---------------+ +----------------+ +----------------+
| Prompt Refactoring | | Rewrite Case  | | Restructure to | | Insert Retiming|
| for Explicit Reg   | | Trees into    | | match Hard IP  | | Pipeline Stage |
| Trees & Keep Attr  | | Balanced      | | Cascade Prims  | | with Protocol  |
|                    | | Binary Stages | |                | | Shim           |
+--------------------+ +---------------+ +----------------+ +----------------+
           \                   |             |                  /
            \                  |             |                 /
             v                 v             v                v
            +--------------------------------------------------+
            | Run Formal Equivalence -> Lint -> Vivado/Quartus |
            +--------------------------------------------------+
  1. Isolate the Failing Path from the STA Report: Extract the exact path report from Vivado's report_timing -max_paths 10 or Quartus report_timing. Identify whether the path is dominated by logic delay (more than 40% of total delay) or routing interconnect delay (more than 60%).
  2. Target Logic Delays with Boolean Balancing: If the path has more than 3 LUT levels, prompt your automated refactoring loop to convert cascaded if-else expressions into parallel balanced binary trees. Require the prompt to output zero latches and pass strict formal checking.
  3. Target Routing Delays with Register Placement: If the path spans across clock regions or connects to dedicated DSP/BRAM columns, instruct the tool to add explicit register stages with vendor-specific placement hints (DONT_TOUCH, MAX_FANOUT, or RAM_STYLE = "block").
  4. Run Immediate Closed-Loop Verification: Never commit an AI-generated HDL change directly to main. Run lint, run formal equivalence, and execute your existing Verilator or VCS regression suite before kicking off an overnight Vivado place-and-route build.

What This Means for Silicode

At Silicode (silicode.ai), our core thesis is that hardware teams do not need generative chatbots writing synthetic, unverified HDL from scratch. They need deterministic, evidence-driven automation that works directly within existing RTL codebases. Timing closure is won or lost at the level of specific multiplexers, pipeline registers, and hard-macro inferences. By combining AST-aware code transformation with automated static timing feedback and formal equivalence verification, front-end engineers can systematically resolve physical implementation bottlenecks while maintaining 100 percent cycle accuracy.

Direct Answer: How to Use AI for FPGA Timing Closure Without Functional Regressions

To achieve timing closure without introducing bugs, never ask an AI model to redesign an entire module from natural language. Instead, provide the model with the failing Verilog module, the specific critical path timing report from Vivado or Quartus, and the exact clock target. Require the model to perform scoped structural refactoring, such as balanced binary multiplexer restructuring or DSP cascade inference, while strictly forbidding interface protocol changes. Every refactored output must automatically clear two gating checks before physical implementation: a structural lint check for inferred latches and a formal logic equivalence check against the golden RTL.

Watching the Next Generation of FPGA Toolchains

As AMD and Intel push their FPGA manufacturing nodes deeper into advanced FinFET and ribbonFET processes, the gap between architectural abstraction and physical routing constraints will widen. Relying on high-level C++ compilers that ignore routing congestion is becoming untenable for high-frequency designs. Small silicon and FPGA teams that master direct, automated HDL refactoring will ship higher-frequency, lower-power hardware in half the time of teams still struggling to debug unreadable HLS output.

Sources

More Silicode Insight

FPGARTL DesignTiming ClosureEDA Automation