align.schema package

Submodules

align.schema.checker module

class align.schema.checker.AbstractSolver[source]

Bases: abc.ABC

abstract Abs(expr)[source]

Absolute value of expression

Note: argument is assumed to be

arithmetic expression

abstract And(*expressions)[source]

Logical And of all arguments

Note: arguments are assumed to be

boolean expressions

abstract Implies(expr1, expr2)[source]

expr1 => expr2

Note: both arguments are assumed

to be boolean expressions

abstract Not(expr)[source]

Logical Not of argument

Note: argument is assumed to be

a boolean expression

abstract Or(*expressions)[source]

Logical Or of all arguments

Note: arguments are assumed to be

boolean expressions

abstract annotate(formulae, label)[source]

Yield formulae annotated with label

Note: Input ‘formulae’ is iterable. Note: MUST return an iterable object Note: Return original iterable if solver

doesn’t support back-annotation

abstract append(formula, label=None)[source]

Append formula to checker.

Note: Please use bbox variables to create formulae

Otherwise you will need to manage types yourself

abstract bbox_vars(name)[source]

Generate a single namedtuple containing appropriate checker variables for placement constraints

abstract cast(type_)[source]

cast expr to type_

Note: Use with care. Not all

engines support all types

abstract checkpoint()[source]

Checkpoint current state of solver

Note: We assume incremental solving here

May need to revisit if we have to rebuild solution from scratch

iter_bbox_vars(names)[source]

Helper utility to generate multiple bbox variables

The output should be an iterator that allows you to loop over bboxes (use yield when possible)

abstract label(object)[source]

Generate label that can be used for back-annotation

Note: Return None if solver

doesn’t support back-annotation

abstract revert()[source]

Revert to last checkpoint

Note: We assume incremental solving here

May need to revisit if we have to rebuild solution from scratch

abstract solve()[source]

Solve & return solutions

If no solution is found, raise SolutionNotFoundError

class align.schema.checker.AnnotatedFormula(formula, label)

Bases: tuple

formula

Alias for field number 0

label

Alias for field number 1

exception align.schema.checker.SolutionNotFoundError(message, labels=None)[source]

Bases: Exception

class align.schema.checker.Z3Checker[source]

Bases: align.schema.checker.AbstractSolver

static Abs(expr)[source]

Absolute value of expression

Note: argument is assumed to be

arithmetic expression

static And(*expressions)[source]

Logical And of all arguments

Note: arguments are assumed to be

boolean expressions

static Implies(expr1, expr2)[source]

expr1 => expr2

Note: both arguments are assumed

to be boolean expressions

static Not(expr)[source]

Logical Not of argument

Note: argument is assumed to be

a boolean expression

static Or(*expressions)[source]

Logical Or of all arguments

Note: arguments are assumed to be

boolean expressions

annotate(formulae, label)[source]

Yield formulae annotated with label

Note: Input ‘formulae’ is iterable. Note: MUST return an iterable object Note: Return original iterable if solver

doesn’t support back-annotation

append(formula)[source]

Append formula to checker.

Note: Please use bbox variables to create formulae

Otherwise you will need to manage types yourself

bbox_vars(name)[source]

Generate a single namedtuple containing appropriate checker variables for placement constraints

static cast(expr, type_)[source]

cast expr to type_

Note: Use with care. Not all

engines support all types

checkpoint()[source]

Checkpoint current state of solver

Note: We assume incremental solving here

May need to revisit if we have to rebuild solution from scratch

label(object)[source]

Generate label that can be used for back-annotation

Note: Return None if solver

doesn’t support back-annotation

revert()[source]

Revert to last checkpoint

Note: We assume incremental solving here

May need to revisit if we have to rebuild solution from scratch

solve()[source]

Solve & return solutions

If no solution is found, raise SolutionNotFoundError

align.schema.constraint module

class align.schema.constraint.Align(*args, constraint: str, instances: align.schema.model.List[str], line: Literal[h_any, h_top, h_bottom, h_center, v_any, v_left, v_right, v_center] = None)[source]

Bases: align.schema.constraint.HardConstraint

Instances will be aligned along line. Could be strict or relaxed depending on value of line

Parameters
  • instances (list[str]) – List of instances

  • line (str, optional) –

    The following line values are currently supported:

    h_any, align instance’s top, bottom or anything in between.

    'v_any', align instance’s left, right or anything in between.

    'h_top', align instance’s horizontally based on top.

    'h_bottom', align instance’s horizomtally based on bottom.

    'h_center', align instance’s horizontally based on center.

    'v_left', align instance’s vertically based on left.

    'v_right', align instance’s vertically based on right.

    'v_center', align instance’s vertically based on center.

    None:default ('h_any' or 'v_any').

../_images/AlignBlocks.PNG

WARNING: Align does not imply ordering of any sort (See Order)

Example:

{"constraint":"Align", "instances": ['MN0', 'MN1', 'MN2'], "line": "v_center"}
classmethod align_instances_validator(value)[source]
constraint: str
instances: align.schema.model.List[str]
line: Optional[Literal[h_any, h_top, h_bottom, h_center, v_any, v_left, v_right, v_center]]
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.AlignInOrder(*args, constraint: str, instances: align.schema.model.List[str], line: Literal[top, bottom, left, right, center] = 'bottom', direction: Literal[horizontal, vertical] = None, abut: bool = False)[source]

Bases: align.schema.constraint.UserConstraint

Align instances on line ordered along direction

Parameters
  • instances (list[str]) – List of instances

  • line (str, optional) –

    The following line values are currently supported:

    'top', align instance’s horizontally based on top.

    'bottom', align instance’s horizomtally based on bottom.

    'center', align instance’s horizontally based on center.

    'left', align instance’s vertically based on left.

    'right', align instance’s vertically based on right.

  • direction

    The following direction values are supported:

    obj

    ’horizontal’, left to right

    obj

    ’vertical’, bottom to top

Example:

{
    "constraint":"Align",
    "instances": ["MN0", "MN1", "MN3"],
    "line": "center",
    "direction": "horizontal"
}

Note: This is a user-convenience constraint. Same effect can be realized using Order & Align

abut: bool
constraint: str
direction: Optional[Literal[horizontal, vertical]]
instances: align.schema.model.List[str]
line: Literal[top, bottom, left, right, center]
yield_constraints()[source]

