Scoping Design Rules

Now reading version 18. For the latest, read: Scoping Design Rules for version 20.2
 

Your Altium Design Software's PCB Editor is a 'rules-driven' environment. Design requirements are enforced through a well-defined set of Design Rules, which collectively define the constraints for the board. Design rules target specific objects within a design. For the PCB rules system to know what objects a given rule applies to, it needs to know the scope of that rule - the extent of its application. Scoping, or targeting the rule, is performed in the PCB Rules and Constraints Editor dialog.

Scoping a Design Rule

Rather than being restricted to a predefined list of possible target options, each design rule is scoped by writing what is called a Query. A query is essentially an instruction to the software that defines the set of design objects to be targeted. Queries are written using query keywords. In the same way that a query can be written in a Filter panel to find a specific set of objects, so to a query is written to define the objects that each rule targets. An example might be:

InNet('VBAT') And OnLayer('Bottom Layer')

If this query were to be used as the scope for a Width rule, whenever you route the VBAT net and switched to the bottom layer, the track width would automatically change to the width specified as part of that rule's constraints. Also, upon running a design rule check, any VBAT net routing on the bottom layer would have to have the specified width, or it would be flagged as a violation.

Use the options available in the PCB Rules and Constraints Editor dialog to build the query as required. Depending on whether the rule is unary or binary, you will need to define one or two scopes respectively.
If there is a syntax error with the query, the rule will be deemed invalid, and will be highlighted in red - within the PCB Rules and Constraints Editor dialog - both in the left-hand rule tree, and any summary view (rule category, or rule type) in which the rule appears. In addition, the text for the rule type and rule category are also presented in red, within the left-hand rule tree. So if you have collapsed an area of the rule tree that contains an invalid rule, you will still be alerted to it, at a higher level in the hierarchy. A warning message will also appear should you attempt to close this dialog. A rule scope that has a syntax error can greatly slow the Online and Batch DRC analysis process - be sure to resolve any rule scopes that are not syntactically correct.

Scoping Options

Simple scoping options are provided that allow you to quickly generate scope queries. Simply select one of the options from the first drop-down field and, if required, use the subsequent drop-down list(s) to select the appropriate target, such as a Net, Layer, Footprint, Package, and so on. The scoping options presented are focused according to rule type.

Quickly create a query using the simple scoping options.Quickly create a query using the simple scoping options.

The Custom Query option enables you to write your own, maybe more complex, but also more specific query. You can type your own specific query for the rule scope directly into the query region to the right. Alternatively, two features are available to help in the creation of logical query expressions - the Query Builder and the Query Helper. These can be very useful when unsure of the syntax of a query, or the possible keywords available for use.

Use the Custom Query option to craft a more complex query expression for your scoping.Use the Custom Query option to craft a more complex query expression for your scoping.

The Query Builder is a simpler method of constructing a query, using sensitive condition types and values that only allow you to build using relevant 'building blocks'. For advanced query construction, with full keyword specification and operator syntax, use the Query Helper.

Scoping a Rule with the Query Builder

Click the  button to open the Building Query from Board dialog, which enables you to create a query for targeting specific objects in the design document, by simple construction of a string of conditional statements.

The left-hand section of the dialog is used to specify the condition(s) required to target the set of objects needed. Each condition is made up of a Condition Type, and a Condition Value. Drop-down fields for these populate with entries that are relevant to building a scope for the current rule type, and values for the chosen condition type, respectively.

As a condition is defined, a preview of the currently built query is shown in the right-hand section of the dialog. Conditions can be ANDed and/or ORed together, and also precedence incorporated (through the use of brackets/indenting), to refine the target set of objects. When the expression for the query has been defined as required, clicking OK will load the expression into the query region of the PCB Rules and Constraints Editor dialog.

Note that additional opening and closing brackets are added to the start and end of the query expression, respectively, when presented back in the PCB Rules and Constraints Editor dialog.

Use the Query Builder to build a logical query expression through a series of conditional statements.Use the Query Builder to build a logical query expression through a series of conditional statements.

