Browse Source

Trim trailing spaces

pre-master-46
Holger Vogt 3 years ago
parent
commit
ba6ff75dab
  1. 180
      src/xspice/icm/digital/d_osc/cfunc.mod
  2. 18
      src/xspice/icm/digital/d_osc/ifspec.ifs

180
src/xspice/icm/digital/d_osc/cfunc.mod

@ -8,14 +8,14 @@ Public Domain
Georgia Tech Research Corporation Georgia Tech Research Corporation
Atlanta, Georgia 30332 Atlanta, Georgia 30332
PROJECT A-8503-405 PROJECT A-8503-405
AUTHORS
AUTHORS
24 Jul 1991 Jeffrey P. Murray 24 Jul 1991 Jeffrey P. Murray
MODIFICATIONS
MODIFICATIONS
23 Aug 1991 Jeffrey P. Murray 23 Aug 1991 Jeffrey P. Murray
30 Sep 1991 Jeffrey P. Murray 30 Sep 1991 Jeffrey P. Murray
@ -27,12 +27,12 @@ SUMMARY
functionally describe the d_osc code model. functionally describe the d_osc code model.
INTERFACES
INTERFACES
FILE ROUTINE CALLED
FILE ROUTINE CALLED
CMmacros.h cm_message_send();
CMmacros.h cm_message_send();
CM.c void *cm_analog_alloc() CM.c void *cm_analog_alloc()
void *cm_analog_get_ptr() void *cm_analog_get_ptr()
@ -42,7 +42,7 @@ INTERFACES
REFERENCED FILES REFERENCED FILES
Inputs from and outputs to ARGS structure. Inputs from and outputs to ARGS structure.
NON-STANDARD FEATURES NON-STANDARD FEATURES
@ -55,7 +55,7 @@ NON-STANDARD FEATURES
#include "d_osc.h" /* ...contains macros & type defns. #include "d_osc.h" /* ...contains macros & type defns.
for this model. 7/24/91 - JPM */ for this model. 7/24/91 - JPM */
/*=== CONSTANTS ========================*/ /*=== CONSTANTS ========================*/
@ -66,31 +66,31 @@ NON-STANDARD FEATURES
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
typedef struct { typedef struct {
double *x; double *x;
double *y; double *y;
} Local_Data_t; } Local_Data_t;
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/ /*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
/*============================================================================== /*==============================================================================
FUNCTION cm_d_osc() FUNCTION cm_d_osc()
AUTHORS
AUTHORS
24 Jul 1991 Jeffrey P. Murray 24 Jul 1991 Jeffrey P. Murray
MODIFICATIONS
MODIFICATIONS
30 Sep 1991 Jeffrey P. Murray 30 Sep 1991 Jeffrey P. Murray
@ -98,23 +98,23 @@ SUMMARY
This function implements the d_osc code model. This function implements the d_osc code model.
INTERFACES
INTERFACES
FILE ROUTINE CALLED
FILE ROUTINE CALLED
CMmacros.h cm_message_send();
CMmacros.h cm_message_send();
CM.c void *cm_analog_alloc() CM.c void *cm_analog_alloc()
void *cm_analog_get_ptr() void *cm_analog_get_ptr()
CMevt.c void cm_event_queue() CMevt.c void cm_event_queue()
RETURNED VALUE RETURNED VALUE
Returns inputs and outputs via ARGS structure. Returns inputs and outputs via ARGS structure.
GLOBAL VARIABLES GLOBAL VARIABLES
NONE NONE
NON-STANDARD FEATURES NON-STANDARD FEATURES
@ -165,7 +165,7 @@ static void cm_d_osc_callback(ARGS,
* I | | | | * * I | | | | *
* I | | * * I | | *
* I | | | | * * I | | | | *
* I-----------------*-----* - - - - - - - - - -*--------- *
* I-----------------*-----* - - - - - - - - - -*--------- *
* t1 t4 * * t1 t4 *
* * * *
* * * *
@ -182,7 +182,7 @@ static void cm_d_osc_callback(ARGS,
#include <stdlib.h> #include <stdlib.h>
void cm_d_osc(ARGS)
void cm_d_osc(ARGS)
{ {
double *x, /* analog input value control array */ double *x, /* analog input value control array */
@ -190,11 +190,11 @@ void cm_d_osc(ARGS)
cntl_input, /* control input value */ cntl_input, /* control input value */
*phase, /* instantaneous phase of the model */ *phase, /* instantaneous phase of the model */
*phase_old, /* previous phase of the model */ *phase_old, /* previous phase of the model */
*t1, /* pointer to t1 value */
*t3, /* pointer to t3 value */
/*time1,*/ /* variable for calculating new time1 value */
/*time3,*/ /* variable for calculating new time3 value */
freq = 0.0, /* instantaneous frequency value */
*t1, /* pointer to t1 value */
*t3, /* pointer to t3 value */
/*time1,*/ /* variable for calculating new time1 value */
/*time3,*/ /* variable for calculating new time3 value */
freq = 0.0, /* instantaneous frequency value */
dphase, /* fractional part into cycle */ dphase, /* fractional part into cycle */
duty_cycle, /* duty_cycle value */ duty_cycle, /* duty_cycle value */
test_double, /* testing variable */ test_double, /* testing variable */
@ -205,17 +205,17 @@ void cm_d_osc(ARGS)
int i, /* generic loop counter index */ int i, /* generic loop counter index */
cntl_size, /* control array size */ cntl_size, /* control array size */
freq_size; /* frequency array size */ freq_size; /* frequency array size */
Local_Data_t *loc; /* Pointer to local static data, not to be included Local_Data_t *loc; /* Pointer to local static data, not to be included
in the state vector (save memory!) */
in the state vector (save memory!) */
/**** Retrieve frequently used parameters... ****/ /**** Retrieve frequently used parameters... ****/
cntl_size = PARAM_SIZE(cntl_array);
freq_size = PARAM_SIZE(freq_array);
cntl_size = PARAM_SIZE(cntl_array);
freq_size = PARAM_SIZE(freq_array);
duty_cycle = PARAM(duty_cycle); duty_cycle = PARAM(duty_cycle);
@ -227,7 +227,7 @@ void cm_d_osc(ARGS)
return; return;
} }
if (INIT) { /*** Test for INIT == TRUE. If so, allocate storage, etc. ***/ if (INIT) { /*** Test for INIT == TRUE. If so, allocate storage, etc. ***/
/* Allocate storage for internal variables */ /* Allocate storage for internal variables */
@ -239,7 +239,7 @@ void cm_d_osc(ARGS)
phase = phase_old = (double *) cm_analog_get_ptr(0,0); phase = phase_old = (double *) cm_analog_get_ptr(0,0);
t1 = (double *) cm_analog_get_ptr(1,0); t1 = (double *) cm_analog_get_ptr(1,0);
t3 = (double *) cm_analog_get_ptr(2,0); t3 = (double *) cm_analog_get_ptr(2,0);
/*** allocate static storage for *loc ***/ /*** allocate static storage for *loc ***/
@ -276,20 +276,20 @@ void cm_d_osc(ARGS)
phase_old = (double *) cm_analog_get_ptr(0,1); phase_old = (double *) cm_analog_get_ptr(0,1);
t1 = (double *) cm_analog_get_ptr(1,0); t1 = (double *) cm_analog_get_ptr(1,0);
t3 = (double *) cm_analog_get_ptr(2,0); t3 = (double *) cm_analog_get_ptr(2,0);
} }
switch (CALL_TYPE) { switch (CALL_TYPE) {
case ANALOG: /** analog call **/ case ANALOG: /** analog call **/
test_double = TIME;
if ( AC == ANALYSIS ) { /* this model does not function
test_double = TIME;
if ( AC == ANALYSIS ) { /* this model does not function
in AC analysis mode. */ in AC analysis mode. */
return;
return;
} }
else { else {
@ -299,26 +299,26 @@ void cm_d_osc(ARGS)
*phase = PARAM(init_phase); *phase = PARAM(init_phase);
if ( 0 > *phase ) { if ( 0 > *phase ) {
*phase = *phase + 360.0; *phase = *phase + 360.0;
}
}
*phase = *phase / 360.0; *phase = *phase / 360.0;
/* set phase value to init_phase */ /* set phase value to init_phase */
*phase_old = *phase; *phase_old = *phase;
/* preset time values to harmless values... */ /* preset time values to harmless values... */
*t1 = -1; *t1 = -1;
*t3 = -1;
*t3 = -1;
} }
loc = STATIC_VAR (locdata); loc = STATIC_VAR (locdata);
x = loc->x; x = loc->x;
y = loc->y;
/* Retrieve cntl_input value. */
y = loc->y;
/* Retrieve cntl_input value. */
cntl_input = INPUT(cntl_in); cntl_input = INPUT(cntl_in);
/* Determine segment boundaries within which cntl_input resides */ /* Determine segment boundaries within which cntl_input resides */
/*** cntl_input below lowest cntl_voltage ***/ /*** cntl_input below lowest cntl_voltage ***/
if (cntl_input <= x[0]) { if (cntl_input <= x[0]) {
@ -327,59 +327,59 @@ void cm_d_osc(ARGS)
freq = y[0] + (cntl_input - x[0]) * slope; freq = y[0] + (cntl_input - x[0]) * slope;
} }
else
else
/*** cntl_input above highest cntl_voltage ***/ /*** cntl_input above highest cntl_voltage ***/
if (cntl_input >= x[cntl_size-1]) {
if (cntl_input >= x[cntl_size-1]) {
slope = (y[cntl_size-1] - y[cntl_size-2]) / slope = (y[cntl_size-1] - y[cntl_size-2]) /
(x[cntl_size-1] - x[cntl_size-2]); (x[cntl_size-1] - x[cntl_size-2]);
freq = y[cntl_size-1] + (cntl_input - x[cntl_size-1]) * slope; freq = y[cntl_size-1] + (cntl_input - x[cntl_size-1]) * slope;
}
else { /*** cntl_input within bounds of end midpoints...
must determine position progressively & then
}
else { /*** cntl_input within bounds of end midpoints...
must determine position progressively & then
calculate required output. ***/ calculate required output. ***/
for (i=0; i<cntl_size-1; i++) { for (i=0; i<cntl_size-1; i++) {
if ( (cntl_input < x[i+1]) && (cntl_input >= x[i]) ) {
if ( (cntl_input < x[i+1]) && (cntl_input >= x[i]) ) {
/* Interpolate to the correct frequency value */ /* Interpolate to the correct frequency value */
freq = ( (cntl_input - x[i]) / (x[i+1] - x[i]) ) *
( y[i+1]-y[i] ) + y[i];
}
freq = ( (cntl_input - x[i]) / (x[i+1] - x[i]) ) *
( y[i+1]-y[i] ) + y[i];
}
} }
} }
/*** If freq < 0.0, clamp to 1e-16 & issue a warning ***/ /*** If freq < 0.0, clamp to 1e-16 & issue a warning ***/
if ( 0.0 > freq ) { if ( 0.0 > freq ) {
freq = 1.0e-16; freq = 1.0e-16;
cm_message_send(d_osc_negative_freq_error);
cm_message_send(d_osc_negative_freq_error);
} }
/* calculate the instantaneous phase */ /* calculate the instantaneous phase */
*phase = *phase_old + freq * (TIME - T(1)); *phase = *phase_old + freq * (TIME - T(1));
/* dphase is the percent into the cycle for /* dphase is the percent into the cycle for
the period */
the period */
dphase = *phase_old - floor(*phase_old); dphase = *phase_old - floor(*phase_old);
/* Calculate the time variables and the output value /* Calculate the time variables and the output value
for this iteration */
for this iteration */
if((*t1 <= TIME) && (TIME <= *t3)) { /* output high */ if((*t1 <= TIME) && (TIME <= *t3)) { /* output high */
*t3 = T(1) + (1 - dphase)/freq; *t3 = T(1) + (1 - dphase)/freq;
if(TIME < *t3) { if(TIME < *t3) {
cm_event_queue(*t3); cm_event_queue(*t3);
}
}
else
}
}
else
if((*t3 <= TIME) && (TIME <= *t1)) { /* output low */ if((*t3 <= TIME) && (TIME <= *t1)) { /* output low */
@ -387,12 +387,12 @@ void cm_d_osc(ARGS)
dphase = dphase - 1.0; dphase = dphase - 1.0;
} }
*t1 = T(1) + ( (1.0 - duty_cycle) - dphase)/freq; *t1 = T(1) + ( (1.0 - duty_cycle) - dphase)/freq;
if(TIME < *t1) { if(TIME < *t1) {
cm_event_queue(*t1); cm_event_queue(*t1);
} }
}
}
else { else {
if(dphase > (1.0 - duty_cycle) ) { if(dphase > (1.0 - duty_cycle) ) {
@ -408,48 +408,48 @@ void cm_d_osc(ARGS)
} }
} }
break; break;
case EVENT: /** discrete call...lots to do **/ case EVENT: /** discrete call...lots to do **/
test_double = TIME;
test_double = TIME;
if ( 0.0 == TIME ) { /* DC analysis...preset values,
if ( 0.0 == TIME ) { /* DC analysis...preset values,
as appropriate.... */ as appropriate.... */
/* retrieve & normalize phase value */ /* retrieve & normalize phase value */
*phase = PARAM(init_phase); *phase = PARAM(init_phase);
if ( 0 > *phase ) { if ( 0 > *phase ) {
*phase = *phase + 360.0; *phase = *phase + 360.0;
}
}
*phase = *phase / 360.0; *phase = *phase / 360.0;
/* set phase value to init_phase */ /* set phase value to init_phase */
*phase_old = *phase; *phase_old = *phase;
/* preset time values to harmless values... */ /* preset time values to harmless values... */
*t1 = -1; *t1 = -1;
*t3 = -1; *t3 = -1;
} }
/* Calculate the time variables and the output value /* Calculate the time variables and the output value
for this iteration */
for this iteration */
/* Output is always set to STRONG */ /* Output is always set to STRONG */
OUTPUT_STRENGTH(out) = STRONG;
OUTPUT_STRENGTH(out) = STRONG;
if( *t1 == TIME ) { /* rising edge */ if( *t1 == TIME ) { /* rising edge */
OUTPUT_STATE(out) = ONE;
OUTPUT_DELAY(out) = PARAM(rise_delay);
OUTPUT_STATE(out) = ONE;
OUTPUT_DELAY(out) = PARAM(rise_delay);
} }
else { else {
if ( *t3 == TIME ) { /* falling edge */ if ( *t3 == TIME ) { /* falling edge */
OUTPUT_STATE(out) = ZERO;
OUTPUT_DELAY(out) = PARAM(fall_delay);
OUTPUT_STATE(out) = ZERO;
OUTPUT_DELAY(out) = PARAM(fall_delay);
} }
else { /* no change in output */ else { /* no change in output */
@ -459,17 +459,17 @@ void cm_d_osc(ARGS)
} }
if ( (*t1 < TIME) && (TIME < *t3) ) { if ( (*t1 < TIME) && (TIME < *t3) ) {
OUTPUT_STATE(out) = ONE;
OUTPUT_STATE(out) = ONE;
} }
else { else {
OUTPUT_STATE(out) = ZERO;
OUTPUT_STATE(out) = ZERO;
} }
} }
} }
break; break;
} }
}
}

