update on B source pwl handling
This commit is contained in:
parent
1fe8cbbf26
commit
92abb04185
|
|
@ -1,3 +1,6 @@
|
||||||
|
2010-05-27 Holger Vogt
|
||||||
|
* inpcom.c: update B source pwl function handling
|
||||||
|
|
||||||
2010-05-26 Holger Vogt
|
2010-05-26 Holger Vogt
|
||||||
* xspice api update: cmcm_analog_alloc() and cm_event_alloc()
|
* xspice api update: cmcm_analog_alloc() and cm_event_alloc()
|
||||||
ng-spice-rework/src/include/cmproto.h
|
ng-spice-rework/src/include/cmproto.h
|
||||||
|
|
|
||||||
|
|
@ -3451,8 +3451,19 @@ inp_split_multi_param_lines( struct line *deck, int line_num )
|
||||||
return line_num;
|
return line_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pspice compatibility:
|
||||||
|
ECOMP 3 0 TABLE {V(1,2)} = (-1MV 0V) (1MV, 10V)
|
||||||
|
-->
|
||||||
|
ECOMP 3 0 int3 int0 1
|
||||||
|
BECOMP int3 int0 V = pwl(V(1,2), -1MV, 0 , 1MV, 10V)
|
||||||
|
|
||||||
/* compatibility:
|
GD16 16 1 TABLE {V(16,1)} ((-100V,-1pV)(0,0)(1m,1u)(2m,1m))
|
||||||
|
-->
|
||||||
|
GD16 16 1 int_16 int_1 1
|
||||||
|
BGD16 int_16 int_1 V = pwl (v(16,1) , -100V , -1pV , 0 , 0 , 1m , 1u , 2m , 1m )
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* hspice compatibility:
|
||||||
Exxx n1 n2 VCVS n3 n4 gain --> Exxx n1 n2 n3 n4 gain
|
Exxx n1 n2 VCVS n3 n4 gain --> Exxx n1 n2 n3 n4 gain
|
||||||
Gxxx n1 n2 VCCS n3 n4 tr --> Exxx n1 n2 n3 n4 tr
|
Gxxx n1 n2 VCCS n3 n4 tr --> Exxx n1 n2 n3 n4 tr
|
||||||
|
|
||||||
|
|
@ -3841,9 +3852,12 @@ static void inp_bsource_compat(struct line *deck)
|
||||||
char actchar, prevchar = ' ';
|
char actchar, prevchar = ' ';
|
||||||
struct line *card, *new_line, *tmp_ptr;
|
struct line *card, *new_line, *tmp_ptr;
|
||||||
wordlist *wl = NULL, *wlist = NULL, *cwl;
|
wordlist *wl = NULL, *wlist = NULL, *cwl;
|
||||||
char buf[512];
|
char buf[512], pwl_buf[512];
|
||||||
size_t i, xlen, ustate = 0;
|
size_t i, xlen, ustate = 0;
|
||||||
int skip_control = 0;
|
int skip_control = 0;
|
||||||
|
char *cvalue;
|
||||||
|
double dvalue;
|
||||||
|
int error1;
|
||||||
|
|
||||||
for (card = deck; card; card = card->li_next) {
|
for (card = deck; card; card = card->li_next) {
|
||||||
|
|
||||||
|
|
@ -3861,6 +3875,9 @@ static void inp_bsource_compat(struct line *deck)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *curr_line == 'b' ) {
|
if ( *curr_line == 'b' ) {
|
||||||
|
/* remove white spaces of everything inside {}*/
|
||||||
|
card->li_line = inp_remove_ws(card->li_line);
|
||||||
|
curr_line = card->li_line;
|
||||||
/* store starting point for later parsing, beginning of {expression} */
|
/* store starting point for later parsing, beginning of {expression} */
|
||||||
equal_ptr = strstr(curr_line, "=");
|
equal_ptr = strstr(curr_line, "=");
|
||||||
/* find the m={m} token and remove it */
|
/* find the m={m} token and remove it */
|
||||||
|
|
@ -3962,11 +3979,66 @@ static void inp_bsource_compat(struct line *deck)
|
||||||
str_ptr++;
|
str_ptr++;
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
/* no parens {} around time, hertz, temper and the constants
|
/* no parens {} around time, hertz, temper, the constants
|
||||||
pi and e which are defined in inpptree.c */
|
pi and e which are defined in inpptree.c and around pwl */
|
||||||
if ((*str_ptr == '(') || cieq(buf, "hertz") || cieq(buf, "temper")
|
if ((*str_ptr == '(') || cieq(buf, "hertz") || cieq(buf, "temper")
|
||||||
|| cieq(buf, "time") || cieq(buf, "pi") || cieq(buf, "e"))
|
|| cieq(buf, "time") || cieq(buf, "pi") || cieq(buf, "e")
|
||||||
|
|| cieq(buf, "pwl"))
|
||||||
{
|
{
|
||||||
|
/* special handling of pwl lines:
|
||||||
|
Put braces around tokens and around expressions, use ','
|
||||||
|
as separator like:
|
||||||
|
pwl(i(Vin), {x0-1},{y0},
|
||||||
|
{x0},{y0},{x1},{y1}, {x2},{y2},{x3},{y3},
|
||||||
|
{x3+1},{y3})
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if (cieq(buf, "pwl")) {
|
||||||
|
// go past i(Vin)
|
||||||
|
i = 3;
|
||||||
|
while (*str_ptr != ')') {
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
}
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
// find first ','
|
||||||
|
while (*str_ptr != ',') {
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
}
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
buf[i] = '{';
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
while (*str_ptr != ')') {
|
||||||
|
if (*str_ptr == ',') {
|
||||||
|
buf[i] = '}';
|
||||||
|
i++;
|
||||||
|
buf[i] = ',';
|
||||||
|
i++;
|
||||||
|
buf[i] = '{';
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
str_ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf[i] = '}';
|
||||||
|
i++;
|
||||||
|
buf[i] = *str_ptr;
|
||||||
|
i++;
|
||||||
|
buf[i] = '\0';
|
||||||
|
str_ptr++;
|
||||||
|
}
|
||||||
|
*/
|
||||||
cwl->wl_word = copy(buf);
|
cwl->wl_word = copy(buf);
|
||||||
}
|
}
|
||||||
/* {} around all other tokens */
|
/* {} around all other tokens */
|
||||||
|
|
@ -3981,23 +4053,15 @@ static void inp_bsource_compat(struct line *deck)
|
||||||
}
|
}
|
||||||
else if (isdigit(actchar))
|
else if (isdigit(actchar))
|
||||||
{
|
{
|
||||||
|
/* allow 100p, 5MEG etc. */
|
||||||
|
dvalue = INPevaluate(&str_ptr, &error1, 1);
|
||||||
|
cvalue = tmalloc(19);
|
||||||
|
sprintf(cvalue,"%18.10e", dvalue);
|
||||||
/* unary -, change sign */
|
/* unary -, change sign */
|
||||||
if (ustate == 2) {
|
if (ustate == 2) {
|
||||||
i = 1;
|
cvalue[0] = '-';
|
||||||
buf[0] = '-';
|
|
||||||
}
|
}
|
||||||
else i = 0;
|
cwl->wl_word = copy(cvalue);
|
||||||
while (isdigit(*str_ptr) || (*str_ptr == '.') || (*str_ptr == 'e')
|
|
||||||
|| (*str_ptr == '+')|| (*str_ptr == '-'))
|
|
||||||
{
|
|
||||||
if (((*str_ptr == '+')|| (*str_ptr == '-')) && (*(str_ptr-1) != 'e'))
|
|
||||||
break;
|
|
||||||
buf[i] = *str_ptr;
|
|
||||||
i++;
|
|
||||||
str_ptr++;
|
|
||||||
}
|
|
||||||
buf[i] = '\0';
|
|
||||||
cwl->wl_word = copy(buf);
|
|
||||||
ustate = 0; /* we have a number */
|
ustate = 0; /* we have a number */
|
||||||
}
|
}
|
||||||
else /* strange char */
|
else /* strange char */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue