1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California.  All rights reserved.
4 Authors: 1987 Thomas L. Quarles
5          1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include "ftedefs.h"
10 #include "inpdefs.h"
11 #include "inpmacs.h"
12 #include "misc.h"
13 
14 /* ARGSUSED */
15 int
DCTparse(ckt,tab,which,currentp,line,task,gnode)16 DCTparse(ckt,tab,which,currentp,line,task,gnode)
17 
18 /*
19     .dc SRC1NAME Vstart1 [Vstop1 [Vinc1]]
20         [SRC2NAME Vstart2 [Vstop2 [Vinc2]]]
21 */
22 GENERIC *ckt;
23 INPtables *tab;
24 int which;
25 GENERIC *currentp;
26 char **line;
27 GENERIC *task;
28 GENERIC *gnode;
29 {
30     GENERIC *foo;   /* pointer to analysis */
31     int error;      /* error code temporary */
32     card *current = (card *)currentp;
33 
34     IFC(newAnalysis,(ckt,which,"DCtransferCurve",&foo, task))
35 
36     GCA(ParseDC,(ckt,line,current,which,foo,tab,1))
37 
38     if (**line) {
39         GCA(ParseDC,(ckt,line,current,which,foo,tab,2))
40     }
41     return (0);
42 }
43 
44 
45 int
ParseDC(ckt,line,current,which,aptr,tab,index)46 ParseDC(ckt,line,current,which,aptr,tab,index)
47 
48 GENERIC *ckt;
49 char **line;
50 card *current;
51 int which;
52 GENERIC *aptr;
53 INPtables *tab;
54 int index;
55 {
56     char *name;     /* the device's name */
57     IFvalue ptemp;  /* a value structure to package stuff into */
58     int error;      /* error code temporary */
59     double vstart, vstop, vstep;
60     char buf[32];
61 
62     INPgetTok(line,&name,1);
63     strtolower(name);
64     INPinsert(&name,tab);
65     ptemp.uValue = name;
66     sprintf(buf,"name%d",index);
67     GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
68 
69     vstart = INPevaluate(line,&error,1);          /* vstart */
70     if (error == 0) {
71         ptemp.rValue = vstart;
72         sprintf(buf,"start%d",index);
73         GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
74     }
75     else {
76         LITERR("Bad vstart parameter.")
77     }
78 
79     vstop = INPevaluate(line,&error,1);           /* vstop? */
80     if (error == 0) {
81         ptemp.rValue = vstop;
82         sprintf(buf,"stop%d",index);
83         GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
84         vstep = INPevaluate(line,&error,1);       /* vstep? */
85         if (error == 0)
86             ptemp.rValue = vstep;
87         else
88             ptemp.rValue = vstop - vstart;
89         sprintf(buf,"step%d",index);
90         GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
91     }
92     else {
93         ptemp.rValue = vstart;
94         sprintf(buf,"stop%d",index);
95         GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
96         ptemp.rValue = 0.0;
97         sprintf(buf,"step%d",index);
98         GCA(INPapName,(ckt,which,aptr,buf,&ptemp))
99     }
100 
101     return (0);
102 }
103