🎯Constraint Debug: Is the DUT Wrong, or Did the Testbench Ask for the Impossible?

A failed regression can lead you straight to a waveform window. Sometimes the useful clue is earlier, in the sequence that was supposed to create the request.

EDA Academy

🎯Constraint Debug: Is the DUT Wrong, or Did the Testbench Ask for the Impossible?

A failed regression can lead you straight to a waveform window. Sometimes the useful clue is earlier, in the sequence that was supposed to create the request. At EDA Academy, we’ll use one AXI4 case to follow that clue from the constraint solver to the interface and then into functional coverage.

1. Start with the failed call

Imagine a test for an aligned AXI4 INCR read on an interface that supports 16 bytes per beat. The sequence asks for four beats starting at 0x0FF0. For this aligned burst, the last byte is the start address plus the total number of bytes minus one.

  • The request covers 0x0FF0 through 0x102F.

  • The first beat ends at 0x0FFF.

  • The remaining three beats would lie beyond the 0x1000 boundary.

AXI4 prohibits an individual burst from crossing a 4 KB address boundary. If a transaction constraint enforces that rule and an inline constraint pins both the address and length, the three requirements have no common solution.

In class-based SystemVerilog randomization, randomize() returns zero on failure. The random variables retain their prior values and post_randomize() is skipped. A reused object can therefore still have a valid-looking address and length. If the sequence submits it, there may even be bus activity. Use the return value and the monitor trace together to tell whether that activity belongs to the request under investigation.

2. Reproduce it with one item

This standalone SystemVerilog example models aligned, 16-byte INCR reads in the first 4 KB region and restricts the beat count to 1–4 for the example.

class aligned_read;
  rand int unsigned addr;
  rand int unsigned beats;

  constraint c_shape {
    addr inside {[32'h0000_0000:32'h0000_0FFF]};
    addr[3:0] == 4'h0;
    beats inside {[1:4]};
  }

  constraint c_page {
    (addr[11:0] + 32'd16 * beats) <= 32'd4096;
  }
endclass

module constraint_debug_demo;
  initial begin
    aligned_read req;
    req = new();

    if (req.randomize() with {
          addr == 32'h0000_0FF0;
          beats == 4;
        })
      $fatal(1, "Expected the boundary-crossing solve to fail");

    if (!req.randomize() with {
          addr == 32'h0000_0FC0;
          beats == 4;
        })
      $fatal(1, "Expected the boundary-ending solve to pass");

    $display("addr=0x%08h beats=%0d", req.addr, req.beats);
  end
endmodule

The first call is expected to fail and the second is expected to succeed. The page check uses an exclusive end offset, so an end offset of 4096 is legal. On the AXI interface, the corrected four-beat request uses ARLEN = 3 and ARSIZE = 4, assuming those fields are present as in the example. The SystemVerilog variable beats is the transfer count.

  • If the test intent is to start at the last aligned address in the page, keep 0x0FF0 and request one beat.

  • If the intent is to land exactly on the boundary with four beats, keep the length and move the address to 0x0FC0.

Both bursts end at byte 0x0FFF.

3. Find out which constraints were active

Save the simulator version and options, test and seed, effective item type, and the values used by the failing call.A factory override can change the concrete item type, and an inline with clause can add restrictions that are absent from the class definition.

Check which named constraint blocks are enabled and which fields are fixed. A field disabled via rand_mode still participates as a fixed value in any active constraints that refer to it. Also look at what pre_randomize() does before the solve.

In a minimal reproducer, vary one input or constraint group at a time. Changing the address alone resolves our conflict and keeps the four-beat test intent.

  • A scenario default can be soft where the design of the generator calls for an override.

  • Keep the protocol legality rule hard for legal traffic.

  • Keep any deliberate protocol-negative tests in a clearly separate path with their own expected outcomes.

In the real sequence, handle failure explicitly. Include enough information in the diagnostic to replay the call. Use a failure path that prevents that item from being submitted and follows the testbench’s sequencer and test termination conventions.

4. Separate legal traffic from useful traffic

Once the solve is fixed, an always-ready read test can pass without ever presenting the DUT with read-data backpressure.

  • On the AXI R channel, a stall is sampled at a rising ACLK edge with RVALID high and RREADY low.

  • A transfer is sampled when both are high.

For a stalled beat, check that the source holds RVALID and the applicable payload and control signals stable until acceptance. If you target a last-beat stall, confirm RLAST was asserted on the stalled beat and that the beat later transferred.

The address distribution can hide a different gap. In one full 4 KB region, our fixed four-beat, 16-byte aligned burst has 253 legal aligned start positions. Only one of them lands on the region’s final byte. Under an ideal uniform draw over those 253 starts, the exact-end case gets about 0.4% of samples. That number describes the simplified example. In an actual test, memory-map restrictions, conditional constraints, explicit weighting, and solver ordering can alter what you observe.

Review the values admitted by each dist expression and the weights it assigns. A broad range or attractive weight on a common case says little about how often a specific address and burst length appear together. For a must-hit condition, a directed sequence gives you a repeatable attempt. The monitor tells you whether the attempt reached the interface.

5. Put the coverage where the behavior happens

  • Count successful solves in the sequence for debug.

  • Sample accepted AXI read requests in the monitor at ARVALID && ARREADY on the active edge.

  • From the observed fields, record burst length and classify whether the last byte is at the 4 KB edge or inside the region for this aligned INCR case.

  • Use a cross to see whether the four-beat exact-end combination occurs.

Track stalls on the read-data channel and associate them with the corresponding burst. In a replay with one outstanding read, the association is simple. In a concurrent regression, use the monitor’s per-ID transaction tracking and the applicable ordering rules. If the test plan calls for a four-beat exact-end burst with a stall on RLAST, record that combination only when the monitor observes it on the same burst.

Here is a coverage comparison you can try.

  • Baseline. Allow the legal address range and hold RREADY high. Record accepted four-beat exact-end bursts and last-beat stalls separately.

  • Targeted run. Send the four-beat burst at 0x0FC0 and deliberately introduce read-data backpressure on the last beat. Require the monitor to confirm both conditions on the same burst.

  • Debug an empty bin. Check generation, driver filtering, handshake observation, and coverage sampling before you adjust the weights.

6. Decide when the evidence points to RTL

Replay the legal request with a known memory pattern and a clearly defined configuration. Confirm the address handshake and reconstruct the response from the accepted beats. Check the ID, beat count, RLAST, response status, and expected data as applicable.

For example, if RLAST is asserted on the third accepted beat of the only outstanding four-beat read, the waveform gives you a specific event to investigate. If the waveform shows four correct beats and the scoreboard reports three, check the monitor and the expected-response model first.

For the next failing seed, ask four questions.

  1. Did the solve succeed for this item?

  2. Did the intended legal request handshake at the interface?

  3. Did the observed traffic exercise the planned scenario?

  4. Does the observed response match an expectation you can justify independently?

These checks give the sequence owner, testbench owner, and RTL owner the same evidence to work from.


Download PDF

Comments