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

📄 cfunc.mod

📁 支持数字元件仿真的SPICE插件
💻 MOD
📖 第 1 页 / 共 5 页
字号:
            c = tolower(c);        switch(c) {        case 't':            scale_factor = 1.0e12;            break;        case 'g':            scale_factor = 1.0e9;            break;        case 'k':            scale_factor = 1.0e3;            break;        case 'u':            scale_factor = 1.0e-6;            break;        case 'n':            scale_factor = 1.0e-9;            break;        case 'p':            scale_factor = 1.0e-12;            break;        case 'f':            scale_factor = 1.0e-15;            break;        case 'm':            i++;            if(i >= len) {                scale_factor = 1.0e-3;                break;            }            c1 = str[i];            if(! isalpha(c1)) {                scale_factor = 1.0e-3;                break;            }            if(islower(c1))                c1 = toupper(c1);            if(c1 == 'E')                scale_factor = 1.0e6;            else if(c1 == 'I')                scale_factor = 25.4e-6;            else                scale_factor = 1.0e-3;            break;        default:            scale_factor = 1.0;        }    }    /* Convert the numeric portion to a float and multiply by the */    /* scale factor.                                              */    n_matched = sscanf(val_str,"%e",&value);    if(n_matched < 1) {        *p_value = 0.0;        return(FAIL);    }    *p_value = value * scale_factor;    return(OK);}/*==============================================================================FUNCTION cm_inputs_mask_and_retrieve()AUTHORS                          23 Jul 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    Masks off and retrieves a two-bit value from a short    integer word passed to the function, using an offset value.     This effectively handles retrieval of eight two-bit values     from a single short integer space in order to conserve memory.INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns a Digital_t value.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*/             /*=== Static CM_INPUTS_MASK_AND_RETRIEVE ROUTINE ===*//***************************************************      The following routine masks and retrieves  **   the value passed to it by the out value       **   by masking the appropriate bits in the        **   base integer. The particular bit affected     **   is determined by the bit_offset value.        **                                                 **   Created 7/23/91               J.P.Murray      ***************************************************/static void cm_inputs_mask_and_retrieve(short base,int bit_offset,Digital_t *out){                                                                  short value;  /* the hexadecimal value of the masked bit  */    switch (bit_offset) {                                case 0:            break;    case 1:        base = base >> 2;        break;    case 2:        base = base >> 4;        break;    case 3:        base = base >> 6;        break;    case 4:            base = base >> 8;        break;    case 5:        base = base >> 10;        break;    case 6:        base = base >> 12;        break;    case 7:        base = base >> 14;        break;    }    value = 0x0003 & base;    switch (value) {    case 0: out->state = ZERO;            break;    case 1: out->state = ONE;            break;    case 2: out->state = UNKNOWN;            break;    }}/*==============================================================================FUNCTION cm_set_indices()AUTHORS                          23 Jul 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    The following routine retrieves the current_state value     from the *states structure. It then searches the entire          state[] array to determine the index0 and indexN values     corresponding to the first and last entries in the     state[] array for the current state.INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns a status int value.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== Static CM_SET_INDICES ROUTINE ===*//*************************************************      The following routine retrieves the      **   current_state value from the *states        **   structure. It then searches the entire      **   state[] array to determine the index0 and   **   indexN values corresponding to the first    **   and last entries in the state[] array for   **   the current state.                          *         *                                               * *   Created 7/23/91               J.P. Murray   *************************************************/static int cm_set_indices(State_Table_t *states){                 int         i,  /* indexing variable */       index0_set,  /* flag for index0   */       indexN_set;  /* flag for index1   */    states->index0 = 0;    states->indexN = 0;    index0_set = 0;    indexN_set = 0;    for (i=0; i< states->depth; i++) { /* loop through all states */        if ( states->state[i] == states->current_state ) {             /* states match... */            /* if not already set, set index0... */            if ( 0 == index0_set ) {                states->index0 = i;                states->indexN = i;                index0_set = 1;            }                                          if ( 1 < (i - states->indexN) ) {                 /* ERROR!! This means that a state match was                   found in a nonn-contiguous portion of the                   state.in file...this is not allowed! */                return TRUE;            }            else {                /* update indexN. */                states->indexN = i;             }        }    }     return FALSE;}                                    /*==============================================================================FUNCTION cm_compare_to_inputs()AUTHORS                          23 Jul 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    The following routine retrieves the          the inputs[] bit value pointed to by            the word_num and bit_num integers, compares     this value with the "in" state value, and       returns a "0" if they match, and a "1" if       they do not match.                          INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns a status int value.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== Static CM_COMPARE_TO_INPUTS ROUTINE ===*//*************************************************      The following routine retrieves the      **   the inputs[] bit value pointed to by        **   the word_num and bit_num integers, compares **   this value with the "in" state value, and   **   returns a "0" if they match, and a "1" if   **   they do not match.                          **                                               **   Created 7/23/91               J.P.Murray    *************************************************/static int cm_compare_to_inputs(State_Table_t *states,int index,int bit_number, Digital_State_t in){    int      int1,      /* temp storage variable    */        bit_index,      /* bits base address at which word bits will                           be found */       bit_offset;      /* offset from ram base address at which bit[0]                           of the required word can be found    */            short    base;      /* variable to hold current base integer for                           comparison purposes. */                                            double   double1,             double2;      /* holding variables for modf routine */                                      Digital_t    out;      /* output variable for state retrieved   */    /* obtain offset value from index, word_width & bit_number */    int1 = index * states->num_inputs + bit_number;    double1 = int1 / 8.0;    modf(double1, &double2);    bit_index = double2;    bit_offset = int1 - (double2 * 8.0);    /* retrieve entire base_address bits integer... */    base = states->inputs[bit_index];                             /* for each offset, mask off the bits and determine values */    cm_inputs_mask_and_retrieve(base,bit_offset,&out);    if ( out.state == in ) {  /* bit matches */        return 0;        }    else     if ( 2==out.state ) {     /* bit compared to is a "don't care" */        return 0;        }    else {                    /* no match */        return 1;    }}                                    /*==============================================================================FUNCTION cm_inputs_mask_and_store()AUTHORS                          22 Jul 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    The following routine masks and stores       the value passed to it by the out value         by masking the appropriate bits in the          base integer. The particular bit affected       is determined by the bit_offset value.          This routine stores to the inputs[] array.  INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns a status int value.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== Static CM_INPUTS_MASK_AND_STORE ROUTINE ===*//*************************************************      The following routine masks and stores   **   the value passed to it by the out value     **   by masking the appropriate bits in the      **   base integer. The particular bit affected   **   is determined by the bit_offset value.      **   This routine stores to the inputs[] array.  **                                               **   Created 7/22/91                             **   Last Modified 7/22/91         J.P.Murray    *************************************************/static int cm_inputs_mask_and_store(short *base,int bit_offset,int bit_value){    switch (bit_offset) {                                case 0:            *base = *base & 0xfffc;

⌨️ 快捷键说明

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