1 /*****************************************************************************/
3 /* Chaine de CAO & VLSI AVERTEC */
5 /* Produit : SIM Version 2.00 */
6 /* Fichier : sim100.h */
8 /* (c) copyright 2000 AVERTEC */
9 /* Tous droits reserves */
11 /* Auteur(s) : Gilles Augustins */
14 /*****************************************************************************/
25 #include <sys/types.h>
29 #include <sys/resource.h>
49 extern int SIM_OUTLOAD
;
50 extern char *SIM_SPICE_OPTIONS
;
51 extern double SIM_OUT_CAPA_VAL
;
52 extern double SIM_INPUT_START
;
53 extern double SIM_TECSIZE
;
54 extern double SIM_VTH
;
55 extern double SIM_VTH_HIGH
;
56 extern double SIM_VTH_LOW
;
57 extern double SIM_SLOP
;
58 extern double SIM_SIMU_STEP
;
59 extern double SIM_DC_STEP
;
60 extern char *SIM_SPICESTRING
;
61 extern char *SIM_SPICEOUT
;
62 extern char *SIM_SPICENAME
;
63 extern char *SIM_SPICESTDOUT
;
64 extern char *SIM_TECHFILE
;
65 extern int SIM_SPI_TRANSISTOR_AS_INSTANCE
;
66 extern void *SIM_EXTRACT_RULE
;
67 extern char SIM_DEFAULT_DRIVE_NETLIST
;
68 extern char SIM_DEFAULT_OVR_FILES
;
69 extern char SIM_DEFAULT_REMOVE_FILES
;
70 extern float SIM_VT_SLOPEIN
;
72 /* Labels for measure */
73 #define SIM_DELAY_LABEL_STRING ((char*)"SIM_DELAY")
74 #define SIM_SLOPE_LABEL_STRING ((char*)"SIM_SLOPE")
75 #define SIM_DELAY_LABEL ((long)0xFF000002)
76 #define SIM_SLOPE_LABEL ((long)0xFF000003)
77 #define SIM_RC_DELAY_LABEL ((long)0xFF000000)
78 #define SIM_RC_SLOPE_LABEL ((long)0xFF000001)
79 #define SIM_LOOP_FEEDBACK_DELAY_LABEL "sim_loop_feed_back_delay"
80 #define SIM_LOOP_FEEDBACK_DELAY_PTYPE 0xFF000004
81 #define SIM_DELAY_TO_VT_LABEL "sim_command_delay_to_vt"
82 #define SIM_DELAY_TO_VT_PTYPE 0xFF000005
84 /* Precision for calcul and storage of real number */
85 #define SIM_FLOAT double
87 typedef SIM_FLOAT (*PWL_FUNCTION
) (SIM_FLOAT
, void *);
89 /* Different outload type */
91 #define SIM_NO_OUTLOAD ((int)0)
92 #define SIM_DYNAMIC_OUTLOAD ((int)1)
93 #define SIM_TRANSISTOR_OUTLOAD ((int)2)
95 /* Model of simulator - for netlist & technology interpretation */
96 #define SIM_TOOLMODEL_SPICE ((int)0) /* Berkeley or old ngspice */
97 #define SIM_TOOLMODEL_HSPICE ((int)1) /* Hspice family */
98 #define SIM_TOOLMODEL_ELDO ((int)2) /* Eldo family */
99 #define SIM_TOOLMODEL_TITAN ((int)3) /* Titan family */
101 /* Simulator - for external simulator linking */
102 #define SIM_TOOL_SPICE ((int)0) /* Berkeley or old Ngspice */
103 #define SIM_TOOL_HSPICE ((int)1) /* Hspice */
104 #define SIM_TOOL_ELDO ((int)2) /* Eldo */
105 #define SIM_TOOL_TITAN ((int)3) /* Titan */
106 #define SIM_TOOL_TITAN7 ((int)4) /* Titanv7 */
107 #define SIM_TOOL_LTSPICE ((int)5) /* Ltspice */
108 #define SIM_TOOL_MSPICE ((int)6) /* Mspice */
109 #define SIM_TOOL_NGSPICE ((int)7) /* Ngspice */
112 #define SIM_ZERO ((char)'0')
113 #define SIM_ONE ((char)'1')
116 #define SIM_YES ((char)'y')
117 #define SIM_NO ((char)'n')
119 /* Input description */
120 #define SIM_STUCK ((char)'t') /* Constant input */
121 #define SIM_SLOPE ((char)'s') /* Slope */
122 #define SIM_FUNC ((char)'f') /* Function */
123 #define SIM_MIMIC ((char)'m') /* Mimic */
124 #define SIM_NC ((char)'z') /* Not connected */
126 #define SIM_INPUT_SIGNAL ((char)'s')
127 #define SIM_INPUT_LOCON ((char)'l')
129 /* Measure description */
130 #define SIM_MEASURE_SIGNAL ((char)'s')
131 //#define SIM_MEASURE_SIGNAL_NODE ((char)'n')
132 #define SIM_MEASURE_LOCON ((char)'l')
135 #define SIM_MEASURE_VOLTAGE ((char)'v')
136 #define SIM_MEASURE_CURRENT ((char)'i')
137 #define SIM_MEASURE_NO ((char)'n')
138 #define SIM_MEASURE_LAST ((long) 1000000)
140 /* Stuck description */
141 #define SIM_STUCK_LEVEL ((char)'l') /* Logical 0 or 1 input */
142 #define SIM_STUCK_VALUE ((char)'v') /* Constant voltage generator */
144 /* Slope description */
145 #define SIM_SLOPE_SINGLE ((char)'s') /* Single slope */
146 #define SIM_SLOPE_PATTERN ((char)'p') /* Multiple splopes */
148 /* Return code from execution */
149 #define SIM_SIMU_COMPLETED ((char)'y')
150 #define SIM_SIMU_CANTRUN ((char)'n')
151 #define SIM_SIMU_NONIMPLEMENTED ((char)'i')
152 #define SIM_SIMU_CANTDRIVEFILE ((char)'f')
155 #define SIM_IC_LEVEL ((char)'l')
156 #define SIM_IC_VOLTAGE ((char)'v')
157 #define SIM_IC_NOIC ((char)'n')
159 #define SIM_IC_LOCON ((char)'c')
160 #define SIM_IC_SIGNAL ((char)'s')
161 //#define SIM_IC_SIGNAL_NODE ((char)'n')
163 /* Unit management */
164 #define SIM_UNIT_TIME ((SIM_FLOAT)1.0)
165 #define SIM_UNIT_LABEL_SPICE_TIME "s"
166 #define SIM_UNIT_CAPACITANCE ((SIM_FLOAT)1.0)
167 #define SIM_UNIT_LABEL_SPICE_CAPACITANCE "F"
168 #define SIM_UNIT_RESISTANCE ((SIM_FLOAT)1.0)
169 #define SIM_UNIT_LABEL_SPICE_RESISTANCE ""
170 #define SIM_UNIT_VOLTAGE ((SIM_FLOAT)1.0)
171 #define SIM_UNIT_LABEL_SPICE_VOLTAGE "V"
173 #define SIM_UNIT_X_TO_Y(x,unitx,unity) ((x)*(unitx)/(unity))
185 #define SIM_RUN_DRIVE 1
186 #define SIM_RUN_EXEC 2
187 #define SIM_RUN_READ 4
188 #define SIM_RUN_MULTI 8
189 #define SIM_RUN_ALL (SIM_RUN_DRIVE|SIM_RUN_READ|SIM_RUN_EXEC)
191 #define SIM_EXT_CAPA 0xfab11105
192 /* Definition of stuck */
194 char VALUE
; // SIM_ZERO, SIM_ONE
202 sim_stuck_voltage STUCK_VOLTAGE
;
203 sim_stuck_level STUCK_LEVEL
;
207 char TYPE
; // SIM_STUCK_LEVEL, SIM_STUCK_VALUE
211 /* Definition of slope */
213 char TRANSITION
; // SIM_RISE, SIM_FALL
226 sim_slope_single SLOPE_SINGLE
;
227 sim_slope_pattern SLOPE_PATTERN
;
231 char TYPE
; // SIM_SLOPE_SINGLE, SIM_SLOPE_PATTERN
236 SIM_FLOAT (*FUNC
)(SIM_FLOAT t
, void *data
);
247 /* Definition of input parameter */
249 sim_slope INPUT_SLOPE
;
250 sim_stuck INPUT_STUCK
;
252 sim_mimic_voltage INPUT_MIMIC
;
255 /* Input connector definition */
256 typedef struct sim_input
{
257 struct sim_input
*NEXT
;
260 char TYPE
; // SIM_STUCK, SIM_SLOPE, SIM_FUNC, SIM_LOAD
267 /* Important : due to hierarchical representation of name, there is no
268 namealloc() allocation for name. */
270 typedef struct sim_measure_detail
{
271 struct sim_measure_detail
*NEXT
;
272 char *NODE_NAME
; // nom original du noeud
273 char *PRINT_NAME
; // nom drive (alias du nom original)
275 } sim_measure_detail
;
277 typedef union sim_measure_where
{
280 } sim_measure_uwhere
;
282 typedef struct sim_measure
{
283 struct sim_measure
*NEXT
;
284 char TYPE
; // SIM_MEASURE_SIGNAL_NODE,SIM_MEASURE_SIGNAL, SIM_MEASURE_LOCON
285 char WHAT
; // SIM_MEASURE_VOLTAGE, SIM_MEASURE_CURRENT
286 sim_measure_uwhere WHERE
;
287 sim_measure_detail
*DETAIL
;
288 chain_list
*NODENAME
;
291 /* Initial condition */
293 typedef struct sim_ic_level
{
294 char LEVEL
; // SIM_ZERO, SIM_ONE
297 typedef struct sim_ic_voltage
{
301 typedef union sim_uic
{
303 sim_ic_voltage VOLTAGE
;
306 typedef union sim_ic_where
{
311 typedef struct sim_ic
{
314 char LOCATE
; // SIM_IC_LOCON, SIM_IC_SIGNAL
315 char TYPE
; // SIM_IC_LEVEL, SIM_IC_VOLTAGE.
317 chain_list
*NODENAME
;
321 /* Simulator configuration */
323 SIM_FLOAT ALIM_VOLTAGE_IN
;
324 SIM_FLOAT VSS_VOLTAGE_IN
;
325 SIM_FLOAT ALIM_VOLTAGE_OUT
;
326 SIM_FLOAT VSS_VOLTAGE_OUT
;
329 SIM_FLOAT VTHSTART
, VTHEND
;
332 SIM_FLOAT TRANSIANT_TMAX
;
333 SIM_FLOAT TRANSIANT_STEP
;
334 SIM_FLOAT SIMULATOR_STEP
;
337 char *TOOL_STDOUTFILE
;
339 chain_list
*TECHNOFILELIST
;
340 char DRIVE_NETLIST
; // SIM_YES, SIM_NO.
341 char OVR_FILES
; // SIM_YES, SIM_NO.
342 char REMOVE_FILES
; // SIM_YES, SIM_NO.
343 char NOISE_TYPE
; // SIM_MIN, SIM_MAX.
344 char TRANSISTOR_AS_INSTANCE
; // SIM_YES, SIM_NO.
345 PWL_FUNCTION PWL_FUNC
;
348 typedef struct sim_translate
350 struct sim_translate
*NEXT
;
360 sim_parameter PARAMETER
;
363 sim_measure
*LMEASURE
;
364 sim_translate
*TRANSLATION
;
375 char SUBCKTFILENAME
[256];
379 /* Results structure */
381 typedef struct sim_timing
{
382 struct sim_timing
*NEXT
;
383 char *ROOT4USR
; // noeud origine vu par l'utilisateur
384 char *NODE4USR
; // noeud destination vu par l'utilisateur
385 char *ROOT
; // noeud origine
386 char *NODE
; // noeud destination
387 SIM_FLOAT DELAY
; // delay entre root et node
388 SIM_FLOAT SLOPE
; // slope du noeud destinataire
389 char ROOTEVENT
; // SIM_FALL ou SIM_RISE
390 int IDXREVENT
; // INDEX of ROOT EVENT
391 char NODEEVENT
; // SIM_FALL ou SIM_RISE
392 int IDXNEVENT
; // INDEX of NODE EVENT
396 typedef struct sim_noise
{
397 struct sim_noise
*NEXT
;
398 char *NAME
; // nom du noeud vu par l'utilisateur
399 char *NODENAME
; // nom du noeud dans le circuit
400 SIM_FLOAT VTHNOISE
; // valeur du seuil de detection du bruit
401 SIM_FLOAT
*TAB
; // tableau contenant toutes les tensions du noeud
402 chain_list
*IDXPEAK
; // indice du bruit : DATA = int (indice du TAB)
403 chain_list
*IDXC
; // indice de passage au seuil : DATA = int (indice du TAB)
406 typedef struct sim_slopes
410 float time_low
, time_high
;
413 #define SIM_UNDEF ((SIM_FLOAT)3.14159e27)