Rule evaluation order - priorities compared to the Board Setup "Constraints and netclasses"

Yes, that specific condition is equivalent to not having any condition at all, I think.

But while this particular example doesn’t make much sense, the wildcards are part of a general system where for example you could say (condition "A.Type == 'Text*'") which would match both text objects and textbox objects. Or you could move beyond Type and say something like (condition "A.NetName == 'usb*'") to match all of your USB nets.

So while, yes, the wildcards don’t make a lot of sense in every situation, they can be used anywhere in the system, and some places you do want them.

(I agree with you that the wildcards aren’t very useful for Type, the text example I gave is the only useful one I can come up with)

Your last rule worked fine for me in your project (once I edited it to take out the Type constraint)

image

(rule "net to net clearance example"
(condition "A.NetName == '/A' && B.NetName=='/B'")
(constraint clearance (min 1.5mm)))

I tested quickly with v8.0.0-RC. I changed the last rule, made the clearance to min 15 to make it easier to catch, and removed the unnecessary type comparison. It’s now


(rule "net to net clearance example"
(condition "A.NetName == '/A' && B.NetName=='/B'" )
(constraint clearance (min 15mm)))

and it seems to work as expected. I select track segments of A and B and use Inspect → Clearance Resolution, and it tells that the rule matches and the clearance is 15mm.

EDIT: I’m not sure if this has been mentioned already, but you can see the authoritative net names here:

1 Like

Rules systems are hard. Altium’s rule definition systems have been a mess for as long as I can remember and I dont recall anything better .
In this specific case, I’d expected to be able to use :

(rule "net to net clearance example"
(condition "A.NetName == '/A' && B.NetName =='/B'  && AB.Type=='*' ")
(constraint clearance (min 1.5mm)))

But it says AB. isnt applicable (syntax error) .
so this should work

(rule "net to net clearance example"
(condition "A.NetName == '/A' && B.NetName=='/B'  && A.Type=='*' && B.Type=='*' " )
(constraint clearance (min 1.5mm)))

but doesnt capture it.

OH BUT IT DOES - see next post

Right, so this is probably a bit hard .
you can see on the screen shot, the traces are showing the minimum clearance.
image

But the when I try and drag it, yes, the rule is in action.

IE click on one trace, it gives me the rule minimum clearance, 0.125mm.

If I click on the A net trace and the B net trace, and choose Constraint Resoluton , it gives me something I do not understand just yet :


Checking rule 'net to net clearance example' clearance: 1.5000 mm.
Checking rule condition "A.Net == 'A' && B.Net=='B' && A.Type=='*' && B.Type=='*'".
ERROR: Type mismatch between 3.000000 and 'A'
ERROR: Type mismatch between 4.000000 and 'B'
ERROR: Type mismatch between 4.000000 and 'A'
ERROR: Type mismatch between 3.000000 and 'B'
Condition not satisfied; rule ignored.

Type == '*' is a NOP - it’s always true. I don’t see any reason to include it.

But as you say in your update, that rule still fires for me with && A.Type == '*' && B.Type == '*'.

AB.predicate is not a generally applicable short hand for A.predicate && B.predicate. It’s really only used for the condition functions that test a relationship between A and B, like AB.isCoupledDiffPair().

OK on AB. I’ve also updated my post with extra shots.
what’s the significance of 3.0000 and 4.000000 in the checker output ?

related to these ?
image

Ah, yes, the displayed clearance is the general least-common-denominator clearance. I don’t see how any system could statically display a matrix of clearances as a visual offset from a trace. But as you say the router does show dynamic clearances when you’re routing/dragging.

As for your error, you’ve switched to using A.Net instead of A.NetName. NetName is the friendly net name that you assign with a label (or KiCad autoassigns if you don’t use a label). Net is the internal netcode, which is what you show in your screenshot in the net inspector.

I don’t know if Net codes are stable. I tend to think that having Net available is a big footgun, but you could use it for something like (condition A.Net == B.Net).

You also lost the slashes in the net names.

Edit: here’s what the documentation says about Net vs. NetName:

You should always tell the KiCad version (at least the exact version number and also the OS) in the beginning of the topic. This may sound strange, but even though you have written many posts and topics recently, I immediately forget what version you (or anyone else) are using. This time this may be a version specific bug. It works OK for me in 8.0.0-RC on Windows.

EDIT: it was the Net vs. NetName, so no version discrepancies here.

Yes I was playing around with different combinations seeing if .Net or .NetName captured.
Must have .NetName
this works

(rule "net to net clearance example"
(condition "A.NetName == '/A' && B.NetName=='/B'  ")
(constraint clearance (min 1.5mm)))

OK, that’s enough kicad time today, 2.5 hours, need to go and do some work.
thanks for the assistance, noted on the version quote.

1 Like

BTW, this isn’t consistent. Why NetClass but not NetClassName?

Hmmm
A net is a string of connections , so I can see why it is NetName.

carrying that further, you might expect referring to a Net would automatically refer to all objects on that net.
I dunno.
When you refer to a net in Altium, it refers to any object that has that net name assigned to it. whereas a netname in Altium might refer to the Net name property of some object… which is also… the net’s name. (careful use of apostrophe for possessive)

That’s above my pay grade. I’d also rather have Net renamed to NetCode personally.

In general, DRC rules need to be backwards-compatible so people’s DRC doesn’t silently change between versions. In a future version TM there will probably be some sort of migration system, but that doesn’t exist today.

Optimally we wouldn’t expose the numeric version at all. The problem is it’s a lot faster.

But yeah, we probably should have gone with Net and NetCode rather than NetName and Net.

I believe Tom has a performance package in the works that would obviate the need for the numeric version. Maybe we could re-visit the naming then…

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.