Output 'out' is a vector.
Pulse have a delay and then are periodic. Pulses are sequentially pushed to each vector element (node pair).
This commit is contained in:
parent
40375934da
commit
87e2b365fd
|
|
@ -60,7 +60,23 @@ NON-STANDARD FEATURES
|
||||||
|
|
||||||
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
|
/*=== LOCAL VARIABLES & TYPEDEFS =======*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
cm_seegen_callback(ARGS, Mif_Callback_Reason_t reason)
|
||||||
|
{
|
||||||
|
switch (reason) {
|
||||||
|
case MIF_CB_DESTROY: {
|
||||||
|
double *last_t_value = STATIC_VAR (last_t_value);
|
||||||
|
if (last_t_value)
|
||||||
|
free(last_t_value);
|
||||||
|
STATIC_VAR (last_t_value) = NULL;
|
||||||
|
int *pulse_number = STATIC_VAR (pulse_number);
|
||||||
|
if (pulse_number)
|
||||||
|
free(pulse_number);
|
||||||
|
STATIC_VAR (pulse_number) = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/
|
||||||
|
|
@ -108,12 +124,15 @@ NON-STANDARD FEATURES
|
||||||
void cm_seegen(ARGS) /* structure holding parms,
|
void cm_seegen(ARGS) /* structure holding parms,
|
||||||
inputs, outputs, etc. */
|
inputs, outputs, etc. */
|
||||||
{
|
{
|
||||||
double talpha;
|
double talpha; /* parameter alpha */
|
||||||
double tbeta;
|
double tbeta; /* parameter beta */
|
||||||
double tdelay;
|
double tdelay; /* delay until first pulse */
|
||||||
double inull;
|
double inull; /* max. current of pulse */
|
||||||
double out;
|
double tperiod; /* pulse repetition period */
|
||||||
double tcurr = TIME;
|
double out; /* output current */
|
||||||
|
double *last_t_value; /* static storage of next pulse time */
|
||||||
|
int *pulse_number; /* static storage of next pulse time */
|
||||||
|
double tcurr = TIME; /* current simulation time */
|
||||||
|
|
||||||
|
|
||||||
/* Retrieve frequently used parameters... */
|
/* Retrieve frequently used parameters... */
|
||||||
|
|
@ -121,14 +140,35 @@ void cm_seegen(ARGS) /* structure holding parms,
|
||||||
talpha = PARAM(talpha);
|
talpha = PARAM(talpha);
|
||||||
tbeta = PARAM(tbeta);
|
tbeta = PARAM(tbeta);
|
||||||
tdelay = PARAM(tdelay);
|
tdelay = PARAM(tdelay);
|
||||||
|
tperiod = PARAM(tperiod);
|
||||||
inull = PARAM(inull);
|
inull = PARAM(inull);
|
||||||
|
|
||||||
if (tcurr < tdelay)
|
if (INIT==1) {
|
||||||
out = 0;
|
/* Allocate storage for last_t_value */
|
||||||
else
|
STATIC_VAR(last_t_value) = (double *) malloc(sizeof(double));
|
||||||
out = inull * (exp(-(tcurr-tdelay)/talpha) - exp(-(tcurr-tdelay)/tbeta));
|
last_t_value = (double *) STATIC_VAR(last_t_value);
|
||||||
|
*last_t_value = tdelay;
|
||||||
|
STATIC_VAR(pulse_number) = (int *) malloc(sizeof(int));
|
||||||
|
pulse_number = (int *) STATIC_VAR(pulse_number);
|
||||||
|
*pulse_number = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
OUTPUT(out) = out;
|
last_t_value = (double *) STATIC_VAR(last_t_value);
|
||||||
|
pulse_number = (int *) STATIC_VAR(pulse_number);
|
||||||
|
|
||||||
|
if (tcurr < *last_t_value)
|
||||||
|
out = 0;
|
||||||
|
else
|
||||||
|
out = inull * (exp(-(tcurr-*last_t_value)/talpha) - exp(-(tcurr-*last_t_value)/tbeta));
|
||||||
|
|
||||||
|
if (tcurr > *last_t_value + tperiod * 0.9) {
|
||||||
|
*last_t_value = *last_t_value + tperiod;
|
||||||
|
(*pulse_number)++;
|
||||||
|
}
|
||||||
|
if (*pulse_number - 1 < PORT_SIZE(out))
|
||||||
|
OUTPUT(out[*pulse_number - 1]) = out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ Description: "single event effect generator"
|
||||||
|
|
||||||
PORT_TABLE:
|
PORT_TABLE:
|
||||||
|
|
||||||
Port_Name: out
|
Port_Name: out
|
||||||
Description: "output"
|
Description: "output"
|
||||||
Direction: out
|
Direction: out
|
||||||
Default_Type: i
|
Default_Type: i
|
||||||
Allowed_Types: [i,id]
|
Allowed_Types: [i,id]
|
||||||
Vector: no
|
Vector: yes
|
||||||
Vector_Bounds: -
|
Vector_Bounds: [1 -]
|
||||||
Null_Allowed: no
|
Null_Allowed: no
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,23 +44,46 @@ PARAMETER_TABLE:
|
||||||
|
|
||||||
Parameter_Name: talpha tbeta
|
Parameter_Name: talpha tbeta
|
||||||
Description: "alpha" "beta"
|
Description: "alpha" "beta"
|
||||||
Data_Type: real real
|
Data_Type: real real
|
||||||
Default_Value: 500e-12 10e-12
|
Default_Value: 500e-12 10e-12
|
||||||
Limits: - -
|
Limits: - -
|
||||||
Vector: no no
|
Vector: no no
|
||||||
Vector_Bounds: - -
|
Vector_Bounds: - -
|
||||||
Null_Allowed: yes yes
|
Null_Allowed: yes yes
|
||||||
|
|
||||||
|
|
||||||
PARAMETER_TABLE:
|
PARAMETER_TABLE:
|
||||||
|
|
||||||
|
|
||||||
Parameter_Name: tdelay inull
|
Parameter_Name: tdelay inull
|
||||||
Description: "pulse delay" "max current"
|
Description: "pulse delay" "max current"
|
||||||
Data_Type: real real
|
Data_Type: real real
|
||||||
Default_Value: 0 200e-6
|
Default_Value: 0 200e-6
|
||||||
Limits: - -
|
Limits: - -
|
||||||
Vector: no no
|
Vector: no no
|
||||||
Vector_Bounds: - -
|
Vector_Bounds: - -
|
||||||
Null_Allowed: yes yes
|
Null_Allowed: yes yes
|
||||||
|
|
||||||
|
PARAMETER_TABLE:
|
||||||
|
|
||||||
|
Parameter_Name: tperiod
|
||||||
|
Description: "pulse repetition"
|
||||||
|
Data_Type: real
|
||||||
|
Default_Value: 0
|
||||||
|
Limits: -
|
||||||
|
Vector: no
|
||||||
|
Vector_Bounds: -
|
||||||
|
Null_Allowed: yes
|
||||||
|
|
||||||
|
STATIC_VAR_TABLE:
|
||||||
|
|
||||||
|
Static_Var_Name: last_t_value
|
||||||
|
Data_Type: pointer
|
||||||
|
Vector: no
|
||||||
|
Description: "next pulse start time"
|
||||||
|
|
||||||
|
STATIC_VAR_TABLE:
|
||||||
|
|
||||||
|
Static_Var_Name: pulse_number
|
||||||
|
Data_Type: pointer
|
||||||
|
Vector: no
|
||||||
|
Description: "number of pulse"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue