Custom Design Rules not properly integrated with interactive router
Description
The Custom Design Rules are not properly checked when interactively routing, resulting in many situations where the router will output tracks that violate the DRC. This has been debugged in a separate thread and found to be down to one core issue relating to how updateSizesAfterLayerSwitch is implemented and used (see related issue that specifically regarded layer switching).
Test Setup
A differential pair with a netclass: (0.1mm track width, 0.1mm clearance, 0.1mm differential pair gap) A custom rule sheet with two rules: A Normal rule: (0.3mm track width, 0.3mm clearance, 0.3mm differential pair gap) A Fanout rule: (0.2mm track width, 0.2mm clearance, 0.2mm differential pair gap)
(version 1)
(rule "Normal"
(condition "A.Type == 'Track'")
(constraint track_width (min 0.3mm) (opt 0.3mm) (max 0.3mm))
(constraint diff_pair_gap (min 0.3mm) (opt 0.3mm) (max 0.3mm))
(constraint clearance (min 0.3mm)))
(rule "Fanout"
(condition "A.Type == 'Track' && A.intersectsArea('Fanout')")
(constraint track_width (min 0.2mm) (opt 0.2mm) (max 0.2mm))
(constraint diff_pair_gap (min 0.2mm) (opt 0.2mm) (max 0.2mm))
(constraint clearance (min 0.2mm)))
Test A
Starting a Differential Pair Routing from a pair of pads
Result: Only NetClass values are respected, though clearances look to be ok - cannot verify this completely.
Test B
Starting a Differential Pair Routing from a pair of vias, and then using + followed by - to switch layers
Result: After the update, track width and differential pair gap update to the correct value. Clearances are mixed, for a GND via it keeps the 0.3mm clearance, but as the screenshot shows, this is not the case for the pads.
Test C
Starting a Differential Pair Routing from a pair of vias within the 'Fanout' area, and then using + followed by - to switch layers
Result: Routed using the "Normal" rule, and only after routing recognised in the toolbar as part of the "Fanout" rule.
Result
My interpretation is as follows:
Test A fails to check the custom rules when starting a new routing job. Without the "copy current track" button toggled, this should use the custom rules over the NetClass (since you cannot otherwise disable the NetClass values). Alternatively a new option "use custom rules" should be in place for Tracks, Vias, and Differential Pair selection.
Test B shows that updateSizesAfterLayerSwitch
can do that, so it stands to reason it should be called whenever a routing is started. It also shows that since it does not update the clearance, only track width and differential pair gap, even updateSizesAfterLayerSwitch
is not correct yet and can cause clearance rule violations while routing.
Test C shows that updateSizesAfterLayerSwitch
does not respect the area rules. This seems to be due to it's implementation only setting a dummy track to check DRC rules against in the relevant layer, but not in the relevant location.
Solution
updateSizesAfterLayerSwitch
needs to be called in appropriate locations, and updated to update all values relevant to the routing job, according to the current local situation. Possibly it should use the last drawn track itself as the dummy track to handle edge cases where the starting point is outside a rule area, but the end point is in one, resulting in the DRC applying (e.g. with intersectsArea
) than the router assumes.
This ofc shouldn't be done repeatedly, especially since a different ruleset could result in a different route, potentially resulting in oscillations.
KiCad Version
Application: KiCad PCB Editor x86_64 on x86_64
Version: 7.0.6, release build
Libraries:
wxWidgets 3.2.2
FreeType 2.12.1
HarfBuzz 5.2.0
FontConfig 2.14.1
libcurl/7.86.0-DEV OpenSSL/3.0.9 zlib/1.2.13 nghttp2/1.55.0
Platform: Linux 6.1.44-1-MANJARO x86_64, 64 bit, Little endian, wxGTK, KDE, wayland
Build Info:
Date: Aug 12 2023 15:50:53
wxWidgets: 3.2.2 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.83.0
OCC: 7.7.2
Curl: 7.86.0-DEV
ngspice: 40
Compiler: GCC 12.2.0 with C++ ABI 1017
Build settings:
KICAD_SPICE=ON