Scoping a Rule with the Query Helper

With the Custom Query option enabled, click the  button to access the Query Helper dialog. The underlying Query Engine analyzes the PCB design and lists all available objects, along with generic keywords for use in queries.

Working with the Query Helper is fairly intuitive, even more-so when you break it down into three distinct areas, as illustrated in the image below:

Example complex query defined using the Query Helper.Example complex query defined using the Query Helper.

These areas are:

  1. Query Region - use this region of the dialog to compose a query expression. The expression currently in-effect for the rule scope will be made available in this region, by default, when the dialog is accessed. You can type directly within the region; a context-sensitive 'prompt list' of possible keywords or objects will appear as an aid.
  2. Operators - this region of the dialog provides a range of mathematical and logical operators for use when constructing an expression. Simply click a button to add that operator at the current cursor location within the query expression in the Query region above.
  3. Categories, Keywords and Objects - this region of the dialog provides access to available PCB Functions, PCB Object Lists and System Functions, which can be used to create the query expression. Clicking on a sub-category within each of these three areas, will display a list of corresponding keywords or objects in the region to the right. Simply locate the keyword or object to be used in the query string, then double-click on its entry; the entry will be inserted at the current cursor location within the query expression in the Query region above.

Use the  button (bottom-left of the dialog) to verify that an expression is syntactically correct. When the expression for the query has been defined as required, clicking OK will load the expression into the query region of the PCB Rules and Constraints Editor dialog.

When using the Query Helper dialog to construct a query, clicking on a keyword in one of the available lists and pressing F1, will access the documentation for that particular keyword, within the Query Language Reference.

Query Expression Operator Precedence

Before leaving this area, it is worthwhile taking a look at the order of precedence in place for the operators used in logical Query expressions. After all, without such knowledge, an expression may not target the objects required.

Brackets have the highest precedence within an order of precedence that has been defined for the various operators, and which determines how queries are interpreted by the software (whenever the user has not provided brackets). The sequence of this order, from highest to lowest, is as follows:

  1. Brackets
  2. Not
  3. ^, *, /, Div, Mod, And
  4. +, -, Or, Xor
  5. =, <>, <, >, <=, >=
  6. &&, ||
This order of precedence is similar to that used in Pascal-type languages. Ambiguities are resolved by working from left to right. Brackets are evaluated from inside to outside and equal levels are evaluated left to right.
It is highly advisable to use brackets whenever there is any possibility, whatsoever, that the query might not be correctly interpreted. Generous usage of brackets removes doubt and makes the resulting queries easier to read by others.

Creating a Rule from the PCB Filter Panel

Since a design rule is scoped to apply to a target set of design objects, it can be easier (and faster) to first identify those objects, and then create a design rule that targets them. The PCB Filter panel provides the facility for creating a design rule, the scope of which uses the currently defined query expression in the panel. So rather than struggling to visualize what your query expression might target, use the PCB Filter panel to test and tweak a query expression until only those required objects are filtered. By then creating a rule that uses that query expression, you are guaranteed to be targeting the correct set of objects.

To add a new design rule:

  1. Click on the Create Rule button. The Choose Design Rule Type dialog will appear. This dialog lists each of the rule categories and rule types that are available in the PCB document.
  2. Choose the type of rule to be created and click OK (or double-click directly on the entry).
  3. The PCB Rules and Constraints Editor dialog will appear. A rule of the chosen type is created and the main editing window for the rule is displayed, ready to define specific constraints for the rule. The scoping option for the rule is set to Custom Query, and the query expression from the PCB Filter panel is entered into the query region accordingly.
  4. Make changes to the rule's name and constraints as necessary. Also change its priority if needed (it will be given the highest priority by default).

Create a new design rule directly from the PCB Filter panel - the filter query expression is used as the scope for the rule.Create a new design rule directly from the PCB Filter panel - the filter query expression is used as the scope for the rule.

Reusing Past Query Expressions

Over time, a number of useful query expressions will be constructed in the course of laying out various boards. Typically, you will want to apply and re-apply the same queries, not only in the same design, but across different designs. To cater for this, the PCB Filter panel supports the notion of Historical and Favorite queries.

