Merge Dan White's contributed additions to spicefile/sp2sp:
[gwave-svn.git] / doc / spice3.txt
blobc6ab3a91af5c1687c1882371a6b0200c7f706098
2 Notes on the "rawfile" format generated by Berkeley spice3 and ng-spice.
3 Sadly, neither program documents the file format.
5 Top of an example file:
7 Title: * RC circuit driven by square wave 
8 Date: Sun Oct  8 22:29:16  2000
9 Plotname: Transient Analysis
10 Flags: real
11 No. Variables: 6
12 No. Points: 85      
13 Command: version 12
14 Variables:
15         0       time    time
16         1       gnd     voltage
17         2       a       voltage
18         3       b       voltage
19         4       va#branch       current
20         5       vgnd#branch     current
21 Values:
22 0               0.000000000000000e+00
23         0.000000000000000e+00
24         0.000000000000000e+00
25         0.000000000000000e+00
26         0.000000000000000e+00
27         0.000000000000000e+00
28 1               5.000000000000002e-12
29         0.000000000000000e+00
30         0.000000000000000e+00
31         0.000000000000000e+00
32         0.000000000000000e+00
33         0.000000000000000e+00
37 The header consists of lines with "name: value" parameter assignments.
39 Following a Variables: line, are "No. Variables" lines each containing
40 an index, name, and variable-type.
42 Following a "Values:" line is the data.
43 Each chunk of data represents a row, and contains "No. Variables" lines.
44 The first line of a chunk starts with an index or point number.
45 Indexes run 0 through "No. points" minus one.
48 If "Flags: complex" instead of "Flags: real", the each data point
49 is a complex pair seperated by a comma:
51 0               1.000000000000000e+00,7.227131787662363e-270
52         0.000000000000000e+00,0.000000000000000e+00
53         0.000000000000000e+00,0.000000000000000e+00
54         1.000000000000000e+00,0.000000000000000e+00
55         8.638022681143612e-01,-9.279561053152983e-08
58 Assumed to be "real,imaginary" but not confirmed.
59 "Complex" is an all-or-nothing situation.
61 Instead of a "Variables:" section there may be a "Binary:" section.
62 In this case, the data appears to be 64-bit double-precion floating point,
63 with "No. variables" * "No. points" doubles, following immediately after
64 the newline in "Binary:\n"
66 To get spice3 or ngspice to generate an ascii rawfile instead of binary, 
67 set the environment variable SPICE_ASCIIRAWFILE
70 Some analysis types have no independent variable.  
71 One is pole-zero analysis; its output consists only of 
72 the complex values of the poles:
74 Title: spice file generated by ...
75 Date: Tue Oct 27 21:50:41  2009
76 Plotname: Pole-Zero Analysis
77 Flags: complex
78 No. Variables: 2
79 No. Points: 1       
80 Variables:
81         0       v(pole(1))      voltage
82         1       v(pole(2))      voltage
83 Values:
84 0               -2.221441543562163e+05,2.221441281761691e+05
85         -2.221441543562163e+05,-2.221441281761691e+05
87 (Binary version has exactly 32 bytes of output - 4 doubles.)