18
src/xspice/icm/digital/d_osc/ifspec.ifs

@ -6,14 +6,14 @@ Georgia Tech Research Corporation
Atlanta, Georgia 30332 Atlanta, Georgia 30332
AUTHORS
AUTHORS
30 Sept 1991 Jeffrey P. Murray 30 Sept 1991 Jeffrey P. Murray
09 Nov 2022 Holger Vogt 09 Nov 2022 Holger Vogt
SUMMARY SUMMARY
This file contains the interface specification file for the
This file contains the interface specification file for the
hybrid d_osc code model. hybrid d_osc code model.
===============================================================================*/ ===============================================================================*/
@ -40,14 +40,14 @@ Null_Allowed: no no
PARAMETER_TABLE: PARAMETER_TABLE:
Parameter_Name: cntl_array freq_array
Parameter_Name: cntl_array freq_array
Description: "control array" "frequency array" Description: "control array" "frequency array"
Data_Type: real real Data_Type: real real
Default_Value: 0.0 1.0e6
Limits: - [0 -]
Default_Value: 0.0 1.0e6
Limits: - [0 -]
Vector: yes yes Vector: yes yes
Vector_Bounds: [2 -] [2 -]
Null_Allowed: no no
Vector_Bounds: [2 -] [2 -]
Null_Allowed: no no
PARAMETER_TABLE: PARAMETER_TABLE:
@ -59,7 +59,7 @@ Default_Value: 0.5 0
Limits: [1e-6 0.999999] [-180.0 +360.0] Limits: [1e-6 0.999999] [-180.0 +360.0]
Vector: no no Vector: no no
Vector_Bounds: - - Vector_Bounds: - -
Null_Allowed: yes yes
Null_Allowed: yes yes
PARAMETER_TABLE: PARAMETER_TABLE:
@ -71,7 +71,7 @@ Default_Value: 1e-9 1e-9
Limits: [0 -] [0 -] Limits: [0 -] [0 -]
Vector: no no Vector: no no
Vector_Bounds: - - Vector_Bounds: - -
Null_Allowed: yes yes
Null_Allowed: yes yes
STATIC_VAR_TABLE: STATIC_VAR_TABLE:

Loading…
Cancel
Save