summaryrefslogtreecommitdiff
path: root/Windows/spice/how-to-use-ngspice140111.txt
blob: b84e96841473a4ac0a8567e75f74094b9bf4c764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
                         H. Vogt, Jan 12th, 2014

ngspice-26 has been compiled from the ngspice-26 tarball, Jan 11th, 2014. 

ngspice.exe was generated by MS Visual Studio 2008, configuration
ReleaseOMP, using full optimization (compiler flags /O2 /Oi /Ot /GL, linker flag /ltcg).

vcomp90.dll is the microsoft runtime distributable for OpenMP 
(see C:\Program Files (x86)\Microsoft Visual Studio 9.0\1031\redist.txt).

The XSPICE code models *.cm were generated with 
TDM mingw gcc 4.8.1 and MSYS 1.0.10 using the following configuration:

./configure --with-windows --enable-xspice --enable-cider --disable-debug

gcc is invoked with the -O2 compiler flag, which is set in configure.ac.

This version of ngspice 26 thus does not contain the adms or ndev extensions.

Expand the ngspice-26-140112.zip file directly into C: so that you will get C:\Spice\bin etc.
For other places for ngspice installation, see below.

The following examples are tested under Windows XP professional and Windows 7 64 Bit.

Directory /examples offers some example input files for special commands.


*** How to use ngspice with examples provided in directory /tests ***

*********************************************************************
Starting ngspice from MS Explorer window (interactive mode):

Double click on ngspice.exe in C:\Spice\bin

*** ngspice window:

cd c:\spice\tests\bsim4

source comprt.cir

run

display

plot v(1) v(2) v(3) v(8) v(9)

write comprt2.raw
 
quit
*********************************************************************
 
*********************************************************************
* Starting ngspice within the msys window, interactive mode:

* Open an MSYS window.

*** msys window:

export PATH=$PATH:/c/Spice/bin

cd /c/Spice/tests/bsim4
 
ngspice comprt.cir

*** ngspice window:

run
display
plot all

*** write data into raw file to actual directory /c/Spice/tests/bsim4:

write comprt.raw

quit

If you want to use interactive mode with a circuit file in a different 
directory (e.g. C:\test\comprt.cir) , you have to call ngspice like this:

ngspice C:\\test\\comprt.cir 
or
ngspice C:\\test/comprt.cir

MSYS 1.0.10 is specific about file and directory names!

You cannot start ngspice from C:\ or D:\ directly if you don't
have administrator rights. You may choose a subdirectory instead.
 
*********************************************************************
 
*********************************************************************
* Starting ngspice within the msys window, batch mode:

* Open an MSYS window.

*** msys window:

export PATH=$PATH:/c/Spice/bin

cd /c/Spice/tests/bsim4
 
ngspice -b -r comprt3.raw -o comprt3.out comprt.cir

* Plotting

*** msys window:

ngspice
load comprt3.raw
plot v(1) v(2) v(3) v(8) v(9)
quit

* The data in the raw file comprt3.raw are stored in a compact binary
* format. If you want them to be ASCII, you have to uncomment  line 
set filetype=ascii
* in C:\Spice\share\ngspice\scripts\spinit (remove the '*').
*********************************************************************

*********************************************************************
* Starting ngspice within the dos window (cmd.exe) , interactive mode:
* (also an example for using xspice extension)

* Open a DOS window.

*** DOS window:

set PATH=%PATH%;C:\Spice\bin

cd C:\Spice\examples\transimpedanceamp
 
ngspice output.net

*** ngspice window:

run
display
* end display with 'q'
plot vout2

* write all data into raw file to actual directory C:\Spice\tests\transimpedanceamp:
write timp.raw
* write only input and output
write timp2.raw v3#branch vout2
quit

Calling a source file in a different directory is done by:

ngspice D:\testinput\output.net

*********************************************************************
*********************************************************************
* Use ngnutmeg for plotting within the dos window (cmd.exe), using the 
raw file timp.raw created above:

* Open a DOS window.

*** DOS window:

set PATH=%PATH%;C:\Spice\bin

cd C:\Spice\examples\transimpedanceamp
 
ngspice

*** ngspice window:
load timp.raw 
plot vout2
plot i(v3)

quit
*********************************************************************

*********************************************************************
* Starting ngspice within the dos window (cmd.exe) , batch mode, using
* .plot and/or .print commands in the input file (printer plot output),
* no raw file, similar to SPICE2G6:

* Open a DOS window.

*** DOS window:

set PATH=%PATH%;C:\Spice\bin

cd C:\Spice\examples\
 
ngspice -b -o cs.out cs_mixtv4.inp

* The ouput will be plotted and printed to C:\Spice\examples\cs.out.

* If you enter
ngspice -b -r cs.raw -o cs.out cs_mixtv4.inp
* instead, you will get a raw file (simulator output data), 
* .print and .plot will be ignored. 
* You may plot the data by using ngnutmeg (see example above).

