/jitx-skills:jitx-pin-assignmentfrom jitx-skills
Models flexible pin mappings between circuit interfaces and component pins using provide/require patterns, pin muxing, DiffPair polarity, PCIe/DDR/LPDDR5 lane/byte swapping, and SI constraints for FPGAs and MCUs.
Ships in jitx-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Model flexible pin mappings between circuit-level interfaces and component pins. A provider offers every mapping the part allows and leaves the choice open; routes on the provider's physical pins resolve it to one mapping.
Environment setup is handled by the base jitx skill. Ensure it has been invoked first.
The worked patterns this skill points at are modules in the jitxexamples package, which the base jitx skill's Step 1 installs. If import jitxexamples raises ModuleNotFoundError, it is not installed: run that step's jitxexamples and eseries lines. If jitxexamples imports but a pointed-at module does not, the installed jitxexamples predates these patterns: rerun that step's jitxexamples line, which upgrades it to the supported release, and if the module is still missing, say so and work from the rules here.
from jitx import Circuit, Net
from jitx.net import Port, DiffPair, Topology, provide, Provide
from jitx.common import Power, GPIO
from jitxlib.protocols.serial import I2C, SPI, UART
from jitx.si import BridgingPinModel, Constrain, ConstrainDiffPair, ConstrainReferenceDifference
from jitx.circuit import Route
from jitx.toleranced import Toleranced
These DO NOT EXIST — never import:
jitx.providers, jitx.pin_assignment, jitx.assign,
jitx.net.provide_one_of, jitxlib.pin_assignment, jitx.pin_assign
provide and Provide are also re-exported from jitx. Every constraint class, DiffPairConstraint and ReferencePlanes included, is in jitx.si.
Use it when a part's pins can serve more than one role and the choice should stay open until routing: MCU GPIO and peripheral muxing, DiffPair P/N polarity where protocol and controller allow it, PCIe lane order and width, DDR byte and bit swapping, channel choice on a pass-through part with identical channels. Use fixed wiring when the mapping is 1:1 (DDR address pins, CK polarity), or the datasheet gives one valid pin function. For a self-critique pass after writing, invoke jitx-code-review (optional for single-task use).
A bundle is a Port subclass that groups related signals; it is the type parameter of provide and require(). Read an unlisted bundle's sub-ports from its class source (Grep class BundleName under .venv).
| Bundle | Import | Sub-ports |
|---|---|---|
GPIO | jitx.common | .gpio |
Power | jitx.common | .Vp, .Vn |
DiffPair | jitx.net | .p, .n |
I2C | jitxlib.protocols.serial | .sda, .scl |
SPI | jitxlib.protocols.serial | .sck, .copi, .cipo, .cs; the last three optional: SPI(cs=True) |
UART | jitxlib.protocols.serial | .tx, .rx on by default; flow control optional: UART(cts=True, rts=True) |
For a custom bundle, subclass Port (never Circuit or Component). Sub-ports are class attributes; use lists for indexed groups and nest bundles for hierarchy:
class PCIeLane(Port):
TX = DiffPair()
RX = DiffPair()
class PCIeLink(Port):
lane = [PCIeLane() for _ in range(4)]
When one choice fixes pins on two sides of a part (both ends of a pass-through channel), put both sides in one bundle so one mapping sets both; separate offers per side can pick different channels for the two ends.
A component defines the pins; a circuit wrapping it declares with provide the bundles it offers and the pins each option maps to; an application circuit calls .require() on the wrapper and wires what it gets back.
Every provide method returns list[dict[Port, Port]]: one dict per option. The keys are the bundle parameter's sub-ports, every one of them in every option. The values are component pins (self.<component>.<port>) or sub-ports of a bundle the provider requires from itself (Hierarchical Provider Composition).
@provide.one_of(I2C)
def provide_i2c(self, i2c: I2C) -> list[dict[Port, Port]]:
return [
{i2c.sda: self.mcu.GPIO[0], i2c.scl: self.mcu.GPIO[1]}, # Option A
{i2c.sda: self.mcu.GPIO[2], i2c.scl: self.mcu.GPIO[3]}, # Option B
]
jitx/SKILL.md bans string-keyed design state and list[dict[str, Any]] spec models. The provide return value alone is exempt: its keys are the bundle's Port objects, and the list is the framework's pin-mapping contract, not a parallel model. Use that shape exactly, with no string key anywhere in it (the discriminator is the key type: jitx/references/architectural-patterns.md § "String-keyed dicts → structural objects").
| Variant | Decorator | Constructor | Offers |
|---|---|---|---|
| all_of | @provide(B) | Provide(B).all_of(fn) | One provider per option, all assignable at once (GPIO). |
| one_of | @provide.one_of(B) | Provide(B).one_of(fn) | One provider, filled by exactly one option (a bus on one pin group or another). |
| subset_of | @provide.subset_of(B, n) | Provide(B).subset_of(n, fn) | At most n options assigned (a current budget across GPIO). |
fn takes the bundle and returns the mapping list. Use the constructor when the options depend on __init__ arguments (here n), and store its result on self:
self.gpios = Provide(GPIO).all_of(lambda g: [{g.gpio: p} for p in self.mcu.GPIO[:n]])
require()provider.require(B) returns a bundle whose sub-ports are netted with + like any port; require(B, count=n) returns a sequence of n. Keep the result in a local variable and store the nets. A require()d port stored on self fails the build with Port <circuit>.<name> is a required port from <Provider> and should not be a member field of a circuit.
gpio = self.mcu_circuit.require(GPIO) # local, never self.gpio
self.led_net = gpio.gpio + self.led.anode
Worked example, end to end (RP2040 SPI and I2C muxing, a shipping design with no routes, legal and illegal verification designs): jitxexamples.jumpstart_kits.js3_pin_assignment.mcu_muxing.
A required bundle has no field of its own. It takes its name from the first stored Net (a >> topology does not count), in the order the circuit assigns its fields, that holds any of its signals, and constraint paths that start on it read as members of that net (RESET_n.ch[0].ca[0]). Name it by storing a net of the whole bundle before any net of its signals:
bus = self.fpga.require(VersalLPDDR4)
self.lpddr4 = Net([bus]) # stored first: paths read lpddr4.ch[0].ca[0]
self.RESET_n = bus.reset_n + self.memory.memory.RESET_n
Worked pattern: jitxexamples.jumpstart_kits.js4_fpga_lpddr4.base.
Inside a provide method a provider can call self.require(...) on its own providers and map the outer bundle onto what it gets back. Use it when parts of an interface are chosen independently, such as SDA and SCL from their own pin lists. Inner bundle types are nested classes on the circuit or live in their own module.
@provide(I2C)
def provide_i2c(self, i2c: I2C) -> list[dict[Port, Port]]:
sda = self.require(self.I2C_SDA) # single-pin bundle, @provide.one_of over SDA pins
scl = self.require(self.I2C_SCL)
return [{i2c.sda: sda.p, i2c.scl: scl.p}]
Concept: I2C Example. Worked pattern: jitxexamples.components.mcus.raspberry_pi_RP2040 (I2C, SPI and UART composed from per-signal one_of pin lists).
Offer a P/N swap only when the part or protocol explicitly supports it at both ends (references/protocol-pin-flexibility.md). The inversion is its own option with the legs crossed:
{link.p: self.ic.TXP, link.n: self.ic.TXN}, # straight
{link.p: self.ic.TXN, link.n: self.ic.TXP}, # inverted
A code route from TXN to the far end's p pin resolves the inverted option. Worked pattern: jitxexamples.patterns.pin_lane_polarity (lane choice and P/N inversion, proven straight, inverted and illegal).
Write the constraint as jitx-interconnect-constraints teaches: plain + nets and Topology(begin, end), no >>. The path between the ends is inferred from the routes; it crosses a via, or a part with a pin model, where routes land on both sides. >> (TopologyNet) is only for a daisy chain whose order is part of the design, such as a flyby clock. What pin assignment adds:
BridgingPinModel between the two pins that path joins (a series resistor, an AC-coupling capacitor, an ESD channel whose datasheet gives an in-to-out path); without one the path stops there (No path for signal constraint ... which has no pin model). A flow-through package whose pin opposite the channel is n.c. has no path through it: no pin model, and the channel pin and the n.c. pin are one net joined by board copper. A pin model's delay and loss come from the part's datasheet; a fixture or placeholder part says it is fictional in its docstring and labels its values illustrative.Routes ending on the provider's physical pins, and gives each component a proof route touches its own .at(...) (jitx-circuit-builder, "Placement"). A route cannot end on a required port (Using require ports as route ends ... is not implemented). A via in a pad joins that pad's pin by PortAttachment(pin, via), never also in a Net (Encountered <via> both in a net and port attached). Proof routes fix one mapping, so they never go in the product design.Code route dropped) and their leg has no path; a leg whose routes fit an offered mapping still measures. A constraint on a required port measures only once its assignment resolves, so with no routes nothing measures.Topology(self.drv.d[0], self.rcv.d[0]). Worked pattern: jitxexamples.patterns.pin_series_array.from src.u.a.n to conn.tx.p for an inverted pair. Worked pattern: jitxexamples.patterns.pin_lane_polarity.ConstrainReferenceDifference, whose guide must be a single pin (Guide must be a single pin type): one leg, such as a strobe's p, never the DiffPair.group.satisfied (Step 3).Offer PCIe lane reversal, polarity inversion or a narrower link width only where the controller datasheet confirms it; the per-feature rules are in references/protocol-pin-flexibility.md. A lane constraint begins on the required lane (rule 4 above); worked pattern: jitxexamples.patterns.pin_lane_polarity.
Where the controller allows bytes to move between byte slots and bits within a byte, model both as two levels of provide, never one_of over bit permutations (8! = 40,320 options per byte):
Slot0Bit, Slot1Bit, ...), offered all_of over the slot's eight DQ pins. Per slot because require() matches an offer by bundle type: one shared type would let a byte's bits resolve onto another slot's pins.one_of, one option per allowed byte-to-slot order. In the options callback, self.require(SlotBit, count=8) once per slot; each option maps the fixed pins, the slot's DQS and DMI, and the byte's eight DQ ports to that slot's eight bits.DQS and DMI move with their byte; address, command and CK (polarity included) are fixed wiring. Match each DQ to its strobe with ConstrainReferenceDifference (rule 5). Worked example: jitxexamples.jumpstart_kits.vp1002_lpddr4 (LPDDR4 on a Versal VP1002: the pin layout in pinout, the two-level offer in circuit with the protocol's shared-CKE controller bundle in bundles). jumpstart_kits.js4_fpga_lpddr4.constraint holds each DQ to its strobe on that offer with VersalLPDDR4Constraint, which builds on jitxexamples.protocols.memory.lpddr4.LPDDR4Constraint for the per-DQ ConstrainReferenceDifference, and js4_fpga_lpddr4.part3_si_constraints applies it. js4_fpga_lpddr4.part4_routing is a reference layout whose routes resolve the offer to a byte swap within channel B.
return self.mcu.GPIO[0]. Return [{g.gpio: self.mcu.GPIO[0]}].self.led_pin = gpio.gpio makes no connection. Use self.led_net = gpio.gpio + self.led.anode.tx.p + self.dst.INP.p alone is built and discarded. Store it: self.tx_net = tx + self.dst.INP.@provide.one_of(GPIO) when several GPIOs are wanted: it gives one GPIO in total. Use @provide (all_of).Step 1: ruff format path/to/circuit.py and pyright path/to/circuit.py.
Step 2: jitx build <module.path.DesignClass>. Don't run parallel JITX builds against the same project; sequence them (Build safety).
Run the check on the verification design (rule 2); the product design reports these constraints unresolved until the board is routed. Run this as a script from the project root while the project's runtime is running:
import jitx
from mypkg.verify import VerifyDesign
def main() -> None:
with jitx.runtime as rt:
report = rt.submit(VerifyDesign).issues(satisfied=True, wait=30)
if not report.complete:
print("report incomplete: raise wait and run again")
for group in report.groups():
print("met" if group.satisfied else "NOT MET", group.text)
if len(group.issues) > 1:
for issue in group:
print(" ", issue.text)
if __name__ == "__main__":
main()
The report API, and the report texts and their causes: jitx-interconnect-constraints references/verification.md. The texts specific to pin assignment:
| Report text | Cause |
|---|---|
Unassigned Pin on Path: nets[0].p | Topology begins on the required port; the assignment did not resolve. |
No path for signal constraint from drv.d[0] to rcv.d[0] | Fixed ends around the assigned part; no routes, or routes matching no offered mapping. |
Code route dropped: it conflicts with other connections | The routes matched no offered mapping (rule 3). On a net with no SI constraint it can read Code route dropped: its ends are on different nets. |
To show the offered mappings are enforced, also prove one routing that matches none: it must report a dropped route and no measurement for that leg.
evals/cases/pin-patterns-retrieval.json (opens in a new tab)evals/cases/reference/usb-through-esd-swap/NOTES.md (opens in a new tab)evals/cases/reference/usb-through-esd-swap/check_usb_esd_swap.py (opens in a new tab)evals/cases/reference/usb-through-esd-swap/usb_esd_swap_design.py (opens in a new tab)evals/cases/usb-through-esd-swap.json (opens in a new tab)evals/eval-contract.yaml (opens in a new tab)evals/routing.jsonl (opens in a new tab)references/protocol-pin-flexibility.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jitx-inc/jitx-skills --plugin jitx-skills13 skills in this plugin
/jitxBase skill for JITX Python PCB design: install, the jitx CLI, auth and the runtime, building designs, the viewers, exports, code quality (ruff, pyright, type annotations, check.py and grep gates), and design introspection (jitx.inspect, jitx.query, runtime submit). Use to set up JITX, start the runtime, build or find a design, open the viewer, fix a build or environment error, or find things in a design from Python. Route a whole board from requirements to jitx-project-builder, code self-review to jitx-code-review, component modeling to jitx-component-modeler, wiring and passives to jitx-circuit-builder, stackups to jitx-substrate-modeler, layout in code and realized-geometry checks to jitx-code-layout, open-layout place and route to jitx-interactive-layout, design rules, stitching, fencing and routing structures by tag to jitx-layout-constraints, SI constraints to jitx-interconnect-constraints, pin flexibility to jitx-pin-assignment, mechanical CAD to jitx-mechanical, and JLCPCB fab and parts to jitx-jlcpcb./jitx-circuit-builderUse when the user asks to "wire up", "connect", "build a circuit", create an "application circuit", declare a circuit's typed ports or bundles (Power, I2C, RGMII), compose sub-circuits into a hierarchy and connect them port to port, "place components" or sub-circuits (fixed or floating), add passives (resistors, capacitors, inductors) or decoupling, or set up power connections. Covers the Circuit class, nets and the + operator, typed ports, hierarchy, placement, and jitxlib-parts passives. Drawing a pour or copper is jitx-code-layout; pour rules are jitx-layout-constraints; provide/require pin assignment is jitx-pin-assignment./jitx-code-layoutUse when the user asks to write a fixed PCB layout in Python: place vias, and parts relative to another instance (Circuit.place), code routes through control points (RoutePoint, PairPoint, PairInsertion), Route.Sketch, Route.Config, a Route.Target taper, narrowing a route in a BGA field or a fine-pitch pad, escape or fanout geometry fixed by a stated number or pad geometry, a connector launch on its pad axis, serpentine or deskew settings on a matched section, thermal vias in an exposed pad, pours, keepouts, cutouts, Copper or OverlappableCopper (antennas, net ties), or reading the realized layout back (capture, Empty pours, 'Unable to find path'). Sorts control points between code and jitx-interactive-layout. Tag rules, escape width rules, stitching and fencing go to jitx-layout-constraints; stackups, vias and structure definitions to jitx-substrate-modeler; land-pattern mask, paste and thermal pads to jitx-component-modeler; nets and passives to jitx-circuit-builder; timing to jitx-interconnect-constraints./jitx-code-reviewSame-model self-critique pass for JITX Python code just written in this workspace. Use when the user asks to "review my JITX code", "self-critique", "check JITX conventions", "find string-hacking", "check framework-boundary issues", "audit before merge", or any equivalent. Mandatory for complete-board tier at task acceptance (folds into Think Twice); user-invoked for single-task work. Catches the architectural failure modes that grep gates and static linters miss — parallel string-keyed models, reflection-as-iteration (regardless of whether on self), owner-shaped data misplaced in design code, build-spec-then-iterate, module-import-time parallel models, and framework-boundary-bypass (the "framework does it, therefore so can I" trap). Applies an ownership test to every banned-pattern hit or proposed exception. Produces severity-tagged findings (CRITICAL / WARNING / NOTE) that fold into the task acceptance block./jitx-component-modelerCreate JITX Python component code from datasheets, KiCad footprints, vendor pin files, or user specifications. ALWAYS use this skill when user asks to "create a component", "model a part", "generate a component", "add a component", or "make a JITX component" - even without a datasheet. Also triggers on part numbers (NE555, LM1117, RP2040) and package types (SOIC, QFN, BGA, SON, SOT). Covers JITX generators for standard packages, a vendor's KiCad footprint read directly for non-standard ones, multi-unit symbols, thermal pads, pin mappings, and datasheet checks with jitx.test.TestCase. Also covers generating from a vendor's machine-readable pinout file rather than a drawing ("generate the FPGA from the pin file", "parse the package pinout file", "model this 1000-ball BGA"): parse-don't-transcribe, reconcile the ball inventory before emitting, and a committed generator with a regenerate-and-diff check. For choosing and placing an ordinary queried passive, use jitx-circuit-builder instead./jitx-interactive-layoutUse when the user asks to place components, route nets, drop vias, add pair insertions or route points, or draw pours in the open board layout from a script, so the result stays editable in the board editor: place and route a board or circuit, fan out a BGA, route DDR byte lanes, change a layout the user edited by hand, fix blocked routes, report layout issues or skew margin. Runs Python against a live design through jitx design session and jitx design exec, with the rd.layout requests (place, route, via, route_point, pair_insertion, region, modify, delete), and reads the result back through route status, rd.issues() and the bundled checks. Assumes the layout constraints are already in the design. Design rules, net classes, tags and escape-width rules in code belong to jitx-layout-constraints; decoupling modules to jitx-circuit-builder; copper, code-placed vias, code Route objects and control points in code to jitx-code-layout; topology, timing and skew constraints to jitx-interconnect-constraints.Other plugins' skills for the same job