landpattern module#

Landpattern and Pad definitions#

This module provides classes for defining component landpatterns, pads, and mappings between ports and pads.

class Landpattern[source]#

Bases: Open, Positionable

Component landpattern definition, also known as a footprint, package, or land-pattern.

Defines the pads and associated geometry for the interface between an electrical component and the circuit board.

>>> # MyPad is a user-defined Pad subclass (see Pad class below)
>>> # Silkscreen, Courtyard are from jitx.feature
>>> # Polyline, rectangle are from jitx.shapes
>>> class ZigZagLandpattern(Landpattern):
    ...     pad1 = MyPad().at(-0.5, 0)
    ...     pad2 = MyPad().at(0.5, 0)
    ...
    ...     silkscreen = Silkscreen(
    ...         Polyline(
    ...             0.1,
    ...             [
    ...                 (-0.4, 1), (-0.3, 1.2), (-0.2, 0.8),
    ...                 (-0.1, 1.2), (0, 0.8), (0.1, 1.2),
    ...                 (0.2, 0.8), (0.3, 1.2), (0.4, 1),
    ...             ]
    ...         )
    ...     )
    ...
    ...     courtyard = Courtyard(rectangle(2, 1))
class PadShape(shape, *, nfp=None)[source]#

Bases: object

Shapes of various features of a pad.

Parameters:
shape: Shape#

The geometric shape of the pad.

nfp: Shape | None = None#

The geometric shape of the pad when non-functional pads are removed.

static stack(pad, n_layers=None)[source]#

Produce a sequence representing the ViaDiameter stack for a Via, from the start_layer of the via through the stop_layer. Each layer will be represented once with the accompanying ViaDiameter object or float.

Parameters:
  • pad (Pad)

  • n_layers (int | None)

class Pad[source]#

Bases: Open, Positionable

Class representing a pad, user code should overload this class in order to create new pad definitions. If the pad contains a Cutout it will be interpreted as a through-hole pad, otherwise it will be interpreted as a surface mount pad.

>>> # Circle, rectangle are from jitx.shapes
>>> # Cutout, Soldermask are from jitx.feature
>>> class MyPad(Pad):
    ...     shape = Circle(diameter=0.8)
    ...     shapes = {
    ...         (0, 2): Circle(diameter=0.7),
    ...         1: PadShape(Circle(diameter=0.8), nfp=Circle(diameter=0.4)),
    ...         -1: rectangle(2., 2.),
    ...     }
    ...
    ...     def __init__(self):
    ...         self.cutout = Cutout(Circle(diameter=0.4))
    ...         self.soldermask = Soldermask(self.shape)
shape: Shape | PadShape#

The geometric shape of the pad or a PadShape to specify the regular shape and the shape when non-functional pads are removed. Can be overridden on a per-layer basis by shapes. When using a PadShape with nfp, the nfp removal does not apply to surface layers, to have surface nfp removal, use the shapes mapping to declare top and bottom explicitly.

shapes: Mapping[int | tuple[int, ...], Shape | PadShape] = {}#

The geometric shapes of the pad for specific layers. Overrides shape for the given layers.

entry: Sequence[Point] = ()#

Points in the pad’s frame where routes should enter the pad, inside or on the boundary of the pad shape. A route attaches to the point closest to where it approaches the pad. If empty, the router picks the point.

class PadMapping(entries)[source]#

Bases: Structural, Ref

Mapping between component ports and landpattern pads.

If a component declares no pad mapping, a default mapping is created when the design is translated: the component’s single-pin ports, in declaration order, are paired one to one with its pads in declaration order. Pads left over stay unconnected, and a port left without a pad is an error. Declare a PadMapping when:

  • a port connects to more than one pad, such as a ground pin and an exposed thermal pad;

  • the ports are declared in a different order from the pads, for example when pin 1 is not the first declared port.

Once a component declares any PadMapping, no default mapping is made, so every single-pin port must appear in one. A pad belongs to at most one port: mapping a second port to a pad already mapped raises an error at translation.

>>> class MyComponent(Component):
...     GND = Power()
...     VIN = Power()
...     VOUT = Power()
...
...     lp = MyLandpattern()
...     mappings = PadMapping({
...         GND: [lp.p[1], lp.p[4]],
...         VIN: lp.p[3],
...         VOUT: lp.p[2],
...     })
>>> class MyComponent(Component):
...     GND = Power()
...     VIN = Power()
...     VOUT = Power()
...
...     lp = MyLandpattern()
...     mappings = PadMapping({
...         GND: lp.p[1],
...         VIN: lp.p[2],
...         VOUT: lp.p[3],
...     })
Parameters:

entries (Mapping[Port, Pad | Sequence[Pad]] | Iterable[tuple[Port, Pad | Sequence[Pad]]])

get[T](port, default=None, /)[source]#

Return the pad or port associated with the given port or pad.

Overloads:
Parameters:
Return type:

Pad | Sequence[Pad] | Port | T

items()[source]#
values()[source]#
inverse()[source]#

Return the inverse mapping from pads to ports.

Return type:

Mapping[Pad, Port]

class CurrentLandpattern(landpattern, postprocessing=list())[source]#

Bases: Context

Context object representing the currently active landpattern during processing. Should not be used directly, but rather accessed through jitx.current’s landpattern instead.

>>> def get_landpattern_pads() -> list[Pad]:
...    landpattern = jitx.current.landpattern
...    pads = extract(landpattern, Pad)
...    return list(pads)
Parameters:
landpattern: Landpattern#
postprocessing: list[Callable[[Landpattern], None]]#
postprocess(func)[source]#
Parameters:

func (Callable[[Landpattern], Any])

class CurrentPad(pad, postprocessing=list())[source]#

Bases: Context

Context object representing the currently active pad during processing. Should not be used directly, but rather accessed through jitx.current’s pad instead.

>>> def get_pad_shape() -> Shape:
...    pad = jitx.current.pad
...    return pad.shape
Parameters:
pad: Pad#
postprocessing: list[Callable[[Pad], None]]#
postprocess(func)[source]#
Parameters:

func (Callable[[Pad], Any])