polish `IFC' macro
checked for object file invariance, different code for inppas3.c, seems to be ok
This commit is contained in:
parent
f14c42b571
commit
9ad007cc7d
|
|
@ -1,6 +1,7 @@
|
||||||
/**********
|
/**********
|
||||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
/* a couple of macros to make much of the input code
|
/* a couple of macros to make much of the input code
|
||||||
* much much shorter and easier to handle.
|
* much much shorter and easier to handle.
|
||||||
*
|
*
|
||||||
|
|
@ -9,9 +10,14 @@ Copyright 1990 Regents of the University of California. All rights reserved.
|
||||||
* If necessary, get the proper error message and tack it on the current
|
* If necessary, get the proper error message and tack it on the current
|
||||||
* error
|
* error
|
||||||
*/
|
*/
|
||||||
#define IFC(func,args)\
|
|
||||||
error=(*(ft_sim->func))args;\
|
#define IFC(func, args) \
|
||||||
if(error)current->error = INPerrCat(current->error,INPerror(error));
|
do { \
|
||||||
|
error = (*(ft_sim->func)) args; \
|
||||||
|
if (error) \
|
||||||
|
current->error = INPerrCat(current->error, INPerror(error)); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
/* and one for calling more General functions that still return an
|
/* and one for calling more General functions that still return an
|
||||||
* error code as above
|
* error code as above
|
||||||
|
|
|
||||||
|
|
@ -282,19 +282,19 @@ INP2M (CKTcircuit *ckt, INPtables * tab, card * current)
|
||||||
fast->GENnode7 = -1;
|
fast->GENnode7 = -1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
IFC (bindNode, (ckt, fast, 5, node5))
|
IFC (bindNode, (ckt, fast, 5, node5));
|
||||||
fast->GENnode6 = -1;
|
fast->GENnode6 = -1;
|
||||||
fast->GENnode7 = -1;
|
fast->GENnode7 = -1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
IFC (bindNode, (ckt, fast, 5, node5))
|
IFC (bindNode, (ckt, fast, 5, node5));
|
||||||
IFC (bindNode, (ckt, fast, 6, node6))
|
IFC (bindNode, (ckt, fast, 6, node6));
|
||||||
fast->GENnode7 = -1;
|
fast->GENnode7 = -1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
IFC (bindNode, (ckt, fast, 5, node5))
|
IFC (bindNode, (ckt, fast, 5, node5));
|
||||||
IFC (bindNode, (ckt, fast, 6, node6))
|
IFC (bindNode, (ckt, fast, 6, node6));
|
||||||
IFC (bindNode, (ckt, fast, 7, node7))
|
IFC (bindNode, (ckt, fast, 7, node7));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,11 @@ int num, i;
|
||||||
if(!tab->defPmod) {
|
if(!tab->defPmod) {
|
||||||
/* create default P model */
|
/* create default P model */
|
||||||
IFnewUid(ckt, &uid, NULL, "P", UID_MODEL, NULL);
|
IFnewUid(ckt, &uid, NULL, "P", UID_MODEL, NULL);
|
||||||
IFC(newModel, (ckt,type,&(tab->defPmod),uid))
|
IFC(newModel, (ckt,type,&(tab->defPmod),uid));
|
||||||
}
|
}
|
||||||
mdfast = tab->defPmod;
|
mdfast = tab->defPmod;
|
||||||
}
|
}
|
||||||
IFC(newInstance,(ckt,mdfast,&fast,name))
|
IFC(newInstance,(ckt,mdfast,&fast,name));
|
||||||
INPgetTok(&line,&model,1);
|
INPgetTok(&line,&model,1);
|
||||||
if ((strcmp(model, "length") == 0) || (strcmp(model, "len") == 0)) {
|
if ((strcmp(model, "length") == 0) || (strcmp(model, "len") == 0)) {
|
||||||
lenval = INPevaluate(&line,&error1,1);
|
lenval = INPevaluate(&line,&error1,1);
|
||||||
|
|
@ -112,7 +112,7 @@ int num, i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IFC(bindNode,(ckt,fast,1,fakename)) */
|
/* IFC(bindNode,(ckt,fast,1,fakename)); */
|
||||||
|
|
||||||
ptemp.iValue = num;
|
ptemp.iValue = num;
|
||||||
GCA(INPpName,("dimension", &ptemp,ckt,type,fast))
|
GCA(INPpName,("dimension", &ptemp,ckt,type,fast))
|
||||||
|
|
|
||||||
|
|
@ -129,16 +129,16 @@ int lenvalgiven = 0;
|
||||||
if(!tab->defRmod) {
|
if(!tab->defRmod) {
|
||||||
/* create default R model */
|
/* create default R model */
|
||||||
IFnewUid(ckt, &uid, NULL, "R", UID_MODEL, NULL);
|
IFnewUid(ckt, &uid, NULL, "R", UID_MODEL, NULL);
|
||||||
IFC(newModel, (ckt,type,&(tab->defRmod),uid))
|
IFC(newModel, (ckt,type,&(tab->defRmod),uid));
|
||||||
}
|
}
|
||||||
mdfast = tab->defRmod;
|
mdfast = tab->defRmod;
|
||||||
rname1 = TMALLOC(char, 10 + strlen(name));
|
rname1 = TMALLOC(char, 10 + strlen(name));
|
||||||
strcpy(rname1, "txlres1");
|
strcpy(rname1, "txlres1");
|
||||||
strcat(rname1, name);
|
strcat(rname1, name);
|
||||||
INPinsert(&rname1, tab);
|
INPinsert(&rname1, tab);
|
||||||
IFC(newInstance,(ckt,mdfast,&fast,rname1))
|
IFC(newInstance,(ckt,mdfast,&fast,rname1));
|
||||||
IFC(bindNode,(ckt,fast,1,node1))
|
IFC(bindNode,(ckt,fast,1,node1));
|
||||||
IFC(bindNode,(ckt,fast,2,inode1))
|
IFC(bindNode,(ckt,fast,2,inode1));
|
||||||
ptemp.rValue = rval;
|
ptemp.rValue = rval;
|
||||||
GCA(INPpName,("resistance",&ptemp,ckt,type,fast))
|
GCA(INPpName,("resistance",&ptemp,ckt,type,fast))
|
||||||
|
|
||||||
|
|
@ -152,9 +152,9 @@ int lenvalgiven = 0;
|
||||||
strcat(rname2, name);
|
strcat(rname2, name);
|
||||||
INPinsert(&rname2, tab);
|
INPinsert(&rname2, tab);
|
||||||
mdfast2 = tab->defRmod;
|
mdfast2 = tab->defRmod;
|
||||||
IFC(newInstance,(ckt,mdfast2,&fast2,rname2))
|
IFC(newInstance,(ckt,mdfast2,&fast2,rname2));
|
||||||
IFC(bindNode,(ckt,fast2,1,inode1))
|
IFC(bindNode,(ckt,fast2,1,inode1));
|
||||||
IFC(bindNode,(ckt,fast2,2,inode2))
|
IFC(bindNode,(ckt,fast2,2,inode2));
|
||||||
ptemp.rValue = rval;
|
ptemp.rValue = rval;
|
||||||
GCA(INPpName,("resistance",&ptemp,ckt,type,fast2))
|
GCA(INPpName,("resistance",&ptemp,ckt,type,fast2))
|
||||||
|
|
||||||
|
|
@ -164,9 +164,9 @@ int lenvalgiven = 0;
|
||||||
strcat(rname3, name);
|
strcat(rname3, name);
|
||||||
INPinsert(&rname3, tab);
|
INPinsert(&rname3, tab);
|
||||||
mdfast3 = tab->defRmod;
|
mdfast3 = tab->defRmod;
|
||||||
IFC(newInstance,(ckt,mdfast3,&fast3,rname3))
|
IFC(newInstance,(ckt,mdfast3,&fast3,rname3));
|
||||||
IFC(bindNode,(ckt,fast3,1,inode2))
|
IFC(bindNode,(ckt,fast3,1,inode2));
|
||||||
IFC(bindNode,(ckt,fast3,2,node2))
|
IFC(bindNode,(ckt,fast3,2,node2));
|
||||||
ptemp.rValue = rval;
|
ptemp.rValue = rval;
|
||||||
GCA(INPpName,("resistance",&ptemp,ckt,type,fast3))
|
GCA(INPpName,("resistance",&ptemp,ckt,type,fast3))
|
||||||
|
|
||||||
|
|
@ -174,16 +174,16 @@ int lenvalgiven = 0;
|
||||||
type = INPtypelook("Capacitor");
|
type = INPtypelook("Capacitor");
|
||||||
if(!tab->defCmod) {
|
if(!tab->defCmod) {
|
||||||
IFnewUid(ckt, &uid, NULL, "C", UID_MODEL, NULL);
|
IFnewUid(ckt, &uid, NULL, "C", UID_MODEL, NULL);
|
||||||
IFC(newModel,(ckt,type,&(tab->defCmod),uid))
|
IFC(newModel,(ckt,type,&(tab->defCmod),uid));
|
||||||
}
|
}
|
||||||
mdfast4 = tab->defCmod;
|
mdfast4 = tab->defCmod;
|
||||||
cname1 = TMALLOC(char, 10 + strlen(name));
|
cname1 = TMALLOC(char, 10 + strlen(name));
|
||||||
strcpy(cname1, "txlcap1");
|
strcpy(cname1, "txlcap1");
|
||||||
strcat(cname1, name);
|
strcat(cname1, name);
|
||||||
INPinsert(&cname1, tab);
|
INPinsert(&cname1, tab);
|
||||||
IFC(newInstance,(ckt,mdfast4,&fast4,cname1))
|
IFC(newInstance,(ckt,mdfast4,&fast4,cname1));
|
||||||
IFC(bindNode,(ckt,fast4,1,node1))
|
IFC(bindNode,(ckt,fast4,1,node1));
|
||||||
IFC(bindNode,(ckt,fast4,2,gnode1))
|
IFC(bindNode,(ckt,fast4,2,gnode1));
|
||||||
ptemp.rValue = cval;
|
ptemp.rValue = cval;
|
||||||
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast4))
|
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast4))
|
||||||
|
|
||||||
|
|
@ -193,9 +193,9 @@ int lenvalgiven = 0;
|
||||||
strcat(cname2, name);
|
strcat(cname2, name);
|
||||||
INPinsert(&cname2, tab);
|
INPinsert(&cname2, tab);
|
||||||
mdfast4 = tab->defCmod;
|
mdfast4 = tab->defCmod;
|
||||||
IFC(newInstance,(ckt,mdfast4,&fast4,cname2))
|
IFC(newInstance,(ckt,mdfast4,&fast4,cname2));
|
||||||
IFC(bindNode,(ckt,fast4,1,inode1))
|
IFC(bindNode,(ckt,fast4,1,inode1));
|
||||||
IFC(bindNode,(ckt,fast4,2,gnode1))
|
IFC(bindNode,(ckt,fast4,2,gnode1));
|
||||||
ptemp.rValue = cval * 2;
|
ptemp.rValue = cval * 2;
|
||||||
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast4))
|
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast4))
|
||||||
|
|
||||||
|
|
@ -205,9 +205,9 @@ int lenvalgiven = 0;
|
||||||
strcat(cname3, name);
|
strcat(cname3, name);
|
||||||
INPinsert(&cname3, tab);
|
INPinsert(&cname3, tab);
|
||||||
mdfast5 = tab->defCmod;
|
mdfast5 = tab->defCmod;
|
||||||
IFC(newInstance,(ckt,mdfast5,&fast5,cname3))
|
IFC(newInstance,(ckt,mdfast5,&fast5,cname3));
|
||||||
IFC(bindNode,(ckt,fast5,1,inode2))
|
IFC(bindNode,(ckt,fast5,1,inode2));
|
||||||
IFC(bindNode,(ckt,fast5,2,gnode1))
|
IFC(bindNode,(ckt,fast5,2,gnode1));
|
||||||
ptemp.rValue = cval * 2;
|
ptemp.rValue = cval * 2;
|
||||||
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast5))
|
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast5))
|
||||||
|
|
||||||
|
|
@ -217,9 +217,9 @@ int lenvalgiven = 0;
|
||||||
strcat(cname4, name);
|
strcat(cname4, name);
|
||||||
INPinsert(&cname4, tab);
|
INPinsert(&cname4, tab);
|
||||||
mdfast6 = tab->defCmod;
|
mdfast6 = tab->defCmod;
|
||||||
IFC(newInstance,(ckt,mdfast6,&fast6,cname4))
|
IFC(newInstance,(ckt,mdfast6,&fast6,cname4));
|
||||||
IFC(bindNode,(ckt,fast6,1,node2))
|
IFC(bindNode,(ckt,fast6,1,node2));
|
||||||
IFC(bindNode,(ckt,fast6,2,gnode1))
|
IFC(bindNode,(ckt,fast6,2,gnode1));
|
||||||
ptemp.rValue = cval;
|
ptemp.rValue = cval;
|
||||||
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast6))
|
GCA(INPpName,("capacitance",&ptemp,ckt,type,fast6))
|
||||||
return;
|
return;
|
||||||
|
|
@ -234,11 +234,11 @@ int lenvalgiven = 0;
|
||||||
if(!tab->defYmod) {
|
if(!tab->defYmod) {
|
||||||
/* create default Y model */
|
/* create default Y model */
|
||||||
IFnewUid(ckt, &uid, NULL, "Y", UID_MODEL, NULL);
|
IFnewUid(ckt, &uid, NULL, "Y", UID_MODEL, NULL);
|
||||||
IFC(newModel, (ckt,type,&(tab->defYmod),uid))
|
IFC(newModel, (ckt,type,&(tab->defYmod),uid));
|
||||||
}
|
}
|
||||||
mdfast = tab->defYmod;
|
mdfast = tab->defYmod;
|
||||||
}
|
}
|
||||||
IFC(newInstance,(ckt,mdfast,&fast,name))
|
IFC(newInstance,(ckt,mdfast,&fast,name));
|
||||||
} else {
|
} else {
|
||||||
LITERR("model name is not found")
|
LITERR("model name is not found")
|
||||||
return;
|
return;
|
||||||
|
|
@ -249,8 +249,8 @@ int lenvalgiven = 0;
|
||||||
GCA(INPpName,("length",&ptemp,ckt,type,fast))
|
GCA(INPpName,("length",&ptemp,ckt,type,fast))
|
||||||
}
|
}
|
||||||
|
|
||||||
IFC(bindNode,(ckt,fast,1,node1))
|
IFC(bindNode,(ckt,fast,1,node1));
|
||||||
IFC(bindNode,(ckt,fast,2,node2))
|
IFC(bindNode,(ckt,fast,2,node2));
|
||||||
|
|
||||||
txl = /*fixme*/ fast;
|
txl = /*fixme*/ fast;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ INPpas3(CKTcircuit *ckt, card *data, INPtables *tab, TSKtask *task,
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning : IC on non-existant node - %s\n", name);
|
"Warning : IC on non-existant node - %s\n", name);
|
||||||
ptemp.rValue = INPevaluate(&line,&error,1);
|
ptemp.rValue = INPevaluate(&line,&error,1);
|
||||||
IFC(setNodeParm, (ckt, node1, which, &ptemp, NULL))
|
IFC(setNodeParm, (ckt, node1, which, &ptemp, NULL));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LITERR(" Error: .ic syntax error.\n")
|
LITERR(" Error: .ic syntax error.\n")
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ MIF_INP2A (
|
||||||
|
|
||||||
/* create a new structure for this instance in ckt */
|
/* create a new structure for this instance in ckt */
|
||||||
mdfast = (MIFmodel*) thismodel->INPmodfast;
|
mdfast = (MIFmodel*) thismodel->INPmodfast;
|
||||||
IFC(newInstance, (ckt, (GENmodel*)mdfast, (GENinstance **)fast, name))
|
IFC(newInstance, (ckt, (GENmodel*)mdfast, (GENinstance **)fast, name));
|
||||||
|
|
||||||
|
|
||||||
/* initialize the code model specific elements of the inst struct */
|
/* initialize the code model specific elements of the inst struct */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue