Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / mcc / sk.h
1 /*---------------------------------------------------------------------
2 Do not change this data manually,
3 it will be automatically updated by RCS
4
5 $RCSfile: sk.h,v $
6
7 ----------------------------------------------------------------------*/
8 /**
9 * Copyright (c) 2002 Nederlandse NXP Semiconductors
10 * NXP Research Laboratories
11 * Eindhoven, The Netherlands
12 *
13 * File : sk.h
14 * Author : Andreas Gessner
15 * Co-Author : Bart Kost, Rob Klaassen
16 * Date : 05.11.2002
17 * Version : 0.2
18 *
19 * History : <date> <name> <changes>
20 * 30-01-02 Andreas Gessner Updated according to the type names
21 * stated in the SDD V0.7
22 * 13-02-02 Andreas Gessner Updated according to the SDD V0.8
23 * 05-03-02 Andreas Gessner Added: err_parameter_not_readable,
24 * err_parameter_not_writeable
25 * reset_inst_params()
26 * -> p_model_data added as argument
27 * (needed to select default values,
28 * depend on type).
29 * 13-03-02 Andreas Gessner Nodal voltages added to
30 * instance variables structure.
31 * Initial values added, controlling
32 * nodes.
33 *
34 * 20-03-02 Andreas Gessner Branch seperated -> branch type
35 * not needed anymore, branch_voltages
36 * deleted, branch charges added,
37 * gmin_status included
38 * in branch_status .
39 *
40 * 05-11-02 Bart Kost Changed interface to support
41 * different clipping values for N/P,
42 * removed pp_op_info (duplicate),
43 * renamed from PMK_ to SK_.
44 *
45 * @file
46 * This file declares the data structures of the SiMKit
47 */
48
49 #ifndef _SK_H
50 #define _SK_H
51
52 #include <stdio.h>
53 #include <string.h>
54 #ifndef WIN32
55 #include <ctype.h>
56 #endif
57 #include <errno.h>
58 #include <stdlib.h>
59 #include "stdarg.h" /* Needed for debugging */
60
61 /**
62 * The SiMKit model interface version number.
63 * Any time the interface changes this value has to be increased.
64 * The SiMKit adapters for Pstar, spectre and ADS use this define also
65 * to check whether their code supports the interface version the compiled
66 * model library reports.
67 *
68 * Version 1: February 2007 The first numbered version of the SK interface
69 * Version 2: February 2007 Added parameter 'p_is_param_changed' to
70 * set_model_params and to set_inst_params (ER18977)
71 * Added p_ev_ig_available array to SK_MODEL (ER19057)
72 */
73 #define SK_INTERFACE_VERSION 2
74
75 /* SiMKit types */
76 typedef char sk_boolean;
77 typedef int sk_integer;
78 typedef double sk_real;
79 typedef short sk_short_integer;
80 typedef float sk_short_real;
81
82 /********************************************************************
83 * M A C R O S *
84 ********************************************************************/
85
86 /* matrix access */
87 #define SK_BRANCH_CURRENT( branch_nr) \
88 p_i_data->inst_variables.p_output_ev[branch_nr].value
89 #define SK_CONDUCTANCE( branch_nr, ctrl_ev_nr) \
90 p_i_data->inst_variables.p_output_ev[branch_nr].p_derivatives[ctrl_ev_nr]
91 #define SK_BRANCH_CHARGE( branch_nr) \
92 p_i_data->inst_variables.p_output_ev[branch_nr].value
93 #define SK_CAPACITANCE( branch_nr, ctrl_ev_nr) \
94 p_i_data->inst_variables.p_output_ev[branch_nr].p_derivatives[ctrl_ev_nr]
95
96 /* Insert noise in the instance variables structure */
97 #define SK_SET_BIAS_DEP_NOISE( source_nr, value ) p_i_data->inst_variables.p_bias_dep_noise_parts[source_nr] = value;
98 #define SK_SET_FREQ_DEP_NOISE( source_nr, value ) p_i_data->inst_variables.p_freq_dep_noise_parts[source_nr] = value;
99
100
101 /********************************************************************
102 * D A T A D E C L A R A T I O N S *
103 ********************************************************************/
104
105 typedef unsigned int sk_unint;
106 typedef unsigned int SK_MASK_TYPE;
107
108 typedef SK_MASK_TYPE SK_AFFECTS_TYPE;
109 #define SK_AT_AFFECTS_NONE 0x0000
110 #define SK_AT_TEMP_AFFECTS 0x0001
111 #define SK_AT_AFFECTS_OP_POINT 0x0002
112 #define SK_AT_OP_POINT_AFFECTS 0x0004
113
114 typedef SK_MASK_TYPE SK_INIT_CONTROL;
115 #define SK_IC_EVAL_COMMON_PARAMS 0x0001
116 #define SK_IC_GEOM_SCALING 0x0002
117 #define SK_IC_TEMP_SCALING 0x0004
118 #define SK_IC_MULT_SCALING 0x0008
119
120 typedef SK_MASK_TYPE SK_EVAL_CONTROL;
121 #define SK_EC_CURRENTS 0x0001
122 #define SK_EC_CHARGES 0x0002
123 #define SK_EC_CONDUCTANCES 0x0004
124 #define SK_EC_CAPACITANCES 0x0008
125 #define SK_EC_OP_INFO 0x0010
126 #define SK_EC_BIAS_DEP_NOISE 0x0020
127 #define SK_EC_FREQ_DEP_NOISE 0x0040
128 #define SK_EC_H_NOISE 0x0080
129 #define SK_EC_U_NOISE 0x0100
130 #define SK_EC_H_NOISE_ADS 0x0200
131
132 typedef SK_MASK_TYPE SK_CLIP_TYPE;
133 #define SK_CB_NONE 0x0000
134 #define SK_CB_LOWER 0x0001
135 #define SK_CB_UPPER 0x0010
136 #define SK_CB_BOTH 0x0011
137
138 /**
139 * Parameter scaling types to support the Spectre 'scale' parameter.
140 * Maxiset instance parameters that have a length in their unit, are scaled.
141 * For example, the value of a parameter with unit "m^2" is
142 * multiplied by factor^2. This also goes for complex units, e.g. m^2/V.
143 */
144 typedef enum
145 {
146 SK_SF_NONE, /**< no length unit */
147 SK_SF_DIVIDE, /**< 1/m */
148 SK_SF_POW_MIN_TWO, /**< 1/m^2 */
149 SK_SF_POW_MIN_THREE, /**< 1/m^3 */
150 SK_SF_POW_MIN_FOUR, /**< 1/m^4 */
151 SK_SF_MULTIPLY, /**< m */
152 SK_SF_POW_TWO, /**< m^2 */
153 SK_SF_POW_THREE, /**< m^3 */
154 SK_SF_POW_FOUR /**< m^4 */
155 } SK_SCALING_FACTOR;
156
157 /* Model family type for several uses:
158 * 1) Determine which initial guess to use by default
159 * 2) Determine if Vds limiting should be performed (unwanted SD interchange)
160 * (Pstar only)
161 */
162 typedef enum
163 {
164 SK_MODEL_FAMILY_MOST, /* SD interchange limiting */
165 SK_MODEL_FAMILY_BJT, /* exponent limiting */
166 SK_MODEL_FAMILY_GENERIC /* no special processing */
167 } SK_MODEL_FAMILY;
168
169 /* SK_device_type for internal use (p_data->type) and calling of init_model() */
170 #define SK_DT_N 0x0001
171 #define SK_DT_P 0x0002
172 #define SK_DT_NPN 0x0004
173 #define SK_DT_PNP 0x0008
174 #define SK_DT_NPNV 0x0010
175 #define SK_DT_PNPV 0x0020
176 #define SK_DT_NPNL 0x0040
177 #define SK_DT_PNPL 0x0080
178 #define SK_DT_NONE 0x4000
179 #define SK_DT_DEFAULT 0x8000
180
181 /* ADS known only N or P, so use these. NEVER use these in the models! */
182 #define SK_DT_GENERIC_N (SK_DT_N | SK_DT_NPN | SK_DT_NPNV | SK_DT_NPNL)
183 #define SK_DT_GENERIC_P (SK_DT_P | SK_DT_PNP | SK_DT_PNPV | SK_DT_PNPL)
184
185 #define SK_NODE_NUMBER_NONE -1
186
187 typedef enum
188 {
189 SK_ND_NONE,
190 SK_ND_TERMINAL,
191 SK_ND_INTERNAL_NODE
192 } SK_NODE_TYPE;
193
194 typedef enum
195 {
196 SK_ST_ON,
197 SK_ST_OFF,
198 SK_ST_SHORT
199 } SK_STATUS_TYPE;
200
201 typedef enum
202 {
203 SK_ERR_NONE,
204 SK_ERR_PARAMETER_NOT_READABLE,
205 SK_ERR_PARAMETER_NOT_WRITEABLE,
206 SK_ERR_UNKNOWN_PARAMETER,
207 SK_ERR_UNKNOWN_TYPE_STRING,
208 SK_ERR_LIMITED
209 } SK_ERROR;
210
211 typedef struct
212 {
213 const int number;
214 const char *p_name;
215 const SK_NODE_TYPE type;
216 } SK_NODE;
217
218 typedef struct
219 {
220 const sk_unint number;
221 const char *p_name;
222 const SK_NODE *p_pos_node;
223 const SK_NODE *p_neg_node;
224 const sk_unint n_ctrl_ev;
225 const sk_unint *p_ctrl_ev_index;
226 } SK_BRANCH;
227
228
229 /*
230 * Noise types
231 * SK_NT_THERMAL : noise is neither function of frequency nor time varying
232 * SK_NT_SHOT : noise is time varying, but not a function of frequency
233 * SK_NT_FLICKER : noise = |h(t)|/frequency
234 * SK_NT_UNCORR : general case where noise = |h(t)|*|U(|h(t)|,f)|
235 * SK_NT_CORR_REAL : general case of real correlated sources
236 * SK_NT_CORR_IMAG : general case of imag correlated sources
237 */
238 typedef enum
239 {
240 SK_NT_THERMAL,
241 SK_NT_SHOT,
242 SK_NT_FLICKER,
243 SK_NT_UNCORR,
244 SK_NT_CORR_REAL,
245 SK_NT_CORR_IMAG
246 } SK_NOISE_TYPE;
247
248 /*
249 * noise sources:
250 * The spectral current density is given by noise = |h(t)|*|U(|h|,f)|.
251 * So for each source there is a bias dep part h(t) and a
252 * freq dep part u(|h|,f). If a u-function also depends on h-functions
253 * of other sources, then p_foreign_h_index is used to store
254 * source number of these noise sources.
255 * The p_foreign_h_index is set in the model code.
256 * Currently only mos1100 and mos1101 have noise source sight for which
257 * p_foreign_h_index is used.
258 * The p_foreign_h_index can be used for all noise types (SK_NOISE_TYPE).
259 * The nodes p_pos/neg_node_corr are used to model correlated noise sources.
260 */
261 typedef struct
262 {
263 const sk_unint number;
264 const char *p_name;
265 const SK_NOISE_TYPE type;
266 const SK_NODE *p_pos_node;
267 const SK_NODE *p_neg_node;
268 const SK_NODE *p_pos_node_corr;
269 const SK_NODE *p_neg_node_corr;
270 const sk_unint n_foreign_h;
271 const sk_unint *p_foreign_h_index;
272 } SK_NOISE_SOURCE;
273
274 /* limiting */
275 typedef enum
276 {
277 SK_LIM_MOS,
278 SK_LIM_BJT
279 } SK_LIM_TYPE;
280
281 typedef struct
282 {
283 sk_real result;
284 sk_real result_rhs;
285 sk_real dresult_dV;
286 sk_real dresult_dT;
287 sk_real d2result_ddV;
288 sk_real d2result_dTdV;
289 } SK_EXPLIM_RESULTS;
290
291
292 typedef struct
293 {
294 sk_real Imax;
295 sk_real Is;
296 sk_real dIs_dT;
297 sk_real One_over_Vt;
298 sk_real dOne_over_Vt_dT;
299 /* V_check */
300 sk_real V_check;
301
302 } SK_EXPLIM_PARAMS;
303
304
305 typedef struct
306 {
307 SK_LIM_TYPE limiting_type;
308 sk_real Vmax;
309 sk_real Imax;
310 sk_boolean inverse_function_applied;
311 sk_boolean dc_or_disc_timestep;
312 sk_unint iter_count;
313
314 SK_ERROR (*p_eval_diode) (
315 sk_real ISt,
316 sk_real *p_Vd,
317 sk_real Vd_prev,
318 sk_real nvt,
319 sk_real *p_rhs,
320 sk_real *p_jac,
321 sk_real v_check,
322 sk_real min_jac,
323 sk_boolean spec_approx,
324 sk_boolean dc_or_disc_timestep,
325 sk_integer iter_count,
326 sk_boolean *p_inverse_func_applied,
327 sk_real *p_value );
328
329 SK_ERROR (*p_eval_exp) (
330 sk_real x, /* in */
331 sk_real x0, /* in */
332 sk_real *p_value, /* out */
333 sk_real *p_dvalue ); /* out */
334
335 SK_ERROR (*p_eval_v_check) (
336 sk_real Is, /* in */
337 sk_real Imax, /* in */
338 sk_real Vt, /* in */
339 sk_real *p_v_check ); /* out */
340
341 SK_ERROR (*p_limit_temperature) (
342 sk_real *p_T,
343 sk_real T_prev,
344 sk_boolean spec_approx,
345 sk_integer iter_count,
346 sk_boolean *p_inverse_func_applied );
347 /* Functions eval_v_check_new, eval_exp, eval_diode with temperature derivatives */
348 /* Init values for linearized exp(V/Vt) */
349 SK_ERROR (*p_eval_v_check_new) (
350 sk_real Imax, /* in */
351 sk_real Is, /* in */
352 sk_real dIs_dT, /* in */
353 sk_real One_over_Vt, /* in */
354 sk_real dOne_over_Vt_dT, /* in */
355 SK_EXPLIM_PARAMS *p_params ); /* out */
356
357 /* Calculates the possibly linearized exp(V/Vt) */
358 SK_ERROR (*p_eval_explim_new) (
359 sk_real V, /* in */
360 SK_EXPLIM_PARAMS *p_params, /* in */
361 SK_EXPLIM_RESULTS *p_results); /* out */
362
363 /* Calculates the possibly linearized Is*(exp(V/Vt) -1) */
364 SK_ERROR (*p_eval_diode_new) (
365 sk_real *p_Vd,
366 sk_real Vd_prev,
367 sk_real min_jac,
368 sk_boolean spec_approx,
369 sk_boolean dc_or_disc_timestep,
370 sk_integer iter_count,
371 sk_boolean *p_inverse_func_applied,
372 SK_EXPLIM_PARAMS *p_params,
373 SK_EXPLIM_RESULTS *p_results );
374
375 } SK_LIMITING;
376
377 /* New initial guess */
378
379 typedef enum
380 {
381 /* Spectre */
382 SK_IG_OFF_SPECTRE,
383 SK_IG_TRIODE,
384 SK_IG_SATURATION,
385 SK_IG_SUBTHRESHOLD,
386 SK_IG_REVERSE,
387 SK_IG_FORWARD,
388 SK_IG_BREAKDOWN,
389
390 /* Pstar */
391 SK_IG_DEFAULT,
392 SK_IG_ON,
393 SK_IG_OFF_PSTAR,
394
395 SK_IG_N_REGION
396 } SK_INITIAL_GUESS_TYPE;
397
398 typedef sk_real SK_INITIAL_EV;
399 typedef unsigned SK_REGION;
400
401 /* Definition structure for EVs. One per EV. */
402 typedef struct
403 {
404 const SK_INITIAL_EV *p_initial_value;
405 const SK_NODE *p_pos_node;
406 const SK_NODE *p_neg_node;
407 } SK_EV_DESCRIP;
408
409 /* Value storage for EVs. One per EV. */
410 typedef struct SK_ev
411 {
412 sk_real value;
413 sk_real previous_value;
414 sk_real not_truncated_value;
415 sk_boolean is_truncated;
416 sk_boolean is_initial_guess;
417 const SK_EV_DESCRIP *p_ev_descrip;
418 } SK_EV;
419
420 /* Value storage for output variables (currents, charges and their derivatives).
421 One per branch. */
422 typedef struct
423 {
424 sk_real value;
425 sk_real *p_derivatives;
426 const SK_BRANCH *p_ev_descrip;
427 } SK_OUTPUT_EV;
428
429
430 /* data structure used to transfer the bias from the adapter */
431 /* to the Modelkit and to transfer the calculated quantities */
432 /* from the Modelkit to the simulator adapters */
433
434 typedef struct
435 {
436 sk_real Real;
437 sk_real Imag;
438 } SK_COMPLEX;
439
440 typedef struct
441 {
442 /* EVs. Number of entries = N_EV */
443 SK_EV *p_ev;
444
445 /* Output values and derivatives. Number of entries = N_TOTAL_BRANCHES */
446 SK_OUTPUT_EV *p_output_ev;
447
448 /* noise */
449 /* entries : [N_NOISE_SOURCES] */
450 sk_real *p_bias_dep_noise_parts;
451 sk_real *p_freq_dep_noise_parts;
452
453 /* topology modifier */
454 SK_STATUS_TYPE *p_branch_status;
455 /* N_TOTAL_BRANCHES entries */
456 SK_STATUS_TYPE *p_noise_source_status;
457 /* N_NOISE_SOURCES entries */
458
459 sk_real *p_opo_values;
460 /* points to start of operating parameter section
461 within values array of inst_data structure (JvP, May 16 2002) */
462 /* limiting*/
463 SK_LIMITING *p_limit_info;
464
465 /* didv_min enabler */
466 sk_boolean insert_didvmin;
467 } SK_INST_VARIABLES;
468
469
470 /* transfers simulation data from the simulator to the model */
471 typedef struct
472 {
473 sk_real temperature;
474 /* needed for temperature scaling */
475 /* ( eval_int_params() ) */
476
477 sk_real frequency;
478 /* needed for frequency dependent */
479 /* noise density calculation */
480 /* ( eval_model() ) */
481
482 sk_real inst_scale;
483 /* needed for scaling in spectre */
484 /* ( eval_int_params() ) */
485 /* ( get_inst_params() ) */
486 } SK_SIM_DATA;
487
488
489 /* Parameter types */
490 #define SK_PT_NONE 0x0000
491 #define SK_PT_MAXISET_MODEL 0x0001
492 #define SK_PT_MAXISET_INST 0x0002
493 #define SK_PT_MINISET 0x0004
494 #define SK_PT_ELECTRICALSET 0x0008
495 #define SK_PT_OPERATINGPOINT 0x0010
496 typedef SK_MASK_TYPE SK_PARAM_TYPE;
497
498 /* parameter descriptor */
499 typedef struct
500 {
501 const sk_unint number;
502 const char *p_name;
503 const char *p_description;
504 const char *p_unit;
505 const sk_boolean is_readable;
506 const sk_boolean is_writeable;
507 const sk_boolean is_model_param;
508 const SK_SCALING_FACTOR scaling_type;
509 const SK_CLIP_TYPE clip_type_n;
510 const SK_CLIP_TYPE clip_type_p;
511 const sk_real clip_low_n;
512 const sk_real clip_low_p;
513 const sk_real clip_high_n;
514 const sk_real clip_high_p;
515 const sk_real default_value_n;
516 const sk_real default_value_p;
517 const SK_AFFECTS_TYPE dependency;
518 const SK_PARAM_TYPE param_type;
519 } SK_PARAM_DESCRIPTOR;
520
521
522 /* parameter descriptor define for unused fields */
523 #define SK_NOT_USED 0
524
525
526 /* Model and instance parameters together form the maxiset */
527 #define SK_PARAM_MAXI_MODEL(name, p_descr, p_unit, \
528 clip_type_n, clip_type_p, \
529 clip_low_n, clip_low_p, clip_high_n, clip_high_p, default_n, default_p) \
530 static SK_PARAM_DESCRIPTOR PARAM_MAXI_MODEL_ ## name = \
531 { \
532 PARNUM_MAXI_MODEL_ ## name, \
533 #name, \
534 p_descr, \
535 p_unit, \
536 TRUE, TRUE, TRUE, \
537 SK_SF_NONE, \
538 clip_type_n, clip_type_p, \
539 clip_low_n, clip_low_p, \
540 clip_high_n, clip_high_p, \
541 default_n, default_p, \
542 SK_AT_AFFECTS_OP_POINT, \
543 SK_PT_MAXISET_MODEL \
544 }
545
546 #define SK_PARAM_MAXI_INST(name, p_descr, p_unit, scaling_type, \
547 clip_type_n, clip_type_p, \
548 clip_low_n, clip_low_p, clip_high_n, clip_high_p, default_n, default_p) \
549 static SK_PARAM_DESCRIPTOR PARAM_MAXI_INST_ ## name = \
550 { \
551 PARNUM_MAXI_INST_ ## name, \
552 #name, \
553 p_descr, \
554 p_unit, \
555 TRUE, TRUE, FALSE, \
556 scaling_type, \
557 clip_type_n, clip_type_p, \
558 clip_low_n, clip_low_p, \
559 clip_high_n, clip_high_p, \
560 default_n, default_p, \
561 SK_AT_AFFECTS_OP_POINT, \
562 SK_PT_MAXISET_INST \
563 }
564
565 /* miniset */
566 #define SK_PARAM_MINI(name, p_descr, p_unit, clip_type_n, clip_type_p, \
567 clip_low_n, clip_low_p, clip_high_n, clip_high_p) \
568 static SK_PARAM_DESCRIPTOR PARAM_MINI_ ## name = \
569 { \
570 PARNUM_MINI_ ## name, \
571 #name, \
572 p_descr, \
573 p_unit, \
574 FALSE, FALSE, FALSE, \
575 SK_SF_NONE, \
576 clip_type_n, clip_type_p, \
577 clip_low_n, clip_low_p, \
578 clip_high_n, clip_high_p, \
579 SK_NOT_USED, SK_NOT_USED, \
580 SK_AT_AFFECTS_OP_POINT, \
581 SK_PT_MINISET \
582 }
583
584 /* electrical set */
585 #define SK_PARAM_ELEC(name, p_descr, p_unit, clip_type_n, clip_type_p, \
586 clip_low_n, clip_low_p, clip_high_n, clip_high_p) \
587 static SK_PARAM_DESCRIPTOR PARAM_ELEC_ ## name = \
588 { \
589 PARNUM_ELEC_ ## name, \
590 #name, \
591 p_descr, \
592 p_unit, \
593 TRUE, FALSE, FALSE, \
594 SK_SF_NONE, \
595 clip_type_n, clip_type_p, \
596 clip_low_n, clip_low_p, \
597 clip_high_n, clip_high_p, \
598 SK_NOT_USED, SK_NOT_USED, \
599 SK_AT_AFFECTS_OP_POINT | SK_AT_TEMP_AFFECTS, \
600 SK_PT_ELECTRICALSET \
601 }
602
603 /* Operating point */
604 #define SK_PARAM_OP(name, p_descr, p_unit) \
605 static SK_PARAM_DESCRIPTOR PARAM_OP_ ## name = \
606 { \
607 PARNUM_OP_ ## name, \
608 #name, \
609 p_descr, \
610 p_unit, \
611 TRUE, FALSE, FALSE, \
612 SK_SF_NONE, \
613 SK_NOT_USED, SK_NOT_USED, \
614 SK_NOT_USED, SK_NOT_USED, \
615 SK_NOT_USED, SK_NOT_USED, \
616 SK_NOT_USED, SK_NOT_USED, \
617 SK_AT_OP_POINT_AFFECTS, \
618 SK_PT_OPERATINGPOINT \
619 }
620
621
622 /* Access parameter values */
623 #define MM(a) p_m_data->values[PARNUM_MAXI_MODEL_##a]
624 #define MI(a) p_i_data->values[PARNUM_MAXI_INST_##a-N_MODEL_PARAMS]
625 #define MS(a) p_i_data->values[PARNUM_MINI_##a-N_MODEL_PARAMS]
626 #define ES(a) p_i_data->values[PARNUM_ELEC_##a-N_MODEL_PARAMS]
627 #define OP(a) p_i_data->values[PARNUM_OP_##a-N_MODEL_PARAMS]
628 #ifdef SELFHEATING
629 #define ES_dVT(a) p_i_data->values_dVT[PARNUM_ELEC_##a-N_MODEL_PARAMS]
630 #endif
631
632
633 /* Macros for testing parameter states */
634 #define SK_IS_PARAM_READABLE(p_param) ((p_param)->is_readable)
635 #define SK_IS_PARAM_WRITEABLE(p_param) ((p_param)->is_writeable)
636 #define SK_IS_TEMP_AFFECTS_PARAM(p_param) \
637 ((p_param)->dependency & SK_AT_TEMP_AFFECTS)
638 #define SK_IS_OP_AFFECTS_PARAM(p_param) \
639 ((p_param)->dependency & SK_AT_OP_POINT_AFFECTS)
640 #define SK_IS_PARAM_AFFECTS_OP(p_param) \
641 ((p_param)->dependency & SK_AT_AFFECTS_OP_POINT)
642
643
644 /* model descriptor */
645 typedef struct
646 {
647 const sk_real gmin;
648 const sk_real didv_min;
649 const sk_real version_nr;
650 const char *p_name;
651 const char *p_title;
652 const sk_unint n_terminals;
653 const sk_unint n_static_branches;
654 const sk_unint n_static_linear_branches;
655 const sk_unint n_dynamic_branches;
656 const sk_unint n_dynamic_linear_branches;
657 const sk_unint n_gmin_branches;
658 const sk_unint n_didvmin_branches;
659 const sk_unint n_noise_sources;
660 const sk_unint n_int_nodes;
661 const SK_BRANCH *p_branch_DS; /* For MOS unwanted SD interch.*/
662 const SK_NODE **pp_term_nodes;
663 const SK_NODE **pp_int_nodes;
664 const sk_unint n_model_params;
665 const sk_unint n_inst_params;
666 const sk_unint n_op_info;
667 const sk_unint model_data_size;
668 const sk_unint inst_data_size;
669 const SK_PARAM_DESCRIPTOR **pp_params; /* Please note: it is assumed
670 this array contains
671 n_model_params model params
672 followed by n_inst_params
673 instance parameters followed
674 by n_op_info op point
675 parameters. */
676 const SK_BRANCH **pp_static_branches;
677 const SK_BRANCH **pp_static_linear_branches;
678 const SK_BRANCH **pp_dynamic_branches;
679 const SK_BRANCH **pp_dynamic_linear_branches;
680 const SK_BRANCH **pp_gmin_branches;
681 const SK_BRANCH **pp_didvmin_branches;
682 const SK_NOISE_SOURCE **pp_noise_sources;
683
684 /* interface functions */
685 SK_ERROR (*p_init_model) ( void *p_model_data,
686 int model_type );
687
688 SK_ERROR (*p_init_inst) ( const void *p_model_data,
689 void *p_inst_data,
690 SK_INST_VARIABLES **pp_inst_variables,
691 const char* p_inst_name,
692 const char** pp_occ_ind,
693 const char** pp_sit );
694
695 SK_ERROR (*p_set_model_params) ( void *p_model_data,
696 const sk_unint *p_param_id_list,
697 const sk_real *p_value_list,
698 const sk_unint n_params,
699 sk_boolean *p_is_param_changed );
700
701 SK_ERROR (*p_set_inst_params) ( void *p_inst_data,
702 const sk_unint *p_param_id_list,
703 const sk_real *p_value_list,
704 const sk_unint n_params,
705 sk_boolean *p_is_param_changed );
706
707 SK_ERROR (*p_get_model_params) ( const void *p_model_data,
708 const sk_unint *p_param_id_list,
709 sk_real *p_value_list,
710 const sk_unint n_params,
711 const SK_SIM_DATA *p_sim_data );
712
713 SK_ERROR (*p_get_inst_params) ( const void *p_inst_data,
714 const sk_unint *p_param_id_list,
715 sk_real *p_value_list,
716 const sk_unint n_params,
717 const SK_SIM_DATA *p_sim_data );
718
719 SK_ERROR (*p_reset_model_params)( void *p_model_data,
720 const sk_unint *p_param_id_list,
721 const sk_unint n_params );
722
723 SK_ERROR (*p_reset_inst_params) ( const void *p_model_data,
724 void *p_inst_data,
725 const sk_unint *p_param_id_list,
726 const sk_unint n_params );
727
728 SK_ERROR (*p_eval_int_params) ( void *p_model_data,
729 void *p_inst_data,
730 const SK_SIM_DATA *p_sim_data,
731 const SK_INIT_CONTROL flag );
732
733 SK_ERROR (*p_eval_model) ( const void *p_model_data,
734 void *p_inst_data,
735 const SK_SIM_DATA *p_sim_data,
736 const SK_EVAL_CONTROL flag );
737
738 SK_ERROR (*p_eval_u_noise) ( const void *p_model_data,
739 const void *p_inst_data,
740 sk_unint noise_src_number,
741 const sk_real frequency,
742 SK_COMPLEX *p_h_noise,
743 SK_COMPLEX *p_u_noise);
744
745 /* start new initial guess */
746 const sk_unint n_ev;
747 const sk_boolean *p_ev_ig_available;
748 const SK_EV_DESCRIP **pp_ev_descrip;
749
750 SK_MODEL_FAMILY model_family;
751 } SK_MODEL;
752
753 /******************************************************************************/
754
755 /* Interface that the models use to report info / warnings / errors to the
756 _simulator_ (as opposed to the adapter, which uses SK_ERROR). The adapter
757 implements the function below which converts this information to simulator
758 specific status reporting. */
759
760 typedef enum
761 {
762 SK_REP_NONE,
763 SK_REP_COPYRIGHT_NOTICE,
764 SK_REP_PARAMETER_CLIPPED,
765 SK_REP_NEGATIVE_WEFF,
766 SK_REP_NEGATIVE_LEFF,
767 SK_REP_INFO_TEXT,
768 SK_REP_PARAMETER_READONLY,
769 SK_REP_PARAMETER_UNKNOWN,
770 SK_REP_SIMKIT_MESSAGE,
771 SK_REP_DEVICE_TOO_HOT,
772 SK_REP_OUT_OF_MEMORY,
773 SK_REP_FAILED_GEOM_CHECK
774 } SK_REPORT_STATUS;
775
776 /**
777 * Type of a function to report warnings, errors and debug output in a simulator
778 * specific way. This function may be called by the adapter
779 * itself or any model.
780 * @param aStatus Message type
781 * @param anInfo Strings to be put in the message
782 */
783 typedef void (*SK_REPORT_TO_SIMULATOR_FUNC)(SK_REPORT_STATUS aStatus, const char* anInfo[]);
784
785 #define SK_REPORT_INFO_SIZE 6
786
787 #define COMPLEX_MULT_ASSIGN(u, v) { \
788 sk_real r_real,r_imag; \
789 r_real=(u).Real*(v).Real-(u).Imag*(v).Imag; \
790 r_imag=(u).Real*(v).Imag+(u).Imag*(v).Real; \
791 (u).Real=r_real; \
792 (u).Imag=r_imag; \
793 }
794
795 #define COMPLEX_DIV_ASSIGN(u, v) { \
796 sk_real r_real,r_imag,norm2; \
797 norm2=(v).Real*(v).Real+(v).Imag*(v).Imag; \
798 r_real=(u).Real*(v).Real+(u).Imag*(v).Imag; \
799 r_imag=-(u).Real*(v).Imag+(u).Imag*(v).Real; \
800 (u).Real=r_real/norm2; \
801 (u).Imag=r_imag/norm2; \
802 }
803
804
805 /******************************************************************************/
806
807 /* DATA DECLARATIONS (no structures) */
808 /* defines / typedefs / macros ... */
809
810 /*----------------------- Type definitions ---------------------------------*/
811
812 /* Defines for boolean values */
813
814 #ifndef FALSE
815 #define FALSE 0
816 #define TRUE 1
817 #endif
818
819 /*------------------------- Release flag dependent -------------------------*/
820
821 #ifdef RELEASE
822 #define MAINTENANCE FALSE /* Release version */
823 #else
824 #define MAINTENANCE TRUE /* Development version */
825 #endif
826
827 /*------------------------- Computer system macros -------------------------*/
828
829
830 /*----------------------- Computer system definition -----------------------*/
831
832 #define EBCDIC FALSE
833 #define CASE_SENSITIVE_FILENAMES TRUE
834 #define LOWERCASE_FILENAMES TRUE
835 #define FLEX_LM TRUE
836 #define MIXED_SIGNAL_SUPPORT TRUE
837
838 #undef tolower
839 #define tolower(c) ( isupper(c) ? ((c)-'A'+'a') : (c) )
840
841 #undef toupper
842 #define toupper(c) ( islower(c) ? ((c)-'a'+'A') : (c) )
843
844
845 /*------------------------ Definitions for Constants -----------------------*/
846
847 /* VAX-11 constants !! */
848 #define MIN_INTEGER ((long int) -2147483647)
849 #define MAX_INTEGER 2147483647
850 #define MIN_NUMBER 3.0E-39
851 #define MAX_NUMBER 1.7E38
852 #define UNDEF_NUMBER 1.654321E38
853 #define UNDEF_BOF_RESULT 1.6E38
854 #define N_SIGNIFICANT_DIGITS 14
855
856 /* constants dependent on VAX-11 constants;
857 * requirements: 1/P_INFINITY > MIN_NUMBER
858 * and
859 * TOLERANCE exponent <= N_SIGNIFICANT_DIGITS
860 */
861 #define P_INFINITY (MAX_NUMBER/100.0)
862 #define TOLERANCE 1.0E-12
863
864 #ifdef LN_MINDOUBLE
865 #undef LN_MINDOUBLE
866 #endif
867 #define LN_MINDOUBLE -800.0
868
869
870 /*---------------------------------------------------------------------------*
871 * Fundamental Physical Constants *
872 * source: Handbook of Chemistry and Physics, 54th edition, 1973 *
873 *---------------------------------------------------------------------------*/
874 #define PI 3.14159265358979323844 /* 21 decimal digits */
875 #define TWOPI 6.28318530717958647688 /* 21 decimal digits */
876 #define SQRT2 1.41421356237309504880 /* 21 decimal digits */
877 #define DEGPERRAD 57.29577951308232087721 /* 22 decimal digits */
878 #define Q_ELECTRON 1.6021918E-19 /* Electron charge (C) */
879 #define K_BOLTZMANN 1.3806226E-23 /* Boltzmann's constant (J/K)*/
880 #define EPSILON_0 8.854214871e-12 /* diele.con. (F/m) */
881 #define EPSILON_OX 3.453143800e-11 /* permittivity of SiO2 (F/m)*/
882 #define EPSILON_SI (11.7*EPSILON_0) /* diele.con. of silicon(F/m)*/
883 #define KELVIN_CONVERSION 273.15 /* Celsius to Kelvin (K) */
884
885 /* Derived from these: */
886 #define K_B_div_Q_EL 8.61708691805812512584e-5
887
888 /* Macro to get rid of GCC's unused parameter warning. When using the GCC
889 compiler this applies the unused attribute and also mangles the variable
890 name so that you really can't use it. */
891 #ifdef __GNUC__
892 #define SK_UNUSED(x) UNUSED_ ## x __attribute__((unused))
893 #else
894 #define SK_UNUSED(x) x
895 #endif
896
897
898 #endif /* _SK_H */
899