What is sp2xg ?
--------------

sp2xg is a spice(1) to xgraph(1x) converter.
spice is the well-known circuit simulator, and xgraph is
a program which visualizes tables (a la gnuplot, but xgraph
has the ability to zoom interactively into your graphs).

Since spice 2g6 doesn't have any data visualisation capability,
(or do you call ascii tables `visualisation' ?), I decided to 
write a spice table to xgraph table translator.


Installation
------------

If you want to recompile sp2xg, type "make". You will get a few
warnings about the "sscanf()" call in line 193

sp2xg.c: In function `ReadAndStoreTitles':
sp2xg.c:193: warning: char format, different type arg (arg 3-11)

but they can be ignored; the program works.

Type "make install", and "make install.man" (as root).


Features
--------

sp2xg has the following command line options:

-i fi    input file name fi
-o fo    output file name fo

-v	 be verbose (debug output)
-t n	 extracts the n th transient table generated by spice's
         .PRINT TRAN command,
-a n     extracts the n th AC table generated by spice's
         .PRINT AC command.	

It is not necessary to supply the -t or -a switches, if they are omitted,
the first appearing table will be converted.


Example
-------

To clarify the usage of sp2xg, I'll give you a small example:
First, we calculate the small.inp example (which was delivered with the
spice package):

spice < small.inp > small.out

Let's take a look at the file small.out:

less small.out

1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)                                           

0****     input listing                    temperature =   27.000 deg c

0***********************************************************************



 *       
 .width out=80   
 *  transistors :
 mq1n   2     1     0     0     cmosn l=3u w=4.5u
 mq1p   2     1   100   100     cmosp l=3u w=4.5u
 mq2n   3     2     0     0     cmosn l=3u w=4.5u
 mq2p   3     2   100   100     cmosp l=3u w=4.5u
 mq3n   4     3     0     0     cmosn l=3u w=4.5u
 mq3p   4     3   100   100     cmosp l=3u w=4.5u
 mq4n   5     4     0     0     cmosn l=3u w=4.5u
 mq4p   5     4   100   100     cmosp l=3u w=4.5u
 mq5n   6     5     0     0     cmosn l=3u w=4.5u
 mq5p   6     5   100   100     cmosp l=3u w=4.5u
 mq6n   7     6     0     0     cmosn l=3u w=4.5u
 mq6p   7     6   100   100     cmosp l=3u w=4.5u
 mq7n   1     7     0     0     cmosn l=3u w=4.5u
 mq7p   1     7   100   100     cmosp l=3u w=4.5u
 *       
 *  voltage cards :      
 vdd 100     0     dc     5v     
 *       
 *  analysis cards :     
 .tran 100ps 1ns 
 .plot tran v(1) v(7)    
 .print tran v(1) v(7)   
 .ic v(1)=0 v(3)=0 v(5)=0 v(7)=0 
 *       
 *  model cards :
 .model cmosn nmos (vto=0.83 kp=33u gamma=1.36 phi=0.6   
 + lambda=0.016 pb=0.8 js=10n ld=0.28u tox=50n nsub=1e16 
 + uo=200 uexp=0.1 ucrit=4e4 vmax=100k xj=0.4u   
 + delta=1.24 nfs=0 neff=2 nss=0 tpg=1.0 rsh=25  
 + cgso=0.5n cgdo=0.5n cj=0.32m mj=0.5 cjsw=0.9n mjsw=0.33       
 + cgbo=0 fc=0.5 level=2)
 .model cmosp pmos (vto=-0.89 kp=15u gamma=0.88 phi=0.6  
 + lambda=0.047 pb=0.8 js=10n ld=0.28u tox=50n nsub=1.12e14      
 + uo=100 uexp=0.1 ucrit=20e4 vmax=100k xj=0.4u  
 + delta=1.94 nfs=0 neff=2 nss=0 tpg=-1.0 rsh=95 
 + cgso=0.4n cgdo=0.4n cj=0.2m mj=0.5 cjsw=0.45n mjsw=0.33       
 + cgbo=0 fc=0.5 level=2)
 .end    
