summaryrefslogtreecommitdiff
path: root/Windows/spice/share/ngspice
diff options
context:
space:
mode:
authorrahulp132020-02-28 11:38:58 +0530
committerrahulp132020-02-28 11:38:58 +0530
commit246319682f60293b132fca1ce6e24689c6682617 (patch)
tree6871b758a17869efecfd617f5513e31f9a933f4a /Windows/spice/share/ngspice
parentd9ab84106cac311d953f344386fef1c1e2bca1cf (diff)
downloadeSim-246319682f60293b132fca1ce6e24689c6682617.tar.gz
eSim-246319682f60293b132fca1ce6e24689c6682617.tar.bz2
eSim-246319682f60293b132fca1ce6e24689c6682617.zip
initial commit
Diffstat (limited to 'Windows/spice/share/ngspice')
-rw-r--r--Windows/spice/share/ngspice/scripts/ciderinit23
-rw-r--r--Windows/spice/share/ngspice/scripts/devaxis69
-rw-r--r--Windows/spice/share/ngspice/scripts/devload21
-rw-r--r--Windows/spice/share/ngspice/scripts/setplot64
-rw-r--r--Windows/spice/share/ngspice/scripts/spectrum165
-rw-r--r--Windows/spice/share/ngspice/scripts/spinit31
6 files changed, 373 insertions, 0 deletions
diff --git a/Windows/spice/share/ngspice/scripts/ciderinit b/Windows/spice/share/ngspice/scripts/ciderinit
new file mode 100644
index 00000000..56163322
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/ciderinit
@@ -0,0 +1,23 @@
+*** This is a sample spice/cider initialization file.
+alias pl print line
+alias pc print col
+alias ds display
+alias hi history
+alias li listing
+alias p plot
+alias pr print
+alias q quit
+alias bye quit
+alias exit quit
+alias so source
+alias ld load
+alias xg xgraph tmp
+alias sp setplot
+alias dl devload
+alias dx devaxis
+set width = 80 height = 24 nosort noaskquit nobreak
+set xbrushheight = 3 xbrushwidth = 3
+set unixcom
+set hcopydevtype = postscript
+set pointstyle = markers
+set term = vt100
diff --git a/Windows/spice/share/ngspice/scripts/devaxis b/Windows/spice/share/ngspice/scripts/devaxis
new file mode 100644
index 00000000..7b3d23f3
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/devaxis
@@ -0,0 +1,69 @@
+* initialize a device plot
+.control
+begin
+ unset axis
+ if $argc = 1
+ set axis = $argv[1]
+ strcmp flag $axis "x"
+ if ($flag = 0)
+ echo "setting axis to x"
+ strcmp flag "$?&devaxis" "0"
+ if ($flag = 0)
+ strcmp flag "$?&xaxis" "0"
+ if ($flag = 0)
+ echo "Error: no x axis present"
+ else
+ transpose all
+ setscale xaxis
+ let devaxis = 1
+ end
+ else
+ strcmp flag "$&devaxis" "-1"
+ if ($flag = 0)
+ strcmp flag "$?&xaxis" "0"
+ if ($flag = 0)
+ echo "Error: no x axis present"
+ else
+ transpose all
+ setscale xaxis
+ let devaxis = 1
+ end
+ end
+ end
+ else
+ strcmp flag $axis "y"
+ if ($flag = 0)
+ echo "setting axis to y"
+ strcmp flag "$?&devaxis" "0"
+ if ($flag = 0)
+ strcmp flag "$?&yaxis" "0"
+ if ($flag = 0)
+ echo "Error: no y axis present"
+ else
+ setscale yaxis
+ let devaxis = -1
+ end
+ else
+ strcmp flag "$&devaxis" "1"
+ if ($flag = 0)
+ strcmp flag "$?&yaxis" "0"
+ if ($flag = 0)
+ echo "Error: no y axis present"
+ else
+ transpose all
+ setscale yaxis
+ let devaxis = -1
+ end
+ end
+ end
+ else
+ echo "Error: unknown axis" $axis
+ echo "usage: devaxis <x|y>"
+ end
+ end
+ else
+ echo "usage: devaxis <x|y>"
+ end
+
+ unset axis flag
+end
diff --git a/Windows/spice/share/ngspice/scripts/devload b/Windows/spice/share/ngspice/scripts/devload
new file mode 100644
index 00000000..d007fad5
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/devload
@@ -0,0 +1,21 @@
+* initialize a device plot
+.control
+begin
+ unset devfile
+ if $argc = 1
+ set devfile = $argv[1]
+ load $devfile
+ strcmp flag "$?&y" "1"
+ if ($flag = 0)
+ let yaxis = y[0]
+ transpose all
+ let xaxis = x[0]
+ transpose all
+ setscale yaxis
+ end
+ else
+ echo "usage: devload <filename>"
+ end
+
+ unset devfile flag
+end
diff --git a/Windows/spice/share/ngspice/scripts/setplot b/Windows/spice/share/ngspice/scripts/setplot
new file mode 100644
index 00000000..38ca0da1
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/setplot
@@ -0,0 +1,64 @@
+* set the current working plot
+.control
+
+begin
+ unset resp
+ if $argc
+ set resp = $argv[1]
+ else
+ if $?plots = 0
+ echo Error: there aren\'t any plots currently loaded.
+ goto bottom
+ else
+ if $#plots = 0
+ echo Error: there aren\'t any plots currently loaded.
+ goto bottom
+ end
+ end
+
+ if $?resp = 0
+ set oldplot = $curplot
+ echo ' Type the name of the desired plot:'
+ echo ''
+ echo ' new New plot'
+ foreach pl $plots
+ set curplot = $pl
+ strcmp i $pl $oldplot
+ if $i = 0
+ echo "Current $pl $curplottitle ({$curplotname})"
+ else
+ echo " $pl $curplottitle ({$curplotname})"
+ end
+ end
+ set curplot = $oldplot
+ echo -n '? '
+ set resp = $<
+ end
+ end
+
+
+ strcmp i $resp ""
+ if $i = 0
+ goto bottom
+ end
+
+ strcmp i $resp new
+ if $i = 0
+ set curplot = new
+ goto bottom
+ end
+
+ foreach pl $plots
+ strcmp i $resp $pl
+ if $i = 0
+ set curplot = $pl
+ goto bottom
+ end
+ end
+
+ echo Error: no such plot name $resp
+
+ label bottom
+
+ unset resp i pl newflag oldplot
+end
diff --git a/Windows/spice/share/ngspice/scripts/spectrum b/Windows/spice/share/ngspice/scripts/spectrum
new file mode 100644
index 00000000..3e394432
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/spectrum
@@ -0,0 +1,165 @@
+* Fourier Series Function for SPICE
+* This script is offered here for learning purposes, even if it is outdated
+* and superseeded by the spec function and especially by the much faster fft function.
+* You may use this script in conjunction with e.g. a ringoscillator output (see
+* the ngspice manual, chapter 17).
+
+.control
+ begin
+
+* Variable argc delivers the number of command line parameters given by the user
+* after the 'spectrum' command
+ if ($argc lt 4)
+ echo Error: Too few arguments.
+ echo ' 'Spectrum produces a plot containing a fourier series transformation of
+ echo ' 'the specified vectors
+ echo usage: spectrum startfreq stop step vec [[vec] ...]
+ goto bottom
+ end
+
+* Check if vectors 'time' and any input vector(s) are available
+* argv[n] delivers the command line entries after the 'spectrum' command,
+* starting with argv[1]. $argv[4-len] delivers the value of all tokens,
+* starting with postion 4 till the end of the command line
+ if ( time eq time )
+ foreach vec $argv[4-len]
+ if ( $vec eq $vec )
+ else
+ goto bottom
+ end
+ end
+ else
+ echo ' 'Spectrum can not work without a time vector from a transient analysis.
+ goto bottom
+ end
+
+ * generate a new plot entitled 'scratch', which will hold intermediate
+ * results and will be discarded after their evaluation.
+ set dt=$curplot
+ set title=$curplottitle
+ set curplot=new
+ set scratch=$curplot
+
+ * A vector 'span' is created in the 'scratch' plot to hold the time difference
+ * of the transient simulation. {$dt}.time allows to access the 'time' vector
+ * from the dt plot (which is normally named 'tranx' with x a consecutoive
+ * integer number, depending on the amount of transient simulations already run
+ * in the present job.
+ let span={$dt}.time[length({$dt}.time)-1]-{$dt}.time[0]
+
+* Calculate the number of steps in all of the spectra to be evaluated below
+ if ($argv[3] gt 0.999/span)
+ let fpoints= ( $argv[2] - $argv[1] ) / $argv[3] +1
+ if (fpoints < 2)
+ echo frequency start stop or step not correctly specified
+ goto reset
+ end
+ else
+ echo Error: time span is not long enough for a step frequency of $argv[3] Hz
+ goto reset
+ end
+ let lent = length({$dt}.time)
+ set lent = "$&lent"
+ let nyquist = {$lent}/2/span
+ if ($argv[2] gt nyquist)
+ echo Error: The nyquist limit is exceeded, try a frequency less than "$&nyquist" Hz
+ goto reset
+ end
+ set fpoints="$&fpoints"
+
+ * generate a new plot to hold the spectra
+ set curplot=new
+ set spec=$curplot
+ set curplottitle=$title
+ set curplotname='Spectrum Analysis'
+
+* argv[3] is the third agrgument from the input line
+* spectrum 1 1000MEG 10MEG v(out25)
+* that is the delta frequency
+* The fcn vector(n) creates a vector of length n, its elements have
+* the values 0, 1, 2, 3, ..., n-2, n-1. Each element then is multiplied
+* with the frequency step value.
+ let frequency=vector( $fpoints )*$argv[3]
+
+* Add an frequency offset to each element of vector 'frequency'
+* to suppress the (typically) large dc component.
+ dowhile frequency[1] < ( $argv[1] + 1e-9 )
+ let frequency = frequency + $argv[3]
+ end
+
+* For each input vector given on the command line,
+* create a new vector for complex numbers
+ foreach vec $argv[4-len]
+ let $vec = vector( $fpoints ) + j(vector( $fpoints ))
+ reshape $vec [{$fpoints}]
+ end
+
+* $scratch is a plot for intermediate results, will be destroyed during cleanup
+* $dt is the plot with the original data
+* $spec is a plot for storing the spectrum
+ set curplot=$scratch
+
+ * some test
+ let npers=1
+ let test = span-2/$argv[3] + 1e-9
+ while test > 0
+ let npers = npers + 1
+ let test = test-1/$argv[3]
+ end
+
+ * Do the spectrum calculations
+ let ircle = 2*pi*max(-1,({$dt}.time-{$dt}.time[{$lent}-1])*{$argv[3]}/npers)
+ let win = 1 - cos(ircle)
+ let ircle = npers*ircle
+ let circle = ircle * ({$spec}.frequency[0]/$argv[3] - 1)
+ let k=vector( $fpoints )
+ foreach k $&k
+ let circle = circle + ircle
+ foreach vec $argv[4-len]
+ let tmp = win*{$dt}.{$vec}
+ let {$spec}.{$vec}[{$k}] = 2*(mean(cos(circle)*tmp),mean(sin(circle)*tmp))
+ end
+ end
+
+* plot (and write) the generated spectrum
+ set curplot = $spec
+ settype frequency frequency
+ foreach vec $argv[4-len]
+ let spectrum = mag({$vec})
+ plot spectrum
+ write specout.out spectrum
+ end
+
+* If you have an oscillator, fimd its frequency
+* as maximum of vector spectrum or goto end (uncomment next line)
+* goto cleanup
+ set curplot=$scratch
+ let counter = 0
+ let contents = 0
+ let freqmax = 0
+ let spectrum = {$spec}.spectrum
+
+ foreach spectrum $&spectrum
+ if counter > 4
+ if ( contents < $spectrum )
+ let contents = $spectrum
+ set count = "$&counter"
+ let freqmax = {$spec}.frequency[{$count}]
+ end
+ end
+ let counter = counter + 1
+ end
+
+ echo
+ echo Osc. frequency at "$&freqmax" Hz
+ echo
+ goto cleanup
+
+ label reset
+ set curplot=$dt
+ label cleanup
+ destroy $scratch
+ unset fpoints dt scratch spec vec k title lent
+ label bottom
+
+ end
diff --git a/Windows/spice/share/ngspice/scripts/spinit b/Windows/spice/share/ngspice/scripts/spinit
new file mode 100644
index 00000000..ed5cd0e6
--- /dev/null
+++ b/Windows/spice/share/ngspice/scripts/spinit
@@ -0,0 +1,31 @@
+* Standard ngspice init file
+alias exit quit
+alias acct rusage all
+set x11lineararcs
+*set rndseed=12
+** ascii rawfile **
+*set filetype=ascii
+** frontend debug output **
+*set ngdebug
+** no asking after quit **
+set noaskquit
+** set the number of threads in openmp
+** default (if compiled with --enable-openmp) is: 2
+*set num_threads=4
+
+strcmp __flag $program "ngspice"
+if $__flag = 0
+
+* For SPICE2 POLYs, edit the below line to point to the location
+* of your codemodel.
+
+ codemodel C:/Spice/lib/ngspice/spice2poly.cm
+
+* The other codemodels
+ codemodel C:/Spice/lib/ngspice/analog.cm
+ codemodel C:/Spice/lib/ngspice/digital.cm
+ codemodel C:/Spice/lib/ngspice/xtradev.cm
+ codemodel C:/Spice/lib/ngspice/xtraevt.cm
+
+end
+unset __flag