From f805d7ab713caf31aadf49808d8cd511d20717a0 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Tue, 23 Aug 2005 08:21:00 +0000 Subject: [PATCH] Applied changes to cfunc.mod sent by Hitoshi --- ChangeLog | 10 +++ src/xspice/icm/digital/adc_bridge/cfunc.mod | 5 ++ src/xspice/icm/digital/d_and/cfunc.mod | 3 + src/xspice/icm/digital/d_buffer/cfunc.mod | 4 ++ src/xspice/icm/digital/d_dff/cfunc.mod | 10 ++- src/xspice/icm/digital/d_dlatch/cfunc.mod | 9 ++- src/xspice/icm/digital/d_fdiv/cfunc.mod | 5 ++ src/xspice/icm/digital/d_inverter/cfunc.mod | 3 + src/xspice/icm/digital/d_jkff/cfunc.mod | 8 ++- src/xspice/icm/digital/d_nand/cfunc.mod | 4 ++ src/xspice/icm/digital/d_nor/cfunc.mod | 3 + src/xspice/icm/digital/d_open_c/cfunc.mod | 4 ++ src/xspice/icm/digital/d_open_e/cfunc.mod | 4 ++ src/xspice/icm/digital/d_or/cfunc.mod | 3 + src/xspice/icm/digital/d_osc/cfunc.mod | 12 +++- src/xspice/icm/digital/d_ram/cfunc.mod | 18 ++++- src/xspice/icm/digital/d_source/cfunc.mod | 45 ++++++++----- src/xspice/icm/digital/d_srff/cfunc.mod | 10 ++- src/xspice/icm/digital/d_srlatch/cfunc.mod | 10 ++- src/xspice/icm/digital/d_state/cfunc.mod | 74 +++++++++++++-------- src/xspice/icm/digital/d_tff/cfunc.mod | 12 +++- src/xspice/icm/digital/d_xnor/cfunc.mod | 7 +- src/xspice/icm/digital/d_xor/cfunc.mod | 9 ++- src/xspice/icm/digital/dac_bridge/cfunc.mod | 8 +++ src/xspice/icm/xtradev/aswitch/cfunc.mod | 4 +- src/xspice/icm/xtradev/core/ifspec.ifs | 2 +- src/xspice/icm/xtraevt/real_delay/cfunc.mod | 1 + src/xspice/icm/xtraevt/real_to_v/cfunc.mod | 2 + 28 files changed, 222 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8203b7186..105166cb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-08-23 Paolo Nenzi + + * src/xspice/icm/xtradev/aswitch/cfunc.mod: Added minimum on resistance + for aswitch to avoid unreasonable high values (due to near zero + resistance) in current of connected voltage source. Change supplied by + Hitoshi Tanaka. + + * src/xspice/icm/{cfunc.mod}: updated cfunc.mod files. Changes sent by + Hitoshi Tanaka. + 2005-08-22 Paolo Nenzi * src/frontend/plotting/x11.c: removed casting in a macro. It conflicts diff --git a/src/xspice/icm/digital/adc_bridge/cfunc.mod b/src/xspice/icm/digital/adc_bridge/cfunc.mod index 15797339a..ae6cea4af 100644 --- a/src/xspice/icm/digital/adc_bridge/cfunc.mod +++ b/src/xspice/icm/digital/adc_bridge/cfunc.mod @@ -182,6 +182,11 @@ void cm_adc_bridge(ARGS) /* Allocate storage for outputs */ out = out_old = (Digital_State_t *) cm_event_alloc(1,size * sizeof(Digital_State_t)); + /* Get analog addresses */ + in = in_old = cm_analog_get_ptr(0,0); + + /* Get discrete addresses */ + out = out_old = (Digital_State_t *) cm_event_get_ptr(1,0); } else { /*** This is not an initialization pass...retrieve storage diff --git a/src/xspice/icm/digital/d_and/cfunc.mod b/src/xspice/icm/digital/d_and/cfunc.mod index 7c8b99534..f59417b62 100644 --- a/src/xspice/icm/digital/d_and/cfunc.mod +++ b/src/xspice/icm/digital/d_and/cfunc.mod @@ -153,6 +153,9 @@ void cm_d_and(ARGS) /* set loading for inputs */ for (i=0; iindex]; - if ( 0.0 == test_double ) { /* Set DC value */ + if ( 0.0 == test_double && info->depth > 0 ) { /* Set DC value */ /* reset current breakpoint */ test_double = timepoints[info->index]; @@ -1232,6 +1239,10 @@ void cm_d_source(ARGS) test_double = timepoints[info->index] - 1.0e-10; cm_event_queue( test_double ); } + for(i=0; iwidth; i++) { + OUTPUT_STATE(out[i]) = UNKNOWN; + OUTPUT_STRENGTH(out[i]) = UNDETERMINED; + } } } else { diff --git a/src/xspice/icm/digital/d_srff/cfunc.mod b/src/xspice/icm/digital/d_srff/cfunc.mod index bb8833079..13f0479f0 100644 --- a/src/xspice/icm/digital/d_srff/cfunc.mod +++ b/src/xspice/icm/digital/d_srff/cfunc.mod @@ -120,7 +120,7 @@ NON-STANDARD FEATURES NONE -=============================================================================*/ +/*=============================================================================*/ /*=== CM_TOGGLE_BIT ROUTINE ===*/ @@ -325,7 +325,13 @@ void cm_d_srff(ARGS) } if ( !PORT_NULL(reset) ) { LOAD(reset) = PARAM(reset_load); - } + } + + /* retrieve storage for the outputs */ + clk = clk_old = (Digital_State_t *) cm_event_get_ptr(0,0); + set = set_old = (Digital_State_t *) cm_event_get_ptr(1,0); + reset = reset_old = (Digital_State_t *) cm_event_get_ptr(2,0); + out = out_old = (Digital_State_t *) cm_event_get_ptr(3,0); } else { /* Retrieve previous values */ diff --git a/src/xspice/icm/digital/d_srlatch/cfunc.mod b/src/xspice/icm/digital/d_srlatch/cfunc.mod index 40e654aab..e71f89d55 100644 --- a/src/xspice/icm/digital/d_srlatch/cfunc.mod +++ b/src/xspice/icm/digital/d_srlatch/cfunc.mod @@ -329,7 +329,15 @@ void cm_d_srlatch(ARGS) } if ( !PORT_NULL(reset) ) { LOAD(reset) = PARAM(reset_load); - } + } + + /* retrieve storage for the outputs */ + s = s_old = (Digital_State_t *) cm_event_get_ptr(0,0); + r = r_old = (Digital_State_t *) cm_event_get_ptr(1,0); + enable = enable_old = (Digital_State_t *) cm_event_get_ptr(2,0); + set = set_old = (Digital_State_t *) cm_event_get_ptr(3,0); + reset = reset_old = (Digital_State_t *) cm_event_get_ptr(4,0); + out = out_old = (Digital_State_t *) cm_event_get_ptr(5,0); } else { /* Retrieve previous values */ diff --git a/src/xspice/icm/digital/d_state/cfunc.mod b/src/xspice/icm/digital/d_state/cfunc.mod index 1e3d71395..24e1f5ea6 100644 --- a/src/xspice/icm/digital/d_state/cfunc.mod +++ b/src/xspice/icm/digital/d_state/cfunc.mod @@ -227,7 +227,7 @@ static char *CNVgettok(char **s) switch(**s) { case '\0': /* End of string found */ - free(buf); + if(buf) free(buf); return(NULL); @@ -260,7 +260,7 @@ static char *CNVgettok(char **s) ret_str = (void *) malloc(strlen(buf) + 1); ret_str = strcpy(ret_str,buf); - free(buf); + if(buf) free(buf); return(ret_str); } @@ -1530,7 +1530,9 @@ static int cm_read_state_file(FILE *state_file,State_Table_t *states) state.in file which needs to be stored */ /*base;*/ /* holding variable for existing non-masked bits[] integer */ - + if (!state_file) { + return 1; + } i = 0; s = temp; @@ -1655,7 +1657,7 @@ static int cm_read_state_file(FILE *state_file,State_Table_t *states) } else { /* need to store this value in the inputs[] array */ - cm_store_inputs_value(states,i,(j-1),bit_value); + cm_store_inputs_value(states,i,(j-1-states->num_outputs),bit_value); } } @@ -1685,8 +1687,7 @@ static int cm_read_state_file(FILE *state_file,State_Table_t *states) /* set bits values to previous bits values */ for (j=0; jnum_outputs; j++) { - /*** Retrieve the previous bit value ***/ -/* + /*** Retrieve the previous bit value ***? cm_get_bits_value(*states,i,j,&out); switch (out.state) { @@ -1755,7 +1756,8 @@ static int cm_read_state_file(FILE *state_file,State_Table_t *states) break; } - */ +*/ + /*** Store this bit value ***/ cm_store_bits_value(states,i,j,bit_value); @@ -1874,7 +1876,7 @@ void cm_d_state(ARGS) err=0, /* integer for storage of error status */ test; /* testing integer */ - State_Table_t *states; /* pointer to base address structure + State_Table_t *states, /* pointer to base address structure for all state arrays. *states contains the pointers to state[], bits[], input[] @@ -1883,7 +1885,7 @@ void cm_d_state(ARGS) calloc, so they do not take up rotational storage space...only the *states structure does this. */ - + *states_old; FILE *state_file; /* pointer to the state.in input vector file */ @@ -1901,9 +1903,12 @@ void cm_d_state(ARGS) input from state.in */ *s; /* main string variable */ - char *loading_error = "\n***ERROR***\nD_STATE: state.in file was not read successfully. \nThe most common cause of this problem is a\ntrailing blank line in the state.in file \n"; + char *open_error = "\n***ERROR***\nD_STATE: failed to open state file.\n"; + + char *loading_error = "\n***ERROR***\nD_STATE: state file was not read successfully. \nThe most common cause of this problem is a\ntrailing blank line in the state.in file \n"; char *index_error = "\n***ERROR***\nD_STATE: An error exists in the ordering of states values\n in the states->state[] array. This is usually caused \nby non-contiguous state definitions in the state.in file \n"; + char buf[100]; @@ -1916,22 +1921,23 @@ void cm_d_state(ARGS) /*** open file and count the number of vectors in it ***/ state_file = fopen( PARAM(state_file), "r"); - + /* increment counter if not a comment until EOF reached... */ i = 0; s = temp; - while ( fgets(s,MAX_STRING_SIZE,state_file) != NULL) { - if ( '*' != s[0] ) { - while(isspace(*s) || (*s == '*')) - (s)++; - if ( *s != '\0' ) i++; + if (state_file!=NULL) + while ( fgets(s,MAX_STRING_SIZE,state_file) != NULL) { + if ( '*' != s[0] ) { + while(isspace(*s) || (*s == '*')) + (s)++; + if ( *s != '\0' ) i++; + } + s = temp; } - s = temp; - } /*** allocate storage for *states... ***/ - states = (State_Table_t *) cm_event_alloc(0,sizeof(State_Table_t)); + states = states_old = (State_Table_t *) cm_event_alloc(0,sizeof(State_Table_t)); /* Store depth value */ states->depth = i; @@ -1942,10 +1948,10 @@ void cm_d_state(ARGS) /* assign storage for arrays to pointers in states table */ - states->state = (int *) calloc(states->depth,sizeof(int)); - states->bits = (short *) calloc((states->num_outputs * states->depth / 4),sizeof(short)); - states->inputs = (short *) calloc((states->num_inputs * states->depth / 8),sizeof(short)); - states->next_state = (int *) calloc(states->depth,sizeof(int)); + states->state = (int *) calloc(states->depth + 1,sizeof(int)); + states->bits = (short *) calloc((states->num_outputs * states->depth / 4 + 1),sizeof(short)); + states->inputs = (short *) calloc((states->num_inputs * states->depth / 8 + 1),sizeof(short)); + states->next_state = (int *) calloc(states->depth + 1,sizeof(int)); /* Initialize *state, *bits, *inputs & *next_state to zero */ @@ -1963,7 +1969,9 @@ void cm_d_state(ARGS) reset = reset_old = (Digital_State_t *) cm_event_alloc(2,sizeof(Digital_State_t)); - + states = states_old = (State_Table_t *) cm_event_get_ptr(0,0); + clk = clk_old = (Digital_State_t *) cm_event_get_ptr(1,0); + reset = reset_old = (Digital_State_t *) cm_event_get_ptr(2,0); /*** Send file pointer and the four storage pointers ***/ /*** to "cm_read_state_file()". This will return after ***/ @@ -1973,9 +1981,12 @@ void cm_d_state(ARGS) /*** and the num_inputs, num_outputs and depth ***/ /*** values supplied. ***/ - rewind(state_file); - err = cm_read_state_file(state_file,states); - + if (state_file) { + rewind(state_file); + err = cm_read_state_file(state_file,states); + } else { + err = 1; + } if (err) { /* problem occurred in load...send error msg. */ @@ -1993,12 +2004,14 @@ void cm_d_state(ARGS) } /* close state_file */ - fclose(state_file); + if (state_file) + fclose(state_file); /* declare load values */ - for (i=0; inum_outputs; i++) { + // for (i=0; inum_outputs; i++) { + for (i=0; inum_inputs; i++) { LOAD(in[i]) = PARAM(input_load); } @@ -2010,6 +2023,9 @@ void cm_d_state(ARGS) else { /**** Retrieve previous values ****/ states = (State_Table_t *) cm_event_get_ptr(0,0); + states_old = (State_Table_t *) cm_event_get_ptr(0,1); + // Copy storage + *states = *states_old; clk = (Digital_State_t *) cm_event_get_ptr(1,0); clk_old = (Digital_State_t *) cm_event_get_ptr(1,1); diff --git a/src/xspice/icm/digital/d_tff/cfunc.mod b/src/xspice/icm/digital/d_tff/cfunc.mod index 5d1e17ad4..7b9d0a472 100644 --- a/src/xspice/icm/digital/d_tff/cfunc.mod +++ b/src/xspice/icm/digital/d_tff/cfunc.mod @@ -127,7 +127,7 @@ NON-STANDARD FEATURES NONE -=============================================================================*/ +/*=============================================================================*/ /*=== CM_TOGGLE_BIT ROUTINE ===*/ @@ -196,7 +196,7 @@ NON-STANDARD FEATURES NONE -=============================================================================*/ +/*=============================================================================*/ /*=== CM_D_TFF ROUTINE ===*/ @@ -248,7 +248,13 @@ void cm_d_tff(ARGS) } if ( !PORT_NULL(reset) ) { LOAD(reset) = PARAM(reset_load); - } + } + + /* retrieve storage for the outputs */ + clk = clk_old = (Digital_State_t *) cm_event_get_ptr(0,0); + set = set_old = (Digital_State_t *) cm_event_get_ptr(1,0); + reset = reset_old = (Digital_State_t *) cm_event_get_ptr(2,0); + out = out_old = (Digital_State_t *) cm_event_get_ptr(3,0); } else { /* Retrieve previous values */ diff --git a/src/xspice/icm/digital/d_xnor/cfunc.mod b/src/xspice/icm/digital/d_xnor/cfunc.mod index 0d01a42ea..bb35b0a0b 100644 --- a/src/xspice/icm/digital/d_xnor/cfunc.mod +++ b/src/xspice/icm/digital/d_xnor/cfunc.mod @@ -120,7 +120,7 @@ NON-STANDARD FEATURES NONE -=============================================================================*/ +/*=============================================================================*/ /*=== CM_TOGGLE_BIT ROUTINE ===*/ @@ -188,7 +188,7 @@ NON-STANDARD FEATURES NONE -=============================================================================*/ +/*=============================================================================*/ /*=== CM_D_XNOR ROUTINE ===*/ @@ -228,6 +228,9 @@ void cm_d_xnor(ARGS) for (i=0; i