1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)

0****     mosfet model parameters          temperature =   27.000 deg c

0***********************************************************************

             cmosn     cmosp   
0type        nmos      pmos  
0level        2.000     2.000
0vto           .830     -.890
0kp        3.30E-05  1.50E-05
0gamma        1.360      .880
0phi           .600      .600
0lambda    1.60E-02  4.70E-02
0pb            .800      .800
0cgso      5.00E-10  4.00E-10
0cgdo      5.00E-10  4.00E-10
0cgbo      0.00E+00  0.00E+00
0rsh         25.000    95.000
0cj        3.20E-04  2.00E-04
0mj            .500      .500
0cjsw      9.00E-10  4.50E-10
0mjsw          .330      .330
0js        1.00E-08  1.00E-08
0tox       5.00E-08  5.00E-08
0nsub      1.00E+16  1.12E+14
0nss       0.00E+00  0.00E+00
0nfs       0.00E+00  0.00E+00
0tpg          1.000    -1.000
0xj        4.00E-07  4.00E-07
0ld        2.80E-07  2.80E-07
0uo         200.000   100.000
0ucrit     4.00E+04  2.00E+05
0uexp          .100      .100
0vmax      1.00E+05  1.00E+05
0neff         2.000     2.000
0fc            .500      .500
0delta        1.240     1.940
1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)                                           

0****     initial transient solution       temperature =   27.000 deg c

0***********************************************************************


  node   voltage     node   voltage     node   voltage     node   voltage


 (  1)     .0003    (  2)    5.0000    (  3)     .0000    (  4)    5.0000

 (  5)     .0000    (  6)    5.0000    (  7)     .0000    (100)    5.0000


     voltage source currents

     name       current


     vdd      -2.560E-04


     total power dissipation   1.28E-03  watts
1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)                                           

0****     operating point information      temperature =   27.000 deg c

0***********************************************************************


0
0**** mosfets


0            mq1n      mq1p      mq2n      mq2p      mq3n      mq3p      mq4n    
0model     cmosn     cmosp     cmosn     cmosp     cmosn     cmosp     cmosn   
 id        1.93E-12 -6.93E-12 -2.12E-25 -1.93E-12  1.93E-12 -6.93E-12 -2.20E-25
 vgs           .000    -5.000     5.000      .000      .000    -5.000     5.000
 vds          5.000      .000      .000    -5.000     5.000      .000      .000
 vbs           .000      .000      .000      .000      .000      .000      .000


0            mq4p      mq5n      mq5p      mq6n      mq6p      mq7n      mq7p    
0model     cmosp     cmosn     cmosp     cmosn     cmosp     cmosn     cmosp   
 id       -1.93E-12  1.93E-12 -6.93E-12 -2.20E-25 -1.93E-12  9.90E-17 -2.56E-04
 vgs           .000      .000    -5.000     5.000      .000      .000    -5.000
 vds         -5.000     5.000      .000      .000    -5.000      .000    -5.000
 vbs           .000      .000      .000      .000      .000      .000      .000
1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)                                           

0****     transient analysis               temperature =   27.000 deg c

0***********************************************************************



     time       v(1)        v(7)        
x
 
  0.000E+00     2.560E-04   6.930E-12
  1.000E-10     1.065E+00   1.118E-01
  2.000E-10     1.998E+00   1.571E-01
  3.000E-10     2.725E+00   1.799E-01
  4.000E-10     3.264E+00   1.737E-01
  5.000E-10     3.644E+00   1.477E-01
  6.000E-10     3.949E+00   1.268E-01
  7.000E-10     4.174E+00   1.026E-01
  8.000E-10     4.325E+00   7.835E-02
  9.000E-10     4.416E+00   5.548E-02
  1.000E-09     4.483E+00   4.095E-02