*********************************************************************
*********************************************************************
* A numparam example with convergence and ringing problems
(Xiaoqun Wu e.a.: "Bifurcation Behavior of SPICE Simulations of Switching Converters: A Systematic
Analysis of Erroneous Results", IEEE TRANSACTIONS ON POWER ELECTRONICS, VOL. 22, NO. 5, SEPTEMBER 2007, p.1743
  
dos window (cmd.exe) , interactive mode:

* Open a DOS window.

*** DOS window:

set PATH=%PATH%;C:\Spice\bin

cd C:\Spice\examples\numparam
 
ngspice power.cir

*** ngspice window:

run
plot vc#branch

*** compare to literature by selecting appropriate plot windows using right mouse tab

* write all data into raw file to actual directory C:\Spice\examples\numparam:
write power-all.raw
* write only relevant output
write  power.raw vc#branch
quit

*********************************************************************
*********************************************************************
* Running ngspice from  a different directory (for example D:\tmp)
* Starting ngspice within the dos window (cmd.exe) , interactive mode:

* Extract ngspice.zip to D:\tmp

* Edit spinit (found in D:\tmp\Spice\share\ngspice\scripts) to have the correct
  path for the XSPICE codemodels:
  Line
  codemodel C:/Spice/lib/spice/spice2poly.cm
  has to be replaced by
  codemodel D:/temp/Spice/lib/spice/spice2poly.cm
  the other codemodels lines have to be changed respectively.

* Open a DOS window.

*** DOS window:

set SPICE_LIB_DIR=D:\tmp\Spice\share\ngspice
set PATH=%PATH%;D:\tmp\Spice\bin
cd D:\tmp\Spice\examples\transimpedanceamp
D:
 
ngspice output.net

*** ngspice window:

run
plot vout2

* write all data into raw file to actual directory D:\tmp\Spice\tests\transimpedanceamp:
write timp.raw
* write only input and output
write timp2.raw v3#branch vout2
quit

*********************************************************************
*********************************************************************
* Running ngspice from  a different directory (for example D:\tmp)
* Starting ngspice within the dos window (cmd.exe) , interactive mode
  or starting with double click on ngspice in MS explorer:
  
* Extract ngspice.zip to D:\tmp
* under Windows XP you may put the following lines into C:\autoexec.bat:

set SPICE_LIB_DIR=D:\tmp\Spice\share\ngspice
set PATH=%PATH%;D:\tmp\Spice\bin

* Edit spinit (found in D:\tmp\share\ngspice\scripts) to have the correct
  path for the XSPICE codemodels:
  Line
  codemodel C:/Spice/lib/spice/spice2poly.cm
  has to be replaced by
  codemodel D:/temp/Spice/lib/spice/spice2poly.cm
  the other codemodels lines have to be changed respectively.

* You may then start immediately after opening the command window (cmd.exe)
  with:

cd D:\tmp\Spice\examples\transimpedanceamp
D:
 
ngspice output.net

*** ngspice window:

run
plot vout2

* write all data into raw file to actual directory D:\tmp\Spice\tests\transimpedanceamp:
write timp.raw
* write only input and output
write timp2.raw v3#branch vout2
quit

*********************************************************************

*********************************************************************
*********************************************************************
* spinit

* spinit is used to set options or to set varioables. spinit is read into ngspice 
  before any input file. The codemeodel path for xspice may be set as well.
  
  There is a search sequence for spinit.
  1) If the invironmental variable is SPICE_LIB_DIR is set to a path, e.g. to
  SPICE_LIB_DIR=D:\tmp\Spice\share\ngspice, then spinit is searched for
  in D:\tmp\Spice\share\ngspice\scripts. If not set then we look for it in 
  C:\Spice\share\ngspice\scripts. If this path is not available or spinit is
  not there, then ngspice searches for spinit in the path where ngspice.exe
  resides. If not found there, a warning note is issued.
  
* .spiceinit

* .spiceinit is read directly after the spinit file. You may keep spinit as is, 
  and put any personal preset variables or scripts into .spiceinit. Data in
  .spiceinit will override data from spinit. 
  ngspice will search for .spiceinit either in your home directory or in the 
  directory where ngspice.exe is located.  

*********************************************************************
*********************************************************************
* Universial, simple install

  Put ngspice.exe and spinit into a subdirectory myspice\bin
  Put the codemodels (e.g. analog.cm) into a subdirectoty myspice\codemodels.
  Edit spinit and change the codemodel lines to
 
  codemodel ../codemodels/spice2poly.cm
  
  etc. 
  
  Instead of 'myspice' you may now choose any directory for your installation
  of \bin and \codemodels, even C:\ will work.


*********************************************************************
*********************************************************************
* miscellaneous

Documentation specific to ngspice is available at 
http://ngspice.sourceforge.net/docs.html.

For additional info I recommend the Spice3 user manual at:
http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/index.html#toc 

For some information on CIDER see
http://embedded.eecs.berkeley.edu/pubs/downloads/cider/index.htm
A manual however is missing on this web site.

For an xspice manual see
http://users.ece.gatech.edu/~mrichard/Xspice/