layout module#
The physical design (layout) of a design held by the runtime.
Reached through RuntimeDesign.layout. Requests change the design in the
runtime, as if made in the UI. Placements are applied to the local design tree
from the reply; routes, vias, control points, and area regions appear in it
when the runtime reports them. monitor registers callbacks on changes
(see jitx.run.monitor), and emit sends user events.
- exception RequestRejected(kind, message, operation=None)[source]#
Bases:
RuntimeErrorThe runtime refused a request.
- class RouteSetting(*values)[source]#
Bases:
StrEnumA route setting, as named by the
resetargument of a modification.>>> rd.layout.modify(route, reset=[RouteSetting.Width])
- Width = 'width'#
The trace width.
- Space = 'space'#
The trace clearance.
- PairSpace = 'pair_space'#
The differential pair spacing.
- EnvelopeOverhead = 'envelope_overhead'#
The extra width of the length matching region.
- class PendingPlacement(target)[source]#
Bases:
objectThe resulting placement of a component placed in a batch, available once the batch has been sent.
- Parameters:
target (Component)
- property placement: Placement#
The board-absolute placement the runtime reported.
- Raises:
RuntimeError – if the batch has not been sent.
- class PendingSync[source]#
Bases:
_PendingThe outcome of a sync in a batch, available once the batch has been sent.
- property settled: bool#
Whether background tasks had finished; False if the sync timed out.
- Raises:
RuntimeError – if the batch has not been sent.
- class PendingRoute(rmap)[source]#
Bases:
_PendingA route created by a request. Its runtime id is available once the batch has been sent; the
Routeobject once the runtime reports it routed or blocked (follow the request with a sync to wait for that), or after a capture.- Parameters:
rmap (Callable[[], ReverseMapper])
- property key: CompositeKey#
The runtime id of the route.
- Raises:
RuntimeError – if the batch has not been sent.
- class PendingVia(rmap, key=None)[source]#
Bases:
_PendingA via created or updated by a request. Its runtime id and position are available once the batch has been sent; the
Viaobject once the runtime reports it (follow the request with a sync to wait for that), or after a capture.- Parameters:
rmap (Callable[[], ReverseMapper])
key (CompositeKey | None)
- property key: CompositeKey#
The runtime id of the via.
- Raises:
RuntimeError – if the batch has not been sent.
- property position: Point#
The board-absolute position of the via, after the runtime moved it to a free spot, if it did.
- Raises:
RuntimeError – if the batch has not been sent.
- property route: PendingRoute | None#
The route from the via’s origin to the via; None if they coincide or the via was updated rather than created.
- class PendingControlPoint(rmap, key=None)[source]#
Bases:
_PendingA control point created or updated by a request. Its runtime id, and the routes made to it, are available once the batch has been sent; the control point object once the runtime reports it (follow the request with a sync to wait for that), or after a capture.
- Parameters:
rmap (Callable[[], ReverseMapper])
key (CompositeKey | None)
- property key: CompositeKey#
The runtime id of the control point.
- Raises:
RuntimeError – if the batch has not been sent.
- property routes: Sequence[PendingRoute]#
The routes made from the origin(s) to the control point when it was created; empty for an update.
- property control_point: ControlPoint | None#
The control point in the current design tree, or None if the runtime has not reported it yet.
- class PendingRegion(rmap)[source]#
Bases:
_PendingAn area region created by a request. Its runtime id is available once the batch has been sent; the model object (the region’s feature, or for a copper pour its
Pour) once the runtime reports it (follow the request with a sync to wait for that), or after a capture.- Parameters:
rmap (Callable[[], ReverseMapper])
- property key: CompositeKey#
The runtime id of the region.
- Raises:
RuntimeError – if the batch has not been sent.
- property region: Feature | Pour | None#
The region in the current design tree, or None if the runtime has not reported it yet. A convex hull region’s feature has a
ConvexHullshape holding its anchors and the evaluated polygon; a copper pour’s shape is its poured copper.
- type RegionFeature = KeepOut | Soldermask | Silkscreen | Paste | Glue | Finish | Custom | Cutout | Pour#
What an area region can be: a keepout, a cutout, a surface feature, or a single-layer copper pour.
- type RegionElement = Pad | Port | Via | PendingVia | ControlPoint | PendingControlPoint | Component | object#
A board element a region refers to (an origin, a hull anchor).
- type RouteEndpoint = Port | Pad | Via | PendingVia | PendingControlPoint | object#
What a route can start or end at: a pad, a port mapped to a single pad, a via (or a
PendingViafrom an earlier request), or a control point (or aPendingControlPoint) or one of its endpoints.
- type DiffPairPads = DiffPair | tuple[Port | Pad | Via | PendingVia, Port | Pad | Via | PendingVia]#
The two sides of a differential pair: a
DiffPairport whosepandneach map to a single pad, or(p, n)as pads, vias, or ports mapped to a single pad.
- type Deletable = Route | Via | ControlPoint | Feature | Pour | PendingRoute | PendingVia | PendingControlPoint | PendingRegion#
What
delete()accepts.
- class AsyncBatch(rmap, send)[source]#
Bases:
_BatchRequests sent together as one request when the
async withblock exits without an exception.The runtime applies the batch in order and all-or-nothing, as one undoable step. Placing a component again in the same batch applies to its earlier placement in the batch.
>>> async with design.layout.batch() as b: ... p = b.place(design.root.u1, (10, 5), 90) ... b.place(design.root.u2, on=Side.Bottom) >>> p.placement
- Raises:
RequestRejected – from the block exit, if the runtime refused the batch.
- Parameters:
rmap (Callable[[], ReverseMapper])
send (Callable[[pdpb2.PhysicalDesignOperations], Awaitable[pdpb2.PhysicalDesignOperationsResponse]])
- class SyncBatch(rmap, send)[source]#
Bases:
_BatchRequests sent together as one request when the
withblock exits without an exception.The runtime applies the batch in order and all-or-nothing, as one undoable step. Placing a component again in the same batch applies to its earlier placement in the batch.
>>> with design.layout.batch() as b: ... p = b.place(design.root.u1, (10, 5), 90) ... b.place(design.root.u2, on=Side.Bottom) >>> p.placement
- Raises:
RequestRejected – from the block exit, if the runtime refused the batch.
- Parameters:
rmap (Callable[[], ReverseMapper])
send (Callable[[pdpb2.PhysicalDesignOperations], pdpb2.PhysicalDesignOperationsResponse])
- class AsyncLayout(rmap, send, *, monitor=None, publish=None)[source]#
Bases:
objectThe layout of an async runtime design. Each request method is one request; see
batch()to send several as one.- Parameters:
rmap (Callable[[], ReverseMapper])
send (Callable[[pdpb2.PhysicalDesignOperations], Awaitable[pdpb2.PhysicalDesignOperationsResponse]])
monitor (LayoutMonitor | None)
publish (Callable[[pdpb2.PhysicalDesignEvent], Awaitable[None]] | None)
- property monitor: LayoutMonitor#
Callbacks on changes to the layout. See
LayoutMonitor.
- async emit(event)[source]#
Send a user event to the other clients monitoring this design.
- Raises:
TypeError – if the event’s data is not JSON-compatible.
ValueError – if an object has no runtime ID.
- Return type:
- Parameters:
event (UserEvent)
- batch()[source]#
Start a batch of requests, sent as one request. See
AsyncBatch.- Return type:
- async sync(timeout=None)[source]#
Wait until the runtime has no background tasks running (routing, checks, …), so the design is settled.
- async place(target, /, position=None, rotation=None, *, on=None)[source]#
Place a component on the board, as if dragged in the UI.
- Overloads:
- Parameters:
- Returns:
The resulting board-absolute placement.
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async route(start, end, layer, *, turns=None, width=None, space=None, pair_space=None, envelope_overhead=None, pour=None, wait=True)[source]#
Route between two endpoints. See
AsyncBatch.route().- Parameters:
wait (
bool) – Wait for background work (the routing) to finish, so the route is routed or blocked when this returns.start (RouteEndpoint)
end (RouteEndpoint)
layer (int)
width (float | None)
space (float | None)
pair_space (float | None)
envelope_overhead (float | None)
pour (bool | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async via(definition, origin, position, layer, *, turns=None, force=False, width=None, space=None, wait=True)[source]#
Place a routing via. See
AsyncBatch.via().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async update_via(via, *, position=None, definition=None, force=False, wait=True)[source]#
Move a via or change its definition. See
AsyncBatch.update_via().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async modify(route, *, turns=None, width=None, space=None, pair_space=None, envelope_overhead=None, pour=None, reset=(), wait=True)[source]#
Change a route’s sketch or settings. See
AsyncBatch.modify().- Parameters:
wait (
bool) – Wait for background work (rerouting) to finish.route (Route | PendingRoute)
width (float | None)
space (float | None)
pair_space (float | None)
envelope_overhead (float | None)
pour (bool | None)
reset (Collection[RouteSetting])
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async route_point(origin, position, layer, *, radius=None, size=None, turns=None, width=None, space=None, wait=True)[source]#
Add a route point. See
AsyncBatch.route_point().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async pair_insertion(pair, position, rotation, layer, *, invert=False, width=None, space=None, pair_space=None, wait=True)[source]#
Add a differential pair insertion point. See
AsyncBatch.pair_insertion().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async pair_point(origin, position, rotation, layer, *, turns=None, width=None, space=None, pair_space=None, wait=True)[source]#
Add a pair point. See
AsyncBatch.pair_point().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async drop_pair_insertion(pair, layer, *, pull=None, width=None, space=None, pair_space=None, wait=True)[source]#
Add a pair insertion point placed next to its pads. See
AsyncBatch.drop_pair_insertion().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async update_control(control, *, position=None, rotation=None, invert=False, radius=None, size=None, wait=True)[source]#
Move, reshape, or invert a control point. See
AsyncBatch.update_control().- Parameters:
wait (
bool) – Wait for background work (rerouting) to finish.control (ControlPoint | PendingControlPoint)
position (Point | None)
rotation (float | None)
invert (bool)
radius (float | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async region(feature, /, *, origin=None, net=None, wait=True)[source]#
Add an area region. See
AsyncBatch.region().- Parameters:
wait (
bool) – Wait for background work (evaluating, pouring) to finish, so the region is in the model when this returns.feature (RegionFeature)
origin (RegionElement | None)
net (Net | Pad | Port | Via | PendingVia | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async update_region(region, /, *, shape=None, layers=None, side=None, rank=None, pour=None, via=None, route=None, name=None, origin=None, net=None, wait=True)[source]#
Change an area region. See
AsyncBatch.update_region().- Parameters:
wait (
bool) – Wait for background work (evaluating, pouring) to finish.region (Feature | Pour | PendingRegion)
shape (Shape | None)
side (Side | None)
rank (int | None)
pour (bool | None)
via (bool | None)
route (bool | None)
name (str | None)
origin (RegionElement | None)
net (Net | Pad | Port | Via | PendingVia | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- async delete(*objects)[source]#
Delete routes, vias, control points, and area regions. See
AsyncBatch.delete().- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- Parameters:
objects (Deletable)
- class SyncLayout(rmap, send, *, monitor=None, publish=None)[source]#
Bases:
objectThe layout of a sync runtime design. Each request method is one request; see
batch()to send several as one.- Parameters:
rmap (Callable[[], ReverseMapper])
send (Callable[[pdpb2.PhysicalDesignOperations], pdpb2.PhysicalDesignOperationsResponse])
monitor (LayoutMonitor | None)
publish (Callable[[pdpb2.PhysicalDesignEvent], None] | None)
- property monitor: LayoutMonitor#
Callbacks on changes to the layout. See
LayoutMonitor.
- emit(event)[source]#
Send a user event to the other clients monitoring this design.
- Raises:
TypeError – if the event’s data is not JSON-compatible.
ValueError – if an object has no runtime ID.
- Return type:
- Parameters:
event (UserEvent)
- sync(timeout=None)[source]#
Wait until the runtime has no background tasks running (routing, checks, …), so the design is settled.
- place(target, /, position=None, rotation=None, *, on=None)[source]#
Place a component on the board, as if dragged in the UI.
- Overloads:
- Parameters:
- Returns:
The resulting board-absolute placement.
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- route(start, end, layer, *, turns=None, width=None, space=None, pair_space=None, envelope_overhead=None, pour=None, wait=True)[source]#
Route between two endpoints. See
SyncBatch.route().- Parameters:
wait (
bool) – Wait for background work (the routing) to finish, so the route is routed or blocked when this returns.start (RouteEndpoint)
end (RouteEndpoint)
layer (int)
width (float | None)
space (float | None)
pair_space (float | None)
envelope_overhead (float | None)
pour (bool | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- via(definition, origin, position, layer, *, turns=None, force=False, width=None, space=None, wait=True)[source]#
Place a routing via. See
SyncBatch.via().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- update_via(via, *, position=None, definition=None, force=False, wait=True)[source]#
Move a via or change its definition. See
SyncBatch.update_via().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- modify(route, *, turns=None, width=None, space=None, pair_space=None, envelope_overhead=None, pour=None, reset=(), wait=True)[source]#
Change a route’s sketch or settings. See
SyncBatch.modify().- Parameters:
wait (
bool) – Wait for background work (rerouting) to finish.route (Route | PendingRoute)
width (float | None)
space (float | None)
pair_space (float | None)
envelope_overhead (float | None)
pour (bool | None)
reset (Collection[RouteSetting])
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- route_point(origin, position, layer, *, radius=None, size=None, turns=None, width=None, space=None, wait=True)[source]#
Add a route point. See
SyncBatch.route_point().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- pair_insertion(pair, position, rotation, layer, *, invert=False, width=None, space=None, pair_space=None, wait=True)[source]#
Add a differential pair insertion point. See
SyncBatch.pair_insertion().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- pair_point(origin, position, rotation, layer, *, turns=None, width=None, space=None, pair_space=None, wait=True)[source]#
Add a pair point. See
SyncBatch.pair_point().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- drop_pair_insertion(pair, layer, *, pull=None, width=None, space=None, pair_space=None, wait=True)[source]#
Add a pair insertion point placed next to its pads. See
SyncBatch.drop_pair_insertion().- Parameters:
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- update_control(control, *, position=None, rotation=None, invert=False, radius=None, size=None, wait=True)[source]#
Move, reshape, or invert a control point. See
SyncBatch.update_control().- Parameters:
wait (
bool) – Wait for background work (rerouting) to finish.control (ControlPoint | PendingControlPoint)
position (Point | None)
rotation (float | None)
invert (bool)
radius (float | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- region(feature, /, *, origin=None, net=None, wait=True)[source]#
Add an area region. See
SyncBatch.region().- Parameters:
wait (
bool) – Wait for background work (evaluating, pouring) to finish, so the region is in the model when this returns.feature (RegionFeature)
origin (RegionElement | None)
net (Net | Pad | Port | Via | PendingVia | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- update_region(region, /, *, shape=None, layers=None, side=None, rank=None, pour=None, via=None, route=None, name=None, origin=None, net=None, wait=True)[source]#
Change an area region. See
SyncBatch.update_region().- Parameters:
wait (
bool) – Wait for background work (evaluating, pouring) to finish.region (Feature | Pour | PendingRegion)
shape (Shape | None)
side (Side | None)
rank (int | None)
pour (bool | None)
via (bool | None)
route (bool | None)
name (str | None)
origin (RegionElement | None)
net (Net | Pad | Port | Via | PendingVia | None)
- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- delete(*objects)[source]#
Delete routes, vias, control points, and area regions. See
SyncBatch.delete().- Raises:
RequestRejected – if the runtime refused the request.
- Return type:
- Parameters:
objects (Deletable)