malt-wr
passfail.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 
5 #include "constype.h"
6 
8 {
9  PULSE *pp, *pp_next;
10  int clk_cycle;
11 
12  sp->check_index=(int*)calloc(sp->clk_cycles_nr, sizeof(int));
13 
14  pp = pp_next = sp->sig_bgn[0];
15  if(pp!= NULL)
16  pp_next=pp->next;
17 
18  for(clk_cycle=1; (clk_cycle<sp->clk_cycles_nr-1) && (pp_next!=NULL); clk_cycle++)
19  {
20  sp->check_index[clk_cycle] = (int) (param.checkpoint_ratio * pp_next->index +
21  (1 - param.checkpoint_ratio) * pp->index);
22  pp = pp_next;
23  pp_next = pp->next;
24  }
25 
26  sp->check_index[0] = STEP_FORWARD;
27  if((pp=sp->sig_bgn[0])!=NULL)
28  if((pp_next=sp->sig_bgn[0]->next)!=NULL)
29  {
30  sp->check_index[0] =
31  pp->index-(1 - param.checkpoint_ratio)*(pp_next->index-pp->index);
32  if(sp->check_index[0]<1)
33  sp->check_index[0]=MIN(STEP_FORWARD, pp->index);
34  }
35 }
36 
37 
38 static ASYNC_CHECK* add_async_checkpoint(ASYNC_CHECK* last_checkpoint,
39  int index, PHASE phase, int sig_nr)
40 {
41  ASYNC_CHECK* checkpoint;
42 
43  checkpoint = last_checkpoint->next = (ASYNC_CHECK*)calloc(1, sizeof(ASYNC_CHECK));
44  checkpoint->index = index;
45  checkpoint->pi_phase = phase/M_PI;
46  if(phase/M_PI - checkpoint->pi_phase > 0.5)
47  checkpoint->pi_phase++;
48  checkpoint->sig_nr=sig_nr;
49  checkpoint->type=REGULAR_CHECKPOINT;
50  checkpoint->next=NULL;
51 
52  return checkpoint;
53 }
54 
55 
57 {
58  PULSE *pp, *pp_next;
59  int clk_cycle, sig_num, out_nr;
60  int check1, check2;
61  ASYNC_CHECK *last_checkpoint;
62  PHASE initial_phase;
63  int initial_phase_set;
64 
65 
67 
68  sp->async_check_index=(ASYNC_CHECK**)calloc(sp->outs_num,
69  sizeof(ASYNC_CHECK*));
70 
71  for(out_nr=0; out_nr<sp->outs_num; out_nr ++)
72  {
73  last_checkpoint = sp->async_check_index[out_nr] =
74  (ASYNC_CHECK*)calloc(1, sizeof(ASYNC_CHECK));
75  sig_num=sp->signal_num-sp->outs_num+out_nr;
76 
77  pp = pp_next = sp->sig_bgn[sig_num];
78 
79  if(pp==NULL)
80  {
81  check1 = (sp->indices_nr-1)-param.max_index_var;
82  if(check1 > param.max_index_var)
83  {
85  last_checkpoint=add_async_checkpoint(last_checkpoint,
86  check1,
87  0,
88  sig_num);
89  }
90  continue;
91  }
92 
93  pp_next=pp->next;
94 
95  initial_phase_set = 0;
96 
97  check2 = pp->index - param.max_index_var;
98  if(check2 > param.max_index_var)
99  {
100  initial_phase = pp->norm_phase;
101  initial_phase_set = 1;
102  sp->initial_phase_index[sig_num] = param.max_index_var;
103 
104  last_checkpoint=add_async_checkpoint(last_checkpoint,
105  check2,
106  0,
107  sig_num);
108  }
109  else
110  {
111  printf("Warning!\n");
112  printf("First pulse at the output %s is too close to the point where\n",
113  sp->signal_names[sig_num]);
114  printf("the simulation is started to be traced.\n");
115  printf("The phase before this pulse will not be checked.\n");
116  printf("position of the pulse = %.2f ps\n\n", pp->t*1.0e12);
117  }
118 
119  while(pp_next!=NULL)
120  {
121  if(pp_next->t - pp->t >= 2*param.max_delay_var*1.0e-12)
122  {
123  check1 = pp->index + param.max_index_var;
124  check2 = pp_next->index - param.max_index_var;
125 
126  if(!initial_phase_set)
127  {
128  initial_phase = pp_next->norm_phase;
129  sp->initial_phase_index[sig_num] = check1;
130  }
131 
132  if(check2>check1)
133  {
134  if(initial_phase_set)
135  last_checkpoint=add_async_checkpoint(last_checkpoint,
136  check1,
137  pp_next->norm_phase-initial_phase,
138  sig_num);
139  last_checkpoint=add_async_checkpoint(last_checkpoint,
140  check2,
141  pp_next->norm_phase-initial_phase,
142  sig_num);
143  }
144  else
145  if(initial_phase_set)
146  last_checkpoint=add_async_checkpoint(last_checkpoint,
147  (check1+check2)/2,
148  pp_next->norm_phase-initial_phase,
149  sig_num);
150  initial_phase_set = 1;
151  }
152  else
153  {
154  printf("Warning!\n");
155  printf("Consecutive output pulses at the output %s\n",
156  sp->signal_names[sig_num]);
157  printf(" are too close to define the checkpoints between them.\n");
158  printf("position of pulse 1 = %.2f ps\n", pp->t*1.0e12);
159  printf("position of pulse 2 = %.2f ps\n\n", pp_next->t*1.0e12);
160  }
161  pp = pp_next;
162  pp_next = pp->next;
163  }
164 
165  if(!initial_phase_set)
166  {
167  printf("Warning!!!\n");
168  printf("None checkpoint could be set at output %s !!!\n\n",
169  sp->signal_names[sig_num]);
170  continue;
171  }
172 
173  if(pp!=NULL)
174  {
175  check1 = pp->index + param.max_index_var;
176  if(check1 < sp->indices_nr)
177  {
178  last_checkpoint=add_async_checkpoint(last_checkpoint,
179  check1,
180  pp->norm_phase+2*M_PI-initial_phase,
181  sig_num);
182  }
183  else
184  {
185  printf("Warning!\n");
186  printf("Last pulse at the output %s is too close to the point where\n",
187  sp->signal_names[sig_num]);
188  printf("the simulation is finished to be traced.\n");
189  printf("The phase after this pulse will not be checked.\n");
190  printf("position of the pulse = %.2f ps\n\n", pp->t*1.0e12);
191  }
192  }
193  }
194 }
195 
196 
197 static ASYNC_CHECK* add_to_the_list(SIGNALS *sp, ASYNC_CHECK* last_checkpoint,
198  ASYNC_CHECK* check)
199 {
200  ASYNC_CHECK* checkpoint;
201 
202  checkpoint = (ASYNC_CHECK*)calloc(1, sizeof(ASYNC_CHECK));
203 
204  checkpoint->index = check->index;
205  checkpoint->pi_phase = check->pi_phase;
206  checkpoint->sig_nr = check->sig_nr;
207  checkpoint->type = check->type;
208 
209  if(last_checkpoint!=NULL)
210  {
211  checkpoint->next = last_checkpoint->next;
212  last_checkpoint->next = checkpoint;
213  }
214  else
215  {
216  checkpoint->next = sp->async_check_list;
217  sp->async_check_list = checkpoint;
218  }
219 
220  return checkpoint;
221 }
222 
223 
225 {
226  ASYNC_CHECK *first_checkpoint=NULL, *tmp_checkpoint=NULL;
227  ASYNC_CHECK **lastcheckpts;
228  int all_null;
229  int minimum_index, minimum_out_nr;
230  int out_nr;
231 
232 
233  if(sp->outs_num==1)
234  {
236  return;
237  }
238 
239  lastcheckpts = (ASYNC_CHECK **)calloc(sp->outs_num, sizeof(ASYNC_CHECK *));
240  for(out_nr=0; out_nr<sp->outs_num; out_nr++)
241  lastcheckpts[out_nr] = sp->async_check_index[out_nr]->next;
242 
243  do
244  {
245  all_null=1;
246  minimum_index = sp->indices_nr+1;
247  for(out_nr=0; out_nr<sp->outs_num; out_nr++)
248  {
249  if(lastcheckpts[out_nr]!=NULL)
250  {
251  if(lastcheckpts[out_nr]->index < minimum_index)
252  {
253  minimum_index = lastcheckpts[out_nr]->index;
254  minimum_out_nr = out_nr;
255  }
256  all_null = 0;
257  }
258  }
259 
260  if(all_null)
261  break;
262 
263  tmp_checkpoint=add_to_the_list(sp, tmp_checkpoint, lastcheckpts[minimum_out_nr]);
264 
265 
266  /* sp->signal_num-sp->outs_num+minimum_out_nr); */
267  if(first_checkpoint==NULL)
268  first_checkpoint = tmp_checkpoint;
269  lastcheckpts[minimum_out_nr]=lastcheckpts[minimum_out_nr]->next;
270  }
271  while(1);
272 
273  sp->async_check_list = first_checkpoint;
274 }
275 
276 
278 {
279  ASYNC_CHECK *tmp_checkpoint;
280 
281  tmp_checkpoint = sp->async_check_list;
282 
283  if(tmp_checkpoint == NULL)
284  {
285  add_to_the_list(sp, tmp_checkpoint, check);
286  return 1;
287  }
288 
289  if(check->index < tmp_checkpoint->index)
290  {
291  add_to_the_list(sp, NULL, check);
292  return 1;
293  }
294 
295  while(tmp_checkpoint->next!=NULL)
296  {
297  if(tmp_checkpoint->next->index > check->index)
298  {
299  add_to_the_list(sp, tmp_checkpoint, check);
300  return 1;
301  }
302  tmp_checkpoint = tmp_checkpoint->next;
303  }
304 
305  add_to_the_list(sp, tmp_checkpoint, check);
306  return 1;
307 }
308 
309 
310 static int generate_sync_passfail(SIGNALS *sp, FILE *fp, int runall)
311 /* returns last check index */
312 {
313  int clk_cycle, sig_num, out_num;
314  int *acc_phase;
315 
316  /* synchronous circuit */
318  for(sig_num=sp->signal_num-sp->outs_num; sig_num<sp->signal_num;sig_num++)
319  {
320  fprintf(fp, "* %s:\n", sp->signal_names[sig_num]);
321  fprintf(fp, "* ");
322  for(clk_cycle=1; clk_cycle<sp->clk_cycles_nr-1; clk_cycle++)
323  fprintf(fp, "%d", sp->sig_log[sig_num][clk_cycle].val);
324  fprintf(fp, "\n\n");
325  }
326  fprintf(fp, "\n\n");
327 
328 
329  if(runall) fprintf(fp, "run\n");
330 
331  acc_phase = (int*) calloc(sp->outs_num, sizeof(int));
332 
333 
334  for(clk_cycle=1; clk_cycle<sp->clk_cycles_nr-1; clk_cycle++)
335  {
336 
337  if(clk_cycle==1)
338  {
339  if(!runall) fprintf(fp, "step %d\n",
340  sp->check_index[clk_cycle]+STEP_FORWARD);
341  fprintf(fp, "\n");
342  }
343  else
344  {
345  fprintf(fp, "if chFAIL = 0\n");
346  if(!runall) fprintf(fp, "\tstep %d\n",
347  sp->check_index[clk_cycle]-sp->check_index[clk_cycle-1]);
348  }
349 
350  for(sig_num=sp->signal_num-sp->outs_num; sig_num<sp->signal_num;sig_num++)
351  {
352  out_num = sig_num - (sp->signal_num-sp->outs_num);
353  if(sp->sig_log[sig_num][clk_cycle].val > 0)
354  acc_phase[out_num]+=2;
355 
356  fprintf(fp, "\tif abs(%s[%d] - %s[%d] - %d*pi) > failthres\n",
357  sp->jspice_phase_names[sig_num],
358  sp->check_index[clk_cycle],
359  sp->jspice_phase_names[sig_num],
360  sp->check_index[0],
361  acc_phase[out_num]);
362  fprintf(fp, "\t\tchFAIL = 1\n");
363  fprintf(fp, "\t\techo FAILED FOR TIME = %.1f\n",
364  (sp->min_time_delta*1.0e12)*sp->check_index[clk_cycle]+
365  sp->start_time*1.0e12);
366  fprintf(fp, "\tend\n");
367  }
368 
369  if(clk_cycle!=1)
370  fprintf(fp, "end\n\n");
371  else
372  fprintf(fp, "\n");
373  }
374  return sp->check_index[sp->clk_cycles_nr-2];
375 }
376 
377 
378 static int add_clk_checkpoints(FILE *fp, SIGNALS *sp)
379 {
380  int clk_cycle, sig_num;
381  int acc_phase=2;
382 
383  for(clk_cycle=1; clk_cycle<sp->clk_cycles_nr-1; clk_cycle++) {
384  fprintf(fp, "\tif abs(%s[%d] - %s[%d] - %d*pi) > failthres\n",
385  sp->jspice_phase_names[0],
386  sp->check_index[clk_cycle],
387  sp->jspice_phase_names[0],
388  sp->check_index[0],
389  acc_phase);
390  acc_phase+=2;
391  fprintf(fp, "\t\tchFAIL = 1\n");
392  fprintf(fp, "\tend\n");
393  }
394 }
395 
396 static int generate_async_passfail(SIGNALS *sp, FILE *fp, int runall)
397 /* returns last check index */
398 {
399  int sig_num;
400  ASYNC_CHECK *tmp_check;
401 
402  int last_index;
403  int i, first;
404 
405  /* asynchronous circuit */
408  tmp_check = sp->async_check_list;
409 
410  fprintf(fp, "* checkpoints:");
411  i=0;
412  while(tmp_check!=NULL)
413  {
414  if((i++)%8==0)
415  fprintf(fp, "\n* ");
416  fprintf(fp, "%6.1f ",
417  (sp->min_time_delta*1.0e12)*tmp_check->index+
418  sp->start_time*1.0e12);
419  while(tmp_check->next!=NULL)
420  {
421  if(tmp_check->next->index == tmp_check->index)
422  tmp_check=tmp_check->next;
423  else
424  break;
425  }
426  tmp_check=tmp_check->next;
427  }
428  fprintf(fp, "\n\n");
429 
430  if(runall) fprintf(fp, "run\n");
431 
432  tmp_check = sp->async_check_list;
433  first=1;
434 
435  while(tmp_check!=NULL)
436  {
437  if(!first)
438  {
439  fprintf(fp, "if chFAIL = 0\n");
440  if(!runall) fprintf(fp, "\tstep %d\n", tmp_check->index-last_index);
441  }
442  else
443  {
444  if(!runall) fprintf(fp, "step %d\n", tmp_check->index+STEP_FORWARD);
445  }
446 
447  sig_num = tmp_check->sig_nr;
448  fprintf(fp, "\tif abs(%s[%d] - %s[%d] - %d*pi) > failthres\n",
449  sp->jspice_phase_names[sig_num],
450  tmp_check->index,
451  sp->jspice_phase_names[sig_num],
452  sp->initial_phase_index[sig_num],
453  tmp_check->pi_phase);
454  fprintf(fp, "\t\tchFAIL = 1\n");
455  fprintf(fp, "\t\techo FAILED FOR TIME = %.1f\n", sp->start_time*1.0e12 +
456  tmp_check->index*(sp->min_time_delta*1.0e12));
457  fprintf(fp, "\tend\n");
458 
459  while(tmp_check->next!=NULL)
460  {
461  if(tmp_check->next->index <= tmp_check->index)
462  {
463  tmp_check=tmp_check->next;
464  sig_num = tmp_check->sig_nr;
465  fprintf(fp, "\tif abs(%s[%d] - %s[%d] - %d*pi) > failthres\n",
466  sp->jspice_phase_names[sig_num],
467  tmp_check->index,
468  sp->jspice_phase_names[sig_num],
469  sp->initial_phase_index[sig_num],
470  tmp_check->pi_phase);
471  fprintf(fp, "\t\tchFAIL = 1\n");
472  fprintf(fp, "\t\techo FAILED FOR TIME = %.1f\n", sp->start_time*1.0e12 +
473  tmp_check->index*(sp->min_time_delta*1.0e12));
474  fprintf(fp, "\tend\n");
475  }
476  else
477  break;
478  }
479 
480  if(!first)
481  fprintf(fp, "end\n\n");
482  else
483  {
484  fprintf(fp, "\n");
485  first = 0;
486  }
487 
488  last_index = tmp_check->index;
489  tmp_check=tmp_check->next;
490  }
491 
492  return last_index;
493 }
494 
495 
496 
497 static int add_input_checkpoint(FILE *fp, SIGNALS* sp, int sig_nr,
498  int *last_index, int runall)
499 {
500  static input_nr=0;
501  PULSE *pp, *pp_prev, *pp_last;
502  int pulses_nr=0, check_index;
503  int initial_phase_set=0;
504  int check_index_set=0;
505  ASYNC_CHECK check;
506 
507 
509 
510  pp = sp->sig_bgn[sig_nr];
511 
512  if(pp==NULL)
513  {
514  if(sp->indices_nr > 2*param.max_index_var)
515  {
516  check_index = (sp->indices_nr - 1) - param.max_index_var;
518  }
519  else
520  {
521  printf("Simulation period too short to check for back travelling pulses\n");
522  printf("at input %s\n\n", sp->signal_names[sig_nr]);
523  return 0;
524  }
525  }
526  else
527  {
528  while(pp!=NULL)
529  {
530  pulses_nr++;
531  if(!initial_phase_set)
532  {
533  if(pulses_nr==1)
534  {
535  if(pp->index > 2*param.max_index_var)
536  {
538  initial_phase_set=1;
539  }
540  else
541  {
542  printf("Warning!\n");
543  printf("First pulse at the input %s is too close to the point where\n",
544  sp->signal_names[sig_nr]);
545  printf("the simulation is started to be traced.\n");
546  printf("The phase before this pulse will not be checked.\n");
547  printf("position of the pulse = %.2f ps\n\n", pp->t*1.0e12);
548  }
549  }
550  else
551  {
552  if(pp->index - pp->prev->index > 2*param.max_index_var)
553  {
555  pulses_nr = 1;
556  initial_phase_set=1;
557  }
558  else
559  {
560  printf("Warning!\n");
561  printf("Consecutive pulses at the input %s\n",
562  sp->signal_names[sig_nr]);
563  printf(" are too set the checkpoint between them.\n");
564  printf("position of pulse 1 = %.2f ps\n", pp->prev->t*1.0e12);
565  printf("position of pulse 2 = %.2f ps\n\n", pp->t*1.0e12);
566  }
567  }
568  }
569  if(pp->next==NULL)
570  pp_last=pp;
571  pp = pp->next;
572  }
573  }
574 
575 
576  if(pulses_nr==0)
577  {
578  check_index = (sp->indices_nr - 1) - param.max_index_var;
579  }
580  else
581  {
582  pp = pp_last;
583 
584  if(sp->indices_nr-pp->index > 2*param.max_index_var)
585  check_index = (sp->indices_nr - 1) - param.max_index_var;
586  else
587  {
588  while(pulses_nr > 1)
589  {
590  pp_prev=pp->prev;
591 
592  if(pp->index - pp_prev->index > 2*param.max_index_var)
593  {
594  check_index = (pp_prev->index + pp->index)/2;
595  check_index_set=1;
596  pulses_nr--;
597  break;
598  }
599  else
600  {
601  pp=pp_prev;
602  pulses_nr--;
603  }
604  }
605  if(!check_index_set)
606  {
607  check_index=pp->index-param.max_index_var;
608  pulses_nr=0;
609  }
610  }
611  }
612 
613  if(check_index > sp->initial_phase_index[sig_nr])
614  {
615  if(check_index > *last_index)
616  {
617  if(!runall) fprintf(fp, "\tstep %d\n", check_index - *last_index);
618  *last_index = check_index;
619  }
620  fprintf(fp, "\tif abs(%s[%d] - %s[%d] - %d*pi) > failthres\n",
621  sp->jspice_phase_names[sig_nr],
622  check_index,
623  sp->jspice_phase_names[sig_nr],
624  sp->initial_phase_index[sig_nr],
625  2*pulses_nr);
626  fprintf(fp, "\t\tchFAIL = 1\n");
627  fprintf(fp, "\tend\n\n");
628 
629  check.sig_nr=sig_nr;
630  check.type = REGULAR_CHECKPOINT;
631  check.index = check_index;
632  check.pi_phase = 2*pulses_nr;
634  }
635  else
636  {
637  printf("Warning!!!\n");
638  printf("Test for back travelling pulses on input %s cannot be performed because the pulses are too close to each other.\n\n", sp->signal_names[sig_nr]);
639  return 0;
640  }
641 
642  return 1;
643 }
644 
645 
646 int generate_passfail_file(SIGNALS *sp, char *filename, int runall)
647 {
648  FILE *fp;
649  int sig_num;
650  int last_index;
651  int i, first;
652  ASYNC_CHECK *tmp_check;
653 
654  fp=fopen(filename, "w");
655  if(fp==NULL)
656  return 0;
657 
658  fprintf(fp, "%s\n", filename);
659  fprintf(fp, ".control\n\n");
660 
661  sp->initial_phase_index=(int*)calloc(sp->signal_num, sizeof(int));
662 
663  if(sp->clk_num>0)
664  last_index=generate_sync_passfail(sp, fp, runall);
665  else
666  last_index=generate_async_passfail(sp, fp, runall);
667 
668  fprintf(fp, "\nif chFAIL = 0\n");
669  fprintf(fp, "if check_inputs = 1\n");
670 
671  if(param.program != HS_PROGRAM) {
672  if(sp->clk_num>0) {
673  add_input_checkpoint(fp, sp, 0, &last_index, runall);
674  add_clk_checkpoints(fp, sp);
675  }
676  for(sig_num=1; sig_num<sp->clk_num+sp->ins_num; sig_num++)
677  add_input_checkpoint(fp, sp, sig_num, &last_index, runall);
678  }
679  else {
680  if(sp->clk_num>0)
681  add_clk_checkpoints(fp, sp);
682  }
683 
684  fprintf(fp, "\tif chFAIL = 1\n");
685  fprintf(fp, "\t\techo FAILED BECAUSE OF EXTRA INPUT PULSES\n");
686  fprintf(fp, "\tend\n");
687  fprintf(fp, "end\n");
688  fprintf(fp, "end\n\n");
689 
690  fprintf(fp, "if chFAIL = 1\n");
691  fprintf(fp, "\tfree all yes\n");
692  fprintf(fp, "\tchFAIL = 1\n");
693  fprintf(fp, "end\n\n");
694 
695  fprintf(fp, "if chFAIL = 0\n");
696  fprintf(fp, "\tfree all yes\n");
697  fprintf(fp, "\tchFAIL = 0\n");
698  fprintf(fp, "end\n\n");
699 
700  return 1;
701 }
702 
703 
705 {
706  ASYNC_CHECK check;
707  int sig_num, last_sig;
708 
709  for(sig_num=0; sig_num<sp->ins_num+sp->clk_num; sig_num++)
710  {
711  if(sp->initial_phase_index[sig_num]>0)
712  {
713  check.sig_nr=sig_num;
714  check.type = INIT_CHECKPOINT;
715  check.index = sp->initial_phase_index[sig_num];
716  check.pi_phase = 0;
718  }
719  }
720 
721  if(sp->clk_num==0)
722  {
723  for(sig_num=sp->signal_num-sp->outs_num; sig_num<sp->signal_num; sig_num++)
724  {
725  if(sp->initial_phase_index[sig_num]>0)
726  {
727  check.sig_nr=sig_num;
728  check.type = INIT_CHECKPOINT;
729  check.index = sp->initial_phase_index[sig_num];
730  check.pi_phase = 0;
732  }
733  }
734  }
735  else
736  {
737  for(sig_num=sp->signal_num-sp->outs_num; sig_num<sp->signal_num; sig_num++)
738  {
739  check.sig_nr=sig_num;
740  check.type = INIT_CHECKPOINT;
741  check.index = sp->check_index[0];
742  check.pi_phase = 0;
744  }
745  }
746 }
747 
748 
750 {
751 
752  int clk_cycle, sig_num, out_num, check_nr;
753  int *acc_phase;
754  ASYNC_CHECK check;
755 
756  acc_phase = (int*) calloc(sp->outs_num, sizeof(int));
757 
758  for(clk_cycle=1; clk_cycle<sp->clk_cycles_nr-1; clk_cycle++)
759  {
760  for(sig_num=sp->signal_num-sp->outs_num; sig_num<sp->signal_num;sig_num++)
761  {
762  out_num = sig_num - (sp->signal_num-sp->outs_num);
763 
764  if(sp->sig_log[sig_num][clk_cycle].val > 0)
765  acc_phase[out_num]+=2;
766 
767  check.sig_nr=sig_num;
768  check.type = REGULAR_CHECKPOINT;
769  check.index = sp->check_index[clk_cycle];
770  check.pi_phase = acc_phase[out_num];
772  }
773  }
774 }
775 
776 
778 {
779  FILE *fp;
780  int i;
781  ASYNC_CHECK *tmp_check;
782  int sig_num, out_num, check_nr;
783 
784 
785  fp=fopen(filename, "w");
786  if(fp==NULL)
787  return 0;
788 
790  if(sp->clk_num>0)
792 
793 
794  fprintf(fp, ".check\n\n");
795 
796  for(i=1; i<=2; i++)
797  {
798  fprintf(fp, "checkVAL%d = \n", i);
799  fprintf(fp, "checkSTP%d = \n", i);
800  fprintf(fp, "checkDEL%d = \n\n", i);
801  }
802 
803  fprintf(fp, "compose checkPNTS values ");
804 
805  tmp_check = sp->async_check_list;
806 
807  while(tmp_check!=NULL)
808  {
809  fprintf(fp, "%6.1fps ",
810  (sp->min_time_delta*1.0e12)*tmp_check->index+
811  sp->start_time*1.0e12);
812  while(tmp_check->next!=NULL)
813  {
814  if(tmp_check->next->index == tmp_check->index)
815  tmp_check=tmp_check->next;
816  else
817  break;
818  }
819  tmp_check=tmp_check->next;
820  }
821  fprintf(fp, "%6.1fps\n\n",
822  (sp->min_time_delta*1.0e12)*(sp->indices_nr-1)+
823  sp->start_time*1.0e12);
824 
825 
826  fprintf(fp, "checkFAIL = 0\n");
827 
828  fprintf(fp, "failthres = %4.2f\n", param.min_fail_thresh);
829 
830  fprintf(fp, "source %s%s%s\n\n", param.input_dir,
832  param.param_ext);
833 
834  fprintf(fp, ".control\n\n");
835 
836  tmp_check = sp->async_check_list;
837  check_nr = 0;
838 
839  while(tmp_check!=NULL)
840  {
841  fprintf(fp, "if TIME > checkPNTS[%d]\n", check_nr);
842  fprintf(fp, "\tif TIME < checkPNTS[%d]\n", check_nr+1);
843 
844  sig_num = tmp_check->sig_nr;
845  if(tmp_check->type==REGULAR_CHECKPOINT)
846  {
847  fprintf(fp, "\t\tif abs(%s - phase0[%d] - %d*pi) > failthres\n",
848  sp->jspice_phase_names[sig_num],
849  sig_num,
850  tmp_check->pi_phase);
851  fprintf(fp, "\t\t\tcheckFAIL = 1\n");
852  fprintf(fp, "\t\tend\n");
853  }
854  if(tmp_check->type==INIT_CHECKPOINT)
855  {
856  fprintf(fp, "\t\tphase0[%d] = %s\n",
857  tmp_check->sig_nr,
858  sp->jspice_phase_names[tmp_check->sig_nr]);
859  }
860 
861  while(tmp_check->next!=NULL)
862  {
863  if(tmp_check->next->index == tmp_check->index)
864  {
865  tmp_check=tmp_check->next;
866  sig_num = tmp_check->sig_nr;
867  if(tmp_check->type==REGULAR_CHECKPOINT)
868  {
869  fprintf(fp, "\t\tif abs(%s - phase0[%d] - %d*pi) > failthres\n",
870  sp->jspice_phase_names[sig_num],
871  sig_num,
872  tmp_check->pi_phase);
873  fprintf(fp, "\t\t\tcheckFAIL = 1\n");
874  fprintf(fp, "\t\tend\n");
875  }
876 
877  if(tmp_check->type==INIT_CHECKPOINT)
878  {
879  fprintf(fp, "\t\tphase0[%d] = %s\n",
880  tmp_check->sig_nr,
881  sp->jspice_phase_names[tmp_check->sig_nr]);
882  }
883  }
884  else
885  break;
886  }
887 
888  fprintf(fp, "\tend\n");
889  fprintf(fp, "end\n\n");
890 
891  tmp_check=tmp_check->next;
892  check_nr++;
893  }
894 
895 
896  fprintf(fp, ".endc\n");
897  fprintf(fp, "%s\n\n", param.circuit_name);
898  fprintf(fp, ".include %s%s%s%s\n\n", param.input_dir,
901  param.check_ext);
902  fprintf(fp, ".end\n");
903 
904  return 1;
905 }
906 
static ASYNC_CHECK * add_to_the_list(SIGNALS *sp, ASYNC_CHECK *last_checkpoint, ASYNC_CHECK *check)
Definition: passfail.c:197
struct async_checkpoint * next
Definition: constype.h:353
struct PULSE_DESC * next
Definition: constype.h:298
static int add_clk_checkpoints(FILE *fp, SIGNALS *sp)
Definition: passfail.c:378
#define REGULAR_CHECKPOINT
Definition: constype.h:359
TIME t
Definition: constype.h:284
struct PULSE_DESC * prev
Definition: constype.h:299
char circuit_name[NAME_LENGTH]
Definition: constype.h:184
ASYNC_CHECK ** async_check_index
Definition: constype.h:456
static int add_input_checkpoint(FILE *fp, SIGNALS *sp, int sig_nr, int *last_index, int runall)
Definition: passfail.c:497
static void make_list_of_async_checks(SIGNALS *sp)
Definition: passfail.c:224
TIME min_time_delta
Definition: constype.h:393
int * check_index
Definition: constype.h:444
PULSE ** sig_bgn
Definition: constype.h:404
static int generate_sync_passfail(SIGNALS *sp, FILE *fp, int runall)
Definition: passfail.c:310
int index
Definition: constype.h:285
float checkpoint_ratio
Definition: constype.h:115
char(* jspice_phase_names)[NAME_LENGTH]
Definition: constype.h:387
#define INIT_CHECKPOINT
Definition: constype.h:360
int * initial_phase_index
Definition: constype.h:449
char param_ext[NAME_LENGTH]
Definition: constype.h:156
int clk_cycles_nr
Definition: constype.h:434
int signal_num
Definition: constype.h:366
static void add_sync_checkpoints(SIGNALS *sp)
Definition: passfail.c:749
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
static int generate_async_passfail(SIGNALS *sp, FILE *fp, int runall)
Definition: passfail.c:396
PARAMETERS param
Definition: init.c:10
PHASE min_fail_thresh
Definition: constype.h:119
static int add_to_the_list_of_async_checks(SIGNALS *sp, ASYNC_CHECK *check)
Definition: passfail.c:277
int val
Definition: constype.h:329
int outs_num
Definition: constype.h:378
int clk_num
Definition: constype.h:369
LOGIC ** sig_log
Definition: constype.h:439
int program
Definition: constype.h:193
static void compute_sync_check_indices(SIGNALS *sp)
Definition: passfail.c:7
float PHASE
Definition: constype.h:55
int indices_nr
Definition: constype.h:399
int max_index_var
Definition: constype.h:133
#define STEP_FORWARD
Definition: constype.h:48
char input_dir[NAME_LENGTH]
Definition: constype.h:143
int generate_check_file(SIGNALS *sp, char *filename)
Definition: passfail.c:777
#define HS_PROGRAM
Definition: constype.h:243
TIME start_time
Definition: constype.h:396
char check_ext[NAME_LENGTH]
Definition: constype.h:161
TIME max_delay_var
Definition: constype.h:129
char circuit_ext[NAME_LENGTH]
Definition: constype.h:155
ASYNC_CHECK * async_check_list
Definition: constype.h:458
static void add_initial_checkpoints(SIGNALS *sp)
Definition: passfail.c:704
int ins_num
Definition: constype.h:372
int generate_passfail_file(SIGNALS *sp, char *filename, int runall)
Definition: passfail.c:646
#define MIN(x, y)
Definition: constype.h:58
static char filename[LINE_LENGTH]
Definition: optimize.c:35
static ASYNC_CHECK * add_async_checkpoint(ASYNC_CHECK *last_checkpoint, int index, PHASE phase, int sig_nr)
Definition: passfail.c:38
PHASE norm_phase
Definition: constype.h:291
static void compute_async_check_indices(SIGNALS *sp)
Definition: passfail.c:56