
/*
 * Structures for model: seegen
 *
 * Automatically generated by cmpp preprocessor
 *
 * !!! DO NOT EDIT !!!
 *
 */


#include "ngspice/ngspice.h"
#include <stdio.h>
#include "ngspice/devdefs.h"
#include "ngspice/ifsim.h"
#include "ngspice/mifdefs.h"
#include "ngspice/mifproto.h"
#include "ngspice/mifparse.h"


static IFparm MIFmPTable[] = {
    IOP("tfall", 0, IF_REAL, "pulse fall time"),
    IOP("trise", 1, IF_REAL, "pulse rise time"),
    IOP("tdelay", 2, IF_REAL, "pulse delay"),
    IOP("inull", 3, IF_REAL, "max current"),
    IOP("tperiod", 4, IF_REAL, "pulse repetition"),
    IOP("ctrlthres", 5, IF_REAL, "control voltage threshold"),
    IOP("let", 6, IF_REAL, "lin energy transfer"),
    IOP("cdepth", 7, IF_REAL, "charge collection depth"),
    IOP("angle", 8, IF_REAL, "particle angle"),
    IOP("perlim", 9, IF_FLAG, "pulse repetition"),
};


static IFparm MIFpTable[] = {
    OP("last_t_value", 10, IF_STRING, "next pulse start time"),
    OP("pulse_number", 11, IF_STRING, "number of pulse"),
    OP("last_ctrl", 12, IF_STRING, "last control value"),
};


static Mif_Port_Type_t MIFportEnum0[] = {
    MIF_VOLTAGE,
    MIF_DIFF_VOLTAGE,
    MIF_CURRENT,
    MIF_DIFF_CURRENT,
};


static char *MIFportStr0[] = {
    "v",
    "vd",
    "i",
    "id",
};


static Mif_Port_Type_t MIFportEnum1[] = {
    MIF_VOLTAGE,
};


static char *MIFportStr1[] = {
    "v",
};


static Mif_Port_Type_t MIFportEnum2[] = {
    MIF_CURRENT,
    MIF_DIFF_CURRENT,
};


static char *MIFportStr2[] = {
    "i",
    "id",
};


static Mif_Conn_Info_t MIFconnTable[] = {
  {
    "ctrl",
    "control input",
    MIF_IN,
    MIF_VOLTAGE,
    "v",
    4,
    MIFportEnum0,
    MIFportStr0,
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "mon",
    "monitor",
    MIF_OUT,
    MIF_VOLTAGE,
    "v",
    1,
    MIFportEnum1,
    MIFportStr1,
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "out",
    "output",
    MIF_OUT,
    MIF_CURRENT,
    "i",
    2,
    MIFportEnum2,
    MIFportStr2,
    MIF_TRUE,
    MIF_TRUE,
    1,
    MIF_FALSE,
    0,
    MIF_FALSE,
  },
};

static union Mif_Parse_Value tfall_default[] = {
    { .rvalue=5.000000e-10 },
};

static union Mif_Parse_Value trise_default[] = {
    { .rvalue=2.000000e-11 },
};

static union Mif_Parse_Value tdelay_default[] = {
    { .rvalue=0.000000e+00 },
};

static union Mif_Parse_Value inull_default[] = {
    { .rvalue=0.000000e+00 },
};

static union Mif_Parse_Value tperiod_default[] = {
    { .rvalue=0.000000e+00 },
};

static union Mif_Parse_Value ctrlthres_default[] = {
    { .rvalue=5.000000e-01 },
};

static union Mif_Parse_Value let_default[] = {
    { .rvalue=1.000000e+01 },
};

static union Mif_Parse_Value cdepth_default[] = {
    { .rvalue=1.000000e+00 },
};

static union Mif_Parse_Value angle_default[] = {
    { .rvalue=0.000000e+00 },
};

static union Mif_Parse_Value perlim_default[] = {
    { .bvalue=MIF_TRUE },
};