y
1*******02/21/94 ********  spice 2g.6    3/15/83 ********00:53:56*****

0*  cmos ring oscillator (7 inverters)                                           

0****     transient analysis               temperature =   27.000 deg c

0***********************************************************************


0legend:

 *: v(1)    
 +: v(7)    
x
     time      v(1)    

(*)-------------  0.000E+00     2.000E+00     4.000E+00     6.000E+00  8.000E+00
                       - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(+)-------------  0.000E+00     5.000E-02     1.000E-01     1.500E-01  2.000E-01
                       - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 0.000E+00  2.560E-04 x             .             .             .             .
 1.000E-10  1.065E+00 .      *      .             .  +          .             .
 2.000E-10  1.998E+00 .             *             .             . +           .
 3.000E-10  2.725E+00 .             .    *        .             .       +     .
 4.000E-10  3.264E+00 .             .        *    .             .      +      .
 5.000E-10  3.644E+00 .             .           * .            +.             .
 6.000E-10  3.949E+00 .             .             *      +      .             .
 7.000E-10  4.174E+00 .             .             .x            .             .
 8.000E-10  4.325E+00 .             .       +     . *           .             .
 9.000E-10  4.416E+00 .             . +           .  *          .             .
 1.000E-09  4.483E+00 .          +  .             .  *          .             .
                       - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


y
0
         job concluded
0         total job time           11.17

The interesting part (at least for sp2xg) is the "transient analysis" 
section. We want to convert this table will by sp2xg:

sp2xg -i small.out -o small.xg

the output file looks like this:

TitleText:  cmos ring oscillator (7 inverters)
XUnitText: t
YUnitText: v(1)
" v(1)
        0.000000E+00         2.560000E-04
        1.000000E-10         1.065000E+00
        2.000000E-10         1.998000E+00
        3.000000E-10         2.725000E+00
        4.000000E-10         3.264000E+00
        5.000000E-10         3.644000E+00
        6.000000E-10         3.949000E+00
        7.000000E-10         4.174000E+00
        8.000000E-10         4.325000E+00
        9.000000E-10         4.416000E+00
        1.000000E-09         4.483000E+00

YUnitText: v(7)
" v(7)
        0.000000E+00         6.930000E-12
        1.000000E-10         1.118000E-01
        2.000000E-10         1.571000E-01
        3.000000E-10         1.799000E-01
        4.000000E-10         1.737000E-01
        5.000000E-10         1.477000E-01
        6.000000E-10         1.268000E-01
        7.000000E-10         1.026000E-01
        8.000000E-10         7.835000E-02
        9.000000E-10         5.548000E-02
        1.000000E-09         4.095000E-02


This file may be plotted (under X Windows) by xgraph:

 xgraph small.xg
 

Note: The experienced user had typed: "spice < small.inp|sp2xg|xgraph".


Copyrights
----------

Copyright (C) 1993 by David Frey.

sp2xg is released under the GNU Public License, read the file 'COPYRIGHT' 
for further information.


Acknowledgments
---------------

Linus Torvalds for writing such a wonderful operating system.

Richard Stallman et. al for their GNU Software,
  
 ...and all the other people writing free software!

Michael Weller, the author of xpalette, wrote:

 "This work and much more would not have been possible without 
  the Linux project initiated by Linus Torvalds (and of course
  all other people contributing their work to this project).  
  This project together with the GNU project made it possible 
  for capable computer users of my generation to choose a free, 
  reliable  and state of the art operating system and to get rid 
  of the arbitrariness  of  commercial software	vendors and 
  business people squeezing just money out of people that have to 
  rely on them instead  of supplying working and useful software."

That's exact my opinion. I have nothing to add.


How to reach the author:
------------------------

By surface mail:

 David Frey
 Urdorferstr. 30
 CH-8952 Schlieren
 Switzerland
 