As a query is entered and applied from the panel, it will be added to a query 'history list'. In addition, that query can be added to a query 'favorites list', by clicking the Add To Favorites button. Use the History and Favorites buttons in the panel to access the corresponding tabs of the same name within the Expression Manager dialog, to see these lists.

Access a history of applied query expressions and build a listing of favorite expressions to be reused time and again.Access a history of applied query expressions and build a listing of favorite expressions to be reused time and again.

To use an expression in either list, simply double-click on its entry, or select its entry and click the Apply Expression button. The Expression Manager dialog will close and the expression will be loaded into the Filter region of the PCB Filter panel.

This functionality streamlines (and expedites) creation of rules with requisite scoping - simply retrieve an historical or favorite query expression, check that it still targets the required object set (apply the filter), then create a rule that utilizes that expression in its scoping, as detailed in the previous section.

Checking Rule Application

Depending on the board design, a fair number of design rules may need to be defined, with scopes that range from the very simple, to the very complex. It is a good idea to check that the rules defined do indeed target their intended objects. Care at the rule definition stage can save wasted time and effort tracing violations, caused through incorrect rule scoping.

From the PCB Rules and Constraints Editor Dialog

The PCB Rules and Constraints Editor dialog includes a query testing facility, allowing you to quickly see what objects a particular rule applies to. Simply click the  button, at the top-right of the main editing window for the rule you wish to test. The Test Queries Result dialog will appear. This dialog reflects the number of objects falling under the scope of the expression, how many are applicable to the current rule, and how many are applicable based on the rule's current priority (where multiple applicable rules exist). By clicking on a link to the right, you can quickly filter to see the applicable objects in each case, directly in the workspace.

Quickly view the objects captured by a rule's scoping expression, using the Test Queries feature.Quickly view the objects captured by a rule's scoping expression, using the Test Queries feature.

From the PCB Rules And Violations Panel

You can also quickly see what objects a particular rule applies to, from the PCB Rules And Violations panel. The panel lists all currently defined rules for the design. All rules can be viewed, or you can browse specifically by rule type - provided at least one rule of any given type has been defined for the active design. As you click on a specific rule in the Rules region of the panel, filtering will be applied, using the rule as the scope of the filter. Only those design objects that fall under the scope of the rule will be filtered. By employing the Mask (or Dim) highlighting feature, you can quickly see the resulting objects targeted by the rule.

An example of using the PCB Rules And Violations panel to check which objects a selected rule applies to.An example of using the PCB Rules And Violations panel to check which objects a selected rule applies to.

If the highlighting method in the dialog has been set to Mask, adjust the level of masking applied to objects not falling under the scope of the active filter, by using the Masked Objects slider bar - accessed from the Mask and Dim Settings section, on the View Options tab of the View Configuration panel. If the highlighting method in the dialog has been set to Dim, adjust the level of dimming applied to objects not falling under the scope of the active filter, by using the Dimmed Objects slider bar - also available from this section of the panel.

Using the PCB Rules And Violations panel to interrogate which objects a rule applies to is particularly useful when creating a query for a rule’s scope(s), since a rule can be edited directly from the panel, and therefore the query can be 'tweaked' until the desired objects are captured by the scope(s).

To edit the scope(s) for a rule, as well as its constraints, either double-click on the rule's entry in the panel, or right-click and choose Properties from the context menu. The relevant Edit PCB Rule dialog will appear, from where the changes can be made.

Rules can be edited directly from the PCB Rules And Violations panel, allowing you to further refine rule scoping and/or constraints, on-the-fly.Rules can be edited directly from the PCB Rules And Violations panel, allowing you to further refine rule scoping and/or constraints, on-the-fly.

 

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.
Note

The features available depend on your Altium product access level. Compare features included in the various levels of Altium Designer Software Subscription and functionality delivered through applications provided by the Altium 365 platform.

If you don’t see a discussed feature in your software, contact Altium Sales to find out more.

Content