⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfunc.mod

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 MOD
📖 第 1 页 / 共 5 页
字号:
/* $Id: cfunc.mod,v 1.4 2005/08/23 08:21:01 pnenzi Exp $ *//*.......1.........2.........3.........4.........5.........6.........7.........8================================================================================FILE d_state/cfunc.modCopyright 1991Georgia Tech Research Corporation, Atlanta, Ga. 30332All Rights ReservedPROJECT A-8503-405               AUTHORS                          6 June 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sept 1991    Jeffrey P. Murray                                   SUMMARY    This file contains the model-specific routines used to    functionally describe the <model_name> code model.INTERFACES           FILE                 ROUTINE CALLED         CMmacros.h           cm_message_send();                                                    CMevt.c              void *cm_event_alloc()                         void *cm_event_get_ptr()                         REFERENCED FILES    Inputs from and outputs to ARGS structure.                     NON-STANDARD FEATURES    NONE===============================================================================*//*=== INCLUDE FILES ====================*/#include <stdio.h>#include <ctype.h>#include <math.h>#include <string.h>                                      /*=== CONSTANTS ========================*/#define MAX_STRING_SIZE 200                      #define HEADER 1#define CONTINUATION 2#define OK 0#define FAIL 1                                        /*=== MACROS ===========================*/  /*=== LOCAL VARIABLES & TYPEDEFS =======*/                         typedef struct {     int current_state,  /* current state of the machine (similar to                           current state of the union, current state                           of the economy, etc. etc. 8-)                */               index0,  /* actual word number (0 to depth-1) in which the                            first line of the current_state definition                           may be found.                                */               indexN,  /* word number (0 to depth-1) of the final curren_state                           definition line...if a state is defined in only one                           line, index0 and indexN will be equal.       */          num_outputs,  /* width of bits[] table...equal to size of                            out port                               */           num_inputs,  /* width of inputs[] table...equal to size of                            in port                                */                depth,  /* depth of table...equal to size of                           current_state & next_state arrays,                            and to the total number of vectors                            retrieved from the                           state.in file.                               */               *state,  /* integer array holding the state                           index values...note that each state will                           have at least one and as many as 2^N                           "words" assigned to it, where N = number                           of input lines to the state machine.         */          *next_state;  /* integer array holding the next state                           to jump to given the input values                           held by the inputs[] array...note that each                            state will have at least one and as many as 2^N                           "words" assigned to it, where N = number                           of input lines to the state machine.         */    short   *bits,  /* the storage array for the                        output bit representations...                       this will have size equal to                       (width * depth)/4, since one                       short will hold four 12-state                       bit descriptions.                */          *inputs;  /* the storage array for the                        input bit representations...                       this will have size equal to                       (width * depth)/8, since one                       short will hold eight 3-state                       bit descriptions.                */} State_Table_t;/* Type definition for each possible token returned. */typedef enum token_type_s {CNV_NO_TOK,CNV_STRING_TOK} Cnv_Token_Type_t;typedef char line_t[82]; /* A SPICE size line. <= 80 characters plus '\n\0' */               /*=== FUNCTION PROTOTYPE DEFINITIONS ===*/                                                         /*==============================================================================FUNCTION *CNVgettok()AUTHORS                          13 Jun 1991     Jeffrey P. MurrayMODIFICATIONS        8 Aug 1991     Jeffrey P. Murray    30 Sep 1991     Jeffrey P. MurraySUMMARY    This function obtains the next token from an input stream.INTERFACES           FILE                 ROUTINE CALLED         N/A                  N/ARETURNED VALUE        Returns a string value representing the next token.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*/#include <stdlib.h>/*=== Static CNVgettok ROUTINE ================*//*Get the next token from the input string.  The input string pointeris advanced to the following token and the token from the inputstring is copied to malloced storage and a pointer to that storageis returned.  The original input string is undisturbed.*/static char  *CNVgettok(char **s){    char    *buf;       /* temporary storage to copy token into */    /*char    *temp;*/      /* temporary storage to copy token into */    char    *ret_str;   /* storage for returned string */    int     i;    /* allocate space big enough for the whole string */    buf = (void *) malloc(strlen(*s) + 1);    /* skip over any white space */    while(isspace(**s) || (**s == '=') ||          (**s == '(') || (**s == ')') || (**s == ','))          (*s)++;    /* isolate the next token */    switch(**s) {    case '\0':           /* End of string found */        if(buf) free(buf);        return(NULL);    default:             /* Otherwise, we are dealing with a    */                         /* string representation of a number   */                         /* or a mess o' characters.            */        i = 0;        while( (**s != '\0') &&               (! ( isspace(**s) || (**s == '=') ||                     (**s == '(') || (**s == ')') ||                     (**s == ',')              ) )  ) {            buf[i] = **s;            i++;            (*s)++;        }        buf[i] = '\0';        break;    }    /* skip over white space up to next token */    while(isspace(**s) || (**s == '=') ||          (**s == '(') || (**s == ')') || (**s == ','))          (*s)++;    /* make a copy using only the space needed by the string length */    ret_str = (void *) malloc(strlen(buf) + 1);    ret_str = strcpy(ret_str,buf);    if(buf) free(buf);    return(ret_str);}/*==============================================================================FUNCTION *CNVget_token()AUTHORS                          13 Jun 1991     Jeffrey P. MurrayMODIFICATIONS        8 Aug 1991     Jeffrey P. Murray    30 Sep 1991     Jeffrey P. MurraySUMMARY    This function obtains the next token from an input stream.INTERFACES           FILE                 ROUTINE CALLED         N/A                  N/ARETURNED VALUE        Returns a string value representing the next token. Uses     *CNVget_tok.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== Static CNVget_token ROUTINE =============*//*Get the next token from the input string together with its type.The input string pointeris advanced to the following token and the token from the inputstring is copied to malloced storage and a pointer to that storageis returned.  The original input string is undisturbed.*/static char  *CNVget_token(char **s, Cnv_Token_Type_t *type){    char    *ret_str;   /* storage for returned string */    /* get the token from the input line */    ret_str = CNVgettok(s);    /* if no next token, return */    if(ret_str == NULL) {        *type = CNV_NO_TOK;        return(NULL);    }    /* else, determine and return token type */    switch(*ret_str) {    default:        *type = CNV_STRING_TOK;        break;    }    return(ret_str);}/*==============================================================================FUNCTION cnv_get_spice_value()AUTHORS                          ???             Bill KuhnMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    This function takes as input a string token from a SPICE    deck and returns a floating point equivalent value.INTERFACES           FILE                 ROUTINE CALLED         N/A                  N/ARETURNED VALUE        Returns the floating point value in pointer *p_value. Also    returns an integer representing successful completion.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== Static CNV_get_spice_value ROUTINE =============*//*   Function takes as input a string token from a SPICEdeck and returns a floating point equivalent value.*/static int cnv_get_spice_value(str,p_value)char    *str;        /* IN - The value text e.g. 1.2K */float   *p_value;    /* OUT - The numerical value     */{    /* the following were "int4" devices - jpm */    int    len;    int    i;    int    n_matched;    line_t  val_str;    /*char    *suffix;*/    char    c = ' ';    char    c1;    float   scale_factor;    float   value;    /* Scan the input string looking for an alpha character that is not  */    /* 'e' or 'E'.  Such a character is assumed to be an engineering     */    /* suffix as defined in the Spice 2G.6 user's manual.                */    len = strlen(str);    if( len > (sizeof(val_str) - 1))        len = sizeof(val_str) - 1;    for(i = 0; i < len; i++) {        c = str[i];        if( isalpha(c) && (c != 'E') && (c != 'e') )            break;        else if( isspace(c) )            break;        else            val_str[i] = c;    }    val_str[i] = '\0';    /* Determine the scale factor */    if( (i >= len) || (! isalpha(c)) )        scale_factor = 1.0;    else {        if(islower(c))            c = tolower(c);        switch(c) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -