Rules#

class pyedb.workflows.drc.drc.Rules(/, **data: Any)#

Bases: pydantic.BaseModel

Centralised, serialisable container for all design-rule categories supported by the PyEDB DRC engine.

The class is a thin pydantic model that provides:

  • JSON/YAML round-trip via parse_file, parse_obj, model_dump, model_dump_json.

  • Type-safe, API to incrementally build rule decks without manipulating raw dictionaries.

Examples

>>> from pyedb.workflows.drc.drc import Rules
>>>
>>> rules = (
...     Rules()
...     .add_min_line_width("pwr", "15 mil")
...     .add_min_clearance("clk2data", "4 mil", "CLK*", "DATA*")
...     .add_min_annular_ring("via5", "5 mil")
...     .add_diff_pair_length_match("usb", tolerance="0.1 mm", pairs=[("USB_P", "USB_N")])
...     .add_copper_balance("top_bal", max_percent=10, layers=["TOP"])
... )
>>> rules.model_dump_json(indent=2)
>>> rules.write_json("my_rules.json")
Attributes:
min_line_widthList[MinLineWidth]

Minimum acceptable trace width per layer or globally.

min_clearanceList[MinClearance]

Spacing requirements between nets (wild-cards allowed).

min_annular_ringList[MinAnnularRing]

Minimum annular ring for drilled holes.

diff_pair_length_matchList[DiffPairLengthMatch]

Length-matching constraints for differential pairs.

back_drill_stub_lengthList[BackDrillStubLength]

Maximum allowed back-drill stub length.

copper_balanceList[CopperBalance]

Copper-density balance limits per layer or zone.

Overview#

from_dict

Alias for model_validate.

to_dict

Alias for model_dump.

add_min_line_width

Append a minimum-line-width rule.

add_min_clearance

Append a minimum-clearance rule between two nets (wild-cards allowed).

add_min_annular_ring

Append a minimum-annular-ring rule for drilled holes.

add_diff_pair_length_match

Append a length-matching rule for differential pairs.

add_back_drill_stub_length

Append a maximum-allowed back-drill stub-length rule.

add_copper_balance

Append a copper-density balance rule.

Import detail#

from pyedb.workflows.drc.drc import Rules

Attribute detail#

Rules.min_line_width: List[MinLineWidth] = []#
Rules.min_clearance: List[MinClearance] = []#
Rules.min_annular_ring: List[MinAnnularRing] = []#
Rules.diff_pair_length_match: List[DiffPairLengthMatch] = []#
Rules.back_drill_stub_length: List[BackDrillStubLength] = []#
Rules.copper_balance: List[CopperBalance] = []#

Method detail#

classmethod Rules.from_dict(data: dict[str, Any]) Rules#

Alias for model_validate.

Parameters:
data

Dictionary produced by json.load, yaml.safe_load, etc.

Returns:
Rules

Validated instance ready for Drc.check().

Rules.to_dict() dict[str, Any]#

Alias for model_dump.

Returns:
dict

JSON-serialisable dictionary.

Rules.add_min_line_width(name: str, value: str, layers: list[str] | None = None) Rules#

Append a minimum-line-width rule.

Parameters:
namestr

Rule identifier

valuestr

Minimum width with unit, e.g. "3.5mil".

layerslist[str], optional

List of layer names to apply the rule to. If None, applies to all signal layers.

Returns:
Rules

Self to enable method chaining.

Rules.add_min_clearance(name: str, value: str, net1: str, net2: str) Rules#

Append a minimum-clearance rule between two nets (wild-cards allowed).

Parameters:
namestr

Rule identifier.

valuestr

Minimum clearance with unit, e.g. "4mil".

net1str

First net name or wild-card ("*").

net2str

Second net name or wild-card ("*").

Returns:
Rules

Self to enable method chaining.

Rules.add_min_annular_ring(name: str, value: str) Rules#

Append a minimum-annular-ring rule for drilled holes.

Parameters:
namestr

Rule identifier.

valuestr

Minimum annular ring with unit, e.g. "2mil".

Returns:
Rules

Self to enable method chaining.

Rules.add_diff_pair_length_match(name: str, tolerance: str, pairs: list[tuple[str, str]]) Rules#

Append a length-matching rule for differential pairs.

Parameters:
namestr

Rule identifier.

tolerancestr

Maximum allowed length difference with unit, e.g. "0.1mm".

pairslist[tuple[str, str]]

List of differential pairs as tuples of

Returns:
Rules

Self to enable method chaining.

Rules.add_back_drill_stub_length(name: str, value: str) Rules#

Append a maximum-allowed back-drill stub-length rule.

Parameters:
namestr

Rule identifier.

valuestr

Maximum allowed stub length with unit, e.g. "6mil".

Returns:
Rules

Self to enable method chaining.

Rules.add_copper_balance(name: str, max_percent: int, layers: list[str]) Rules#

Append a copper-density balance rule.

Parameters:
namestr

Rule identifier.

max_percentint

Maximum allowed copper imbalance in percent (e.g. 15 for 15%).

layerslist[str]

List of layer names to apply the rule to.

Returns:
Rules

Self to enable method chaining.