jitxlib.parts package#
JITX parts#
A pluggable parts database and search interface. Describe a passive by what it has to do and a chain of providers decides which part satisfies it:
- class Divider(Circuit):
- def __init__(self):
self.top = Resistor(resistance=10 * kohm, tolerance=AtMost(1 * pct)) self.bottom = Resistor(resistance=4.7 * kohm, tolerance=AtMost(1 * pct)) self.nets = [self.top.p2 + self.bottom.p1]
Resistor, Capacitor, PolarizedCapacitor and Inductor are ordinary components with their ports already declared. Constructing one enqueues a query; the batch resolves at the end of elaboration, or earlier if something reads a resolved field such as value or mpn.
Where the parts come from is meant to be configuration. A project names its chain under [tool.jitx.parts], or installs a package that publishes one, and no part number appears in the design source. A chain can equally be built in code: a PartSource is a context, so it can be assigned on a Design or scoped with a with block, which is what a test, a notebook or a one-off variant wants. Configuration is the intended route rather than the only one.
Selections are pinned to a lockfile, so a later run gives the same board even after a catalogue has grown; Lock chooses the file and the mode, and parts_verdict reports what the run did.
To write a provider, implement Provider: answer a batch of CanonicalQuery with Resolved, NoMatch, Unsupported or Deny, and hand back a ResolvedPart that knows how to build its own geometry. Import what you need from jitxlib.parts.provider, which re-exports the query and record names in one place.