malt-wr
constype.h
Go to the documentation of this file.
1 #include <math.h>
2 
3 #define NAME_LENGTH 40
4 #define LINE_LENGTH 100
5 #define LONG_LINE_LENGTH 512
6 
7 
8 /* OPTIONS */
9 
10 #define M_SET 0x0001
11 #define JM_SET 0x0002
12 #define H_SET 0x0004
13 #define JH_SET 0x0008
14 #define S_SET 0x0010
15 #define JS_SET 0x0020
16 #define R_SET 0x4000
17 #define JR_SET 0x8000
18 #define J_SET (JM_SET | JH_SET | JS_SET | JR_SET)
19 
20 #define Q_SET 0x0040
21 #define V_SET 0x0080
22 
23 #define P_SET 0x0100
24 
25 #define C_SET 0x0400
26 #define B_SET 0x0800
27 #define TWO_SET 0x1000
28 
29 #define ID_SET 0x00010000
30 #define IH_SET 0x00020000
31 #define IS_SET 0x00040000
32 
33 #define W_SET 0x00080000
34 
35 #define BATCH_SET 0x00080000
36 #define I_SET (ID_SET | IH_SET | IS_SET)
37 
38 #define LATCH_SET 0x00100000
39 
40 
41 #define COLLECT_PHASE 0
42 #define COLLECT_VOLTAGE 1
43 
44 #define COLLECT_BY_PHASE 0
45 #define COLLECT_BY_VOLTAGE 1
46 #define COLLECT_EDGES 2
47 
48 #define STEP_FORWARD 5
49 
50 #define RISING_EDGE 0
51 #define FALLING_EDGE 1
52 
53 
54 typedef float TIME;
55 typedef float PHASE;
56 typedef float VOLTAGE;
57 
58 #define MIN(x,y) (((x)<(y))?(x):(y))
59 #define MAX(x,y) (((x)<(y))?(y):(x))
60 
61 
62 typedef struct
63 {
64  /* maximum number of hull planes */
65  int maxplane;
66 
67  /* maximum number of iterations */
68  int maxiter;
69 
70  /* maximum number of iterations */
71  int miniter;
72 
73  /* pulse extraction method
74  possible values:
75  COLLECT_BY_PHASE = phase threshold method
76  COLLECT_BY_VOLTAGE = peak voltage method
77  */
79 
80  /* phase threshold that determines the exact moment
81  when the pulse apears */
83 
84  /* minimum expected value of the phase in simulated timepoints
85  closest to the phase threshold */
87 
88  /* maximum expected value of the phase in simulated timepoints
89  closest to the phase threshold */
91 
92  /* if this variable is set to 1 the time when the value of
93  the signal phase crosses the threshold is determined
94  by the use of interpolation;
95  if this variable is set to 0 the simulation point
96  with the value of phase closest to the threshold
97  is used;
98  */
100 
101  /* the minimum value of voltage peak that can be treated
102  as the RSFQ pulse */
104 
105  /* the minimum value of difference in phase between
106  two consucutive voltage peaks above which they are treated
107  as two separate pulses;
108  if the difference in phase is less than minimum
109  the peak with higher voltage level is assumed to be the pulse,
110  the other is ignored */
112 
113  /* ratio determining the timepoint within the clock cycle for which
114  the passfail test for proper phase is performed; */
116 
117  /* minimum difference between real and expected value of phase
118  threshold considered as test failure */
120 
121 /* accuracy in binary search for hold and setup times */
123 
124 /* timing search accuracy */
126 
127 /* maximum assumed variation of the output propagation delay resulting
128  from variation of circuit operating parameters */
130 
131 /* maximum assumed variation of the index corresponding to
132  max_delay_var in delay */
134 
135 /* min nr of simulation steps between passfail checktimes */
137 
138 /* marker, if inputs are to be checked for extra pulses */
140 
141 /* names of subdirectories: */
142  /* for input files */
143  char input_dir[NAME_LENGTH];
144 
145  /* for temporary files */
146  char tmp_dir[NAME_LENGTH];
147 
148  /* for output files */
149  char output_dir[NAME_LENGTH];
150 
151 /* call name for jspice: */
152  char spice_name[NAME_LENGTH];
153 
154 /* extensions: */
155  char circuit_ext[NAME_LENGTH];
156  char param_ext[NAME_LENGTH];
157  char print_ext[NAME_LENGTH];
158  char passfail_ext[NAME_LENGTH];
159  char phase_ext[NAME_LENGTH];
160  char step_ext[NAME_LENGTH];
161  char check_ext[NAME_LENGTH];
162  char avr_ext[NAME_LENGTH];
163  char hold_ext[NAME_LENGTH];
164  char setup_ext[NAME_LENGTH];
165  char separation_ext[NAME_LENGTH];
166  char good_ext[NAME_LENGTH];
167  char bad_ext[NAME_LENGTH];
168  char logic_ext[NAME_LENGTH];
169  char async_ext[NAME_LENGTH];
170  char hose_ext[NAME_LENGTH];
171  char report_ext[NAME_LENGTH];
172  char period_ext[NAME_LENGTH];
173  char comp_ext[NAME_LENGTH];
174  char nom_ext[NAME_LENGTH];
175  char init_ext[NAME_LENGTH];
176  char marg_ext[NAME_LENGTH];
177  char opt_ext[NAME_LENGTH];
178  char bound_ext[NAME_LENGTH];
179  char region_ext[NAME_LENGTH];
180  char timeinit_ext[NAME_LENGTH];
181  char signal_ext[NAME_LENGTH];
182 
183  /* circuit name */
184  char circuit_name[NAME_LENGTH];
185 
186  /* code of the program which is run;
187  used to modify the function of
188  the procedures called from the different
189  programs of the packet;
190  possible values of this variable are
191  given below;
192  */
193  int program;
194 
195  /* parameter set number */
196  char opt_num[NAME_LENGTH];
197 
198  /* command line options */
200 
201 /* OPTIONS FOR LATCHING LOGIC */
202 
203 /* average voltage in the "1" state */
204  double avr_one_volt;
205 
206 /* thresholds used to determine the position of the rising and falling
207  edge of the signal in MVTL logic */
209 
210 /* maximum voltage in the "0" state */
212 
213 /* minimum voltage in the "1" state */
214  double min_one_volt;
215 
216 /* minimum separation between rising and falling edge of the signal
217  in the latching logic */
219 
220 /* minimum interval between passfail checks */
222 
223 /* minimum interval between checkpoint and the rising edge of the signal
224  for nominal values of parameters */
226 
227 /* minimum interval between the falling edge of the signal
228  and the checkpoint for nominal values of parameters */
230 
231 /* ratio determining the timepoint within an interval
232  of high value of the clock signal, when the output signals
233  are checked for the correct value */
235 
236 } PARAMETERS;
237 
238 extern PARAMETERS param;
239 
240 
241 /* possible values of the field program in the structure PARAMETERS */
242 
243 #define HS_PROGRAM 0
244 #define INIT_PROGRAM 1
245 #define MARG_PROGRAM 2
246 #define OPT_PROGRAM 3
247 
248 typedef struct
249 {
250  /* minimum value of the generator parameter describing position of data
251  pulses within clock pulses */
253 
254  /* maximum value of the generator parameter describing position of data
255  pulses within clock pulses */
257 
258  /* maximum value of the generator parameter describing position of data
259  pulses within clock pulses */
261 
262  /* time step between subsequent simulations */
264 
265  /* number of input driven by the variable generator */
266  int input_nr;
267 
268  /* number of the input clock cycle for which the propagation delay
269  is computed */
271 
272  /* number of the output clock cycle for which the propagation delay
273  is computed */
275 
276 
277 } XY_PARAMETERS;
278 
279 
281 {
282 /* values describing the pulse */
283 
284  TIME t; /* position in time */
285  int index; /* # of sample */
286 
287  double val; /* voltage */
288  PHASE phase; /* phase */
289 
290 /* the following fields are used only when the pulse is extracted by phase: */
291  PHASE norm_phase; /* phase rounded to k*2*PI */
296 
297 /* pointers to the next and previous positions on the list */
298  struct PULSE_DESC* next;
299  struct PULSE_DESC* prev;
300 };
301 
302 typedef struct PULSE_DESC PULSE;
303 
304 
305 struct EDGE_DESC
306 {
307 /* values describing the pulse */
308 
309  TIME t; /* position in time */
310  int index; /* # of sample */
311 
312  double val; /* voltage */
313  int direction; /* edge type: 0 = rising; 1 = falling; */
314 
315 /* the more exact position of the pulse in time obtained by interpolation */
317 
318 /* pointers to the next and previous positions on the list */
319  struct EDGE_DESC* next;
320  struct EDGE_DESC* prev;
321 };
322 
323 typedef struct EDGE_DESC EDGE;
324 
325 
326 typedef struct
327 {
328 /* logical value of the signal in a given clk cycle */
329  int val;
330 
331 /* distance between the input/output pulse and the preceeding clk pulse */
333 
334 } LOGIC;
335 
336 
337 
339 {
340 /* output nr */
341  int sig_nr;
342 
343 /* point type = initial point or check point */
344  int type;
345 
346 /* index corresponding to the checkpoint */
347  int index;
348 
349 /* proper phase difference at the given output divided by pi */
350  int pi_phase;
351 
352 /* pointer to the next element of the list */
354 };
356 
357 
358 /* possible values of the field type */
359 #define REGULAR_CHECKPOINT 0
360 #define INIT_CHECKPOINT 1
361 
362 
363 typedef struct
364 {
365 /* number of signals traced */
367 
368 /* number of clk signals traced */
369  int clk_num;
370 
371 /* number of input signals traced */
372  int ins_num;
373 
374 /* number of internal signals traced */
376 
377 /* number of output signals traced */
378  int outs_num;
379 
380 /* names of the signals given by the designer */
381  char (*signal_names)[NAME_LENGTH];
382 
383 /* names of the signals used in jspice simulations */
384  char (*jspice_voltage_names)[NAME_LENGTH];
385 
386 /* names of the signals used in jspice simulations */
387  char (*jspice_phase_names)[NAME_LENGTH];
388 
389 /* number of the input with variable generator attached */
391 
392 /* time resolution (distance in time between two adjecant input samples) */
394 
395 /* time at which simulation tracing begins */
397 
398 /* number of input samples available */
400 
401 
402 /* array (of signal_num length) of pointers to the begining
403  of list of pulses (each pulse represented by the PULSE structure) */
405 
406 /* array (of signal_num length) of pointers to the current end
407  of list of pulses (each pulse represented by the PULSE structure) */
409 
410 /* array (of signal_num length) of pointers to the begining
411  of list of edges (each edge represented by the EDGE structure) */
413 
414 /* array (of signal_num length) of pointers to the current end
415  of list of edges (each edge represented by the EDGE structure) */
417 
418 /* array (of signal_num length) of initial logic values
419  of the signals in latching logic*/
421 
422 /* array (of signal_num length) of the current phases
423  for each signal (rounded to k*2*PI) */
425 
426 /* array (of signal_num length) of indices of the last samples
427  greater than the voltage threshold */
429 
430 /* array of points in time corresponding to clk pulses */
432 
433 /* number of clk cycles simulated */
435 
436 /* array (of signal_num length) of pointers to the beginnings
437  of arrays (of clk_cycles_nr length) of logic values in each traced node
438  (logic value in each clk cycle represented by the LOGIC structure) */
440 
441 /* array (of clk_cycles_nr length) of indices for which pass/fail
442  check is performed in passfail JSPICE control file;
443  they are chosen as laying in a given point of each clk_cycle; */
445 
446 /* array (of signal_num length) of indices corresponding to the points
447  where phase is sampled at the beginning of the simulation interval
448  being traced */
450 
451 /* array (of outs_num in length) of pointers to lists
452  of indices for which pass/fail check is performed in passfail
453  JSPICE control file;
454  the indices correspond to timepoints MAX_DELAY_VARIATION before and after
455  each output pulse; */
457 
459 
460 } SIGNALS;
461 
462 
463 typedef struct
464 {
465 /* hold or setup time */
467 
468 /* clk cycle in which hold/setup requirement is violated */
469  int cycle;
470 
471 /* # of input at which hold/setup requirement is violated */
472  int input;
473 
474 } HOLDSETUP;
475 
476 
477 
478 typedef union
479 {
480  struct
481  {
485  } t;
486  struct
487  {
491  } p;
492  struct
493  {
497  } v;
498 }
500 
501 
503 {
506  struct DELAYS_DESC *next;
507 };
508 
509 typedef struct DELAYS_DESC DELAYS;
510 
512 {
513  int *input_val;
516  struct INPUTS_DESC *next;
517 };
518 
519 typedef struct INPUTS_DESC INPUTS;
520 
521 
522 typedef struct
523 {
524  double val;
525  int sgn;
526  int param_nr;
527  int pseudo;
528  double error;
529 } MARGIN;
530 
531 
533 {
534  int x;
535  int y;
538 };
539 
541 
542 
544 {
545  int param_nr;
549  double delta_ratio;
550  double value;
553 };
554 
556 
557 /* possible values of the field choice_meth in the TIME_PARAM_STRUCT */
558 #define ADD_DELTA 'A'
559 #define MUL_BY_FACTOR 'M'
560 #define RANDOM_UNIFORM 'R'
561 #define RANDOM_NORMAL 'N'
562 
563 
565 {
566  int sig_num;
569 };
570 
572 
573 
575 {
576  int sig1_num;
578  int sig2_num;
581 };
582 
584 
585 
586 
TIME * clk_times
Definition: constype.h:431
struct async_checkpoint * next
Definition: constype.h:353
struct PULSE_DESC * next
Definition: constype.h:298
double avr_one_volt
Definition: constype.h:204
double delta_ratio
Definition: constype.h:549
TIME t
Definition: constype.h:284
int direction
Definition: constype.h:313
int clk_cycle
Definition: constype.h:505
DELAYS * last_delay
Definition: constype.h:515
struct PULSE_DESC * prev
Definition: constype.h:299
ASYNC_CHECK ** async_check_index
Definition: constype.h:456
int * last_index
Definition: constype.h:428
struct INPUTS_DESC * next
Definition: constype.h:516
struct TIME_PARAM_STRUCT * next
Definition: constype.h:552
double max_zero_volt
Definition: constype.h:211
TIME exact_time
Definition: constype.h:316
TIME min_time_delta
Definition: constype.h:393
TIME avr
Definition: constype.h:483
int * check_index
Definition: constype.h:444
PULSE ** sig_bgn
Definition: constype.h:404
int input_options
Definition: constype.h:199
TIME t
Definition: constype.h:309
int index
Definition: constype.h:285
float checkpoint_ratio
Definition: constype.h:115
int interpolate
Definition: constype.h:99
PULSE ** sig_end
Definition: constype.h:408
int var_in_nr
Definition: constype.h:390
double end_deviation_value
Definition: constype.h:548
int * initial_phase_index
Definition: constype.h:449
int clk_cycles_nr
Definition: constype.h:434
TIME max
Definition: constype.h:484
EDGE ** sig_edge_bgn
Definition: constype.h:412
int * input_val
Definition: constype.h:513
VOLTAGE max
Definition: constype.h:496
int signal_num
Definition: constype.h:366
double start_mean_value
Definition: constype.h:547
TIME * delta
Definition: constype.h:332
VOLTAGE avr
Definition: constype.h:495
PHASE * current_phase
Definition: constype.h:424
TIME delta
Definition: constype.h:466
DELAYS * delay
Definition: constype.h:514
TIME accuracy
Definition: constype.h:122
int inter_num
Definition: constype.h:375
int miniter
Definition: constype.h:71
int input
Definition: constype.h:472
PHASE min_pulse_phase_diff
Definition: constype.h:111
PHASE min_phase_thresh
Definition: constype.h:86
PARAMETERS param
Definition: init.c:10
TIME min_checks_interval
Definition: constype.h:221
PHASE p_above
Definition: constype.h:295
PHASE min_fail_thresh
Definition: constype.h:119
int val
Definition: constype.h:329
int outs_num
Definition: constype.h:378
PHASE nom_phase_thresh
Definition: constype.h:82
int out_clk_cycle
Definition: constype.h:274
#define NAME_LENGTH
Definition: constype.h:3
TIME min_interval_to_falledge
Definition: constype.h:229
TIME delta
Definition: constype.h:504
double min_one_volt
Definition: constype.h:214
struct EDGE_DESC * prev
Definition: constype.h:320
int clk_num
Definition: constype.h:369
LOGIC ** sig_log
Definition: constype.h:439
VOLTAGE min
Definition: constype.h:494
int program
Definition: constype.h:193
int min_time_step
Definition: constype.h:136
TIME min_interval_to_riseedge
Definition: constype.h:225
float PHASE
Definition: constype.h:55
int indices_nr
Definition: constype.h:399
int sgn
Definition: constype.h:525
EDGE ** sig_edge_end
Definition: constype.h:416
int index
Definition: constype.h:310
int max_index_var
Definition: constype.h:133
TIME time_accuracy
Definition: constype.h:125
TIME t_above
Definition: constype.h:293
PHASE p_below
Definition: constype.h:294
TIME min
Definition: constype.h:482
struct DELAYS_DESC * next
Definition: constype.h:506
double error
Definition: constype.h:528
TIME start_time
Definition: constype.h:396
float TIME
Definition: constype.h:54
int pulse_extraction_method
Definition: constype.h:78
float VOLTAGE
Definition: constype.h:56
VOLTAGE volt_thresh
Definition: constype.h:103
PHASE max
Definition: constype.h:490
double nom_edge_thresh
Definition: constype.h:208
TIME max_delay_var
Definition: constype.h:129
int param_nr
Definition: constype.h:526
struct SYNC_TIME_DELAY_STRUCT * next
Definition: constype.h:568
PHASE min
Definition: constype.h:488
int maxiter
Definition: constype.h:68
int pseudo
Definition: constype.h:527
double clk_chktime_ratio
Definition: constype.h:234
double val
Definition: constype.h:524
ASYNC_CHECK * async_check_list
Definition: constype.h:458
PHASE max_phase_thresh
Definition: constype.h:90
TIME min_edge_sep
Definition: constype.h:218
PHASE avr
Definition: constype.h:489
int inputs_checked
Definition: constype.h:139
int in_clk_cycle
Definition: constype.h:270
int * sig_initial
Definition: constype.h:420
int ins_num
Definition: constype.h:372
int maxplane
Definition: constype.h:65
struct ASYNC_TIME_DELAY_STRUCT * next
Definition: constype.h:580
struct PARAMETER_SET_STRUCT * next
Definition: constype.h:537
PHASE phase
Definition: constype.h:288
TIME t_below
Definition: constype.h:292
double val
Definition: constype.h:287
double val
Definition: constype.h:312
PHASE norm_phase
Definition: constype.h:291
int cycle
Definition: constype.h:469
struct EDGE_DESC * next
Definition: constype.h:319