Circuit¶
spicefault.circuit
¶
The circuit under investigation: a SPICE netlist seen as components, nodes and parameters.
Circuit
¶
A nominal circuit. It is never modified: every simulation works on a copy.
Only the top level of the netlist is exposed; what is inside a subcircuit is reached through the parameters of its instances.
imported_analyses
property
¶
Dot analyses imported from a schematic export, for Experiment to run.
netlist()
¶
A fresh, editable copy of the netlist.
parameters()
¶
(component, parameter) -> nominal value, for every numeric parameter.
check()
¶
Report elements and directives the library cannot inspect or mutate safely.
spicefault.netlist
¶
SPICE netlist as text, with the three fault-injection primitives.
A fault is a list of these primitives and nothing else changes the netlist (see docs/FAULT_MODEL.md):
set_parameterchange a component value or an instance parameter;insert_seriesput a resistance between one terminal and its node;insert_parallelput a resistance between the nodes of two terminals.
The text is edited in place, token by token, so everything the primitives do not
touch stays byte for byte as it was written. Only top-level elements can be
addressed: lines inside .subckt definitions and .control blocks are skipped.
Limitations: instance parameters must be written name=value without spaces, and
the terminals of an element are known only for the types in _TERMINALS and for
subcircuit instances (X).
Netlist
¶
components()
¶
Names of the top-level elements, in order and as written.
model(component)
¶
The subcircuit of an X instance or the model of a device (D, Q, J, M), as written.
Empty for the other elements. A bipolar transistor may have a substrate node before its model and an area after it; a plain number after the model is taken as the area.
nodes(component)
¶
Nodes of the terminals of a component, in netlist order.
parameters(component)
¶
Numeric parameters of a component: value, dc and its name=value pairs.
add_directive(line)
¶
Add a line such as .options temp=85 before the control block or .end.
set_parameter(component, parameter, rule, value)
¶
Change a parameter ("value" for R, C and L) and return its new value.
insert_series(component, terminal, resistance, name=None, node=None)
¶
Reconnect a terminal (1-based) to its node through a resistance.
The resistor (Rser_<component> by default) is written before the component
and the new internal node is <component>_x. Returns the resistor name.
insert_parallel(component, terminal_a, terminal_b, resistance, name=None)
¶
Add a resistance between the nodes of two terminals (1-based).
The resistor (Rpar_<component> by default) is written after the component.
Returns the resistor name.
parse_value(token)
¶
Number in SPICE notation: 10k, 1meg, 4.7uF, 1e-9.
format_value(value)
¶
Shortest text that reads back as the same float.
apply_rule(old, rule, value)
¶
absolute: value; relative: old * (1 + value); scale: old * value; divide.