Documentation
¶
Overview ¶
Package model is the design read-surface CONTRACT. It holds the Model interface that rules and queries evaluate against, and the value types that interface exposes. It imports only the generated IR/geom/param protos, never the check implementation, its rules, or the param logic package. So a consumer such as an auto-layout, a diff or an overlay can depend on the contract without pulling the analysis engine into its build. The default implementation is check.NewModel, and check re-exports these names as aliases, so check.Model / check.ComponentClass and this package's names are the same types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderRoute ¶ added in v0.2.2
RenderRoute is the ONE renderer for a series route, and every surface that prints one calls it. Callers depend on the rendered string as a format (DECISIONS.md, "A path is not a query column"), so a second implementation, such as the IO-map rules rendering off a check.Trace, must call this rather than copy it (#664). It takes plain hops so neither caller's walk type leaks in.
Types ¶
type BoardNet ¶
BoardNet is one net's routed copper. The geometric rules quantify over it, and their findings aggregate per net, because copper primitives have no stable identity of their own. Net is the join key to ir.Net.name.
type BoardRules ¶ added in v0.2.2
BoardRules are the board-wide minimums a design declares for its copper, in nanometres. They describe the process the designer routed the board for (agni issue 933). Zero means the design declares no such minimum, and a rule then falls back to its own default rather than to zero.
type BoardSeg ¶
BoardSeg is one routed track segment. Coordinates and width are in the sidecar's units (nanometers for the KiCad producer).
type BoardVia ¶
BoardVia is one via. Annular returns the copper ring width around the drill. The annular-width rule bounds that quantity.
type ComponentClass ¶
type ComponentClass string
ComponentClass is the device class of a placed component, the component.class fact (docsite/content/architecture/rules-and-checks.md#the-fact-base-and-querying-it). Values are stable strings so rules and reports can match on them. A class the derivation cannot establish is ClassUnknown, never a guess, so class-quantified rules are silent on unfamiliar designs.
const ( ClassResistor ComponentClass = "resistor" ClassCapacitor ComponentClass = "capacitor" ClassInductor ComponentClass = "inductor" ClassFerrite ComponentClass = "ferrite" // ClassThermistor is a temperature-dependent resistor (NTC inrush limiters, PTC resettable fuses, // temperature sense elements). Its family is ClassResistor, because it is a two-terminal resistor // for every topological question and not for anything temperature-related. ClassFerrite splits // from ClassInductor the same way. Without it a thermistor emits no component.class row and drops // out of every class-scoped rule; on one real board that was 15 parts (agni issue 627). ClassThermistor ComponentClass = "thermistor" ClassDiode ComponentClass = "diode" ClassLED ComponentClass = "led" ClassTVS ComponentClass = "tvs" ClassZener ComponentClass = "zener" ClassFuse ComponentClass = "fuse" // ClassNetTie is a deliberate short between two nets, a copper bridge or a shorted header, so one // rail keeps two names in the netlist and the series walk crosses it as it crosses a resistor. ClassNetTie ComponentClass = "net_tie" ClassConnector ComponentClass = "connector" ClassTestConnector ComponentClass = "test_connector" ClassTestPoint ComponentClass = "test_point" ClassClock ComponentClass = "clock" ClassOscillator ComponentClass = "oscillator" ClassCrystal ComponentClass = "crystal" ClassCeramicResonator ComponentClass = "ceramic_resonator" ClassIC ComponentClass = "ic" ClassTransistor ComponentClass = "transistor" // ClassIdealDiodeController is a controller that drives an external FET to behave as a diode // (ORing controllers, ideal-diode controllers, power muxes). No netlist labels a FET plus bias // network as an ideal diode, so reverse-blocking analysis takes the identity from a seeded // datasheet or reports that it does not know (agni issue 74). It is DATASHEET-DRIVEN like the // crystal / ceramic_resonator split, reached through deviceClassAliases from a seeded // device_class rather than from a refdes prefix or a name keyword. ClassIdealDiodeController ComponentClass = "ideal_diode_controller" // ClassCurrentLimitSwitch is a power switch that limits its own current, such as an eFuse, a USB // power switch or a current-limited load switch. Placed between a connector and the board it is the // board's overcurrent protection, and some also block reverse current (agni issue 1248). A // regulator limits its current too and is not one, so like ClassIdealDiodeController it comes // only from a seeded datasheet's device_class, never from a ref-des or a name keyword. ClassCurrentLimitSwitch ComponentClass = "current_limit_switch" ClassUnknown ComponentClass = "unknown" )
The component.class vocabulary. ClassLED, ClassTVS, and ClassZener are distinct from ClassDiode (protection and indicator rules quantify over them separately), and ClassFerrite from ClassInductor, even though each is electrically a subtype. ClassZener is distinct from ClassTVS because a Zener is a slower clamp than a fast ESD TVS (esd-clamp-not-tvs, WS3-078, credits them differently). ClassTestConnector is distinct from ClassConnector because a debug, test, edge-card or programming connector is a bench interface, not a field-facing harness. The protection rules (esd, input-protection) quantify over ClassConnector and exclude it. A board-to-board connector is NOT a class, because whether it faces the field depends on the product rather than the part; a design declares it in its intent instead (Model.ExposedConnector, agni issue 831).
ClassClock is the clock-source FAMILY (WS10-015), with ClassOscillator, ClassCrystal, and ClassCeramicResonator as its subtypes. The family is NOT ClassCrystal, since an active oscillator CONTAINS a crystal rather than being one, so a family-level clock rule must not answer HasClass(crystal) for it. A part's clock TYPE branches rules (an oscillator uses no external load caps, a ceramic resonator has them integrated, a bare crystal needs them). Crystal-vs-resonator is datasheet-driven, because the vendor label is unreliable and the two are structurally alike. So the keyword/structural path only resolves the oscillator subtype or leaves the part at the family, and the crystal / ceramic_resonator subtype comes from a seeded device_class.
func ComponentClasses ¶ added in v0.2.2
func ComponentClasses() []ComponentClass
ComponentClasses is every class in the vocabulary above except ClassUnknown, in declaration order. Anything that enumerates the vocabulary reads this rather than keeping its own list (agni issue 677). Go cannot enumerate constants, so TestComponentClassesListsEveryConstant reads the const block and holds this list to it.
type Model ¶
type Model interface {
// Nets and Components are the entity sets a rule quantifies over (select).
Nets() []*ir.Net
Components() []*ir.Component
// SourceFormat is the reader label of the design's source (e.g. "kicad-pcb", "edif-2.0.0"),
// "" when unknown. The catalog-availability gate (check.Available) reads it, so a board.* rule is
// only available for a board-carrying format.
SourceFormat() string
// HasParams reports whether a datasheet parameter tier is attached, meaning a ParamProvider was
// supplied through check.WithParamProvider. It does not ask whether any specific part is seeded.
// A datasheet rule is applicable exactly when this is true.
HasParams() bool
// HasBoard reports whether a board-geometry tier is attached, meaning a non-nil BoardGeometry was
// supplied through check.WithBoard. It does not depend on the design's source format. Under
// `agni review --board-path` the netlist SourceFormat is not a board format, and HasBoard still
// makes a geometric rule applicable there. A board file with no routed copper still reports true
// (checked, clean).
HasBoard() bool
// SuppliesDiagnostic reports whether the reader COMPUTED a diagnostic, named by its
// InputDiagnostics field name ("ref_des_collisions"). It separates "looked and found none" from
// "never looked", which every list below flattens into the same empty slice. A rule about one of
// these diagnostics gates on it (check.Available). On a format whose reader cannot detect the
// construct, the rule then reports not-applicable rather than passing.
SuppliesDiagnostic(name string) bool
// DanglingEndpoints, NoJunctionEndpoints and RefDesCollisions are reader-emitted input
// diagnostics (docsite/content/architecture/rules-and-checks.md#where-a-rule-runs). They report
// wire endpoints on nothing, and ref-des collisions. Empty for sources that carry none; a thin
// rule reports each.
DanglingEndpoints() []*ir.DanglingEndpoint
NoJunctionEndpoints() []*ir.DanglingEndpoint
RefDesCollisions() []*ir.RefDesCollision
// UnmodeledBuses are bus constructs a reader detected but does not expand into member nets
// (WS1-034). Empty for sources with no bus; the bus-not-modeled rule reports each so a bussed
// design is flagged, not silently mis-read.
UnmodeledBuses() []*ir.BusNotModeled
// RangeLabels are the labels spelled with an index range, each saying whether the format reads
// it as a bus (agni issue 605). Gate on SuppliesDiagnostic("range_labels") before reading an
// empty slice as "no misspelled bus", since a reader that never looked returns the same nothing.
RangeLabels() []*ir.RangeLabel
// UnresolvedSymbols are symbol references the reader could not open or parse (WS1-052), each
// with the placements that lost their pins. Non-empty means the netlist is INCOMPLETE by an
// unknown amount, and a rule reading connectivity cannot tell those pinless parts from a design
// where the connections were never drawn. Rules that read pin or connectivity facts are gated to
// inconclusive while this is non-empty (check.Run).
UnresolvedSymbols() []*ir.UnresolvedSymbol
// ResolvedSymbols are the symbol references that DID load, one per distinct reference, with the
// pin count each supplied. It is the other half of UnresolvedSymbols, so a rule over symbol
// resolution can state what it examined rather than only what failed (agni issue 418).
//
// Empty is ambiguous, and SuppliesDiagnostic("resolved_symbols") separates the cases. A reader
// that declares the diagnostic and returns nothing placed no symbol. A reader that does not
// declare it never looked. Skipping that check reads "we read without symbols" as "we checked and
// everything was fine".
ResolvedSymbols() []*ir.ResolvedSymbol
// JoinedTaps are the wire-end-on-wire-body taps that something DOES join, with the construct that
// joined them (agni issue 420). It is the other half of NoJunctionEndpoints, and the two
// partition the taps, so no tap is on both lists.
//
// Gate on SuppliesDiagnostic("junction_taps") before reading an empty slice as "no tap was
// silent", since a reader that never looked at wire geometry returns the same nothing.
JoinedTaps() []*ir.JoinedTap
// UnannotatedComponents are the placeholder designators the source has not assigned yet ("R?",
// "C?"), one entry per placeholder with every placement wearing it. Unlike UnresolvedSymbols
// nothing was LOST in the read, since the parts and their pins are all present. Only an identity is
// absent, so a consumer must not key on these designators (see internal/refdes).
UnannotatedComponents() []*ir.UnannotatedComponent
// UnexpandedHierarchy are the hierarchical blocks whose contents the read left out, each with its
// instance count (agni issue 707). Non-empty means every count and every rule covers the top level
// alone. No rule reads it, since being hierarchical is not a defect; a run carries it on its
// response so a report can say what the read covered (agni issue 717).
UnexpandedHierarchy() []*ir.UnexpandedHierarchy
// PinDir is a pin's electrical direction (traverse / pin-role), or the unspecified zero value when
// the source carries no part-type pin data (so direction-based rules do not fire).
PinDir(refDes, pin string) ir.PinDirection
// PinDeclared reports whether the component's part type declares this pin at all, even with an
// explicitly unspecified electrical type. False for pins known only from net connections (a
// board footprint's pads, a partially-read hierarchy), where the unspecified PinDir means "the
// read never saw the symbol" rather than "the author declared nothing". A rule such as
// unspecified-pin-with-driver keys on declared-but-untyped pins, so it must not read a read gap as
// an authoring gap.
PinDeclared(refDes, pin string) bool
// PinName is the pin's NAME as its part type declares it ("VCCA", "GND"), or "" when the source
// carries no part-type pin data (traverse / param-join). The designator changes when the same die
// ships in a different package. The name is die-relative, so a datasheet join leads with it; see
// param.ResolvePin for the precedence.
PinName(refDes, pin string) string
// IsPinlessPart reports whether a component resolves to a part type that declares no pins, as a
// mounting hole, a logo or a module's assembly symbol does (agni issue 937). False when the read
// does not carry the component's part type, since its pins are then unknown rather than absent.
IsPinlessPart(refDes string) bool
// IsFitted reports whether a component is assembled onto the board, false for a part the design
// marks do-not-populate. A DNP part is still in the netlist, since its footprint and nets are real.
// An unfitted part does nothing, so a rule asks this before it credits a part with doing something
// electrical, such as a resistor pulling a line up (agni issue 938).
IsFitted(refDes string) bool
// IsConnected reports whether a ref_des appears on at least one net (on_net, section-aware).
IsConnected(refDes string) bool
// HasComponent reports whether a ref_des is known to the design at all (membership). The ref_des
// can be a listed component or a connection ref, since a netlist read may carry connections
// without a component list. Unlike IsConnected, it is true for a listed-but-unconnected part.
HasComponent(refDes string) bool
// HasNetName reports whether a net with the given name exists (pair, case-insensitive).
HasNetName(name string) bool
// IsPowerRail reports whether a net is a power/ground rail. A rail is asserted-driven or global,
// or has a ground/power-rail name. Such rails are distributed by power-symbol taps, not drawn
// wires (WS9-039). Unknown net -> false.
IsPowerRail(name string) bool
// IsGroundNet, IsRailNet, IsRegulatorInternalNet and HasAnyRole ask whether a net carries a
// naming role such as ground or rail (role). They read the STAMPED role fact, ir.Net.roles, which
// ingestion fills. They fall back to this model's naming lexicon only for a net that skipped the
// loader (WS3-106). They take the net rather than its name because names are not unique (see
// NetNameCount), so a by-name lookup can answer about a different net.
// IsRailNet is NARROWER than IsPowerRail. IsPowerRail also answers true for a driven-or-global net
// and for grounds, and IsRailNet excludes IsRegulatorInternalNet. A rule asking "is this a rail"
// wants IsRailNet.
IsGroundNet(n *ir.Net) bool
IsRailNet(n *ir.Net) bool
IsRegulatorInternalNet(n *ir.Net) bool
HasAnyRole(n *ir.Net, roles ...ir.Role) bool
// These ask whether a bare NAME matches a role vocabulary (naming lexicon). Some callers hold no
// net to read a stamped role from, such as the spec-language name FFIs over a literal and pin-name
// role derivation. Each uses the lexicon the design was READ with (WS3-106), so a project's
// conventions reach a name match without a package global.
IsPowerRailName(name string) bool
IsGroundName(name string) bool
IsFeedbackName(name string) bool
IsSwitchingName(name string) bool
IsControlName(name string) bool
IsGateDriveName(name string) bool
// IsI2CName reads a NET name as an I2C bus line and IsExposedPadName a PIN name as a package's
// exposed pad, each from the lexicon's own vocabulary rather than a rule's pattern (agni 1265).
IsI2CName(name string) bool
IsExposedPadName(name string) bool
// IsFeedbackPinName and IsSwitchingPinName read a PIN name as a regulator's feedback or switch pin.
IsFeedbackPinName(name string) bool
IsSwitchingPinName(name string) bool
// DiffNegative is the complementary net name for a differential pair's positive member, under this
// model's lexicon, and ok=false when the name is not a positive member.
DiffNegative(name string) (string, bool)
// NoConnectMarked reports whether a net carries a designer's no-connect, the reader's flag or a name
// in this model's no_connect vocabulary. A tool's stub name is neither.
NoConnectMarked(n *ir.Net) bool
// NominalVoltage reads the voltage a net NAME states (3V3 -> 3.3) under this model's voltage
// vocabulary, and ok=false when it states none or two that disagree ("12V_TO_5V"). It reads any
// name, so a caller asking about a rail checks the net is one first (agni issue 194).
NominalVoltage(name string) (volts float64, ok bool)
// RailMaxVoltage is the net.max_voltage fact. It is the net's max_voltage attribute when the net
// carries one, otherwise NominalVoltage of its name.
RailMaxVoltage(n *ir.Net) (volts float64, ok bool)
// NetNameCount is how many nets carry EXACTLY this name (pair, case-sensitive unlike HasNetName).
// More than one means the design states the same name for electrically distinct nets. A
// connect-by-name format cannot produce that, because the solver merges them. An explicit-net-list
// format such as EDIF can, so a count above one is either an authoring slip or a reader gap. The
// duplicate-net-name rule reads this.
NetNameCount(name string) int
// Pins returns every part-type pin of every placed component (pins). It is empty for sources that
// carry no part-type pin data, so pin-level rules do not fire. PinConnected gives per-pin net
// membership, as the per-pin analogue of IsConnected. It reports whether this specific
// (ref_des, designator) appears in any net's connections.
Pins() []PinInst
PinConnected(refDes, pin string) bool
// PinRole is the pin's semantic role (pin-role, WS1-009). It is DERIVED from the pin's declared
// name within the component's device-class context. Anode and cathode apply only to the diode
// family, and power/ground rail names apply on any class. It is a projection like
// component.class, never an IR field, because no source format states polarity as data.
// RoleUnknown when the name carries no recognized convention; rules skip, never guess.
PinRole(refDes, pin string) PinRole
// PinNetName is the name of the net this pin appears on ("" when unconnected). A pin belongs to
// one net by definition, so a pin in several nets' connection lists is malformed input, and
// PinNetName then reports the first net in design order. That pick is safe because the conflict
// surfaces through PinNetConflicts and the pin-net-conflict rule.
PinNetName(refDes, pin string) string
// PinNetConflicts lists every pin that appears in more than one net's connections, with the full
// net list. PinNetName's contract relies on these malformed-input diagnostics. The model collects
// them once at build from the normalized IR. They are not a reader InputDiagnostic, since no
// reader-only information is involved.
PinNetConflicts() []PinNetConflict
// HasNoConnectChannel reports whether the source can express "intentionally unconnected" at all
// (the no-connect channel). The channel is any NO_CONNECT-typed pin, any no-connect-flagged net,
// or a designer's NC_ / no_connect net name. Where the channel is absent (a bare EDIF netlist), an
// unwired pin carries no NC flag because none exists, not because the designer missed it. So
// per-pin absence rules must not fire there.
HasNoConnectChannel() bool
// FormatTypesPowerOut reports whether the source format classifies power-OUTPUT pins at all (the
// power-output typing channel, WS3-072 PR2). EDIF's port grammar has only INPUT/OUTPUT/INOUT (no
// power_out), and IPC-2581 is a board format with no pin electrical types. On those a power
// rail's driver reads as a plain input. A rule such as power-input-not-driven infers "unpowered"
// from the ABSENCE of a typed driver. It must not fire where this is false, because the source is
// under-typed rather than undriven.
FormatTypesPowerOut() bool
// HasNetClasses reports whether the design carries any tool-assigned net-class membership at all
// (the net-class channel, WS3-105). Only a KiCad project supplies it (net_settings in the
// .kicad_pro). An EDIF or IPC-2581 read, a bare .kicad_sch, and a project that declares no classes
// all leave every net_class empty. A rule SCOPED by net class would evaluate over nothing there and
// read as a pass, so such a rule declares CapNetClass and reads not-applicable instead.
HasNetClasses() bool
// NetClassDefs returns the per-class routing constraints the project declares (net-class
// DEFINITIONS, WS3-111), such as clearance, track width and via sizes. Each is an ir.Constraint
// node of kind "netclass". It is separate from HasNetClasses because membership and definitions
// are two independent blocks of net_settings. A project can assign nets to a class it never
// defines, or define classes it assigns nothing to.
NetClassDefs() []*ir.Constraint
// Reach returns the bounded series-walk neighborhood of a net (reach, WS3-011). These are the nets
// reachable by crossing two-net pass elements (R/L/ferrite/fuse), with rails excluded. A series
// element splits the net, so a per-net quantifier cannot see "a fuse sits between connector and
// regulator".
Reach(start *ir.Net, hops int) Reach
// ReachToTerminus is the same walk with one admission rule changed. A bus-like net is a legal
// DESTINATION and still an illegal transit node. Some questions end on a rail, such as a pull-up's
// terminus or a trace to a pin that sits on one. Reach cannot answer them, because it drops such a
// net from the result set entirely.
ReachToTerminus(start *ir.Net, hops int) Reach
Between(from, to *ir.Net, class ComponentClass, hops int) bool
// BoardNets returns each net's routed copper from the board-geometry sidecar (board tier, WS3-008).
// Empty when the model was built without a board; see check.WithBoard.
BoardNets() []BoardNet
// BoardRules returns the copper minimums the design declares (board_rules, agni issue 933). Today
// they come from a KiCad project's board.design_settings.rules. It returns the zero value when the
// design declares none, so a rule can fall back to a fabrication floor of its own.
BoardRules() BoardRules
// ComponentClass returns the MOST-SPECIFIC device class from the normalized device_classes set
// (component.class, WS3-071). The classify pass stamps that set once at ingestion, and part-type
// data refines it.
// ClassUnknown when the design carries no usable signal, so class-quantified rules skip
// rather than misfire.
ComponentClass(refDes string) ComponentClass
// HasClass reports whether a component carries a class in its device_classes SET, so a rule
// asks family membership (HasClass(ref, ClassDiode) is true for a diode, an LED, or a TVS)
// rather than equality against the single most-specific class (WS3-071). An unknown ref-des
// or class is false.
HasClass(refDes string, class ComponentClass) bool
// ExposedConnector reports whether a component is a connector that faces the outside of the
// product, meaning the design's intent does not declare it internal (agni issue 831). The exposure
// rules ask this rather than HasClass(ref, ClassConnector). Whether a connector faces the field is
// a fact about one product, and only that product's declaration can state it.
ExposedConnector(refDes string) bool
// PullUpReachLimit is how many series resistors a pull-up walk may cross. The walk starts at a net
// and ends at the rail the net's pull-up ties it to. The limit is the net's declared
// `pull_up_reach_hops` in the design's intent, else check.PullUpReachHops (agni issue 820). Every pull-up walk asks this rather than the
// constant, so a declaration reaches the rule, its Spec twin and the profiles alike.
PullUpReachLimit(net string) int
// Classes returns the full device_classes set for a component (specific class plus family
// tags), or nil for an unknown/unclassified ref-des. This set backs component.class(ref, class).
Classes(refDes string) []ComponentClass
// ComponentMPN and PartSpec are the params tier (WS10-003). ComponentMPN is the design-side part
// identity, taken from the BomLine mpn, else the component's mpn field, else "". PartSpec is the
// seeded datasheet spec joined to that MPN. The MPN is joined on every model. The spec is nil when
// the model has no provider (check.WithParamProvider) or the part is unseeded, so datasheet-backed
// rules skip rather than false-pass; see params.go.
ComponentMPN(refDes string) string
PartSpec(refDes string) *parampb.PartSpec
}
Model is the query interface that rules evaluate against. It exposes the entity sets a rule selects over and the derived facts a rule reads. A Run depends only on this interface, so an alternate implementation (lazy, cached, columnar) can be substituted without touching any rule.
The generic combinators (Select/Exists/Count in package check) are not methods because Go generics cannot be interface methods. They operate on the slices the interface returns.
type PinInst ¶
PinInst is one part-type pin of one placed component. Pin-level rules quantify over it. It exists only for components whose part type declares pins (a netlist-only source with no part data yields none). It carries no direction, so every consumer resolves it through Model.PinDir and sees the same last-section-wins value; membership is Model.PinConnected.
type PinNetConflict ¶
type PinNetConflict struct {
RefDes string
Pin string
Nets []string
Prov *ir.Provenance
}
PinNetConflict is one malformed-input pin. It appears in more than one net's connections, and the pins-to-net many-to-one invariant forbids that. Nets lists every claiming net in design order; Prov locates the second claim (the first place the input is provably wrong).
type PinRole ¶
type PinRole string
PinRole is the semantic role of a pin, derived from its declared name within the component's device-class context (Model.PinRole).
const ( RoleAnode PinRole = "anode" RoleCathode PinRole = "cathode" RolePower PinRole = "power" RoleGround PinRole = "ground" // Transistor terminals (WS3-117) are assigned only within the transistor class, as the polarity // roles are only within the diode family. A bare "G", "S" or "D" pin name means something on // almost every part, so an ungated match would mis-role most of a design. RoleGate PinRole = "gate" RoleSource PinRole = "source" RoleDrain PinRole = "drain" RoleUnknown PinRole = "unknown" )
The pin-role vocabulary. Polarity roles are assigned only within the diode family (diode, led, tvs) so a "K" pin on an IC never reads as a cathode; power/ground come from rail-name conventions on any class. RoleUnknown is the default, and rules skip unknowns rather than guess.
type Reach ¶
type Reach struct {
Nets []*ir.Net
Crossed map[string]bool
Parent map[string]ReachStep // net name -> how it was entered
// Depth is the number of series crossings from the start net as the BFS recorded it (the
// start net is 0, so the walk is reflexive at distance zero). Do not re-derive it by chasing
// Parent, because where parallel passes bridge the same two nets the chain is one of several
// paths and its length can disagree with the walk's. Reachability rules read it (WS3-112).
Depth map[string]int // net name -> series crossings from the start
}
Reach is a bounded series-walk neighborhood (WS3-011). It holds the nets reachable from a start net by crossing SERIES PASS ELEMENTS, in BFS order (start first), and the ref-des set of the elements crossed. See Model.Reach for why protection rules need it. Parent records how each net was entered, for PathTo / ThroughOnPath, and the Model implementation's walk populates it.
func (Reach) PathTo ¶
PathTo returns the series path from the walk's start net to target, in crossing order (start first, target last); nil when target was not reached. Where parallel passes exist (two resistors bridging the same two nets) any of them is equally on the path for a protection question.
func (Reach) RouteLine ¶ added in v0.2.2
RouteLine renders the route from the walk's start to target as one line, naming the nets it passed through and the part crossed between each pair:
VBUS -> [R5] -> VBUS_F -> [L1] -> VDD_3V3
It is the fourth reading of one walk, beside PathTo (the nets), ThroughOnPath (the parts) and StepsTo (both, with pins). It serves a caller whose answer IS the rendering, so a query can bind a route as a value and a table can hold it in a cell (agni issue 518).
It returns one of three things:
- a route, when target was reached across one or more crossings
- target's own name, when target IS the start, since the two points are one electrical node
- "", when target was not reached
Pins are left out to keep a table column narrow; StepsTo has them.
func (Reach) StepsTo ¶ added in v0.2.0
StepsTo returns the crossings from the walk's start to target, in crossing order; nil when the target was not reached or IS the start. It is ThroughOnPath with the whole step kept, pins included, for a caller reporting the route (agni issue 518). Callers asking a membership question over the path ("is a fuse on it") still use ThroughOnPath.
type ReachStep ¶
type ReachStep struct {
From string
Through string
FromPin string // Through's pin on the From net
ToPin string // Through's pin on the net this step reached
}
ReachStep records how a net was reached during the series walk. It names the net crossed FROM, the pass element (ref-des) crossed THROUGH, and that element's own pin on each side of the crossing.
The pins let a step render as "R5.1 to R5.2" rather than a bare component name. They come off ir.Connection.pin_ref on each net. Either may be empty on a source whose connections carry no pin reference, and a renderer must handle that.