Skip to content

Semantic directives

Directives represent simulator-independent intent. They do not store the command tokens used by a particular simulator.

Transient analysis

from nimphel.directives import TransientAnalysis

analysis = TransientAnalysis(
    stop="10n",
    step="100p",
    start=0,
    max_step="1n",
)

The fields express analysis meaning. A writer decides how its simulator spells that analysis.

Simulator-only options are retained under a dialect namespace:

analysis = TransientAnalysis(
    stop="10n",
    vendor_options={
        "spectre": {
            "maxiters": 5,
            "annotate": "status",
        }
    },
)

Portable fields can be converted by another writer. Vendor options are emitted only by their matching dialect.

Global nodes

from nimphel.directives import GlobalNodes

ground = GlobalNodes(nodes=(0, "gnd!"))

Include files and sections

from nimphel.directives import Include

models = Include(
    path="models.scs",
    section="TT",
)

The directive stores the logical path and optional section. Quoting and simulator-specific keywords are output concerns.

Save signals

from nimphel.directives import Save

outputs = Save(signals=("out", "internal_node"))

Raw fallback

Use RawDirective only when Nimphel does not understand a command semantically:

from nimphel.directives import RawDirective

raw = RawDirective(
    dialect="spectre",
    text="simulator lang=spectre",
)

A raw directive is intentionally non-portable:

  • It can be preserved and emitted to the matching dialect.
  • It cannot be emitted by a different simulator writer.
  • Cross-dialect conversion raises UnsupportedElementError.
  • Nimphel does not validate or interpret its text.

This explicit limitation is safer than a generic command + args + params model that appears portable but contains simulator syntax.

Add directives to a circuit

Directive constructors are pure and do not register themselves implicitly:

from nimphel import Circuit

circuit = Circuit(name="testbench")
circuit.extend([
    ground,
    models,
    analysis,
    outputs,
])

This keeps model construction deterministic and lets readers create directives without depending on an ambient context.

Current semantic set

Class Meaning
TransientAnalysis Transient simulation settings
GlobalNodes Globally visible electrical nodes
Include Included file and optional section
Save Requested output signals
RawDirective Dialect-bound uninterpreted syntax

New directive classes should be introduced when their cross-simulator meaning is understood. They should not be added merely to mirror one simulator's grammar.

Next