SV_ADMITTANCE, signal prototype

This commit is contained in:
h_vogt 2009-05-21 15:11:06 +00:00
parent e92a7d397f
commit 13acf2cef1
5 changed files with 205 additions and 205 deletions

View File

@ -1,3 +1,7 @@
2009-05-21 Holger Vogt
* evaluate.c, outitf.c, sim.h: use SV_ADMITTANCE for plotting @dev[gxx]
* defines.h change signal prototype for _MSC_VER
2009-05-21 Paolo Nenzi
* src/frontend/postcoms.c: Fix from Lemaitre Laurent to avoid a segmentation
fault when v->v_plot->pl_scale is NULL.
@ -3100,6 +3104,7 @@ Spaghetti:
- based on spice3f5-chili, hardly anything touched on it.
=======
>>>>>>> 1.417
2009-05-16 Holger Vogt
* inpcom.c lines 778ff: allow the following .model names:
First character is alphabetical

View File

@ -68,7 +68,7 @@ ft_evaluate(struct pnode *node)
}
if (d==NULL) {
return NULL;
return NULL;
}
if (node->pn_name && !ft_evdb && d && !d->v_link2) {
@ -107,117 +107,115 @@ doop(char what,
v1 = ft_evaluate(arg1);
v2 = ft_evaluate(arg2);
if (!v1 || !v2)
return (NULL);
return (NULL);
/* Now the question is, what do we do when one or both of these
* has more than one vector? This is definitely not a good
* thing. For the time being don't do anything.
*/
if (v1->v_link2 || v2->v_link2) {
fprintf(cp_err, "Warning: no operations on wildcards yet.\n");
if (v1->v_link2 && v2->v_link2)
fprintf(cp_err, "\t(You couldn't do that one anyway)\n");
return (NULL);
fprintf(cp_err, "Warning: no operations on wildcards yet.\n");
if (v1->v_link2 && v2->v_link2)
fprintf(cp_err, "\t(You couldn't do that one anyway)\n");
return (NULL);
}
/* How do we handle operations on multi-dimensional vectors?
* For now, we only allow operations between one-D vectors,
* equivalently shaped multi-D vectors, or a multi-D vector and
* a one-D vector. It's not at all clear what to do in the other cases.
* So only check shape requirement if its an operation between two multi-D
* So only check shape requirement if it is an operation between two multi-D
* arrays.
*/
if ((v1->v_numdims > 1) && (v2->v_numdims > 1)) {
if (v1->v_numdims != v2->v_numdims) {
fprintf(cp_err,
"Warning: operands %s and %s have incompatible shapes.\n",
v1->v_name, v2->v_name);
return (NULL);
}
for (i = 1; i < v1->v_numdims; i++) {
if ((v1->v_dims[i] != v2->v_dims[i])) {
fprintf(cp_err,
"Warning: operands %s and %s have incompatible shapes.\n",
v1->v_name, v2->v_name);
return (NULL);
}
}
if (v1->v_numdims != v2->v_numdims) {
fprintf(cp_err,
"Warning: operands %s and %s have incompatible shapes.\n",
v1->v_name, v2->v_name);
return (NULL);
}
for (i = 1; i < v1->v_numdims; i++) {
if ((v1->v_dims[i] != v2->v_dims[i])) {
fprintf(cp_err,
"Warning: operands %s and %s have incompatible shapes.\n",
v1->v_name, v2->v_name);
return (NULL);
}
}
}
/* This is a bad way to do this. */
switch (what) {
case '=':
case '>':
case '<':
case 'G':
case 'L':
case 'N':
case '&':
case '|':
case '~':
relflag = TRUE;
case '=':
case '>':
case '<':
case 'G':
case 'L':
case 'N':
case '&':
case '|':
case '~':
relflag = TRUE;
}
/* Don't bother to do type checking. Maybe this should go in at
* some point.
*/
/* Type checking is done later */
/* Make sure we have data of the same length. */
length = ((v1->v_length > v2->v_length) ? v1->v_length : v2->v_length);
if (v1->v_length < length) {
free1 = TRUE;
if (isreal(v1)) {
ld = 0.0;
d1 = (double *) tmalloc(length * sizeof (double));
for (i = 0; i < v1->v_length; i++)
d1[i] = v1->v_realdata[i];
if (length > 0)
ld = v1->v_realdata[v1->v_length - 1];
for ( ; i < length; i++)
d1[i] = ld;
} else {
realpart(&lc) = 0.0;
imagpart(&lc) = 0.0;
c1 = (complex *) tmalloc(length * sizeof (complex));
for (i = 0; i < v1->v_length; i++)
c1[i] = v1->v_compdata[i];
if (length > 0)
lc = v1->v_compdata[v1->v_length - 1];
for ( ; i < length; i++)
c1[i] = lc;
}
free1 = TRUE;
if (isreal(v1)) {
ld = 0.0;
d1 = (double *) tmalloc(length * sizeof (double));
for (i = 0; i < v1->v_length; i++)
d1[i] = v1->v_realdata[i];
if (length > 0)
ld = v1->v_realdata[v1->v_length - 1];
for ( ; i < length; i++)
d1[i] = ld;
} else {
realpart(&lc) = 0.0;
imagpart(&lc) = 0.0;
c1 = (complex *) tmalloc(length * sizeof (complex));
for (i = 0; i < v1->v_length; i++)
c1[i] = v1->v_compdata[i];
if (length > 0)
lc = v1->v_compdata[v1->v_length - 1];
for ( ; i < length; i++)
c1[i] = lc;
}
} else
if (isreal(v1))
d1 = v1->v_realdata;
else
c1 = v1->v_compdata;
if (isreal(v1))
d1 = v1->v_realdata;
else
c1 = v1->v_compdata;
if (v2->v_length < length) {
free2 = TRUE;
if (isreal(v2)) {
ld = 0.0;
d2 = (double *) tmalloc(length * sizeof (double));
for (i = 0; i < v2->v_length; i++)
d2[i] = v2->v_realdata[i];
if (length > 0)
ld = v2->v_realdata[v2->v_length - 1];
for ( ; i < length; i++)
d2[i] = ld;
} else {
realpart(&lc) = 0.0;
imagpart(&lc) = 0.0;
c2 = (complex *) tmalloc(length * sizeof (complex));
for (i = 0; i < v2->v_length; i++)
c2[i] = v2->v_compdata[i];
if (length > 0)
lc = v2->v_compdata[v1->v_length - 1];
for ( ; i < length; i++)
c2[i] = lc;
}
free2 = TRUE;
if (isreal(v2)) {
ld = 0.0;
d2 = (double *) tmalloc(length * sizeof (double));
for (i = 0; i < v2->v_length; i++)
d2[i] = v2->v_realdata[i];
if (length > 0)
ld = v2->v_realdata[v2->v_length - 1];
for ( ; i < length; i++)
d2[i] = ld;
} else {
realpart(&lc) = 0.0;
imagpart(&lc) = 0.0;
c2 = (complex *) tmalloc(length * sizeof (complex));
for (i = 0; i < v2->v_length; i++)
c2[i] = v2->v_compdata[i];
if (length > 0)
lc = v2->v_compdata[v1->v_length - 1];
for ( ; i < length; i++)
c2[i] = lc;
}
} else
if (isreal(v2))
d2 = v2->v_realdata;
else
c2 = v2->v_compdata;
if (isreal(v2))
d2 = v2->v_realdata;
else
c2 = v2->v_compdata;
/* Some of the math routines generate SIGILL if the argument is
* out of range. Catch this here.
@ -237,7 +235,7 @@ doop(char what,
(void) signal(SIGILL, SIG_DFL);
if (!data)
return (NULL);
return (NULL);
/* Make up the new vector. */
res = alloc(struct dvec);
ZERO(res,struct dvec);
@ -269,97 +267,93 @@ doop(char what,
/* Copy dimensions. */
if (v1->v_numdims > v2->v_numdims) {
res->v_numdims = v1->v_numdims;
for (i = 0; i < v1->v_numdims; i++)
res->v_dims[i] = v1->v_dims[i];
res->v_numdims = v1->v_numdims;
for (i = 0; i < v1->v_numdims; i++)
res->v_dims[i] = v1->v_dims[i];
} else {
res->v_numdims = v2->v_numdims;
for (i = 0; i < v2->v_numdims; i++)
res->v_dims[i] = v2->v_dims[i];
res->v_numdims = v2->v_numdims;
for (i = 0; i < v2->v_numdims; i++)
res->v_dims[i] = v2->v_dims[i];
}
/* This depends somewhat on what the operation is. XXX Should fix
* res->v_type = v1->v_type;
* Introduced to show the real units coming out from an
* operation. A.Roldán
/* ** Type checking for multiplication and division of vectors **
* Determines the units resulting from the operation.
* A.Roldán
*/
switch (what)
{
case '*': /* Multiplication of two vectors */
switch(v1->v_type)
{
case SV_VOLTAGE:
switch(v2->v_type)
{
case '*': /* Multiplication of two vectors */
switch(v1->v_type)
{
case SV_VOLTAGE:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_VOLTAGE;
break;
case SV_CURRENT:
res->v_type = SV_POWER;
break;
default:
break;
}
break;
case SV_CURRENT:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_VOLTAGE;
break;
res->v_type = SV_POWER;
break;
case SV_CURRENT:
res->v_type = SV_POWER;
break;
res->v_type = SV_CURRENT;
break;
default:
break;
}
break;
}
break;
break;
case SV_CURRENT:
default:
break;
}
break;
case '/': /* division of two vectors */
switch(v1->v_type)
{
case SV_VOLTAGE:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_NOTYPE;
break;
case SV_CURRENT:
res->v_type = SV_IMPEDANCE;
break;
default:
break;
}
break;
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_POWER;
break;
case SV_CURRENT:
res->v_type = SV_CURRENT;
break;
default:
break;
}
break;
case SV_CURRENT:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_ADMITTANCE;
break;
case SV_CURRENT:
res->v_type = SV_NOTYPE;
break;
default:
break;
}
break;
default:
default:
break;
}
break;
}
break;
case '/': //Multiplicación de 2 vectores
switch(v1->v_type)
{
case SV_VOLTAGE:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_NOTYPE;
break;
case SV_CURRENT:
res->v_type = SV_IMPEDANCE;
break;
default:
break;
}
break;
case SV_CURRENT:
switch(v2->v_type)
{
case SV_VOLTAGE:
res->v_type = SV_ADMITANCE;
break;
case SV_CURRENT:
res->v_type = SV_NOTYPE;
break;
default:
break;
}
break;
default:
break;
}
default:
break;
default:
break;
}
vec_new(res);
@ -637,7 +631,7 @@ op_ind(struct pnode *arg1, struct pnode *arg2)
blocksize = v->v_length / majsize;
/* Now figure out if we should put the dim down by one. Because of the
* way we parse thestrchr, we figure that if the value is complex
* way we parse the strchr, we figure that if the value is complex
* (e.g, "[1,2]"), the guy meant a range. This is sort of bad though.
*/
if (isreal(ind)) {

View File

@ -441,7 +441,7 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind)
return (OK);
}
int
OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
@ -580,37 +580,31 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
blt_lockvec(i);
#endif
if (run->data[i].outIndex == -1) {
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i],
refValue->rValue);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i],
refValue->cValue);
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i], refValue->rValue);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i], refValue->cValue);
} else if (run->data[i].regular) {
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i],
valuePtr->v.vec.rVec
[run->data[i].outIndex]);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i],
valuePtr->v.vec.cVec
[run->data[i].outIndex]);
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i],
valuePtr->v.vec.rVec[run->data[i].outIndex]);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i],
valuePtr->v.vec.cVec[run->data[i].outIndex]);
} else {
/* should pre-check instance */
if (!getSpecial(&run->data[i], run, &val))
continue;
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i],
val.rValue);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i],
val.cValue);
else
fprintf(stderr, "OUTpData: unsupported data type\n");
/* should pre-check instance */
if (!getSpecial(&run->data[i], run, &val))
continue;
if (run->data[i].type == IF_REAL)
plotAddRealValue(&run->data[i], val.rValue);
else if (run->data[i].type == IF_COMPLEX)
plotAddComplexValue(&run->data[i], val.cValue);
else
fprintf(stderr, "OUTpData: unsupported data type\n");
}
#ifdef TCL_MODULE
/*relinks and unlocks vector*/
blt_relink(i,(run->data[i]).vec);
/*relinks and unlocks vector*/
blt_relink(i,(run->data[i]).vec);
#endif
}
gr_iplot(run->runPlot);
@ -627,7 +621,6 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -649,7 +642,7 @@ OUTwEnd(void *plotPtr)
return (OK);
}
int
OUTendPlot(void *plotPtr)
@ -672,7 +665,7 @@ OUTendPlot(void *plotPtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -688,7 +681,7 @@ OUTendDomain(void *plotPtr)
return (OK);
}
/* ARGSUSED */ /* until some code gets written */
int
@ -727,7 +720,7 @@ OUTattributes(void *plotPtr, char *varName, int param, IFvalue *value)
return (OK);
}
/* The file writing routines. */
@ -794,10 +787,12 @@ fileInit_pass2(runDesc *run)
type = SV_TIME;
else if (cieq(name, "frequency"))
type = SV_FREQUENCY;
else if (cieq(name, "temp-sweep")) /* Added by H.T */
else if (cieq(name, "temp-sweep"))
type = SV_TEMP;
else if (cieq(name, "res-sweep")) /* Added by H.T */
else if (cieq(name, "res-sweep"))
type = SV_RES;
else if ((*name == '@') && (substring("[g", name)))
type = SV_ADMITTANCE;
else
type = SV_VOLTAGE;
@ -911,7 +906,7 @@ fileEnd(runDesc *run)
return;
}
/* The plot maintenance routines. */
@ -953,10 +948,12 @@ plotInit(runDesc *run)
v->v_type = SV_TIME;
else if (cieq(v->v_name, "frequency"))
v->v_type = SV_FREQUENCY;
else if (cieq(v->v_name, "temp-sweep")) /* Added by H.T */
else if (cieq(v->v_name, "temp-sweep"))
v->v_type = SV_TEMP;
else if (cieq(v->v_name, "res-sweep")) /* Added by H.T */
else if (cieq(v->v_name, "res-sweep"))
v->v_type = SV_RES;
else if ((*(v->v_name) == '@') && (substring("[g", v->v_name)))
v->v_type = SV_ADMITTANCE;
else
v->v_type = SV_VOLTAGE;
v->v_length = 0;
@ -1022,7 +1019,7 @@ plotEnd(runDesc *run)
return;
}
/* ParseSpecial takes something of the form "@name[param,index]" and rips
* out name, param, andstrchr.

View File

@ -112,8 +112,12 @@
#ifndef SIGNAL_FUNCTION
#if defined(_MSC_VER)
# define SIGNAL_FUNCTION RETSIGTYPE (*)(int)
#else
# define SIGNAL_FUNCTION RETSIGTYPE (*)( )
#endif
#endif
#define BSIZE_SP 512

View File

@ -1,4 +1,4 @@
#ifndef _SIM_H
#ifndef _SIM_H
#define _SIM_H
enum simulation_types {
@ -17,7 +17,7 @@ enum simulation_types {
SV_TEMP,
SV_RES,
SV_IMPEDANCE, //Añadido por A.Roldán
SV_ADMITANCE, //Añadido por A.Roldán
SV_ADMITTANCE, //Añadido por A.Roldán
SV_POWER //Añadido por A.Roldán
};