Skip to content

D148 — The router avoids KiCad's diff-pair coupling-gap errors

Context

D147 ported KiCad 10.0.6's diff-pair coupling test into the DRC, but not into the router. B1's RoyalBlue fixture with the USB pair profile (a 0.15 mm gap, so a rule with min = max = 0.15 mm) was left with five diff_pair_gap_out_of_range errors by KiCad. They sit at the USB-C connector, where the interleaved D+/D− pads are joined pad to pad and the halves leave in parallel before the pair forms. Rule 1 says nothing goes on the board without the exact check, and these errors broke it. Design: doc 05 §59. Records: bench/records/m21-b2/runs/couple-b1, couple-b2.

Decision

  • The coupling test is part of Obstacles::segment_state for a net whose partner exists and that has a non-ignored diff_pair_gap rule with a minimum or a maximum on the layer. A new track is coupled with each of the partner's tracks on that layer by drc::couple, with the same epsilon and the same visibility test as the DRC.
  • When the gap is out of range and the partner track was routed, it is rippable.
  • When the partner track is fixed copper, the track is blocked.
  • The search tests each lattice step of such a net as well. With the test only at commit, the router found the same path that the check then refused, and the USB connections failed with "exact check rejected the lattice path" (101 of 147 routed against 104).
  • The bounds are taken per net and layer from the last matching rule for a track of the net, as the DRC does. A rule that depends on the place is taken as it matches anywhere.
  • The visibility test ignores pad holes on layers that have none of the pad's copper. It may call a pair coupled that KiCad would call hidden, so it is stricter than KiCad, never looser.
  • Always on. Boards without such a rule skip the test entirely.

Alternatives

  • Commit check only: cheaper per step, but it lost three connections on RoyalBlue as described above.
  • A cost on the lattice for the partner's neighbourhood, the way pairs are steered towards their gap: it would not be exact, so the commit check would still be needed, and it would not cover the "nothing between" condition.
  • Route pairs as coupled pairs end to end: the right long-term answer for pairs, but much larger. It also would not cover the pad-to-pad stretches at the connector, where KiCad sees coupling before the pair forms.

Consequences

  • RoyalBlue with the profile still routes 104/147, with no gap errors (353 tracks against 349).
  • The other four B1 fixtures and the three B2 fixtures are identical to the runs before: routed counts, tracks, vias and added errors.
  • A unit test routes a pair whose pads are 2 mm apart under a 0.15–0.25 mm gap rule. With the rule ignored the straight tracks break it, and with the rule in force none do.
  • Cost: one coupling test per partner track on the layer, on each step of a pair net, and only on boards with a bounded gap rule.
  • Still open:
  • diff_pair_uncoupled is checked but not routed for.
  • Pairs are recognised by the last character only, unlike KiCad's MatchDpSuffix.
  • Doc 05 §59 has a new paragraph and a new results line, and its "Not done" item is removed.