First the small text: the rule syntax WILL CHANGE. What’s there today is a PROTOTYPE. There will be NO TOOLS for migrating today’s rules to later rules. Think of it as a sandbox, not a work-in-progress.
But I’d still like to get some feedback on what it does well, what it does poorly, and what is missing.
If you’ve never use a nightly, our built from scratch, this probably isn’t for you. But if you have…
The rules go in a file in your project named “drc-rules”. You can edit them there in your favourite text editor, or you can edit them in Board Setup > Design Rules > Rules and let Kicad worry about the name, location, etc.
The rule file is in sexpr. The top level is a list; the first expression must be (version x)
followed by any number of (selector…)
and (rule…)
expressions.
Selectors determine what to apply rules to; rules enforce minimums.
Match tokens:
match_netclass
match_type
match_layer
match_all
match_area (not yet implemented with the exception of “$board”, which matches everything)
(selector (match_area "$board") (rule "OSHParkClass3") (priority 100))
(selector (match_netclass "HV") (rule "HV_internal"))
(selector (match_netclass "HV") (match_layer "F_Cu") (rule "HV_external"))
(selector (match_netclass "HV") (match_layer "B_Cu") (rule "HV_external"))
(selector (match_netclass "HV") (match_netclass "HV") (rule "HV2HV"))
(selector (match_netclass "HV") (match_netclass "HV") (match_layer "F_Cu") (rule "HV2HV_external"))
(selector (match_netclass "HV") (match_netclass "HV") (match_layer "B_Cu") (rule "HV2HV_external"))
TODO: pads for connector pins or wire pads have even larger required creepage clearances. How to encode?
User attributes on parent footprint?
(selector (match_netclass "HV") (match_type "pad") (match_netclass "HV") (match_type "pad") (rule "pad2PadHV"))
(selector (match_netclass "signal") (match_area "BGA") (rule "neckdown"))
Type tokens:
track
via
micro_via
blind_via
pad
zone
text
graphic
board_edge
hole
npth
pth
Rule tokens:
allow (not yet implemented)
clearance
annulus_width
track_width
hole
Rule modifiers:
relaxed
(rule "HV" (clearance 200))
(rule "HV_external" (clearance 400))
(rule "HV2HV" (clearance 200))
(rule "HV2HV_external" (clearance 500))
(rule "pad2padHV" (clearance 500))
(rule "signal" (clearance 20))
(rule "neckdown" (clearance relaxed 15))
(rule "allowMicrovias" (allow microvia))