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

📄 cfunc.mod

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 MOD
📖 第 1 页 / 共 3 页
字号:
*   is determined by the ram_offset value.        **                                                 **   Created 7/8/91                 J.P.Murray     ***************************************************/static int cm_mask_and_retrieve(short base,int ram_offset,Digital_State_t *out){    switch (ram_offset) {                                case 0:            if ( (MASK0 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK0 & base) == 0x0001 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;    case 1:        if ( (MASK1 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK1 & base) == 0x0004 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;       case 2:        if ( (MASK2 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK2 & base) == 0x0010 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;             case 3:        if ( (MASK3 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK3 & base) == 0x0040 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;       case 4:        if ( (MASK4 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK4 & base) == 0x0100 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;       case 5:        if ( (MASK5 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK5 & base) == 0x0400 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;       case 6:        if ( (MASK6 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK6 & base) == 0x1000 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;       case 7:        if ( (MASK7 & base) == 0x0000 ) {            *out = ZERO;           }        else {            if ( (MASK7 & base) == 0x4000 ) {                *out = ONE;             }            else {                *out = UNKNOWN;            }        }        break;    }return 0;}/*==============================================================================FUNCTION cm_initialize_ram()AUTHORS                           9 Jul 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    This function stores digital data into specific short    integer array locations.INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns updated ram[] value.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== CM_INITIALIZE_RAM ROUTINE ===*//*************************************************      The following routine stores two-bit     **   data into short integer array "ram". The    **   integers are assumed to be at least two     **   bytes each, so each will hold eight two-    **   bit values.                                 **                                               **   Created 7/9/91               J.P.Murray     *************************************************/static void cm_initialize_ram(Digital_State_t out,int word_width,int bit_number,                        int word_number,short *ram){    int       /*err,*/      /* error index value    */             int1,      /* temp storage variable    */             /*int2,*/      /* temp storage variable    */        ram_index,      /* ram base address at which word bits will                           be found */       ram_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,      /* holding variable for doubles  */              double2;      /* holding variable for doubles  */    /* obtain offset value from word_number, word_width &        bit_number */    int1 = word_number * word_width + bit_number;    double1 = int1 / 8.0;    modf(double1, &double2);    ram_offset = int1 - (double2 * 8.0);    /* obtain ram_index value */    modf( int1/8.0, &double1);    ram_index = double1;                /* retrieve entire base_address ram integer... */    base = ram[ram_index];                             /* for each offset, mask off the bits and store values */    cm_mask_and_store(&base,ram_offset,out);                              /* store modified base value */    ram[ram_index] = base;                   }/*==============================================================================FUNCTION cm_store_ram_value()AUTHORS                          27 Jun 1991     Jeffrey P. MurrayMODIFICATIONS        9 Jul 1991     Jeffrey P. Murray    30 Sep 1991     Jeffrey P. MurraySUMMARY    This function stores digital data into specific short    integer array locations, after decoding address bits     passed to it (using cm_address_to_decimal routine).INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns updated ram[] value via *ram pointer.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== CM_STORE_RAM_VALUE ROUTINE ===*//*************************************************      The following routine stores two-bit     **   data into short integer array "ram". The    **   integers are assumed to be at least two     **   bytes each, so each will hold eight two-    **   bit values. A sister routine, cm_get_       **   ram_value is used to retrieve the two-      **   bit values from the "ram" array.            **                                               **   Created 6/27/91               J.P.Murray    *************************************************/static void cm_store_ram_value(Digital_State_t out,int word_width,int bit_number,                        Digital_State_t *address,int address_size,                        short *ram){    int       err,      /* error index value    */             int1,      /* temp storage variable    */      word_number,      /* particular word of interest...this value                           is derived from the passed address bits  */        ram_index,      /* ram base address at which word bits will                           be found */       ram_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    */    /** first obtain word_number from *address values **/    err = cm_address_to_decimal(address,address_size,&word_number);                                                    if ( FALSE == err ) { /** valid data was returned...store value **/             /* obtain offset value from word_number, word_width &            bit_number */        int1 = word_number * word_width + bit_number;        double1 = int1 / 8.0;        modf(double1, &double2);        ram_offset = int1 - (double2 * 8.0);        /* obtain ram_index value */        modf( int1/8.0, &double1);        ram_index = double1;                    /* retrieve entire base_address ram integer... */        base = ram[ram_index];                                     /* for each offset, mask off the bits and store values */        cm_mask_and_store(&base,ram_offset,out);                                      /* store modified base value */        ram[ram_index] = base;                       }}/*==============================================================================FUNCTION cm_get_ram_value()AUTHORS                          27 Jun 1991     Jeffrey P. MurrayMODIFICATIONS       30 Sep 1991     Jeffrey P. MurraySUMMARY    This function retrieves digital data from specific short    integer array locations, after decoding address bits     passed to it (using cm_address_to_decimal routine). This     is a sister routine to cm_store_ram_value.INTERFACES           FILE                 ROUTINE CALLED          N/A                  N/ARETURNED VALUE        Returns output value via *out pointer.GLOBAL VARIABLES        NONENON-STANDARD FEATURES    NONE==============================================================================*//*=== CM_GET_RAM_VALUE ROUTINE ===*//*************************************************      The following routine retrieves two-bit  **   data from short integer array "ram". The    **   integers are assumed to be at least two     **   bytes each, so each will hold eight two-    **   bit values. A sister routine, cm_store_     **   ram_value is used to store the two-bit      **   values into the "ram" array.                **                                               **   Created 6/27/91               J.P.Murray    *************************************************/static void cm_get_ram_value(int word_width,int bit_number,Digital_State_t *address,                 int address_size,short *ram,Digital_State_t *out){    int       err,      /* error index value    */             int1,      /* temp storage variable    */      word_number,      /* particular word of interest...this value                           is derived from the passed address bits  */        ram_index,      /* ram base address at which word bits will                           be found */       ram_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 */

⌨️ 快捷键说明

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