Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 1.47 KB

File metadata and controls

74 lines (51 loc) · 1.47 KB

.IF / .ELSE / .ENDIF Statements

The .IF / .ELSE / .ENDIF statements provide conditional inclusion of netlist sections based on parameter expressions evaluated at parse time.

Syntax

.IF (<condition>)
  ...statements included when condition is true...
.ELSE
  ...statements included when condition is false...
.ENDIF

The .ELSE block is optional.

Examples

Simple Condition

.PARAM use_fast=1

.IF (use_fast == 1)
R1 IN OUT 100
.ELSE
R1 IN OUT 10k
.ENDIF

MNA View

.IF chooses which netlist statements exist before circuit setup. It does not stamp MNA directly.

The selected branch can still change the matrix. For example, choosing a resistor value changes a conductance stamp; including or excluding a capacitor changes whether transient integration history exists for that node.

Without .ELSE

.PARAM add_cap=1

.IF (add_cap > 0)
C1 OUT 0 100p
.ENDIF

Nested (with Parameters)

.PARAM version=2

.IF (version == 1)
.INCLUDE "model_v1.lib"
.ELSE
.INCLUDE "model_v2.lib"
.ENDIF

Condition Expressions

The condition can use any expression that evaluates to a numeric value:

  • Non-zero = true
  • Zero = false

Standard comparison operators (==, !=, >, <, >=, <=) and logical operators are supported.

Notes

  • Conditions are evaluated at parse time using the current parameter values.
  • The conditional blocks can contain any valid SPICE statements: components, models, subcircuits, analysis commands, etc.