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
-
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
-
static
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
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'
).
WARNING: Align does not imply ordering of any sort (See Order)
Example:
{"constraint":"Align", "instances": ['MN0', 'MN1', 'MN2'], "line": "v_center"}
-
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
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
-
direction
: Optional[Literal[horizontal, vertical]]¶
-
line
: Literal[top, bottom, left, right, center]¶
-
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
Example:
{"constraint": "AspectRatio", "ratio_low": 0.1, "ratio_high": 10, "weight": 1 }
-
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.
AssignBboxVariables
(*args, constraint: str, bbox_name: str, llx: int, lly: int, urx: int, ury: int)[source]¶ Bases:
align.schema.constraint.HardConstraint
-
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.
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
Example:
{ "constraint" : "BlockDistance", "abs_distance" : 420 }
-
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
Example:
{"constraint": "Boundary", "subcircuit": "OTA", "max_height": 100 }
-
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.
Example:
{ "constraint": "ClockPorts", "ports": ["CLK1", "CLK2"], }
-
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"}
-
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 }
-
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]¶
-
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
Example:
{ "constraint":"CreateAlias", "instances": ["MN0", "MN1", "MN3"], "name": "alias1" }
-
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
-
class
align.schema.constraint.
DoNotRoute
(*args, constraint: str, nets: align.schema.model.List[str])[source]¶
-
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
Example:
{ "constraint": "DoNotUseLib", "libraries": ["DP_NMOS", "INV"], "propagate": false }
-
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
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 }
-
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}
-
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 } }
-
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"], }
-
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
Example:
{ "constraint":"GroupBlocks", "name": "group1", "instances": ["MN0", "MN1", "MN3"] "generator": {name: 'MOS', 'parameters': { "pattern": "cc", } } }
-
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 }
-
num_units
: align.schema.types.List¶
-
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
Example:
{ "constraint" : "GuardRing", "guard_ring_primitives" : "guard_ring", "global_pin }
-
class
align.schema.constraint.
HardConstraint
(*args, constraint: str)[source]¶ Bases:
align.schema.constraint.SoftConstraint
,abc.ABC
-
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
-
abstract
-
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
Example:
{ "constraint" : "HorizontalDistance", "abs_distance" : 80 }
-
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
Example
{ "constraint" : "MultiConnection", "nets" : ["N1", "N2", "N3"], "multiplier" : 4 }
-
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
Example:
{ "constraint" : "NetConst", "nets" : ["net1", "net2", "net3"], "shield" : "VSS", "criticality" : 10 }
-
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}
-
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
-
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
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
WARNING: Order does not imply aligment / overlap of any sort (See Align)
Example:
{"constraint":"Order", "instances": ['MN0', 'MN1', 'MN2'], "direction": "left_to_right"}
-
direction
: Optional[Literal[horizontal, vertical, left_to_right, right_to_left, bottom_to_top, top_to_bottom]]¶
-
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.
-
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
-
direction
: Literal[H, V]¶
-
ored_terms
: align.schema.constraint.List[OffsetsScalings]¶
-
-
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
-
direction
: Optional[Literal[horizontal, vertical]]¶
-
-
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
Example
{ "constraint" : "PortLocation", "ports" : ["P0", "P1", "P2"], "location" : "TL" }
-
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"], }
-
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
Example:
{"constraint":"SameTemplate", "instances": ["MN0", "MN1", "MN3"]}
-
class
align.schema.constraint.
SoftConstraint
(*args, constraint: str)[source]¶ Bases:
align.schema.types.BaseModel
-
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
WARNING: This constraint checks for overlap but doesn’t enforce it (See Align)
Example:
{ "constraint": "Spread", "instances": ['MN0', 'MN1', 'MN2'], "direction": horizontal, "distance": 100 }
-
direction
: Optional[Literal[horizontal, vertical]]¶
-
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
Example:
{ "constraint" : "SymmetricBlocks", "pairs" : [["MN0","MN1"], ["MN2","MN3"], ["MN4"]], "direction" : "V" }
-
direction
: Literal[H, V]¶
-
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
Example
{ "constraint" : "SymmetricNets", "net1" : "net1" "net2" : "net2" "pins1" : ["block1/A", "block2/A", "port1"] "pins2" : ["block1/B", "block2/B", "port2"] "direction" : 'V' }
-
direction
: Literal[H, V]¶
-
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
-
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.
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
Example:
{ "constraint" : "VerticalDistance", "abs_distance" : 84 }
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
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]¶
-
-
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]¶
-
-
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¶
align.schema.library module¶
align.schema.model module¶
align.schema.parser module¶
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
-
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
-
direction
: Literal[h, v]¶
-
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]]¶
-
-
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
-
unit_r
: Optional[Dict[int, align.schema.pdk.ParasiticValues]]¶
-
-
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
-
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]]¶
-
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
-
constraints
: align.schema.constraint.ConstraintDB¶
-
elements
: align.schema.subcircuit.List[Instance]¶
-
-
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
-
constraints
: align.schema.constraint.ConstraintDB¶
-
elements
: align.schema.subcircuit.List[Instance]¶
-
property
nets
¶
-
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
-
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
-
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
-
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¶
-
-
property
parent
¶
-
class
-
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¶
-
-
extend
(items: align.schema.types.List)[source]¶
-
property
parent
¶
-
class
-
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)
-
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.
-
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)
@cache(types=[…]) Cache all incoming nodes that are instances of types (Mostly used by generic_visit)