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

📄 pp_lst.c

📁 支持数字元件仿真的SPICE插件
💻 C
📖 第 1 页 / 共 3 页
字号:
        sprintf(msg, "WARNING - File not found: %s", filename);        print_error(msg);        return(OK);    }    /* Read the pathnames from the file, one line at a time until EOF */    n = 0;    line_num = 0;    while( fgets(path, sizeof(path), fp) ) {        line_num++;        len = strlen(path);        /* If line was too long for buffer, exit with error */        if(len > MAX_PATH_LEN) {            sprintf(msg, "ERROR - Line %d of %s exceeds %d characters",                    line_num, filename, MAX_PATH_LEN);            print_error(msg);            return(ERROR);        }        /* Strip white space including newline */        for(i = 0, j = 0; i < len; ) {            if(isspace(path[i])) {                i++;            }            else {                path[j] = path[i];                i++;                j++;            }        }        path[j] = '\0';        len = j;        /* Strip trailing '/' if any */        if(path[len - 1] == '/')            path[--len] = '\0';        /* If blank line, continue */        if(len == 0)            continue;        /* Make sure pathname is short enough to add a filename at the end */        if(len > (MAX_PATH_LEN - (MAX_FN_LEN + 1)) ) {            sprintf(msg, "ERROR - Pathname on line %d of %s exceeds %d characters",                    line_num, filename, (MAX_PATH_LEN - (MAX_FN_LEN + 1)));            print_error(msg);            return(ERROR);        }        /* Allocate and initialize a new node info structure */        if(n == 0)            node = (void *) malloc(sizeof(Node_Info_t));        else            node = (void *) realloc(node, (n + 1) * sizeof(Node_Info_t));        node[n].path_name = NULL;        node[n].node_name = NULL;        node[n].unique = TRUE;        /* Put pathname into info structure */        node[n].path_name = malloc(len);        strcpy(node[n].path_name, path);        /* Increment count of paths read */        n++;    }    /* Close node pathname file and return data read */    fclose(fp);    *num_nodes = n;    *node_info = node;    return(OK);}/* *********************************************************************** *//*read_model_namesThis function opens each of the models and gets the names of the modeland the C function into the internal model information structure.*/static Status_t read_model_names(    int            num_models,  /* Number of model pathnames */    Model_Info_t   *model_info  /* Info about each model */){    Boolean_t   all_found;               /* True if all ifspec files read */    int         i;                       /* A temporary counter */    char        msg[MAX_PATH_LEN+257];   /* space for an error message */    char        path[MAX_PATH_LEN+1];    /* full pathname to ifspec file */    Status_t    status;                  /* Return status */    Ifs_Table_t ifs_table;   /* Repository for info read from ifspec file */    /* For each model found in model pathname file, read the interface */    /* spec file to get the SPICE and C function names into model_info */    for(i = 0, all_found = TRUE; i < num_models; i++) {        /* Form the full pathname to the interface spec file */        strcpy(path, model_info[i].path_name);        strcat(path, "/");        strcat(path, IFSPEC_FILENAME);        /* Read the SPICE and C function names from the interface spec file */        status = read_ifs_file(path, GET_IFS_NAME, &ifs_table);        /* Transfer the names into the model_info structure */        if(status == OK) {            model_info[i].spice_name = ifs_table.name.model_name;            model_info[i].cfunc_name = ifs_table.name.c_fcn_name;        }        else {            all_found = FALSE;            sprintf(msg, "ERROR - Problems reading %s in directory %s",                    IFSPEC_FILENAME, model_info[i].path_name);            print_error(msg);        }    }    if(all_found)        return(OK);    else        return(ERROR);}/* *********************************************************************** *//*read_node_namesThis function opens each of the user-defined node definition filesand gets the names of the node into the internal information structure.*/static Status_t read_node_names(    int           num_nodes,  /* Number of node pathnames */    Node_Info_t   *node_info  /* Info about each node */){    Boolean_t   all_found;               /* True if all files read OK */    int         i;                       /* A temporary counter */    char        msg[MAX_PATH_LEN+257];   /* space for an error message */    char        path[MAX_PATH_LEN+1];    /* full pathname to file */    Status_t    status;                  /* Return status */    char        *node_name;              /* Name of node type read from file */    /* For each node found in node pathname file, read the udnfunc.c */    /* file to get the node type names into node_info */    for(i = 0, all_found = TRUE; i < num_nodes; i++) {        /* Form the full pathname to the interface spec file */        strcpy(path, node_info[i].path_name);        strcat(path, "/");        strcat(path, UDNFUNC_FILENAME);        /* Read the udn node type name from the file */        status = read_udn_type_name(path, &node_name);        /* Transfer the names into the node_info structure */        if(status == OK) {            node_info[i].node_name = node_name;        }        else {            all_found = FALSE;            sprintf(msg, "ERROR - Problems reading %s in directory %s",                    UDNFUNC_FILENAME, node_info[i].path_name);            print_error(msg);        }    }    if(all_found)        return(OK);    else        return(ERROR);}/* *********************************************************************** *//*check_uniquenessFunction check_uniqueness determines if model names and functionnames are unique with respect to each other and to the models andfunctions internal to SPICE 3C1.*/static Status_t check_uniqueness(    int            num_models,  /* Number of model pathnames */    Model_Info_t   *model_info, /* Info about each model */    int            num_nodes,   /* Number of node type pathnames */    Node_Info_t    *node_info   /* Info about each node type */){    int         i;                       /* A temporary counter */    int         j;                       /* A temporary counter */    char        msg[MAX_PATH_LEN+257];   /* space for an error message */    Boolean_t   all_unique;              /* true if names are unique */    /* Define a list of model names used internally by XSPICE */    /* These names (except 'poly') are defined in src/sim/INP/INPdomodel.c and */    /* are case insensitive */    static char *SPICEmodel[] = { "npn",                                  "pnp",                                  "d",                                  "njf",                                  "pjf",                                  "nmf",                                  "pmf",                                  "urc",                                  "nmos",                                  "pmos",                                  "r",                                  "c",                                  "sw",                                  "csw",                                  "poly" };    static int  numSPICEmodels = sizeof(SPICEmodel) / sizeof(char *);    /* Define a list of node type names used internally by the simulator */    /* These names are defined in src/sim/include/MIFtypes.h and are case */    /* insensitive */    static char *UDNidentifier[] = { "v",                                     "vd",                                     "i",                                     "id",                                     "vnam",                                     "g",                                     "gd",                                     "h",                                     "hd",                                     "d" };    static int  numUDNidentifiers = sizeof(UDNidentifier) / sizeof(char *);    /* First, normalize case of all model and node names to lower since */    /* SPICE is case insensitive in parsing decks */    for(i = 0; i < num_models; i++)        str_to_lower(model_info[i].spice_name);    for(i = 0; i < num_nodes; i++)        str_to_lower(node_info[i].node_name);    /* Then, loop through all model names and report errors if same as SPICE */    /* model name or same as another model name in list */    for(i = 0, all_unique = TRUE; i < num_models; i++) {        /* First check against list of SPICE internal names */        for(j = 0; j < numSPICEmodels; j++) {            if(strcmp(model_info[i].spice_name, SPICEmodel[j]) == 0) {                all_unique = FALSE;                sprintf(msg,                        "ERROR - Model name '%s' is same as internal SPICE model name\n",                        model_info[i].spice_name);                print_error(msg);            }        }        /* Skip if already seen once */        if(model_info[i].spice_unique == FALSE)            continue;        /* Then check against other names in list */        for(j = 0; j < num_models; j++) {            /* Skip checking against itself */            if(i == j)                continue;            /* Compare the names */            if(strcmp(model_info[i].spice_name, model_info[j].spice_name) == 0) {                all_unique = FALSE;                model_info[i].spice_unique = FALSE;                model_info[j].spice_unique = FALSE;                sprintf(msg,                        "ERROR - Model name '%s' in directory: %s",                        model_info[i].spice_name,                        model_info[i].path_name);                print_error(msg);                print_error("        is same as");                sprintf(msg,                        "        model name '%s' in directory: %s\n",                        model_info[j].spice_name,                        model_info[j].path_name);                print_error(msg);            }        }    }    /* Loop through all C function names and report errors if duplicates found */    for(i = 0; i < num_models; i++) {        /* Skip if already seen once */        if(model_info[i].cfunc_unique == FALSE)            continue;        /* Check against other names in list only, not against SPICE identifiers */        /* Let linker catch collisions with SPICE identifiers for now */        for(j = 0; j < num_models; j++) {            /* Skip checking against itself */            if(i == j)                continue;            /* Compare the names */            if(strcmp(model_info[i].cfunc_name, model_info[j].cfunc_name) == 0) {                all_unique = FALSE;                model_info[i].cfunc_unique = FALSE;                model_info[j].cfunc_unique = FALSE;                sprintf(msg,                        "ERROR - C function name '%s' in directory: %s",                        model_info[i].cfunc_name,                        model_info[i].path_name);                print_error(msg);                print_error("        is same as");                sprintf(msg,                        "        C function name '%s' in directory: %s\n",                        model_info[j].cfunc_name,                        model_info[j].path_name);                print_error(msg);            }        }    }    /* Loop through all node type names and report errors if same as internal */    /* name or same as another name in list */    for(i = 0; i < num_nodes; i++) {        /* First check against list of internal names */        for(j = 0; j < numUDNidentifiers; j++) {            if(strcmp(node_info[i].node_name, UDNidentifier[j]) == 0) {                all_unique = FALSE;                sprintf(msg,                        "ERROR - Node type '%s' is same as internal node type\n",                        node_info[i].node_name);                print_error(msg);            }        }

⌨️ 快捷键说明

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