From 9280b62be9ed4d4497e65c977c0661214e92a205 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 20 May 2025 17:10:56 +0200 Subject: [PATCH] Add a control input ctrl with threshold 0.5: If ctrl rises from below to above threshold, the whole SEE pulse sequence isrepeated (including delay) from the current simulation time point. --- src/xspice/icm/xtradev/seegenerator/cfunc.mod | 23 ++++++++++++++--- .../icm/xtradev/seegenerator/ifspec.ifs | 25 ++++++++++++------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/xspice/icm/xtradev/seegenerator/cfunc.mod b/src/xspice/icm/xtradev/seegenerator/cfunc.mod index 37c997f59..55bad8000 100644 --- a/src/xspice/icm/xtradev/seegenerator/cfunc.mod +++ b/src/xspice/icm/xtradev/seegenerator/cfunc.mod @@ -28,9 +28,6 @@ INTERFACES FILE ROUTINE CALLED - CMutil.c void cm_smooth_corner(); - void cm_smooth_discontinuity(); - void cm_climit_fcn() REFERENCED FILES @@ -74,6 +71,10 @@ cm_seegen_callback(ARGS, Mif_Callback_Reason_t reason) free(pulse_number); STATIC_VAR (pulse_number) = NULL; break; + double *last_ctrl = STATIC_VAR (last_ctrl); + if (last_ctrl) + free(last_ctrl); + STATIC_VAR (last_ctrl) = NULL; } } } @@ -129,9 +130,11 @@ void cm_seegen(ARGS) /* structure holding parms, double tdelay; /* delay until first pulse */ double inull; /* max. current of pulse */ double tperiod; /* pulse repetition period */ + double ctrl; /* control input */ double out; /* output current */ double *last_t_value; /* static storage of next pulse time */ int *pulse_number; /* static storage of next pulse time */ + double *last_ctrl; /* static storage of last ctrl value */ double tcurr = TIME; /* current simulation time */ @@ -143,6 +146,11 @@ void cm_seegen(ARGS) /* structure holding parms, tperiod = PARAM(tperiod); inull = PARAM(inull); + if (PORT_NULL(ctrl)) + ctrl = 1; + else + ctrl = INPUT(ctrl); + if (INIT==1) { /* Allocate storage for last_t_value */ STATIC_VAR(last_t_value) = (double *) malloc(sizeof(double)); @@ -151,11 +159,20 @@ void cm_seegen(ARGS) /* structure holding parms, STATIC_VAR(pulse_number) = (int *) malloc(sizeof(int)); pulse_number = (int *) STATIC_VAR(pulse_number); *pulse_number = 1; + STATIC_VAR(last_ctrl) = (double *) malloc(sizeof(double)); + last_ctrl = (double *) STATIC_VAR(last_ctrl); + *last_ctrl = ctrl; } else { last_t_value = (double *) STATIC_VAR(last_t_value); pulse_number = (int *) STATIC_VAR(pulse_number); + last_ctrl = (double *) STATIC_VAR(last_ctrl); + + if (*last_ctrl < 0.5 && ctrl >= 0.5) { + *last_t_value = *last_t_value + tcurr; + *last_ctrl = ctrl; + } if (tcurr < *last_t_value) out = 0; diff --git a/src/xspice/icm/xtradev/seegenerator/ifspec.ifs b/src/xspice/icm/xtradev/seegenerator/ifspec.ifs index 1b7f9d616..08f3c45f0 100644 --- a/src/xspice/icm/xtradev/seegenerator/ifspec.ifs +++ b/src/xspice/icm/xtradev/seegenerator/ifspec.ifs @@ -30,14 +30,14 @@ Description: "single event effect generator" PORT_TABLE: -Port_Name: out -Description: "output" -Direction: out -Default_Type: i -Allowed_Types: [i,id] -Vector: yes -Vector_Bounds: [1 -] -Null_Allowed: no +Port_Name: ctrl out +Description: "control input" "output" +Direction: in out +Default_Type: v i +Allowed_Types: [v,vd,i,id] [i,id] +Vector: no yes +Vector_Bounds: - [1 -] +Null_Allowed: yes no PARAMETER_TABLE: @@ -45,7 +45,7 @@ PARAMETER_TABLE: Parameter_Name: talpha tbeta Description: "alpha" "beta" Data_Type: real real -Default_Value: 500e-12 10e-12 +Default_Value: 500e-12 20e-12 Limits: - - Vector: no no Vector_Bounds: - - @@ -87,3 +87,10 @@ Static_Var_Name: pulse_number Data_Type: pointer Vector: no Description: "number of pulse" + +STATIC_VAR_TABLE: + +Static_Var_Name: last_ctrl +Data_Type: pointer +Vector: no +Description: "last control value"