Abstract Method to yield low level constraints Every class that inherits from UserConstraint MUST implement this function. This ensures clean separation of user-facing constraints from PnR constraints

class align.schema.constraint.AspectRatio(*args, constraint: str, subcircuit: str, ratio_low: float = 0.1, ratio_high: float = 10, weight: int = 1)[source]

Bases: align.schema.constraint.HardConstraint

Define lower and upper bounds on aspect ratio (=width/height) of a subcircuit

ratio_low <= width/height <= ratio_high

Parameters
  • subcircuit (str) – Name of subciruit

  • ratio_low (float) – Minimum aspect ratio (default 0.1)

  • ratio_high (float) – Maximum aspect ratio (default 10)

  • weight (int) – Weigth of this constraint (default 1)

Example:

{"constraint": "AspectRatio", "ratio_low": 0.1, "ratio_high": 10, "weight": 1 }
constraint: str
ratio_high: float
classmethod ratio_high_validator(value, values)[source]
ratio_low: float
subcircuit: str
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

weight: int
class align.schema.constraint.AssignBboxVariables(*args, constraint: str, bbox_name: str, llx: int, lly: int, urx: int, ury: int)[source]

Bases: align.schema.constraint.HardConstraint

bbox_name: str
constraint: str
llx: int
lly: int
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

urx: int
ury: int
classmethod x_is_valid(value, values)[source]
classmethod y_is_valid(value, values)[source]
class align.schema.constraint.BlockDistance(*args, constraint: str, abs_distance: int)[source]

Bases: align.schema.constraint.SoftConstraint

TODO: Replace with Spread

Places the instances with a fixed gap. Also used in situations when routing is congested.

Parameters

abs_distance (int) – Distance between two blocks. The number should be multiple of pitch of lowest horizontal and vertical routing layer i.e., M2 and M1

../_images/HorizontalDistance.PNG

Example:

{
    "constraint" : "BlockDistance",
    "abs_distance" : 420
}
abs_distance: int
constraint: str
class align.schema.constraint.Boundary(*args, constraint: str, subcircuit: str, max_width: float = 10000, max_height: float = 10000)[source]

Bases: align.schema.constraint.HardConstraint

Define max_height and/or max_width on a subcircuit in micrometers.

Parameters
  • subcircuit (str) – Name of subcircuit

  • max_width (float, Optional) –

  • max_height (float, Optional) –

Example:

