af7c43b2a8
The Ti375 fanout could not be resolved with three routing layers, so L5 stops being a dedicated 1.8-V plane and becomes a signal layer. No rail owns a whole layer any more: the supplies are split into zone islands on L4 and L6, L2 and L7 stay solid and completely unrouted, and F.Cu, L3, L5 and B.Cu are all available for signals. Routing is staged rather than handed to the autorouter wholesale. The BGA escape, the buck high-current loops, plane stitching and the local power completion all run first and are locked; Freerouting then sees only the ordinary digital classes, with everything else present as fixed copper. finalize_routing.py installs the audited RF and USB geometry and closes whatever the autorouter left. Four bugs behind the routing failures, all of them the same shape - a layer list written down instead of read from the board, which was correct while L5 was a plane and silently wrong afterwards: - export_routing_stage.py emitted via keepouts for three layers only, so every existing via was invisible to the router on L5. It drove traces straight through them: 102 shorting_items in DRC. - route_local_power.py never used L5 at all, and picked up escape vias on two layers instead of all four. - add_rf_ground() judged fence positions against vias and pads but not tracks. It runs after the session import, when that region already has routed copper, and dropped a ground via on top of a signal trace. route_local_power.py also grew a via cloud on every rail: reaching a plane counted as progress even when it merged nothing, so the same pad collected a via per pass, 0.4 mm further out each time. Progress is now measured by the group count actually falling, and groups already sitting on their plane are skipped. That removed 404 redundant vias. The MAX2771 PLL loop filter was spread across three corners of the package, which forced the charge-pump node onto an inner layer under the GPS front end. All three parts now sit in the pocket at U21's north-west corner and the net stays on F.Cu. A permanent RF_NO_DIGITAL area plus a scoped rule keeps that region free of non-power copper on L3/L5/L6/B.Cu, and the local router enforces the same restriction, since it is the one stage that runs after the temporary keepout is deleted. Also enables the solder-mask bridge check that was switched off board-wide; the board passes it with no violations. Final board: DRC clean - no shorts, clearance, disallowed-item or dangling-copper violations - with 26 unconnected endpoints left. Routing is spread 37% L3, 27% F.Cu, 26% L5, 10% B.Cu over 6548 mm and 971 vias. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Optionally scale only DSN clearance entries by an explicit factor.
|
|
|
|
The bundled Freerouting 2.3.0 build reads KiCad 10 micrometre clearance values
|
|
directly, so the safe default is 1.0 (no scaling). This utility is retained for
|
|
reproducible experiments with other router builds; never apply a non-unity
|
|
factor without comparing the imported physical rule values first.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import re
|
|
from pathlib import Path
|
|
|
|
|
|
CLEARANCE = re.compile(r"(\(clearance\s+)(\d+(?:\.\d+)?)")
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("input", type=Path)
|
|
parser.add_argument("output", type=Path)
|
|
parser.add_argument("--factor", type=float, default=1.0)
|
|
args = parser.parse_args()
|
|
if args.factor <= 0:
|
|
raise ValueError("--factor must be positive")
|
|
|
|
source = args.input.read_text()
|
|
original = [float(match.group(2)) for match in CLEARANCE.finditer(source)]
|
|
if not original:
|
|
raise RuntimeError(f"No clearance rules found in {args.input}")
|
|
|
|
def scale(match: re.Match[str]) -> str:
|
|
value = float(match.group(2)) * args.factor
|
|
rendered = str(int(value)) if value.is_integer() else f"{value:g}"
|
|
return match.group(1) + rendered
|
|
|
|
converted, count = CLEARANCE.subn(scale, source)
|
|
scaled = [float(match.group(2)) for match in CLEARANCE.finditer(converted)]
|
|
assert count == len(original) == len(scaled)
|
|
assert all(after == before * args.factor
|
|
for before, after in zip(original, scaled, strict=True))
|
|
# A conversion must never touch the board geometry or trace-width rules.
|
|
assert source.count("(width ") == converted.count("(width ")
|
|
assert source.count("(polygon ") == converted.count("(polygon ")
|
|
args.output.write_text(converted)
|
|
print(f"Scaled {count} clearance rules by {args.factor:g}x")
|
|
print(f"Saved {args.output}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|