summaryrefslogtreecommitdiff
path: root/Windows/spice/examples/control_structs
diff options
context:
space:
mode:
authorrahulp132020-03-03 05:31:58 +0530
committerrahulp132020-03-03 05:31:58 +0530
commitdfc268e0863c913a1b8726cd54eea3b40caf7c67 (patch)
tree1cd82634684da5ae86b558d44756189e080545d4 /Windows/spice/examples/control_structs
parentfd62c52150c7d1f81da8060b2f5db6b94d174ccf (diff)
downloadeSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.tar.gz
eSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.tar.bz2
eSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.zip
upgrade ngspice to v31
Diffstat (limited to 'Windows/spice/examples/control_structs')
-rw-r--r--Windows/spice/examples/control_structs/if-batchmode.cir31
-rw-r--r--Windows/spice/examples/control_structs/if-test-1.cir78
2 files changed, 109 insertions, 0 deletions
diff --git a/Windows/spice/examples/control_structs/if-batchmode.cir b/Windows/spice/examples/control_structs/if-batchmode.cir
new file mode 100644
index 00000000..b26b345c
--- /dev/null
+++ b/Windows/spice/examples/control_structs/if-batchmode.cir
@@ -0,0 +1,31 @@
+use $batchmode
+
+* use $batchmode variable to steer control flow
+*
+* start either with
+* ngspice -b -r rawfile.raw if-batchmode.cir
+* or with
+* ngspice if-batchmode.cir
+
+v0 1 0 dc 1
+R1 1 2 1k
+C1 2 0 1u
+
+.tran 100u 10m uic
+.print tran all
+
+.control
+
+if $?batchmode
+ echo "Info: batchmode has been set by command line option -b"
+ echo
+else
+ echo "Info: batchmode has not been set"
+ echo
+ unset ngdebug
+ tran 100u 10m uic
+ plot v(2)
+end
+
+.endc
+.end
diff --git a/Windows/spice/examples/control_structs/if-test-1.cir b/Windows/spice/examples/control_structs/if-test-1.cir
new file mode 100644
index 00000000..41927bdf
--- /dev/null
+++ b/Windows/spice/examples/control_structs/if-test-1.cir
@@ -0,0 +1,78 @@
+test if conditions
+
+* test behaviour in special circumstances
+
+v1 1 0 dc 42
+R1 1 0 1k
+
+
+.control
+
+echo "expect Error: missing if condition"
+* does not enter cp_istrue()
+if
+ echo "FAIL: you should not see this"
+else
+ echo "nonetheless evaluated as FALSE"
+end
+echo
+
+set testvar_b=""
+echo "expect |false|"
+* in cp_istrue(): wl!=NULL names==NULL v==NULL
+if $testvar_b
+ echo "FAIL: you should not see this"
+else
+ echo "|false|"
+end
+echo
+
+set testvar_c
+echo "expect testvar_c=|TRUE|"
+* in cp_istrue(): wl!=NULL names!=NULL v!=NULL
+if $testvar_c
+ echo "testvar_c=|$testvar_c|"
+end
+echo
+
+echo "expect Error: testvar_d: no such variable."
+* in cp_istrue(): wl!=NULL then wl==NULL names==NULL v==NULL
+if $testvar_d
+ echo "FAIL: you should not see this"
+else
+ echo "nonetheless evaluated as FALSE"
+end
+echo
+
+echo "expect Error(parse.c--checkvalid): testvar_e: no such vector."
+* in cp_istrue(): wl!=NULL names==NULL v==NULL
+if testvar_e = 3.3
+ echo "FAIL: you should not see this"
+else
+ echo "nonetheless evaluated as FALSE"
+end
+echo
+
+let testvar_f = 3.5
+
+echo "expect |false|"
+if testvar_f = 3.3
+ echo "FAIL: you should not see this"
+else
+ echo "|false|"
+end
+echo
+
+echo "expect |true|"
+if testvar_f = 3.5
+ echo "|true|"
+else
+ echo "FAIL: you should not see this"
+end
+echo
+
+op
+print v(1)
+
+.endc
+.end