constraints module#
Design constraints and effects#
This module provides classes for defining design rule constraints and their effects on routing, spacing, and via placement.
- class TraceWidth(width)[source]#
A constraint effect specifying the exact trace width to be used in routing.
See
trace_width()for usage.- Parameters:
width (float)
- class Clearance(clearance)[source]#
A constraint effect specifying the clearance between two objects.
See
clearance()for usage.- Parameters:
clearance (float)
- class ViaStitchPattern(pitch, inset)[source]#
Base class for via stitch patterns used in StitchVia constraints.
Via stitch patterns arrange vias within copper regions.
- class SquareViaStitchGrid(pitch, inset)[source]#
Bases:
ViaStitchPatternA square grid pattern for via stitching.
Places vias in a regular square grid pattern within the target area. Used in the StitchVia design rule constraint.
>>> pattern = SquareViaStitchGrid(pitch=2.0, inset=0.5)
- class TriangularViaStitchGrid(pitch, inset)[source]#
Bases:
ViaStitchPatternA triangular grid pattern for via stitching.
Places vias in a triangular (hexagonal close-packed) pattern within the target area. Used in the StitchVia design rule constraint.
>>> pattern = TriangularViaStitchGrid(pitch=1.5, inset=1.0)
- class StitchVia(definition, pattern)[source]#
A constraint effect specifying that vias should be arranged within copper areas in a pattern.
See
stitch_via()for usage.- Parameters:
pattern (SquareViaStitchGrid | TriangularViaStitchGrid)
-
pattern:
SquareViaStitchGrid|TriangularViaStitchGrid# The geometric pattern for via placement
- class ViaFencePattern(pitch, offset, num_rows=None, min_pitch=None, max_pitch=None, initial_offset=None, input_shape_only=None)[source]#
A pattern configuration for via fencing around routes or copper features.
Via fencing places vias around the perimeter of routes or copper areas. The pattern controls how these vias are arranged. Used in the FenceVia design rule constraint.
See
fence_via()for usage.>>> fence_pattern = ViaFencePattern( ... pitch=1.0, ... offset=0.5, ... num_rows=2, ... min_pitch=0.5, ... max_pitch=2.0 ... )
- Parameters:
-
offset:
float# The center-to-center distance between fence via rows, and the default initial offset in millimeters
Positive values indicate an outwards offset, negative values an inwards offset. The offset for routes must be positive. If
initial_offsetis not specified, this value serves as the default initial offset.
-
min_pitch:
float|None= None# The minimum allowed center-to-center pitch between vias in millimeters
-
max_pitch:
float|None= None# The maximum allowed center-to-center pitch between vias in millimeters
-
initial_offset:
float|None= None# The initial offset of the first row of fence vias
The initial offset is the perpendicular distance from the boundary of the route or copper feature to the centers of the first row of fence vias. Positive values indicate an outwards offset, while negative values indicate an inwards offset (inset). The offset must be positive for routes. Defaults to the same value as
offsetif unspecified.
- class FenceVia(definition, pattern)[source]#
A constraint effect specifying that fencing vias should be generated
The vias are generated around perimeter of the copper region or route which this constraint is applied to. The vias will be given the same net as the copper region.
See
fence_via()for usage. This constraint can also be given tojitx.si.RoutingStructure.Layerandjitx.si.DifferentialRoutingStructure.Layer. See there for usage.- Parameters:
pattern (ViaFencePattern)
-
pattern:
ViaFencePattern# The geometric pattern for fence placement
- class ThermalRelief(gap_distance, spoke_width, num_spokes)[source]#
A constraint effect specifying thermal connections between pours and objects.
Thermal reliefs control how pours connect to objects with gaps and spokes.
See
thermal_relief()for usage.
- class Tag[source]#
Tags are the fundamental building blocks for design rules.
Tags are applied to design objects, and are then used by the rule system to determine which rules apply to which objects.
Tags form a hierarchy through class inheritance, and thus a rule applied to a tag will apply to all tags that are a subclass of that tag. The name of a tag is derived from its class name.
Tags can be combined using logical operators to create complex conditions: - & (AND): Both conditions must be true - | (OR): Either condition can be true - ~ (NOT): Inverts the condition
>>> class PowerTag(Tag): ... "This is a power net, or some appropriate docstring for this tag"
>>> class SignalTag(Tag): ... "This is a signal net"
>>> class HighSpeedTag(SignalTag): ... "This is a high speed signal"
>>> # This rule applies to ALL Signal tags (including HighSpeed) >>> signal_rule = UnaryDesignConstraint(SignalTag()).trace_width(0.2)
>>> # This rule applies only to HighSpeed signals >>> high_speed_rule = UnaryDesignConstraint(HighSpeedTag()).trace_width(0.1)
Tags can be assigned to objects and used in rule conditions:
>>> # Assign tags to nets >>> PowerTag().assign(power_net) >>> GroundTag().assign(ground_net) >>> >>> # Create rules using tag combinations >>> rule1 = UnaryDesignConstraint(PowerTag()).trace_width(0.5) >>> rule2 = UnaryDesignConstraint(PowerTag() & HighSpeedTag()).clearance(0.3) >>> rule3 = UnaryDesignConstraint(PowerTag() | SignalTag()).stitch_via(MyVia, pattern) >>> rule4 = UnaryDesignConstraint(~HighSpeedTag()).trace_width(0.2)
- assign(*other)[source]#
Assign this tag to an object.
- Parameters:
other – The object to assign this tag to
- Returns:
The tag instance for method chaining
>>> ports = [Port(), Port()] >>> net = Net(ports) >>> PowerTag().assign(net)
- class BuiltinTag(*values)[source]#
-
- IsCopper = 'IsCopper'#
- IsTrace = 'IsTrace'#
- IsPour = 'IsPour'#
- IsVia = 'IsVia'#
- IsPad = 'IsPad'#
- IsBoardEdge = 'IsBoardEdge'#
- IsThroughHole = 'IsThroughHole'#
- IsNeckdown = 'IsNeckdown'#
- IsHole = 'IsHole'#
- class OnLayer(index)[source]#
Bases:
TagTag for specifying layer-specific rules.
- Parameters:
index (int)
- class Tags(tags, *more)[source]#
Bases:
PropertyA collection of tags assigned to an object, as a property.
Tags are markers on design objects that are then used by the rule system to determine which rules apply to which objects.
- Parameters:
>>> # Assign a single tag >>> Tags(PowerTag()).assign(power_net) >>> >>> # Assign multiple tags >>> Tags([PowerTag(), HighSpeedTag()]).assign(signal_net) >>> >>> # Assign using multiple arguments >>> Tags(PowerTag(), HighSpeedTag(), CriticalTag()).assign(clock_net)
- class BoolExpr[source]#
Base class for boolean expressions used in design rule conditions.
Boolean expressions are created by combining Tags using logical operators. They form the condition part of design rules that determine when the rule should be applied.
Boolean expressions support the same logical operators as Tags: - & (AND): Both expressions must be true - | (OR): Either expression can be true - ~ (NOT): Inverts the expression
>>> expr1 = PowerTag() & HighSpeedTag() >>> expr2 = GroundTag() | SignalTag() >>> complex_expr = expr1 | (expr2 & ~CriticalTag())
- class TrueExpr[source]#
Bases:
BoolExprAlways true boolean expression.
This expression always evaluates to true and can be used to create rules that apply to all objects regardless of their tags.
>>> # Rule that applies to everything >>> rule = design_constraint(TrueExpr()).trace_width(0.2)
- AnyObject: TrueExpr = TrueExpr()#
A convenience constant alias for TrueExpr, representing a boolean expression that is always true, thus applying to any object.
- class AtomExpr(atom)[source]#
Bases:
BoolExprAtomic boolean expression containing a single tag.
This is the simplest form of boolean expression, containing just a single tag. It’s created automatically when a Tag is used in a rule condition.
- Parameters:
atom (
Tag) – The Tag this expression represents
- class NotExpr(expr)[source]#
Bases:
BoolExprNegation of a boolean expression.
Represents the logical NOT of another boolean expression.
- Parameters:
expr (
BoolExpr) – The boolean expression to negate
>>> not_power = NotExpr(AtomExpr(PowerTag())) >>> # Or more commonly: ~PowerTag()
- class OrExpr(left, right)[source]#
Bases:
BoolExprLogical OR of two boolean expressions.
Represents a condition where either the left OR right expression (or both) must be true.
- Parameters:
>>> power_or_ground = OrExpr(AtomExpr(PowerTag()), AtomExpr(GroundTag())) >>> # Or more commonly: >>> power_or_ground = PowerTag() | GroundTag()
- class AndExpr(left, right)[source]#
Bases:
BoolExprLogical AND of two boolean expressions.
Represents a condition where both the left AND right expressions must be true.
- Parameters:
>>> power_and_critical = AndExpr(AtomExpr(PowerTag()), AtomExpr(CriticalTag())) >>> # Or more commonly: >>> power_and_critical = PowerTag() & CriticalTag()
- design_constraint(condition1, condition2=None, /, *, priority=0, name=None)[source]#
Syntactic helper function for creating the correct type of class. The overloads will generate
UnaryDesignConstraintorBinaryDesignConstraintdepending on the number of conditions, and should provide correct method completion in the editor.
- class DesignConstraint(*, priority=0, name=None)[source]#
Bases:
ABCTop-level design constraint that defines manufacturing and electrical rules.
A DesignConstraint combines conditional logic (based on Tags) with constraint effects controlling the physical layout. Rules can specify trace widths, clearances, via stitches, via fences, and thermal reliefs.
Rules are prioritized - higher priority numbers take precedence when multiple rules could apply to the same object. Rules can have single conditions or pairs of conditions (for rules that apply between two different objects).
Single condition rules (apply to objects matching the condition):
>>> # Basic trace width rule for power nets >>> power_rule = design_constraint(PowerTag()).trace_width(0.5)
>>> # Complex condition with priority >>> critical_rule = design_constraint(PowerTag() & CriticalTag(), priority=10).trace_width(1.0)
>>> # Via stitching for ground planes >>> stitch_pattern = SquareViaStitchGrid(pitch=2.0, inset=0.5) >>> ground_rule = design_constraint(GroundTag()).stitch_via(GroundVia, stitch_pattern)
Dual condition rules (apply between objects matching different conditions):
>>> # Clearance between power and signal nets >>> clearance_rule = design_constraint(PowerTag(), SignalTag()).clearance(0.3)
>>> # Clearance between any ground and non-critical nets >>> ground_clearance = design_constraint(GroundTag(), ~CriticalTag()).clearance(0.2)
Method chaining for complex rules:
>>> complex_rule = ( ... design_constraint(PowerTag(), priority=5) ... .trace_width(0.8) ... .stitch_via(PowerVia, SquareViaStitchGrid(pitch=1.5, inset=0.3)) ... .thermal_relief(gap_distance=0.15, spoke_width=0.1, num_spokes=4) ... )
Via fencing example:
>>> fence_pattern = ViaFencePattern( ... pitch=1.0, ... offset=0.5, ... num_rows=2, ... min_pitch=0.5, ... max_pitch=2.0 ... ) >>> shield_rule = design_constraint(HighSpeedTag()).fence_via(ShieldVia, fence_pattern)
Universal rules using a true (or TrueExpr) condition:
>>> # Default trace width for all nets >>> default_rule = design_constraint(true).trace_width(0.2)
- class UnaryDesignConstraint(condition, *, priority=0, name=None)[source]#
Bases:
DesignConstraint-
trace_width_constraint:
TraceWidth|None= None#
-
thermal_relief_constraint:
ThermalRelief|None= None#
- trace_width(width)[source]#
Set the trace width constraint for this rule.
- Parameters:
width (
float) – Trace width in millimeters- Return type:
Self- Returns:
Self for method chaining
>>> rule = UnaryDesignConstraint(PowerTag()).trace_width(0.5)
- stitch_via(definition, pattern)[source]#
Set the via stitching constraint for this rule.
- Parameters:
pattern (
SquareViaStitchGrid|TriangularViaStitchGrid) – The geometric pattern for arranging the vias
- Return type:
Self- Returns:
Self for method chaining
>>> pattern = SquareViaStitchGrid(pitch=2.0, inset=0.5) >>> rule = design_constraint(GroundTag()).stitch_via(GroundVia, pattern)
- fence_via(definition, pattern)[source]#
Set the via fencing constraint for this rule.
- Parameters:
pattern (
ViaFencePattern) – The geometric pattern for arranging the vias
- Return type:
Self- Returns:
Self for method chaining
>>> fence_pattern = ViaFencePattern(pitch=1.0, offset=0.5, num_rows=2) >>> rule = design_constraint(HighSpeedTag()).fence_via(ShieldVia, fence_pattern)
-
trace_width_constraint:
- class BinaryDesignConstraint(first, second, *, priority=0, name=None)[source]#
Bases:
DesignConstraint