static Mif_Param_Info_t MIFparamTable[] = {
  {
    "tfall",
    "pulse fall time",
    MIF_REAL,
    1,
    tfall_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "trise",
    "pulse rise time",
    MIF_REAL,
    1,
    trise_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "tdelay",
    "pulse delay",
    MIF_REAL,
    1,
    tdelay_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "inull",
    "max current",
    MIF_REAL,
    1,
    inull_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "tperiod",
    "pulse repetition",
    MIF_REAL,
    1,
    tperiod_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "ctrlthres",
    "control voltage threshold",
    MIF_REAL,
    1,
    ctrlthres_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "let",
    "lin energy transfer",
    MIF_REAL,
    1,
    let_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "cdepth",
    "charge collection depth",
    MIF_REAL,
    1,
    cdepth_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "angle",
    "particle angle",
    MIF_REAL,
    1,
    angle_default,
    MIF_TRUE,
    { .rvalue=0.000000e+00 },
    MIF_TRUE,
    { .rvalue=1.570790e+00 },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
  {
    "perlim",
    "pulse repetition",
    MIF_BOOLEAN,
    1,
    perlim_default,
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    { .bvalue=MIF_FALSE },
    MIF_FALSE,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_FALSE,
    0,
    MIF_TRUE,
  },
};


static Mif_Inst_Var_Info_t MIFinst_varTable[] = {
  {
    "last_t_value",
    "next pulse start time",
    MIF_STRING,
    MIF_FALSE,
  },
  {
    "pulse_number",
    "number of pulse",
    MIF_STRING,
    MIF_FALSE,
  },
  {
    "last_ctrl",
    "last control value",
    MIF_STRING,
    MIF_FALSE,
  },
};


extern void cm_seegen(Mif_Private_t *);

static int val_terms             = 0;
static int val_numNames          = 0;
static int val_numInstanceParms  = 3;
static int val_numModelParms     = 10;
static int val_sizeofMIFinstance = sizeof(MIFinstance);
static int val_sizeofMIFmodel    = sizeof(MIFmodel);

SPICEdev cm_seegen_info = {
    .DEVpublic = {
        .name = "seegen",
        .description = "single event effect generator",
        .terms = &val_terms,
        .numNames = &val_numNames,
        .termNames = NULL,
        .numInstanceParms = &val_numInstanceParms,
        .instanceParms = MIFpTable,
        .numModelParms = &val_numModelParms,
        .modelParms = MIFmPTable,
        .flags = 0,

        .cm_func = cm_seegen,
        .num_conn = 3,
        .conn = MIFconnTable,
        .num_param = 10,
        .param = MIFparamTable,
        .num_inst_var = 3,
        .inst_var = MIFinst_varTable,
    },

    .DEVparam = NULL,
    .DEVmodParam = MIFmParam,
    .DEVload = MIFload,
    .DEVsetup = MIFsetup,
    .DEVunsetup = MIFunsetup,
    .DEVpzSetup = NULL,
    .DEVtemperature = NULL,
    .DEVtrunc = MIFtrunc,
    .DEVfindBranch = NULL,
    .DEVacLoad = MIFload,
    .DEVaccept = NULL,
    .DEVdestroy = NULL,
    .DEVmodDelete = MIFmDelete,
    .DEVdelete = MIFdelete,
    .DEVsetic = NULL,
    .DEVask = MIFask,
    .DEVmodAsk = MIFmAsk,
    .DEVpzLoad = NULL,
    .DEVconvTest = MIFconvTest,
    .DEVsenSetup = NULL,
    .DEVsenLoad = NULL,
    .DEVsenUpdate = NULL,
    .DEVsenAcLoad = NULL,
    .DEVsenPrint = NULL,
    .DEVsenTrunc = NULL,
    .DEVdisto = NULL,
    .DEVnoise = NULL,
    .DEVsoaCheck = NULL,
    .DEVinstSize = &val_sizeofMIFinstance,
    .DEVmodSize = &val_sizeofMIFmodel,

#ifdef CIDER
    .DEVdump = NULL,
    .DEVacct = NULL,
#endif

#ifdef KLU
    .DEVbindCSC = MIFbindCSC,
    .DEVbindCSCComplex = MIFbindCSCComplex,
    .DEVbindCSCComplexToReal = MIFbindCSCComplexToReal,
#endif
};

