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

📄 writ_ifs.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 3 页
字号:
    fprintf(fp, "};\n");    fprintf(fp, "\n");}/* *********************************************************************** *//*write_conn_infoFunction write_conn_info writes information used by theSimulator's new MIF package to interpret and error check amodel's connection list in a SPICE deck.  This information isderived from the Interface Specification file's PORT table.*/static void  write_conn_info(    FILE        *fp,          /* File to write to */    Ifs_Table_t *ifs_table)   /* Table of Interface Specification data */{    int             i;    int             j;    char            *str;    /* Only write the connTable if there is something to put in it.      */    /* Otherwise, we will put NULL in the SPICEdev structure in its slot */    if(ifs_table->num_conn == 0)  /* An unlikely condition for sure ... */        return;    /* First, we must define arrays of port types */    /* Note that there should be always at least one allowed port type */    /* so we don't have to worry about arrays with no elements         */    for(i = 0; i < ifs_table->num_conn; i++) {        fprintf(fp, "\n");        fprintf(fp, "static Mif_Port_Type_t MIFportEnum%d[] = {\n", i);        if(ifs_table->conn[i].num_allowed_types < 1)            print_error("ERROR - write_conn_info() - Number of allowed types cannot be zero");        for(j = 0; j < ifs_table->conn[i].num_allowed_types; j++) {            str = port_type_to_str(ifs_table->conn[i].allowed_port_type[j]);            fprintf(fp, "\t%s,\n", str);        }  /* for number of allowed types */        fprintf(fp, "};\n");        fprintf(fp, "\n");        fprintf(fp, "\n");        fprintf(fp, "static char *MIFportStr%d[] = {\n", i);        for(j = 0; j < ifs_table->conn[i].num_allowed_types; j++) {            if(ifs_table->conn[i].allowed_port_type[j] == USER_DEFINED)                fprintf(fp, "\t\"%s\",\n", ifs_table->conn[i].allowed_type[j]);            else {                str = gen_port_type_str(ifs_table->conn[i].allowed_port_type[j]);                fprintf(fp, "\t\"%s\",\n", str);            }        }  /* for number of allowed types */        fprintf(fp, "};\n");        fprintf(fp, "\n");    }  /* for number of connections */    /* Now write the structure */    fprintf(fp, "\n");    fprintf(fp, "static Mif_Conn_Info_t MIFconnTable[] = {\n");    /* Write out an entry for each parameter in the table               */    for(i = 0; i < ifs_table->num_conn; i++) {        fprintf(fp, "  {\n");        fprintf(fp, "    \"%s\",\n",ifs_table->conn[i].name);        fprintf(fp, "    \"%s\",\n",ifs_table->conn[i].description);        str = dir_to_str(ifs_table->conn[i].direction);        fprintf(fp, "    %s,\n", str);        str = port_type_to_str(ifs_table->conn[i].default_port_type);        fprintf(fp, "    %s,\n", str);        fprintf(fp, "    \"%s\",\n",		(ifs_table->conn[i].default_port_type == USER_DEFINED)		? ifs_table->conn[i].default_type		: gen_port_type_str (ifs_table->conn[i].default_port_type));        fprintf(fp,"    %d,\n",ifs_table->conn[i].num_allowed_types);	        fprintf(fp, "    MIFportEnum%d,\n", i);        fprintf(fp, "    MIFportStr%d,\n", i);        str = boolean_to_str(ifs_table->conn[i].is_array);        fprintf(fp, "    %s,\n", str);        if(ifs_table->conn[i].is_array == FALSE) {            str = boolean_to_str(FALSE);    /* has_lower_bound */            fprintf(fp, "    %s,\n", str);            str = integer_to_str(0);        /* lower_bound */            fprintf(fp, "    %s,\n", str);            str = boolean_to_str(FALSE);    /* has_upper_bound */            fprintf(fp, "    %s,\n", str);            str = integer_to_str(0);        /* upper_bound */            fprintf(fp, "    %s,\n", str);        }        else {  /* is_array == TRUE */            str = boolean_to_str(ifs_table->conn[i].has_lower_bound);            fprintf(fp, "    %s,\n", str);            if(ifs_table->conn[i].has_lower_bound == TRUE)                str = integer_to_str(ifs_table->conn[i].lower_bound);            else                str = integer_to_str(0);            fprintf(fp, "    %s,\n", str);            str = boolean_to_str(ifs_table->conn[i].has_upper_bound);            fprintf(fp, "    %s,\n", str);            if(ifs_table->conn[i].has_upper_bound == TRUE)                str = integer_to_str(ifs_table->conn[i].upper_bound);            else                str = integer_to_str(0);            fprintf(fp, "    %s,\n", str);        }  /* if is_array */            str = boolean_to_str(ifs_table->conn[i].null_allowed);        fprintf(fp, "    %s,\n", str);        fprintf(fp, "  },\n");    } /* for number of parameters */    /* Finish off the structure */    fprintf(fp, "};\n");    fprintf(fp, "\n");}/* *********************************************************************** *//*write_param_infoFunction write_param_info writes information used by theSimulator's new MIF package to interpret and error check amodel's parameter list in an XSPICE deck.  This information isderived from the Interface Specification file's PARAMETER table. It is essentially a superset of the IFparm information written bywrite_mPTable().  The IFparm information written bywrite_mPTable() is required to work with SPICE's device set andquery functions.  The information written by write_param_info ismore extensive and is required to parse and error check the XSPICEinput deck.*/static void  write_param_info(    FILE        *fp,           /* File to write to */    Ifs_Table_t *ifs_table)    /* Table of Interface Specification data */{    int             i;    char            *str;    /* Only write the paramTable if there is something to put in it.      */    /* Otherwise, we will put NULL in the SPICEdev structure in its slot */    if(ifs_table->num_param == 0)        return;    /* Write the structure beginning */    fprintf(fp, "\n");    fprintf(fp, "static Mif_Param_Info_t MIFparamTable[] = {\n");    /* Write out an entry for each parameter in the table               */    for(i = 0; i < ifs_table->num_param; i++) {        fprintf(fp, "  {\n");        fprintf(fp, "    \"%s\",\n",ifs_table->param[i].name);        fprintf(fp, "    \"%s\",\n",ifs_table->param[i].description);        str = data_type_to_str(ifs_table->param[i].type);        fprintf(fp, "    %s,\n", str);        str = boolean_to_str(ifs_table->param[i].has_default);        fprintf(fp, "    %s,\n", str);        if(ifs_table->param[i].has_default == TRUE)            str = value_to_str(ifs_table->param[i].type, ifs_table->param[i].default_value);        else            str = no_value_to_str();        fprintf(fp, "    %s,\n", str);        str = boolean_to_str(ifs_table->param[i].has_lower_limit);        fprintf(fp, "    %s,\n", str);        if(ifs_table->param[i].has_lower_limit == TRUE)            str = value_to_str(ifs_table->param[i].type, ifs_table->param[i].lower_limit);        else            str = no_value_to_str();        fprintf(fp, "    %s,\n", str);        str = boolean_to_str(ifs_table->param[i].has_upper_limit);        fprintf(fp, "    %s,\n", str);        if(ifs_table->param[i].has_upper_limit == TRUE)            str = value_to_str(ifs_table->param[i].type, ifs_table->param[i].upper_limit);        else            str = no_value_to_str();        fprintf(fp, "    %s,\n", str);        str = boolean_to_str(ifs_table->param[i].is_array);        fprintf(fp, "    %s,\n", str);        if(ifs_table->param[i].is_array == FALSE) {            str = boolean_to_str(FALSE);    /* has_conn_ref */            fprintf(fp, "    %s,\n", str);            str = integer_to_str(0);        /* conn_ref */            fprintf(fp, "    %s,\n", str);            str = boolean_to_str(FALSE);    /* has_lower_bound */            fprintf(fp, "    %s,\n", str);            str = integer_to_str(0);        /* lower_bound */            fprintf(fp, "    %s,\n", str);            str = boolean_to_str(FALSE);    /* has_upper_bound */            fprintf(fp, "    %s,\n", str);            str = integer_to_str(0);        /* upper_bound */            fprintf(fp, "    %s,\n", str);        }        else {  /* is_array == TRUE */            str = boolean_to_str(ifs_table->param[i].has_conn_ref);            fprintf(fp, "    %s,\n", str);            if(ifs_table->param[i].has_conn_ref == TRUE) {                str = integer_to_str(ifs_table->param[i].conn_ref);                fprintf(fp, "    %s,\n", str);                str = boolean_to_str(FALSE);    /* has_lower_bound */                fprintf(fp, "    %s,\n", str);                str = integer_to_str(0);        /* lower_bound */                fprintf(fp, "    %s,\n", str);                str = boolean_to_str(FALSE);    /* has_upper_bound */                fprintf(fp, "    %s,\n", str);                str = integer_to_str(0);        /* upper_bound */                fprintf(fp, "    %s,\n", str);            }            else {  /* has_conn_ref == FALSE */                str = integer_to_str(0);        /* conn_ref */                fprintf(fp, "    %s,\n", str);                str = boolean_to_str(ifs_table->param[i].has_lower_bound);                fprintf(fp, "    %s,\n", str);                if(ifs_table->param[i].has_lower_bound == TRUE)                    str = integer_to_str(ifs_table->param[i].lower_bound);                else                    str = integer_to_str(0);                fprintf(fp, "    %s,\n", str);                str = boolean_to_str(ifs_table->param[i].has_upper_bound);                fprintf(fp, "    %s,\n", str);                if(ifs_table->param[i].has_upper_bound == TRUE)                    str = integer_to_str(ifs_table->param[i].upper_bound);                else                    str = integer_to_str(0);                fprintf(fp, "    %s,\n", str);            }  /* if has_conn_ref */        }  /* if is_array */            str = boolean_to_str(ifs_table->param[i].null_allowed);        fprintf(fp, "    %s,\n", str);        fprintf(fp, "  },\n");    } /* for number of parameters */    /* Finish off the structure */    fprintf(fp, "};\n");    fprintf(fp, "\n");}/* *********************************************************************** *//*write_inst_var_infoFunction write_inst_var_info writes information used by theSimulator's new MIF package to allocate space for and to output(using SPICE's .save feature) variables defined in the InterfaceSpecification file's STATIC_VAR table.  It is essentially asuperset of the IFparm information written by write_mPTable(). The IFparm information written by write_pTable() is required towork with SPICE's device query functions.  The informationwritten by write_inst_var_info is more extensive.*/static void  write_inst_var_info(    FILE        *fp,         /* File to write to */    Ifs_Table_t *ifs_table)  /* Table of Interface Specification data */{    int             i;    char            *str;    /* Only write the inst_varTable if there is something to put in it.  */    /* Otherwise, we will put NULL in the SPICEdev structure in its slot */    if(ifs_table->num_inst_var == 0)        return;    /* Write the structure beginning */    fprintf(fp, "\n");    fprintf(fp, "static Mif_Inst_Var_Info_t MIFinst_varTable[] = {\n");    /* Write out an entry for each parameter in the table               */    for(i = 0; i < ifs_table->num_inst_var; i++) {        fprintf(fp, "  {\n");        fprintf(fp, "    \"%s\",\n",ifs_table->inst_var[i].name);        fprintf(fp, "    \"%s\",\n",ifs_table->inst_var[i].description);        str = data_type_to_str(ifs_table->inst_var[i].type);        fprintf(fp, "    %s,\n", str);        str = boolean_to_str(ifs_table->inst_var[i].is_array);        fprintf(fp, "    %s,\n", str);        fprintf(fp, "  },\n");    } /* for number of parameters */    /* Finish off the structure */    fprintf(fp, "};\n");    fprintf(fp, "\n");}/* *********************************************************************** *//*write_SPICEdevFunction write_SPICEdev writes the global XXX_info structure usedby SPICE to define a model.  Here ``XXX'' is the name of the codemodel.  This structure contains the name of themodel, a pointer to the C function that implements the model, andpointers to all of the above data structures.*/static void  write_SPICEdev(    FILE        *fp,         /* File to write to */    Ifs_Table_t *ifs_table)  /* Table of Interface Specification data */{	    /* Extern the code model function name */    fprintf(fp, "\n");    fprintf(fp, "extern void %s(Mif_Private_t *);\n",                 ifs_table->name.c_fcn_name);	/* SPICE now needs these static integers */	fprintf(fp, "\n");	fprintf(fp, "static int val_terms             = 0;\n");	fprintf(fp, "static int val_numNames          = 0;\n");	fprintf(fp, "static int val_numInstanceParms  = %d;\n",ifs_table->num_inst_var);	fprintf(fp, "static int val_numModelParms     = %d;\n",ifs_table->num_param);	fprintf(fp, "static int val_sizeofMIFinstance = sizeof(MIFinstance);\n");

⌨️ 快捷键说明

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