HyperCircuit
HyperCircuit is the semantic circuit and PCB layer of the Hyper workspace. It
keeps electrical identity, hierarchy, interfaces, simulation intent,
schematics, layout intent, fabrication evidence, and release policy connected
without treating a solver matrix, drawing, or mesh as the source of truth.
Core circuit values use hyperreal::Real. Numerical solvers and external tools
are proposal adapters: accepted circuit results retain exact residual replay or
an explicit uncertainty boundary.
The crate ranges from a small exact-aware Modified Nodal Analysis (MNA) model
to optional PCB authoring, routing, KiCad exchange, manufacturing release, and
HyperDRC handoff. Features let applications select only the layers they need.
What HyperCircuit is for
A circuit design has several related representations:
parts + models + nets + hierarchy + intent
│
┌─────────┼───────────┐
▼ ▼ ▼
simulation schematic PCB layout
│ │
▼ ▼
exact replay routing / geometry / DRC
│
▼
fabrication + assembly release
HyperCircuit keeps stable typed identities across those branches. A net remains
the same semantic net when lowered into MNA unknowns, schematic wires,
Hyperpath routing carriers, CSGRS copper geometry, HyperDRC findings, Gerber
attributes, and assembly outputs.
Ownership is deliberately separated:
- HyperCircuit owns circuit, schematic, PCB, and release semantics.
- Hyperpath owns routed-path geometry and exact path
predicates.
- CSGRS composes profiles and solids for materialization.
- HyperDRC owns readiness policy and findings.
- Hyperphysics owns physical property models.
- Hypersolve accepts coupled residual systems.
Primary types
Circuit is the retained electrical model: nets, buses, ports, rails,
device models, instances, manual stamps, stimuli, module parameters, and
child circuits.
CircuitId, NetId, ComponentId, DeviceModelId, CircuitInstanceId,
PortId, and the other ID wrappers prevent accidental cross-domain identity
mixing.
DeviceModel and DeviceModelKind describe supported electrical behavior;
CircuitInstance binds model pins to nets and supplies exact parameters.
LinearStamp, MnaProblem, LinearMnaSystem, and MnaUnknown are the
executable linear MNA layer.
ResidualReplayReport, LinearSolveReport, and nonlinear/AC/transient
reports distinguish a proposal from its checked result.
CircuitLibrary, SubcircuitInstance, and CircuitModuleParameter model
reusable hierarchy and parameter forwarding.
SchematicLayout and its symbol/wire/sheet types retain presentation
without duplicating logical connectivity.
- With
layout, PcbLayout and its land-pattern, placement, route, via, zone,
stackup, rule, tuning, and test-intent types retain board semantics.
- With
interchange, SemanticDocument is the versioned deterministic
persistence boundary.
- With
drc, ReleaseReport and HyperDrcReadinessReport connect design
semantics to release blockers and evidence.
Installation
The circuit and simulation core has no default features:
[dependencies]
hypercircuit = "0.3.0"
Enable PCB authoring and semantic interchange as needed:
[dependencies]
hypercircuit = { version = "0.3.0", features = ["layout", "interchange"] }
Quick start
This one-node conductance problem lowers to exact MNA, solves it, and replays
the residual:
use hypercircuit::{
AdapterKind, Circuit, CircuitId, CircuitResult, ComponentId, LinearStamp, Net, NetId, Real,
TransientPolicy,
};
fn main() -> CircuitResult<()> {
let output = NetId::new("out")?;
let circuit = Circuit::new(
CircuitId::new("conductance")?,
TransientPolicy::Static,
AdapterKind::Dc,
)
.with_net(Net {
id: output.clone(),
is_ground: false,
})
.with_stamp(LinearStamp::Conductance {
component: ComponentId::new("g1")?,
part: None,
pos: Some(output),
neg: None,
conductance: Real::from(2),
});
let system = circuit.linear_mna_system()?;
let solution = system.solve_exact()?;
assert!(solution.replay.accepted);
assert_eq!(solution.candidate, vec![Real::zero()]);
Ok(())
}
Run the repository copy with:
cargo run --example basic
The example uses an explicit stamp to make the MNA boundary visible. Most
applications author DeviceModel and CircuitInstance values, then call
linear_mna_from_devices.
Useful API
The generated Rust documentation contains full signatures and report fields.
The groups below cover the useful public surface.
Circuit identity, models, and validation
- core model:
Circuit, Net, Bus, BusSlice, CircuitPort,
RailIntent, CircuitInstance, DeviceModel, DeviceModelKind,
DevicePin, PinBinding, CircuitParameter;
- identity: the types in
identity, including circuit, component, net, pin,
port, layout, package, event, route, via, zone, and tuning IDs;
- policy:
TransientPolicy, AdapterKind, PortDirection,
PinElectricalKind, PortSignalType, RailKind, MosfetPolarity;
- validation:
Circuit::validate, CircuitValidationReport,
CircuitValidationIssue, and CircuitCertificationReport;
- intent:
DesignIntent, NetIntent, FunctionalRole,
FunctionalBinding, PartSelectionIntent, ResolvedPartEvidence,
SourceSpan, and their validation reports.
Builder methods on Circuit add nets, buses, ports, rails, models, instances,
stamps, stimuli, module parameters, and subcircuits while preserving stable
identity.
Linear MNA and exact replay
Circuit::linear_mna_system lowers authored LinearStamp values.
Circuit::linear_mna_from_devices lowers supported device instances.
LinearMnaSystem::solve_exact performs certified-pivot dense elimination
and replays its own candidate.
LinearMnaSystem::replay_candidate evaluates exact A*x-b residuals for an
external proposal.
MnaProblem, LinearStamp, MnaUnknown, LinearSolveReport, and
ResidualReplayReport expose the equation and evidence model.
Supported linear stamp families include conductance, current and voltage
sources, voltage-controlled current sources, and transient capacitor/inductor
companions. Duplicate unknowns and uncertified pivots are errors.
Transient, events, and behavior
- sources:
SourceStimulus, SourceWaveform, SourceWaveformPoint;
- one-step simulation:
transient_step, transient_step_at,
TransientStepReport, ReactiveState;
- bounded series:
transient_run, TransientRunPolicy,
TransientAdaptation, TransientRunReport, TransientRunStatus;
- stateful execution:
TransientSession, TransientSessionStep,
TransientSessionAuditReport;
- exact breakpoints:
ExactBreakpointProvider, ExactBreakpointSchedule,
earliest_exact_breakpoint_after;
- events:
CircuitEventAgenda, CircuitEventRequest, CircuitEvent,
phase/kind/target/cause types, lifecycle records, counters, replay, and
deterministic fingerprints;
- behavior:
BehaviorRuntime, CircuitEventHandler, BehaviorContext,
BehaviorQueue, and SelectiveEventMailbox;
- asynchronous cooperative behavior behind
behavior-async:
AsyncBehaviorRuntime and AsyncCircuitBehavior;
- reproducible randomness:
StochasticStream, StochasticSample, and
RandomDrawId.
Constant, step, piecewise-linear, periodic pulse, damped-sine, and dual-edge
exponential stimuli keep exact timing parameters. Adaptive linear runs compare
replayed full and half steps under caller-authored bounds.
Nonlinear DC and AC
- piecewise-linear:
PiecewiseLinearDevice, PiecewiseLinearSegment,
solve_piecewise_linear, and its bounded active-region report;
- diodes:
ShockleyDiode, DiodeNewtonPolicy,
solve_shockley_diode_newton, diode transient step/run reports;
- MOSFETs:
SquareLawMosfet, MosfetRegion, MosfetNewtonPolicy,
solve_square_law_mosfet_newton, Circuit::solve_mosfet_dc;
- AC:
AcMnaSystem, AcStamp, Phasor, AcExcitation,
AcOperatingPoint, AcSolveReport, and sweep reports.
Primitive-float exponential/Newton coefficients are retained as proposal
evidence. Acceptance replays the true device law against explicit voltage,
current, and residual policies. The current MOSFET model is the body-tied-source
level-one Shichman–Hodges law; dynamic capacitance, body effect, subthreshold,
and reverse-channel behavior are not implied.
Hierarchy, interfaces, and packages
- hierarchy:
CircuitLibrary, SubcircuitInstance,
SubcircuitPortBinding, flatten, flatten_with_scopes,
CircuitFlatteningReport;
- parameters:
CircuitModuleParameter,
CircuitModuleParameterTarget, and overrides;
- typed bundles:
SignalBundle, SignalBundleMember, Modport,
SignalBundleEndpoint, SignalBundleLibrary;
- design modules:
DesignModule, DesignModuleInstance, CheckedProject;
- package resolution:
CircuitPackageCatalog, PackageRequirement,
CircuitPackageLock, PackageDigest, CircuitPackageStore;
- portable library artifacts:
CircuitLibraryArtifact,
PartLibraryArtifact, and portable part definitions.
Hierarchy validation rejects recursion and missing or incompatible bindings.
Flattening produces stable path-qualified identities and deterministic scope
maps.
ERC and semantic authoring
- ERC:
electrical_rule_check, ErcRuleDeck, ErcReport,
ConfiguredErcReport, ErcFinding, ErcRuleId, and severity types;
- high-level authoring with
layout: Design, CheckedDesign, Part,
PartDefinition, PartInstance, typed handles, authoring traces, and source
maps;
- reusable symbols and footprints:
PartSymbolUnit, SymbolUnitPlacement,
Footprint, LandPattern, and pin-to-pad maps.
ERC covers driven-net conflicts, undriven inputs, power-source evidence,
no-connect misuse, ground/signal role mismatches, and copper-trace handoff
issues. It is electrical-intent review, not analog stability proof.
Schematics and KiCad schematic exchange
- drawing model:
SchematicLayout, SchematicSymbolDefinition,
SchematicSymbol, SchematicWire, labels, sheets, sheet ports/links,
graphics, presentation, and validation reports;
- generation:
auto_schematic, SchematicAutoLayoutPolicy,
SchematicAutoLayoutReport;
- rendering: schematic SVG options, reports, and numeric projections;
- KiCad: schematic import/export reports, book import/export, numeric
projection/import evidence, and typed omissions.
Schematic objects point back to circuit identities. They do not create a
second connectivity model.
PCB layout, placement, and routing
Available with layout:
- board model:
PcbLayout, BoardOutline, BoardContour,
BoardBoundaryGeometry, PcbStackup, and stackup-layer types;
- libraries and placement:
LandPattern, pads, graphics, 3D model references,
PcbPlacement, placement constraints, PlacementSolvePolicy, and reports;
- routing:
PcbRoute, PcbRouteSegment, PcbVia, ViaStyle, NetClass,
DifferentialPair, RouteConstraintRegion, RouteRuleRegion,
EscapePolicy;
- zones and finishing:
CopperZone, fill/island/stitching policy and evidence;
- tuning:
LengthTuningPattern, PhaseTuningGroup, synthesis/realization
policies and reports;
- hierarchy:
LayoutModule, PlacementGroup, LayoutAssembly, and composed
layout reports;
- panels and tests:
PanelDefinition, rails, coupons, fiducials, tooling,
separation features, DesignForTestIntent, test access, boundary scan,
programming, and power-domain requirements.
RoutingProblemReport::from_layout lowers placed-pad terminals, path rules,
keepouts, fixed copper, and aliases into Hyperpath. RoutingSolution imports
accepted Hyperpath paths back into semantic route/via identities.
PcbLayout::negotiated_autoroute and
adaptive_negotiated_autoroute provide bounded deterministic proposal
engines. Their policies and reports retain grid topology, refinements, passes,
expansions, conflicts, failures, differential-pair evidence, via styles,
regional rules, and exact quality metrics. iteration_svg and replay_html
render that retained evidence without becoming another routing IR.
The tsCircuit adapter exports and imports SimpleRouteJson