ordec.layout — Working with layouts

ordec.layout.makevias(layout: Layout, rect: Rect4I, layer: Layer, size: Vec2I, spacing: Vec2I, margin: Vec2I = None, rows: int = None, cols: int = None) → Rect4I

Generates via array in given rectangle area.

The array is centered in rect, so margin is a lower bound on the clearance to the rect edges, not the resulting clearance itself: only whole vias fit, and the leftover space is split between both sides. To place vias flush with an edge, pass a margin of 0 for that axis.

Either give both rows and cols (fixed array, margin unused), or give neither (both derived from margin). Specifying only one is rejected, because the margin component of the other axis would then be silently ignored.

Parameters:
  • layout – Layout to which the vias are added.

  • rect – Area in which the via array is generated.

  • layer – Layer of generated via array.

  • size – Dimensions of individual vias.

  • spacing – Spacing between individual vias.

  • margin – Minimum clearance between the outmost vias and the rect edges. Only used to derive rows and cols; it does not constrain counts that are given explicitly. Required if rows and cols are not given, and rejected if they are.

  • rows – Number of rows. If not specified (None), its value is automatically determined based on rect, size, spacing and margin.

  • cols – Number of columns. If not specified (None), its value is automatically determined based on rect, size, spacing and margin.

ordec.layout.poly_orientation(vertices: list[Vec2I])

Returns either ‘cw’ or ‘ccw’. Warning: Does not work for complex (i.e. self-intersecting) polygons!

ordec.layout.expand_paths(layout: Layout)

For the given Layout, replaces all LayoutPath instances by geometrically equivalent LayoutPoly instances.

ordec.layout.expand_rects(layout: Layout)

For the given Layout, replaces all LayoutRect instances by geometrically equivalent LayoutPoly instances.

ordec.layout.expand_geom(layout: Layout)

Replaces all LayoutRect and LayoutPath instances by equivalent LayoutPoly instances.

ordec.layout.expand_pins(layout: Layout, directory: Directory)

For a given layout, removes LayoutPin objects and adds according LayoutPoly and LayoutLabel instances.

Handles LayoutPoly and LayoutPath refs directly. Expects that LayoutRect objects have already been expanded (e.g. through expand_rects).

ordec.layout.expand_instancearrays(layout: Layout)

For the given Layout, replaces all LayoutInstanceArrays by geometrically equivalent LayoutInstances.

ordec.layout.write_gds(layout: Layout, file: IO[bytes], directory: Directory | None = None)

Write layout ‘layout’ as GDS binary data to file-like object ‘file’.

ordec.layout.gds_text(file: IO[bytes]) → str

Reads GDS data from file-like object ‘file’ and returns text representation. Used mainly for testing.

Hides modification and access times.

ordec.layout.compare(layout_a, layout_b) → str | None

Compare two layouts for geometric equivalence.

Flattens and expands both layouts to LayoutPoly/LayoutLabel/LayoutPin, then compares normalized geometry. ORDB path names are ignored.

Parameters:
  • layout_a – First Layout to compare.

  • layout_b – Second Layout to compare.

Returns:

None if the layouts are identical, else a str describing the differences.

class ordec.layout.SRouter(routing_spec: RoutingSpec, layout: Layout = None, solver: Solver = None)

Stack router

move(layer: Layer, pos: Vec2LinearTerm)

Set position and layer without drawing (like SVG ‘M’).

wire(pos: Vec2LinearTerm)

Draw a wire to pos (like SVG ‘L’).

wire_x(x)

Draw a horizontal wire (like SVG ‘H’).

wire_y(y)

Draw a vertical wire (like SVG ‘V’).

layer(layer: Layer)

Change to another routing layer, emitting a complete via stack at the current position: cuts plus landing pads on every metal layer traversed, including the start and destination layers.

The pads at both ends of the stack are wire-sized (route_pad): the route runs into them, on the start layer through the wire or the geometry it came from, on the destination layer through the wire it is expected to continue with. Only the metals in between stand on their own and get a full route_via pad.