Jspice3
sensprse.c
Go to the documentation of this file.
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 
15 /* ARGSUSED */
16 int
17 SENSparse(ckt,tab,which,currentp,line,task,gnode)
18 
19 /*
20  .sens output [ac {dec lin oct} NP FSTART FSTOP]
21  [ dc SRC1NAME Vstart1 [Vstop1 [Vinc1]]
22  [SRC2NAME Vstart2 [Vstop2 [Vinc2]]] ]
23 */
24 GENERIC *ckt;
25 INPtables *tab;
26 int which;
27 GENERIC *currentp;
28 char **line;
29 GENERIC *task;
30 GENERIC *gnode;
31 {
32  char *nname1; /* the first node's name */
33  char *nname2; /* the second node's name */
34  GENERIC *node; /* node pointer */
35  GENERIC *foo; /* pointer to analysis */
36  IFvalue ptemp; /* a value structure to package stuff into */
37  IFvalue *parm; /* a pointer to a value struct for function returns */
38  int error; /* error code temporary */
39  char *token; /* a token from the line */
40  card *current = (card *)currentp;
41 
42  IFC(newAnalysis,(ckt,which,"Sensitivity Analysis",&foo, task))
43 
44  /* Get the output voltage or current */
45  INPgetTok(line,&token,1);
46  /* token is now either V or I or a serious error */
47  if ((*token == 'v' || *token == 'V') && strlen(token) == 1) {
48  txfree(token);
49  if (**line != '(' /* match) */) {
50  LITERR("Syntax error: '(' expected after 'v'");
51  return (0);
52  }
53  INPgetTok(line, &nname1, 0);
54  INPtermInsert(ckt, &nname1, tab, &node);
55  ptemp.nValue = node;
56  GCA(INPapName,(ckt,which,foo,"outpos",&ptemp))
57 
58  if (**line != /* match ( */ ')') {
59  INPgetTok(line, &nname2, 1);
60  INPtermInsert(ckt, &nname2, tab, &node);
61  ptemp.nValue = node;
62  GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
63  ptemp.sValue = (char *)
64  tmalloc(sizeof(char)*(5+strlen(nname1)+strlen(nname2)));
65  (void)sprintf(ptemp.sValue,"v(%s,%s)",nname1,nname2);
66  GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
67  }
68  else {
69  ptemp.nValue = gnode;
70  GCA(INPapName,(ckt,which,foo,"outneg",&ptemp))
71  ptemp.sValue = (char *)tmalloc(sizeof(char)*(4+strlen(nname1)));
72  (void)sprintf(ptemp.sValue,"v(%s)",nname1);
73  GCA(INPapName,(ckt,which,foo,"outname",&ptemp))
74  }
75  }
76  else if (*token == 'i' && strlen(token) == 1) {
77  txfree(token);
78  INPgetTok(line,&token,1);
79  strtolower(token);
80  INPinsert(&token,tab);
81  ptemp.uValue = token;
82  GCA(INPapName,(ckt,which,foo,"outsrc",&ptemp))
83  }
84  else {
85  txfree(token);
86  LITERR("Syntax error: voltage or current expected.")
87  return (0);
88  }
89 
90  INPgetTok(line,&token,1);
91  if (token && !strcmp(token, "pct")) {
92  txfree(token);
93  ptemp.iValue = 1;
94  GCA(INPapName,(ckt,which,foo,"pct",&ptemp))
95  INPgetTok(line,&token,1);
96  }
97  if (token && !strcmp(token, "ac")) {
98  txfree(token);
99  GCA(ParseAC,(ckt,line,current,which,foo,tab))
100  }
101 
102  if (token && *token && strcmp(token, "dc")) {
103  /* Bad flag */
104  LITERR("Syntax error: 'ac' or 'dc' expected.")
105  }
106  txfree(token);
107  return (0);
108 }
int INPtermInsert()
Definition: inpdefs.h:62
Definition: subckt.c:51
int iValue
Definition: ifsim.h:232
int SENSparse(GENERIC *ckt, INPtables *tab, int which, GENERIC *currentp, char **line, GENERIC *task, GENERIC *gnode)
Definition: sensprse.c:17
#define LITERR(text)
Definition: inpmacs.h:35
int INPinsert()
char * tmalloc()
Definition: fteinp.h:14
void txfree()
void strtolower()
IFnode nValue
Definition: ifsim.h:237
#define GCA(func, args)
Definition: inpmacs.h:27
#define IFC(func, args)
Definition: inpmacs.h:19
int INPapName()
char * sValue
Definition: ifsim.h:235
int ParseAC()
char GENERIC
Definition: ifsim.h:27
IFuid uValue
Definition: ifsim.h:236
int INPgetTok()