{"constraint": "Boundary", "subcircuit": "OTA", "max_height": 100 }
constraint: str
max_height: Optional[float]
max_width: Optional[float]
subcircuit: str
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.ClockPorts(*args, constraint: str, ports: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

Clock port for each hieararchy. These are used as stop-points during auto-constraint identification, means no constraint search will be done beyond the nets connected to these ports.

Parameters

ports (list[str]) – List of ports.

Example:

{
    "constraint": "ClockPorts",
    "ports": ["CLK1", "CLK2"],
}
constraint: str
ports: align.schema.model.List[str]
class align.schema.constraint.CompactPlacement(*args, constraint: str, style: Literal[left, right, center] = 'left')[source]

Bases: align.schema.constraint.SoftConstraint

Defines snapping position of placement for all blocks in design.

Parameters

style (str) –

Following options are available.

'left', Moves all instances towards left during post-processing of placement.

'right', Moves all instances towards right during post-processing of placement.

'center', Moves all instances towards center during post-processing of placement.

Example:

{"constraint": "CompactPlacement", "style": "center"}
constraint: str
style: Literal[left, right, center]
class align.schema.constraint.ConfigureCompiler(*args, constraint: str, is_digital: bool = False, auto_constraint: bool = True, identify_array: bool = True, fix_source_drain: bool = True, remove_dummy_hierarchies: bool = True, remove_dummy_devices: bool = True, merge_series_devices: bool = True, merge_parallel_devices: bool = True, propagate: bool = True)[source]

Bases: align.schema.constraint.SoftConstraint

Compiler default optimization flags

Parameters
  • is_digital (bool) – true/false , stops any annotation or constraint generation

  • auto_constraint (bool) – true/false , stops auto-symmetry-constraint identification

  • identify_array (bool) – true/false , stops array identification

  • fix_source_drain (bool) – true/false , ensures (drain of NMOS/ source of PMOS) is at higher potential.

  • remove_dummy_hierarchies (bool) – true/false , Removes any single instance hierarchies.

  • remove_dummy_devices (bool) – true/false , Removes dummy devices in the design.

  • merge_series_devices (bool) – true/false , stack series devices

  • merge_parallel_devices (bool) – true/false , merge parallel devices

  • propagate (bool) – true/false , propagates these constarints to lower hierarchies

Example:

{
    "constraint": "ConfigureCompiler",
    "is_digital": true,
    "remove_dummy_hierarchies": true,
    "propagate": true
}
auto_constraint: bool
constraint: str
fix_source_drain: bool
identify_array: bool
is_digital: bool
merge_parallel_devices: bool
merge_series_devices: bool
propagate: bool
remove_dummy_devices: bool
remove_dummy_hierarchies: bool
class align.schema.constraint.ConstraintDB(*args, __root__: Sequence[Union[align.schema.constraint.Order, align.schema.constraint.Align, align.schema.constraint.Floorplan, align.schema.constraint.Enclose, align.schema.constraint.Spread, align.schema.constraint.AssignBboxVariables, align.schema.constraint.AspectRatio, align.schema.constraint.Boundary, align.schema.constraint.AlignInOrder, align.schema.constraint.CompactPlacement, align.schema.constraint.Generator, align.schema.constraint.SameTemplate, align.schema.constraint.CreateAlias, align.schema.constraint.GroupBlocks, align.schema.constraint.PlaceCloser, align.schema.constraint.DoNotIdentify, align.schema.constraint.PlaceOnGrid, align.schema.constraint.BlockDistance, align.schema.constraint.HorizontalDistance, align.schema.constraint.VerticalDistance, align.schema.constraint.GuardRing, align.schema.constraint.SymmetricBlocks, align.schema.constraint.GroupCaps, align.schema.constraint.NetConst, align.schema.constraint.PortLocation, align.schema.constraint.SymmetricNets, align.schema.constraint.MultiConnection, align.schema.constraint.DoNotRoute, align.schema.constraint.PowerPorts, align.schema.constraint.GroundPorts, align.schema.constraint.ClockPorts, align.schema.constraint.DoNotUseLib, align.schema.constraint.ConfigureCompiler, align.schema.constraint.NetPriority]])[source]

Bases: pydantic.generics.GenericModel, Generic[align.schema.types.DataT]

append(constraint: Union[align.schema.constraint.Order, align.schema.constraint.Align, align.schema.constraint.Floorplan, align.schema.constraint.Enclose, align.schema.constraint.Spread, align.schema.constraint.AssignBboxVariables, align.schema.constraint.AspectRatio, align.schema.constraint.Boundary, align.schema.constraint.AlignInOrder, align.schema.constraint.CompactPlacement, align.schema.constraint.Generator, align.schema.constraint.SameTemplate, align.schema.constraint.CreateAlias, align.schema.constraint.GroupBlocks, align.schema.constraint.PlaceCloser, align.schema.constraint.DoNotIdentify, align.schema.constraint.PlaceOnGrid, align.schema.constraint.BlockDistance, align.schema.constraint.HorizontalDistance, align.schema.constraint.VerticalDistance, align.schema.constraint.GuardRing, align.schema.constraint.SymmetricBlocks, align.schema.constraint.GroupCaps, align.schema.constraint.NetConst, align.schema.constraint.PortLocation, align.schema.constraint.SymmetricNets, align.schema.constraint.MultiConnection, align.schema.constraint.DoNotRoute, align.schema.constraint.PowerPorts, align.schema.constraint.GroundPorts, align.schema.constraint.ClockPorts, align.schema.constraint.DoNotUseLib, align.schema.constraint.ConfigureCompiler, align.schema.constraint.NetPriority])[source]
checkpoint()[source]
remove(constraint: Union[align.schema.constraint.Order, align.schema.constraint.Align, align.schema.constraint.Floorplan, align.schema.constraint.Enclose, align.schema.constraint.Spread, align.schema.constraint.AssignBboxVariables, align.schema.constraint.AspectRatio, align.schema.constraint.Boundary, align.schema.constraint.AlignInOrder, align.schema.constraint.CompactPlacement, align.schema.constraint.Generator, align.schema.constraint.SameTemplate, align.schema.constraint.CreateAlias, align.schema.constraint.GroupBlocks, align.schema.constraint.PlaceCloser, align.schema.constraint.DoNotIdentify, align.schema.constraint.PlaceOnGrid, align.schema.constraint.BlockDistance, align.schema.constraint.HorizontalDistance, align.schema.constraint.VerticalDistance, align.schema.constraint.GuardRing, align.schema.constraint.SymmetricBlocks, align.schema.constraint.GroupCaps, align.schema.constraint.NetConst, align.schema.constraint.PortLocation, align.schema.constraint.SymmetricNets, align.schema.constraint.MultiConnection, align.schema.constraint.DoNotRoute, align.schema.constraint.PowerPorts, align.schema.constraint.GroundPorts, align.schema.constraint.ClockPorts, align.schema.constraint.DoNotUseLib, align.schema.constraint.ConfigureCompiler, align.schema.constraint.NetPriority])[source]
class align.schema.constraint.CreateAlias(*args, constraint: str, instances: align.schema.model.List[str], name: str)[source]

Bases: align.schema.constraint.SoftConstraint

Creates an alias for list of instances. You can use this alias later while defining constraints

Parameters

Example:

{
    "constraint":"CreateAlias",
    "instances": ["MN0", "MN1", "MN3"],
    "name": "alias1"
}
constraint: str
instances: align.schema.model.List[str]
name: str
class align.schema.constraint.DoNotIdentify(*args, constraint: str, instances: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

Stop any auto-grouping of provided instances Automatically adds instances from all constraint

WARNING: user-defined groupblock/groupcap constraint will ignore this constraint

constraint: str
instances: align.schema.model.List[str]
class align.schema.constraint.DoNotRoute(*args, constraint: str, nets: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

constraint: str
nets: align.schema.model.List[str]
class align.schema.constraint.DoNotUseLib(*args, constraint: str, libraries: align.schema.model.List[str], propagate: bool = False)[source]

Bases: align.schema.constraint.SoftConstraint

Primitive libraries which should not be used during hierarchy annotation.

Parameters
  • libraries (list[str]) – List of libraries.

  • propagate – Copy this constraint to sub-hierarchies

Example:

{
    "constraint": "DoNotUseLib",
    "libraries": ["DP_NMOS", "INV"],
    "propagate": false
}
constraint: str
libraries: align.schema.model.List[str]
propagate: bool
class align.schema.constraint.Enclose(*args, constraint: str, instances: align.schema.model.List[str] = None, min_height: int = None, max_height: int = None, min_width: int = None, max_width: int = None, min_aspect_ratio: float = None, max_aspect_ratio: float = None)[source]

Bases: align.schema.constraint.HardConstraint

Enclose instances within a flexible bounding box with min_ & max_ bounds

Parameters
  • instances (list[str], optional) – List of instances

  • min_height (int, optional) – assign minimum height to the subcircuit

  • max_height (int, optional) – assign maximum height to the subcircuit

  • min_width (int, optional) – assign minimum width to the subcircuit

  • max_width (int, optional) – assign maximum width to the subcircuit

  • min_aspect_ratio (float, optional) – assign minimum aspect ratio to the subcircuit

  • max_aspect_ratio (float, optional) – assign maximum aspect ratio to the subcircuit

Note: Specifying any one of the following variables makes it a valid constraint but you may wish to specify more than one for practical purposes

Example:

{"constraint":"Enclose", "instances": ['MN0', 'MN1', 'MN2'], "min_aspect_ratio": 0.1, "max_aspect_ratio": 10 }
classmethod bound_in_box_optional_fields(value, values)[source]
constraint: str
instances: Optional[align.schema.model.List[str]]
max_aspect_ratio: Optional[float]
max_height: Optional[int]
max_width: Optional[int]
min_aspect_ratio: Optional[float]
min_height: Optional[int]
min_width: Optional[int]
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.Floorplan(*args, constraint: str, regions: align.schema.constraint.List[List[str]], order: bool = False, symmetrize: bool = False)[source]

Bases: align.schema.constraint.UserConstraint

Row-based layout floorplan from top to bottom Instances on each row are ordered from left to right.

Example: Define three regions and assign each instance to a region:

{“constraint”:”Floorplan”, “regions”: [[“A”, “B”, “C”], [“D”, “E”], [“G”], “order”: true}

constraint: str
order: bool
regions: align.schema.constraint.List[List[str]]
symmetrize: bool
yield_constraints()[source]

Abstract Method to yield low level constraints Every class that inherits from UserConstraint MUST implement this function. This ensures clean separation of user-facing constraints from PnR constraints

class align.schema.constraint.Generator(*args, constraint: str, name: str = None, parameters: dict = None)[source]

Bases: align.schema.constraint.SoftConstraint

Used to guide primitive generator. :param name: name of genrator e.g., mos/cap/res/ring :type name: str :param parameters: {

pattern (str): common centroid (cc)/ Inter digitated (id)/Non common centroid (ncc) parallel_wires (dict): {net_name:2} body (bool): true/ false }

Example:

{
    "constraint": "Generator",
    "name": "mos",
    "parameters : {
                    "pattern": "cc",
                    "parallel_wires": {"net1":2, "net2":2},
                    "body": true
                    }
}
constraint: str
name: Optional[str]
parameters: Optional[dict]
class align.schema.constraint.GroundPorts(*args, constraint: str, ports: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

Ground port for each hieararchy

Parameters

ports (list[str]) – List of ports. The first port of top hierarchy will be used for ground grid creation. Power ports are used to identify source and drain of transistors by identifying the terminal at higher potential.

Example:

{
    "constraint": "GroundPorts",
    "ports": ["GND", "GNVD1"],
}
constraint: str
ports: align.schema.model.List[str]
class align.schema.constraint.GroupBlocks(*args, constraint: str, name: str, instances: align.schema.model.List[str], generator: dict = None)[source]

Bases: align.schema.constraint.HardConstraint

Forces a hierarchy creation for group of instances. This brings the instances closer. This reduces the problem statement for placer thus providing better solutions.

Parameters
  • instances (list[str]) – List of instances

  • name (str) – alias for the list of instances

  • generator (dict) – adds a generator constraint to the created groupblock, look into the generator constraint for more options

Example:

{
    "constraint":"GroupBlocks",
    "name": "group1",
    "instances": ["MN0", "MN1", "MN3"]
    "generator": {name: 'MOS',
                'parameters':
                    {
                    "pattern": "cc",
                    }
                }
}
constraint: str
generator: Optional[dict]
classmethod group_block_name(value)[source]
instances: align.schema.model.List[str]
name: str
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.GroupCaps(*args, constraint: str, name: str, instances: align.schema.model.List[str], unit_cap: str, num_units: align.schema.types.List, dummy: bool)[source]

Bases: align.schema.constraint.SoftConstraint

Creates a common centroid cap using a combination

of unit sized caps. It can be of multiple caps.

Args:

name (str): name for grouped caps instances (List[str]): list of cap instances unit_cap (str): Capacitance value in fF num_units (List[int]): Number of units for each capacitance instance dummy (bool): Whether to fill in dummies or not

Example:

{
    "constraint" : "GroupCaps",
    "name" : "cap_group1",
    "instances" : ["C0", "C1", "C2"],
    "num_units" : [2, 4, 8],
    "dummy" : true
}
constraint: str
dummy: bool
instances: align.schema.model.List[str]
name: str
num_units: align.schema.types.List
unit_cap: str
class align.schema.constraint.GuardRing(*args, constraint: str, guard_ring_primitives: str, global_pin: str, block_name: str)[source]

Bases: align.schema.constraint.SoftConstraint

Adds guard ring for particular hierarchy.

Parameters
  • guard_ring_primitives (str) – Places this instance across boundary of a hierarchy

  • global_pin (str) – connect the pin of guard ring to this pin, mostly ground pin

  • block_name – Name of the hierarchy

Example:

{
    "constraint" : "GuardRing",
    "guard_ring_primitives" : "guard_ring",
    "global_pin
}
block_name: str
constraint: str
global_pin: str
guard_ring_primitives: str
class align.schema.constraint.HardConstraint(*args, constraint: str)[source]

Bases: align.schema.constraint.SoftConstraint, abc.ABC

constraint: str
abstract translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.HorizontalDistance(*args, constraint: str, abs_distance: int)[source]

Bases: align.schema.constraint.SoftConstraint

TODO: Replace with Spread

Places the instances with a fixed horizontal gap. Also used in situations when routing is congested.

Parameters

abs_distance (int) – Distance between two blocks. The number should be multiple of pitch of lowest vertical routing layer i.e., M1

../_images/HorizontalDistance.PNG

Example:

{
    "constraint" : "HorizontalDistance",
    "abs_distance" : 80
}
abs_distance: int
constraint: str
class align.schema.constraint.MultiConnection(*args, constraint: str, nets: align.schema.model.List[str], multiplier: int)[source]

Bases: align.schema.constraint.SoftConstraint

Defines multiple parallel wires for a net. This constraint is used to reduce parasitics and Electro-migration (EM) violations

Parameters
  • nets (List[str]) – List of nets

  • multiplier (int) – Number of parallel wires

Example

{
    "constraint" : "MultiConnection",
    "nets" : ["N1", "N2", "N3"],
    "multiplier" : 4
}
constraint: str
multiplier: int
nets: align.schema.model.List[str]
class align.schema.constraint.NetConst(*args, constraint: str, nets: align.schema.model.List[str], shield: str = None, criticality: int = None)[source]

Bases: align.schema.constraint.SoftConstraint

Net based constraint. Shielding and critically can be defined.

Parameters
  • nets (List[str]) – List of net names.

  • shield (str, optional) – Name of net for shielding.

  • criticality (int, optional) – Criticality of net. Higher criticality means the net would be routed first.

Example:

{
    "constraint" : "NetConst",
    "nets" : ["net1", "net2", "net3"],
    "shield" : "VSS",
    "criticality" : 10
}
constraint: str
criticality: Optional[int]
nets: align.schema.model.List[str]
shield: Optional[str]
class align.schema.constraint.NetPriority(*args, constraint: str, nets: align.schema.model.List[str], weight: int)[source]

Bases: align.schema.constraint.SoftConstraint

Specify a non-negative priority for a list of nets for placement (default = 1). Example: {“constraint”: “NetPriority”, “nets”: [“en”, “enb”], “priority”: 0}

constraint: str
nets: align.schema.model.List[str]
weight: int
class align.schema.constraint.OffsetsScalings(*args, offsets: align.schema.constraint.List[int] = None, scalings: align.schema.constraint.List[Literal[- 1, 1]] = None)[source]

Bases: align.schema.types.BaseModel

offsets: align.schema.constraint.List[int]
scalings: align.schema.constraint.List[Literal[-1, 1]]
class align.schema.constraint.Order(*args, constraint: str, instances: align.schema.model.List[str], direction: Literal[horizontal, vertical, left_to_right, right_to_left, bottom_to_top, top_to_bottom] = None, abut: bool = False)[source]

Bases: align.schema.constraint.HardConstraint

Defines a placement order for instances in a subcircuit.

Parameters
  • instances (list[str]) – List of instances

  • direction (str, optional) –

    The following options for direction are supported

    'horizontal', placement order is left to right or vice-versa.

    'vertical', placement order is bottom to top or vice-versa.

    'left_to_right', placement order is left to right.

    'right_to_left', placement order is right to left.

    'bottom_to_top', placement order is bottom to top.

    'top_to_bottom', placement order is top to bottom.

    None: default ('horizontal' or 'vertical')

  • abut (bool, optional) – If abut is true adjoining instances will touch

../_images/OrderBlocks.PNG

WARNING: Order does not imply aligment / overlap of any sort (See Align)

Example:

{"constraint":"Order", "instances": ['MN0', 'MN1', 'MN2'], "direction": "left_to_right"}
abut: bool
constraint: str
direction: Optional[Literal[horizontal, vertical, left_to_right, right_to_left, bottom_to_top, top_to_bottom]]
instances: align.schema.model.List[str]
classmethod order_instances_validator(value)[source]
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.PlaceCloser(*args, constraint: str, instances: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

instances are preferred to be placed closer.

constraint: str
instances: align.schema.model.List[str]
class align.schema.constraint.PlaceOnGrid(*args, constraint: str, direction: Literal[H, V], pitch: int, ored_terms: align.schema.constraint.List[OffsetsScalings] = None)[source]

Bases: align.schema.constraint.SoftConstraint

constraint: str
direction: Literal[H, V]
ored_terms: align.schema.constraint.List[OffsetsScalings]
classmethod ored_terms_validator(value, values)[source]
pitch: int
class align.schema.constraint.PlaceSymmetric(*args, constraint: str, instances: align.schema.constraint.List[List[str]], direction: Literal[horizontal, vertical] = None)[source]

Bases: align.schema.constraint.SoftConstraint

Place instance / pair of instances symmetrically around line of symmetry along direction

Note: This is a user-convenience constraint. Same effect can be realized using Align & Group

For example: instances = [[‘1’], [‘4’, ‘5’], [‘2’, ‘3’], [‘6’]] direction = ‘vertical’

1 | 5 4 | 6 | 4 5 | 1 | 5 4

4 5 | 1 | 5 4 | 6 | 6 | 1 2 3 | 2 3 | 3 2 | 1 | 5 4 | 6

6 | 6 | 1 | 2 3 | 2 3 | 3 2

constraint: str
direction: Optional[Literal[horizontal, vertical]]
instances: align.schema.constraint.List[List[str]]
classmethod place_symmetric_instances_validator(value)[source]

X = Align(2, 3, ‘h_center’) Y = Align(4, 5, ‘h_center’) Align(1, X, Y, 6, ‘center’)

class align.schema.constraint.PortLocation(*args, constraint: str, ports: align.schema.types.List, location: Literal[TL, TC, TR, RT, RC, RB, BL, BC, BR, LB, LC, LT])[source]

Bases: align.schema.constraint.SoftConstraint

Defines approximate location of the port. T (top), L (left), C (center), R (right), B (bottom)

Parameters
  • ports (List[str]) – List of ports

  • location (str) –

    Literal:

    ['TL', 'TC', 'TR',
    'RT', 'RC', 'RB',
    'BL', 'BC', 'BR',
    'LB', 'LC', 'LT']
    

Example

{
    "constraint" : "PortLocation",
    "ports" : ["P0", "P1", "P2"],
    "location" : "TL"
}
constraint: str
location: Literal[TL, TC, TR, RT, RC, RB, BL, BC, BR, LB, LC, LT]
ports: align.schema.types.List
class align.schema.constraint.PowerPorts(*args, constraint: str, ports: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

Defines power ports for each hieararchy

Parameters

ports (list[str]) – List of ports. The first port of top hierarchy will be used for power grid creation. Power ports are used to identify source and drain of transistors by identifying the terminal at higher potential.

Example:

{
    "constraint":"PowerPorts",
    "ports": ["VDD", "VDD1"],
}
constraint: str
ports: align.schema.model.List[str]
class align.schema.constraint.SameTemplate(*args, constraint: str, instances: align.schema.model.List[str])[source]

Bases: align.schema.constraint.SoftConstraint

Makes identical copy of all isntances

Parameters

instances (list[str]) – List of instances

Example:

{"constraint":"SameTemplate", "instances": ["MN0", "MN1", "MN3"]}
constraint: str
instances: align.schema.model.List[str]
class align.schema.constraint.SoftConstraint(*args, constraint: str)[source]

Bases: align.schema.types.BaseModel

constraint: str
class align.schema.constraint.Spread(*args, constraint: str, instances: align.schema.model.List[str], direction: Literal[horizontal, vertical] = None, distance: int)[source]

Bases: align.schema.constraint.HardConstraint

Spread instances by forcing minimum spacing along direction if two instances overlap in other direction

Parameters
  • instances (list[str]) – List of instances

  • direction (str, optional) – Direction for placement spread. ('horizontal' or 'vertical' or None)

  • distance (int) – Distance in nanometer

WARNING: This constraint checks for overlap but doesn’t enforce it (See Align)

Example:

{
    "constraint": "Spread",
    "instances": ['MN0', 'MN1', 'MN2'],
    "direction": horizontal,
    "distance": 100
}
constraint: str
direction: Optional[Literal[horizontal, vertical]]
distance: int
instances: align.schema.model.List[str]
classmethod spread_instances_validator(value)[source]
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.SymmetricBlocks(*args, constraint: str, pairs: align.schema.constraint.List[List[str]], direction: Literal[H, V])[source]

Bases: align.schema.constraint.HardConstraint

Defines a symmetry constraint between single and/or pairs of blocks.

Parameters
  • pairs (list[list[str]]) – List of pair of instances. A pair can have one instance or two instances, where single instance implies self-symmetry

  • direction (str) –

    Direction for axis of symmetry. Literal:

    ['V', 'H']
    

../_images/SymmetricBlocks.PNG

Example:

{
    "constraint" : "SymmetricBlocks",
    "pairs" : [["MN0","MN1"], ["MN2","MN3"], ["MN4"]],
    "direction" : "V"
}
constraint: str
direction: Literal[H, V]
pairs: align.schema.constraint.List[List[str]]
classmethod pairs_validator(value)[source]
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

class align.schema.constraint.SymmetricNets(*args, constraint: str, net1: str, net2: str, pins1: align.schema.types.List = None, pins2: align.schema.types.List = None, direction: Literal[H, V])[source]

Bases: align.schema.constraint.SoftConstraint

Defines two nets as symmetric. A symmetric net will also enforce a SymmetricBlock between blocks connected to the nets.

Parameters
  • net1 (str) – Name on net1

  • net2 (str) – Name of net2

  • pins1 (List, Optional) – oredered list of connected pins to be matched

  • pins2 (List, Optional) – oredered list of connected pins to be matched

  • direction (str) – Literal [‘H’, ‘V’], Horizontal or vertical line of symmetry

Example

{
    "constraint" : "SymmetricNets",
    "net1" : "net1"
    "net2" : "net2"
    "pins1" : ["block1/A", "block2/A", "port1"]
    "pins2" : ["block1/B", "block2/B", "port2"]
    "direction" : 'V'
}
constraint: str
direction: Literal[H, V]
net1: str
net2: str
pins1: Optional[align.schema.types.List]
pins2: Optional[align.schema.types.List]
class align.schema.constraint.UserConstraint(*args, constraint: str)[source]

Bases: align.schema.constraint.HardConstraint, abc.ABC

constraint: str
translate(solver)[source]
Abstract Method for built in self-checks

Every class that inherits from HardConstraint MUST implement this function.

Function must yield a list of mathematical

expressions supported by the ‘solver’ backend. This can be done using multiple ‘yield’ statements or returning an iterable object such as list

abstract yield_constraints()[source]
Abstract Method to yield low level constraints

Every class that inherits from UserConstraint MUST implement this function. This ensures clean separation of user-facing constraints from PnR constraints

class align.schema.constraint.VerticalDistance(*args, constraint: str, abs_distance: int)[source]

Bases: align.schema.constraint.SoftConstraint

TODO: Replace with Spread

Places the instances with a fixed vertical gap. Also used in situations when routing is congested.

Parameters

abs_distance (int) – Distance between two blocks. The number should be multiple of pitch of lowest horizontal routing layer i.e., M2

../_images/VerticalDistance.PNG

Example:

{
    "constraint" : "VerticalDistance",
    "abs_distance" : 84
}
abs_distance: int
constraint: str
align.schema.constraint.assert_non_negative(cls, value)[source]
align.schema.constraint.expand_user_constraints(const_list)[source]
align.schema.constraint.get_instances_from_hacked_dataclasses(constraint)[source]
align.schema.constraint.upper_case(cls, value)[source]
align.schema.constraint.validate_instances(cls, value)[source]

align.schema.gen_dot module

align.schema.gen_dot.gen_dot_file(nm, ifn, ofn)[source]

align.schema.graph module

align.schema.hacks module

These hacked data structures emulate dictionaries used in

our existing flow but allow us to insert, validate & use formal constraints in ConstraintDB. They serve to boostrap our transition from ALIGN 1.0 to 2.0

TODO: Eliminate this module by replacing these data

structures with SubCircuit, Instance etc.

class align.schema.hacks.DictEmulator(*args, **kwargs)[source]

Bases: align.schema.types.BaseModel

class Config[source]

Bases: object

allow_mutation = True
extra = 'allow'
class align.schema.hacks.FormalActualMap(*args, formal: str, actual: str, **kwargs)[source]

Bases: align.schema.hacks.DictEmulator

actual: str
formal: str
class align.schema.hacks.VerilogJsonInstance(*args, instance_name: str, fa_map: align.schema.hacks.List[FormalActualMap], **kwargs)[source]

Bases: align.schema.hacks.DictEmulator

fa_map: align.schema.hacks.List[FormalActualMap]
instance_name: str
translate(solver)[source]

Bounding boxes must have non-zero height & width

class align.schema.hacks.VerilogJsonModule(*args, parameters: align.schema.model.List[str], constraints: align.schema.constraint.ConstraintDB, instances: align.schema.hacks.List[VerilogJsonInstance], **kwargs)[source]

Bases: align.schema.hacks.DictEmulator

constraints: align.schema.constraint.ConstraintDB
instances: align.schema.hacks.List[VerilogJsonInstance]
parameters: align.schema.model.List[str]
translate(solver)[source]
verify(constraint=None)[source]
class align.schema.hacks.VerilogJsonTop(*args, modules: align.schema.hacks.List[VerilogJsonModule], leaves: align.schema.hacks.List[Dict] = None, **kwargs)[source]

Bases: align.schema.hacks.DictEmulator

leaves: Optional[align.schema.hacks.List[Dict]]
modules: align.schema.hacks.List[VerilogJsonModule]

align.schema.instance module

class align.schema.instance.Instance(*args, model: str, name: str, pins: align.schema.model.Dict[str, str], parameters: align.schema.model.Dict[str, str] = None, abstract_name: str = None)[source]

Bases: align.schema.types.BaseModel

class Config[source]

Bases: object

allow_mutation = True
abstract_name: Optional[str]
add_abs_name(abn)[source]
property mclass
model: str
classmethod model_exists_in_library(model)[source]
name: str
classmethod name_complies_with_model(name, values)[source]
parameters: Optional[align.schema.model.Dict[str, str]]
classmethod parameters_comply_with_model(parameters, values)[source]
pins: align.schema.model.Dict[str, str]
classmethod pins_comply_with_model(pins, values)[source]
translate(solver)[source]

Bounding boxes must have non-zero height & width

xyce()[source]

align.schema.library module

class align.schema.library.Library(loadbuiltins=False, pdk_models=None)[source]

Bases: pydantic.generics.GenericModel, Generic[align.schema.types.DataT]

append(item)[source]
default_models()[source]
find(name)[source]
align.schema.library.read_lib_json(json_file_path)[source]

align.schema.model module

class align.schema.model.Model(*args, name: str, base: str = None, pins: align.schema.model.List[str] = None, parameters: align.schema.model.Dict[str, str] = None, prefix: str = None)[source]

Bases: align.schema.types.BaseModel

Model creation class

base: Optional[str]
classmethod base_check(base)[source]
property bases
name: str
classmethod name_check(name)[source]
classmethod parameter_check(parameters, values)[source]
parameters: Optional[align.schema.model.Dict[str, str]]
classmethod pin_check(pins, values)[source]
pins: Optional[align.schema.model.List[str]]
prefix: Optional[str]
classmethod prefix_check(prefix, values)[source]
xyce()[source]

align.schema.parser module

class align.schema.parser.SpiceParser(library=None, mode='Xyce')[source]

Bases: object

parse(text)[source]
class align.schema.parser.Token(type, value)

Bases: tuple

type

Alias for field number 0

value

Alias for field number 1

align.schema.parser.str2float(val)[source]

align.schema.pdk module

class align.schema.pdk.Layer(*args, name: str, gds_layer_number: int, gds_data_type: Dict[str, int] = None)[source]

Bases: align.schema.types.BaseModel

gds_data_type: Optional[Dict[str, int]]
gds_layer_number: int
name: str
class align.schema.pdk.LayerMetal(*args, name: str, gds_layer_number: int, gds_data_type: Dict[str, int] = None, direction: Literal[h, v], min_length: int, max_length: int = None, min_end_to_end: int, offset: int, width: Union[int, align.schema.constraint.List[int]], space: Union[int, align.schema.constraint.List[int]], color: align.schema.model.List[str] = None, stop_pitch: int, stop_point: int, stop_offset: int, unit_c: Dict[int, align.schema.pdk.ParasiticValues] = None, unit_r: Dict[int, align.schema.pdk.ParasiticValues] = None, unit_cc: Dict[int, align.schema.pdk.ParasiticValues] = None)[source]

Bases: align.schema.pdk.Layer

color: Optional[align.schema.model.List[str]]
direction: Literal[h, v]
gds_data_type: Optional[Dict[str, int]]
gds_layer_number: int
max_length: Optional[int]
min_end_to_end: int
min_length: int
name: str
offset: int
space: Union[int, align.schema.constraint.List[int]]
stop_offset: int
stop_pitch: int
stop_point: int
unit_c: Optional[Dict[int, align.schema.pdk.ParasiticValues]]
unit_cc: Optional[Dict[int, align.schema.pdk.ParasiticValues]]
unit_r: Optional[Dict[int, align.schema.pdk.ParasiticValues]]
width: Union[int, align.schema.constraint.List[int]]
class align.schema.pdk.LayerVia(*args, name: str, gds_layer_number: int, gds_data_type: Dict[str, int] = None, stack: align.schema.model.List[str], width_x: int, width_y: int, space_x: int, space_y: int, layer_l_width: align.schema.constraint.List[int] = None, layer_l_enc_x: int = 0, layer_l_enc_y: int = 0, layer_h_width: align.schema.constraint.List[int] = None, layer_h_enc_x: int = 0, layer_h_enc_y: int = 0, unit_r: Dict[int, align.schema.pdk.ParasiticValues] = None)[source]

Bases: align.schema.pdk.Layer

class Config[source]

Bases: object

allow_mutation = True
gds_data_type: Optional[Dict[str, int]]
gds_layer_number: int
layer_h_enc_x: Optional[int]
layer_h_enc_y: Optional[int]
layer_h_width: Optional[align.schema.constraint.List[int]]
layer_l_enc_x: Optional[int]
layer_l_enc_y: Optional[int]
layer_l_width: Optional[align.schema.constraint.List[int]]
name: str
space_x: int
space_y: int
stack: align.schema.model.List[str]
unit_r: Optional[Dict[int, align.schema.pdk.ParasiticValues]]
width_x: int
width_y: int
class align.schema.pdk.PDK(*args, name: str, layers: Dict[str, Union[align.schema.pdk.LayerMetal, align.schema.pdk.LayerVia]] = None, scale_factor: int = 1)[source]

Bases: align.schema.types.BaseModel

class Config[source]

Bases: object

allow_mutation = True
add_layer(layer)[source]
generate_adr_collaterals(write_path: pathlib.Path, x_pitch: int, x_grid: int, y_pitch: int, y_grid: int, region: align.schema.constraint.List[int])[source]
layers: Dict[str, Union[align.schema.pdk.LayerMetal, align.schema.pdk.LayerVia]]
name: str
scale_factor: int
class align.schema.pdk.ParasiticValues(*args, mean: int = 0, min: int = 0, max: int = 0)[source]

Bases: align.schema.types.BaseModel

max: int
mean: int
min: int

align.schema.subcircuit module

class align.schema.subcircuit.Circuit(*args, name: str = None, base: str = None, pins: align.schema.model.List[str] = None, parameters: align.schema.model.Dict[str, str] = None, prefix: str = '', elements: align.schema.subcircuit.List[Instance], generator: align.schema.model.Dict[str, str] = None, constraints: align.schema.constraint.ConstraintDB)[source]

Bases: align.schema.subcircuit.SubCircuit

base: Optional[str]
constraints: align.schema.constraint.ConstraintDB
elements: align.schema.subcircuit.List[Instance]
generator: Optional[align.schema.model.Dict[str, str]]
name: Optional[str]
classmethod name_is_unique(name, values)[source]
parameters: Optional[align.schema.model.Dict[str, str]]
classmethod pin_check(pins, values)[source]
pins: Optional[align.schema.model.List[str]]
prefix: str
xyce()[source]
class align.schema.subcircuit.SubCircuit(*args, name: str, base: str = None, pins: align.schema.model.List[str] = None, parameters: align.schema.model.Dict[str, str] = None, prefix: str = '', elements: align.schema.subcircuit.List[Instance], generator: align.schema.model.Dict[str, str] = None, constraints: align.schema.constraint.ConstraintDB)[source]

Bases: align.schema.model.Model

add_generator(gen)[source]
base: Optional[str]
constraints: align.schema.constraint.ConstraintDB
elements: align.schema.subcircuit.List[Instance]
generator: Optional[align.schema.model.Dict[str, str]]
get_element(name)[source]
is_identical(subckt)[source]
name: str
property nets
parameters: Optional[align.schema.model.Dict[str, str]]
pins: Optional[align.schema.model.List[str]]
prefix: str
translate(solver)[source]
update_element(name, kwargs)[source]
verify(constraint=None)[source]
xyce()[source]

align.schema.transistor module

class align.schema.transistor.Transistor(*args, device_type: str, nf: int, l: float = None, w: float = None, nfin: int = None, model_name: str, params: Dict[str, Union[str, int, float]] = None)[source]

Bases: align.schema.types.BaseModel

device_type: str
l: Optional[float]
model_name: str
nf: int
nfin: Optional[int]
params: Optional[Dict[str, Union[str, int, float]]]
w: Optional[float]
class align.schema.transistor.TransistorArray(*args, unit_transistor: align.schema.transistor.Transistor, m: Dict[int, int], ports: Dict[int, Dict[str, str]], n_rows: int)[source]

Bases: align.schema.types.BaseModel

m: Dict[int, int]
n_rows: int
ports: Dict[int, Dict[str, str]]
unit_transistor: align.schema.transistor.Transistor

align.schema.types module

class align.schema.types.BaseModel(*args)[source]

Bases: pydantic.main.BaseModel

class Config[source]

Bases: object

allow_mutation = False
copy_on_model_validation = False
extra = 'forbid'
validate_assignment = True
copy(include=None, exclude=None, update={})[source]

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters
  • include – fields to include in new model

  • exclude – fields to exclude from new model, as with values this takes precedence over include

  • update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep – set to True to make a deep copy of the model

Returns

new model instance

property parent
class align.schema.types.Dict(*args, __root__: Dict[KeyT, DataT])[source]

Bases: pydantic.generics.GenericModel, Generic[align.schema.types.KeyT, align.schema.types.DataT]

class Config[source]

Bases: object

allow_mutation = False
copy_on_model_validation = False
extra = 'forbid'
validate_assignment = True
items()[source]
keys()[source]
property parent
values()[source]
class align.schema.types.List(*args, __root__: Sequence[DataT])[source]

Bases: pydantic.generics.GenericModel, Generic[align.schema.types.DataT]

class Config[source]

Bases: object

allow_mutation = False
copy_on_model_validation = False
extra = 'forbid'
validate_assignment = True
append(item: DataT)[source]
checkpoint()[source]
clear()[source]
extend(items: align.schema.types.List)[source]
property parent
pop(index=- 1)[source]
remove(item: DataT)[source]
revert(name=None)[source]
translate(solver)[source]
class align.schema.types.NamedTuple(typename, fields=None, /, **kwargs)[source]

Bases: object

Typed version of namedtuple.

Usage in Python versions >= 3.6:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:

Employee = NamedTuple('Employee', name=str, id=int)

In Python versions <= 3.5 use:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
align.schema.types.PrivateAttr(default: Any = PydanticUndefined, *, default_factory: Optional[Callable[], Any]] = None) → Any

Indicates that attribute is only used internally and never mixed with regular fields.

Types or values of private attrs are not checked by pydantic and it’s up to you to keep them relevant.

Private attrs are stored in model __slots__.

Parameters
  • default – the attribute’s default value

  • default_factory – callable that will be called when a default value is needed for this attribute If both default and default_factory are set, an error is raised.

align.schema.types.root_validator(_func: Optional[Callable[[], Any]] = None, *, pre: bool = False, allow_reuse: bool = False, skip_on_failure: bool = False) → Union[classmethod, Callable[[Callable[[], Any]], classmethod]]

Decorate methods on a model indicating that they should be used to validate (and perhaps modify) data either before or after standard model parsing/validation is performed.

align.schema.types.validate_arguments(func: Optional[AnyCallableT] = None, *, config: ConfigType = None) → Any

Decorator to validate the arguments passed to a function.

align.schema.types.validator(*fields: unicode, pre: bool = False, each_item: bool = False, always: bool = False, check_fields: bool = True, whole: bool = None, allow_reuse: bool = False) → Callable[[Callable[[], Any]], classmethod]

Decorate methods on the class indicating that they should be used to validate fields :param fields: which field(s) the method should be called on :param pre: whether or not this validator should be called before the standard validators (else after) :param each_item: for complex objects (sets, lists etc.) whether to validate individual elements rather than the

whole object

Parameters
  • always – whether this method and other validators should be called even if the value is missing

  • check_fields – whether to check that the fields actually exist on the model

  • allow_reuse – whether to track and raise an error if another validator refers to the decorated function

align.schema.visitor module

class align.schema.visitor.Transformer[source]

Bases: align.schema.visitor.Visitor

An ALIGN Visitor subclass that walks the ALIGN specification tree and allows modification of nodes.

By default, the Transformer will walk the AST and use the return value of visitor methods to replace the old node. Note that the return value may be the original node in which case no replacement takes place.

Keep in mind that if the node you’re operating on has child nodes you must either transform the child nodes yourself or call the generic_visit method for the node first.

Usually you use the transformer like this:: node = YourTransformer().visit(node)

generic_visit(node)[source]
class align.schema.visitor.Visitor[source]

Bases: object

The Visitor base class walks the ALIGN specification tree and calls a visitor function for every node found. This is very similar to the NodeVisitor class implemented by the python internal ast module (except that it operates on types.BaseModel derivates).

This class is meant to be subclassed, with the subclass adding visitor methods. The visitor functions for the nodes are 'visit_' + the class name of the node. So a SubCircuit node visit function would be visit_SubCircuit. If no visitor function exists for a node the generic_visit visitor is used instead.

Don’t use the Visitor if you want to apply changes to nodes during traversing. For this a special visitor exists (NodeTransformer) that allows modifications.

Usually you use the Visitor like this:: result = YourVisitor().visit(node)

Where the type of result is determined by the return type of the root node visitor. Note that the generic_visitor attempts to return either a list or None for most visitors.

static flatten(l)[source]
generic_visit(node)[source]
static iter_fields(node)[source]
visit(node)[source]
align.schema.visitor.cache(function=None, *, types=None)[source]

This decorator will store the results of a visitor method in self.cache and retrieve it if the id of a new object matches one in the cache.

This simultaeneously helps avoid redundant computation and ensures that shared pointers in the original tree results in shared pointers in the new tree. If this is not desired (if the result of a subtree is dependent upon the nodes above it for example), please implement a custom visit_* method WITHOUT the @cache decorator.

It is to be noted that the decorator can be used in two ways: 1) @cache

Cache all results (Used 99.999% of the time)

  1. @cache(types=[…]) Cache all incoming nodes that are instances of types (Mostly used by generic_visit)

Module contents