From 98f7c6c9cd01bc597faf2c117c3603e67ce888cd Mon Sep 17 00:00:00 2001 From: pnenzi Date: Tue, 5 Aug 2003 15:32:25 +0000 Subject: [PATCH] *** empty log message *** --- src/xspice/Makefile.am | 2 +- src/xspice/mif/mif_inp2.c | 167 +++++++++++++++----------------------- src/xspice/mif/mifutil.c | 11 +-- 3 files changed, 70 insertions(+), 110 deletions(-) diff --git a/src/xspice/Makefile.am b/src/xspice/Makefile.am index 90ab4d779..975cbba93 100755 --- a/src/xspice/Makefile.am +++ b/src/xspice/Makefile.am @@ -9,7 +9,7 @@ EXTRA_DIST = README ## libs. It is currently compiled manually, last. ##SUBDIRS = mif cm enh evt ipc idn icm -SUBDIRS = mif cm enh evt ipc idn cmpp +SUBDIRS = mif cm enh evt ipc idn cmpp icm INCLUDES = -I$(top_srcdir)/src/include -I$(top_srcdir) diff --git a/src/xspice/mif/mif_inp2.c b/src/xspice/mif/mif_inp2.c index 55f6ac1d4..b85ef0947 100755 --- a/src/xspice/mif/mif_inp2.c +++ b/src/xspice/mif/mif_inp2.c @@ -188,7 +188,6 @@ card *current; /* the card we are to parse */ /* and return a pointer to its structure in 'thismodel' */ current->error = MIFgetMod(ckt, model, &thismodel, tab); - tfree(name); if(current->error) { return; @@ -196,8 +195,8 @@ card *current; /* the card we are to parse */ #ifdef TRACE /* SDB debug statement */ - printf("In MIF_INP2A, about to get ports on line %s\n", - current->line); + printf("In MIF_INP2A, after tokenizing, name = %s, model = %s\n", + name, model); #endif @@ -232,21 +231,20 @@ card *current; /* the card we are to parse */ /* and reading the first token following */ line = current->line; - MIFgettok(&line); /* read instance name again . . . .*/ + MIFgettok(&line); + next_token = MIFget_token(&line,&next_token_type); + + + /* loop through the fixed number of connections expected */ - /******* loop through the fixed number of connections expected *******/ for(i = 0; i < DEVices[type]->DEVpublic.num_conn; i++) { /* there better be at least one more token besides the model name */ if(*line == '\0') { - LITERR("Encountered end of line before all connections were found in model."); + LITERR("Missing connections on A device"); return; } - /* now get next token, should be a % after this statement */ - next_token = MIFget_token(&line,&next_token_type); - - /* prepare a pointer for fast access to info about this connection */ conn_info = &(DEVices[type]->DEVpublic.conn[i]); @@ -254,34 +252,6 @@ card *current; /* the card we are to parse */ def_port_type = conn_info->default_port_type; def_port_type_str = conn_info->default_type; - - /* Now get real info about connection type (instead of default info) */ - if(next_token_type == MIF_PERCENT_TOK) { /* next_token_type should be a % */ - - /* get the port type identifier and check it for validity */ - next_token = MIFget_token(&line,&next_token_type); - MIFget_port_type(ckt, - tab, - current, - &line, - &next_token, - &next_token_type, - &def_port_type, - &def_port_type_str, - conn_info, - &status); - if(status == MIF_ERROR) - return; - } - else { - LITERR("Non percent token encountered when expecting MIF_PERCENT_TOK"); - return; - } - - - /* At this point, next_token should hold the token *after* the port type - identified (%v, %id, etc). */ - /* set analog and event_driven flags on instance and model */ if((def_port_type == MIF_DIGITAL) || (def_port_type == MIF_USER_DEFINED)) { fast->event_driven = MIF_TRUE; @@ -292,8 +262,8 @@ card *current; /* the card we are to parse */ mdfast->analog = MIF_TRUE; } - /* check for a null connection and continue to next connection if found */ + if(next_token_type == MIF_NULL_TOK) { /* make sure null is allowed */ @@ -315,13 +285,10 @@ card *current; /* the card we are to parse */ fast->conn[i]->is_null = MIF_FALSE; } + /* process connection as appropriate for scalar or array */ - - /* ===== process connection as appropriate for scalar or array ====== */ if(! conn_info->is_array) { /* a scalar connection - the simpler case */ - /* At this point, next_token should hold the first netname in the port netlist. */ - /* do a couple of error checks */ if(next_token_type == MIF_LARRAY_TOK) { LITERR("ERROR - Scalar connection expected, [ found"); @@ -348,27 +315,44 @@ card *current; /* the card we are to parse */ 0, /* port index for scalar connection */ &status); - /* upon leaving MIFget_port, we should be *ready* to read a % with the next - get_token */ - if(status == MIF_ERROR) return; fast->conn[i]->size = 1; } - else { /* ====== the connection is an array - much to be done ... ====== */ + else { /* the connection is an array - much to be done ... */ - /* At this point, the next_token should be a [ */ + /* get the leading port type for the array if any */ + /* it will distribute across all ports inside the braces */ + /* overriding the default type in the interface spec */ + + if(next_token_type == MIF_PERCENT_TOK) { + + /* get the port type identifier and check it for validity */ + next_token = MIFget_token(&line,&next_token_type); + MIFget_port_type(ckt, + tab, + current, + &line, + &next_token, + &next_token_type, + &def_port_type, + &def_port_type_str, + conn_info, + &status); + if(status == MIF_ERROR) + return; + } /* check for required leading array delim character and eat it if found */ if(next_token_type != MIF_LARRAY_TOK) { LITERR("Missing [, an array connection was expected"); return; } - else /* eat the [ */ + else next_token = MIFget_token(&line,&next_token_type); - /*------ get and process ports until ] is encountered ------*/ + /* get and process ports until ] is encountered */ for(j = 0; (next_token_type != MIF_RARRAY_TOK) && @@ -402,24 +386,16 @@ card *current; /* the card we are to parse */ if(status == MIF_ERROR) return; - } /*------ end of for loop until ] is encountered ------*/ - - /* At this point, next_token should hold the next token after the - port netnames. This token should be a ]. */ + } /* make sure we exited because the end of the array connection */ - /* was reached. If so, eat the closing array delimiter ] */ + /* was reached. If so, eat the closing array delimiter */ if(*line == '\0') { LITERR("Missing ] in array connection"); return; } - - /* else { - * next_token = MIFget_token(&line,&next_token_type); - * } - */ - - /* At this point, the next time we get_token, we should get a % */ + else + next_token = MIFget_token(&line,&next_token_type); /* record the number of ports found for this connection */ if(j < 1) { @@ -428,13 +404,12 @@ card *current; /* the card we are to parse */ } fast->conn[i]->size = j; - } /* ====== array connection processing ====== */ + } /* array connection processing */ /* be careful about putting stuff here, there is a 'continue' used */ /* in the processing of NULL connections above */ - - } /******* for number of connections *******/ + } /* for number of connections */ /* *********************** */ @@ -443,12 +418,8 @@ card *current; /* the card we are to parse */ /* check for too many connections */ - /* At this point, we should have eaten all the net connections. At - this point, line should hold only the remainder of the model line (i.e. - the model name). */ - - if(strcmp(line,name) != 0) { - LITERR("Too many connections -- expecting model name but encountered other tokens."); + if(*line != '\0') { + LITERR("Too many connections"); return; } @@ -615,17 +586,7 @@ static void MIFinit_inst( /* MIFget_port_type -This function gets the port type identifier and checks it for validity. It also -replaces false default information in conn_info with the real info based upon -the discovered port type string. - -When we call it, we expect that the next token type (sent from above) -should be the port type (MIF_STRING_TOK type). That is, we should be sitting right -on the def of the port type (i.e. %vnam, %vd, %id, etc.) Note that the parser -should have stripped the % already. - -Upon return, this fcn should leave next_token holding the token *after* the -port type (i.e. the thing after vnam, v, vd, id, etc). +This function gets the port type identifier and checks it for validity. */ @@ -682,20 +643,8 @@ MIFget_port_type( LITERR("Port type is invalid"); *status = MIF_ERROR; } - else { - - /* Fix by SDB so that the netlist parser uses the actual nature - of the port instead of the default state to decide if it is an array. */ - if ( (*port_type == MIF_DIFF_VOLTAGE) || - (*port_type == MIF_DIFF_CURRENT) || - (*port_type == MIF_DIFF_CONDUCTANCE) || - (*port_type == MIF_DIFF_RESISTANCE) ) { - conn_info->is_array = 1; - } - + else *status = MIF_OK; - } - } @@ -709,13 +658,6 @@ MIFget_port This function processes a port being parsed, either single ended, or both connections of a differential. - -When we call this fcn, next_token should be the *first* netname in the port -net list. Depending upon the type of port, this fcn should eat the appropriate -number of net tokens. - -When we leave this fcn, next_token should hold the next token after the last -netname processed. */ @@ -745,6 +687,27 @@ MIFget_port( char *node; + /* get the leading port type if any */ + + if(*next_token_type == MIF_PERCENT_TOK) { + + /* get the port type identifier and check it for validity */ + *next_token = MIFget_token(line, next_token_type); + MIFget_port_type(ckt, + tab, + current, + line, + next_token, + next_token_type, + &def_port_type, + &def_port_type_str, + conn_info, + status); + + if(*status == MIF_ERROR) { + return; + } + } /* allocate space in the instance data struct for this port */ if(port_num == 0) { diff --git a/src/xspice/mif/mifutil.c b/src/xspice/mif/mifutil.c index 8e69a04e7..54540cc42 100755 --- a/src/xspice/mif/mifutil.c +++ b/src/xspice/mif/mifutil.c @@ -314,11 +314,8 @@ This function allocates a new copy of a string. char *MIFcopy(char *str) { - char *temp; - - /* Allocate space for the string and then copy it */ - temp = MALLOC(strlen(str) + 1); - strcpy(temp,str); - - return(temp); + if(str) + return copy(str); + else + return NULL; }