malt-wr
collect.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 
7 static char line[LONG_LINE_LENGTH];
8 
9 
10 static int read_line(FILE *fp, char* line, int *line_no)
11 {
12  if(fgets(line, LONG_LINE_LENGTH, fp)!=NULL)
13  {
14  (*line_no)++;
15  return 1;
16  }
17  else
18  return 0;
19 }
20 
21 
22 static void add_signal_by_voltage(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, int sig_index)
23 {
24  PULSE * pp;
25 
26 
27  if(sp->sig_bgn[sig_num] == NULL)
28  {
29  /* first sample of the first pulse */
30  pp=(PULSE*) calloc(1,sizeof(PULSE));
31  pp->t = sig_time;
32  pp->val = sig_val;
33  pp->index = sig_index;
34  pp->next = pp->prev = NULL;
35 
36  sp->sig_bgn[sig_num]=sp->sig_end[sig_num]=pp;
37  }
38  else
39  {
40  if((sig_index - sp->last_index[sig_num]) == 1)
41  {
42  /* next sample from the same pulse */
43  if(sig_val > sp->sig_end[sig_num]->val)
44  {
45  /* value closer to the maximum (peak) value */
46  sp->sig_end[sig_num]->val = sig_val;
47  sp->sig_end[sig_num]->t = sig_time;
48  sp->sig_end[sig_num]->index = sig_index;
49  }
50  }
51  else
52  /* beginning of next pulse */
53  {
54  pp=(PULSE*) calloc(1,sizeof(PULSE));
55  pp->t=sig_time;
56  pp->val=sig_val;
57  pp->index= sig_index;
58  pp->next=NULL;
59 
60  pp->prev = sp->sig_end[sig_num];
61  sp->sig_end[sig_num]->next = pp;
62  sp->sig_end[sig_num] = pp;
63  }
64  }
65 
66  sp->last_index[sig_num] = sig_index;
67 }
68 
69 
70 static void add_signal_by_phase(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, int sig_index)
71 {
72  PULSE * pp;
73  PHASE delta;
74 
75 
76  if(sp->sig_bgn[sig_num] == NULL)
77  {
78  /* first sample of the first pulse */
79  pp=(PULSE*) calloc(1,sizeof(PULSE));
80  pp->t = pp->t_below = sig_time;
81  pp->phase = pp->p_below = sig_val;
82  pp->index = sig_index;
83  pp->norm_phase= sp->current_phase[sig_num];
84  pp->p_above = sp->current_phase[sig_num]+param.max_phase_thresh;
85  pp->t_above = 0;
86  pp->next = pp->prev = NULL;
87 
88  sp->sig_bgn[sig_num]=sp->sig_end[sig_num]=pp;
89  }
90  else
91  {
92  if(sp->current_phase[sig_num] == sp->sig_end[sig_num]->norm_phase)
93  {
94  /* next sample from the same pulse */
95  if(sig_val > sp->current_phase[sig_num] + param.max_phase_thresh)
96  {
97  sp->current_phase[sig_num]+=2*M_PI;
98  if(sp->sig_end[sig_num]->t_above==0)
99  {
100  if((param.program == INIT_PROGRAM) ||
102  {
103  printf("Warning!\n");
104  printf("Only one simulation point has been encountured between PHASE_THRESHOLD_MIN and PHASE_THRESHOLD_MAX!\n");
105  printf("The position of the pulse may be estimated with inadequate precision!\n");
106  printf("%s: time=%6.2lf\n\n", sp->signal_names[sig_num], sp->sig_end[sig_num]->t_below*1.0e12);
107  }
108  if(sig_val > sp->sig_end[sig_num]->p_below)
109  {
110  sp->sig_end[sig_num]->p_above=sig_val;
111  sp->sig_end[sig_num]->t_above=sig_time;
112  }
113  else
114  {
115  sp->sig_end[sig_num]->p_above=sp->sig_end[sig_num]->p_below;
116  sp->sig_end[sig_num]->t_above=sp->sig_end[sig_num]->t_below;
117  }
118  }
119  }
120  else
121  {
122  if(fabs(sig_val - sp->current_phase[sig_num] - param.nom_phase_thresh) <
123  fabs(sp->sig_end[sig_num]->phase -
124  sp->sig_end[sig_num]->norm_phase - param.nom_phase_thresh))
125  {
126  sp->sig_end[sig_num]->phase=sig_val;
127  sp->sig_end[sig_num]->t=sig_time;
128  sp->sig_end[sig_num]->index=sig_index;
129  }
130  if((sig_val <= sp->current_phase[sig_num] + param.nom_phase_thresh) &&
131  (sig_val > sp->sig_end[sig_num]->p_below))
132  {
133  sp->sig_end[sig_num]->p_below=sig_val;
134  sp->sig_end[sig_num]->t_below=sig_time;
135  }
136  if((sig_val >= sp->current_phase[sig_num] + param.nom_phase_thresh) &&
137  (sig_val < sp->sig_end[sig_num]->p_above))
138  {
139  sp->sig_end[sig_num]->p_above=sig_val;
140  sp->sig_end[sig_num]->t_above=sig_time;
141  }
142  }
143  }
144  else
145  /* beginning of next pulse */
146  {
147  pp=(PULSE*) calloc(1,sizeof(PULSE));
148  pp->t=pp->t_below=sig_time;
149  pp->phase=pp->p_below=sig_val;
150  pp->index= sig_index;
151  pp->norm_phase= sp->current_phase[sig_num];
152  pp->p_above = sp->current_phase[sig_num]+param.max_phase_thresh;
153  pp->t_above = 0;
154  pp->next=NULL;
155 
156  pp->prev = sp->sig_end[sig_num];
157  sp->sig_end[sig_num]->next = pp;
158  sp->sig_end[sig_num] = pp;
159  }
160  }
161 
162 }
163 
164 
165 static int add_edge(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, double old_sig_val, TIME old_sig_time, int sig_index, int old_sig_index, int direction)
166 {
167  EDGE * pp;
168  double delta;
169 
170  if(sp->sig_edge_bgn[sig_num] != NULL)
171  if(sig_time - sp->sig_edge_end[sig_num]->t < param.min_edge_sep)
172  return 0;
173 
174  pp=(EDGE*) calloc(1,sizeof(EDGE));
175  if(fabs(sig_val - param.nom_edge_thresh) < fabs(param.nom_edge_thresh - old_sig_val)) {
176  pp->t = sig_time;
177  pp->index = sig_index;
178  pp->val = sig_val;
179  }
180  else {
181  pp->t = old_sig_time;
182  pp->index = old_sig_index;
183  pp->val = old_sig_val;
184  }
185  pp->direction = direction;
186  delta = fabs(old_sig_val - param.nom_edge_thresh)/fabs(sig_val - old_sig_val);
187  pp->exact_time = (sig_time-old_sig_time)*delta + old_sig_time;
188 
189  if(sp->sig_edge_bgn[sig_num] == NULL) {
190  /* first sample of the first pulse */
191  pp->next = pp->prev = NULL;
192  sp->sig_edge_bgn[sig_num]=sp->sig_edge_end[sig_num]=pp;
193  }
194  else {
195  pp->next=NULL;
196  pp->prev = sp->sig_edge_end[sig_num];
197  sp->sig_edge_end[sig_num]->next = pp;
198  sp->sig_edge_end[sig_num] = pp;
199  }
200 
201  return 1;
202 }
203 
204 
206 {
207  PULSE *pp;
208  int sig_num;
209 
210  for(sig_num=0; sig_num<sp->signal_num; sig_num++)
211  {
212  if(sp->sig_end[sig_num]!=NULL)
213  if(sp->sig_end[sig_num]->t_above==0)
214  {
215 /* remove description of the last pulse from the list */
216  pp=sp->sig_end[sig_num];
217  if(pp->prev==NULL)
218  {
219  sp->sig_bgn[sig_num]=NULL;
220  free(pp);
221  }
222  else
223  {
224  pp->prev->next=NULL;
225  free(pp);
226  }
227  }
228  }
229 }
230 
232 {
233  int k;
234 
235  k=p_val/(2*M_PI);
236  if(p_val<0)
237  k--;
238  if((p_val - k*(2*M_PI)) < param.nom_phase_thresh)
239  return k*(2*M_PI);
240  else
241  return (k+1)*(2*M_PI);
242 }
243 
244 
245 static SIGNALS * collect_pulses(char* filename, int method)
246 {
247  FILE *fp;
248  int i,k,m;
249 
250  int Sdiv3, Smod3;
251 
252  int line_no=0;
253  int signals_in_row;
254 
255  SIGNALS *sp;
256  double sig_val;
257  double old_sig_val;
258 
259  int index, old_index=0;
260  float time, old_time;
261 
262  int expected_edge[3];
263 
264 
265 /* open input file for reading */
266  fp=fopen(filename, "r");
267  if(fp==NULL)
268  {
269  printf("Cannot open file: %s.\n", filename);
270  return NULL;
271  }
272 
273 /* allocate memory for main data structure */
274  sp=(SIGNALS*) calloc(1,sizeof(SIGNALS));
275 
276 /* read number of signals traced */
277  read_line(fp, line, &line_no);
278 
279 
280  if(sscanf(line, "%d %d %d %d", &sp->clk_num, &sp->ins_num,
281  &sp->inter_num, &sp->outs_num) != 4)
282  {
283  printf("ERROR IN FILE \".io\"\nset inout_num = %s\n", line);
284  return NULL;
285  }
286  sp->signal_num=sp->clk_num+sp->ins_num+sp->inter_num+sp->outs_num;
287 
288  read_line(fp, line, &line_no);
289  i=sscanf(line, "%d", &sp->var_in_nr);
290  if(i!=1)
291  {
292  printf("ERROR IN FILE \".io\"\nset var_in_num = %s\n", line);
293  return NULL;
294  }
295 
296  sp->sig_initial = (int*) calloc(sp->signal_num, sizeof(int));
297 
298 /* read the names of signals given by the designer */
299  sp->signal_names=(char (*)[NAME_LENGTH])calloc(sp->signal_num,
300  NAME_LENGTH*sizeof(char));
301  read_line(fp, line, &line_no);
302  k=0;
303  for(m=0; m<sp->signal_num; m++)
304  {
305  if(sscanf(&line[k], "%s", sp->signal_names[m])!=1)
306  {
307  printf("ERROR IN FILE \".io\"\nset user_names = %s\n", line);
308  return NULL;
309  }
310  k+=skip_arg(&line[k], 1);
311  }
312 
313 /* read the names of signals used in jspice simulations */
314  if(method==COLLECT_BY_PHASE)
315  sp->jspice_phase_names=(char (*)[NAME_LENGTH])calloc(sp->signal_num,
316  NAME_LENGTH*sizeof(char));
317  if((method==COLLECT_BY_VOLTAGE) || (method==COLLECT_EDGES))
318  sp->jspice_voltage_names=(char (*)[NAME_LENGTH])calloc(sp->signal_num,
319  NAME_LENGTH*sizeof(char));
320 
321  read_line(fp, line, &line_no);
322  k=0;
323  for(m=0; m<sp->signal_num; m++) {
324  if(method==COLLECT_BY_PHASE) {
325  i=sscanf(&line[k], "%s", sp->jspice_phase_names[m]);
326  if(i!=1) {
327  printf("ERROR IN FILE \".io\"\nset phase_names = %s\n", line);
328  return NULL;
329  }
330  }
331 
332  if((method==COLLECT_BY_VOLTAGE) || (method==COLLECT_EDGES)) {
333  i=sscanf(&line[k], "%s", sp->jspice_voltage_names[m]);
334  if(i!=1) {
335  printf("ERROR IN FILE \".io\"\nset voltage_names = %s\n", line);
336  return NULL;
337  }
338  }
339 
340  k+=skip_arg(&line[k], 1);
341  }
342 
343 
344 /* allocate memory for necessary arrays */
345  sp->sig_bgn=(PULSE**) calloc(sp->signal_num, sizeof(PULSE*));
346  sp->sig_end=(PULSE**) calloc(sp->signal_num, sizeof(PULSE*));
347 
348  if(method==COLLECT_BY_PHASE)
349  sp->current_phase=(PHASE*) calloc(sp->signal_num, sizeof(int));
350 
351  if(method==COLLECT_BY_VOLTAGE)
352  sp->last_index=(int*) calloc(sp->signal_num, sizeof(int));
353 
354  if(method==COLLECT_EDGES) {
355  sp->sig_edge_bgn=(EDGE**) calloc(sp->signal_num, sizeof(EDGE*));
356  sp->sig_edge_end=(EDGE**) calloc(sp->signal_num, sizeof(EDGE*));
357  }
358 
359 /* number of sets of signals (3 signals in the set) */
360  Sdiv3=sp->signal_num/3;
361 
362 /* number of signals in the last set */
363  Smod3=sp->signal_num%3;
364 
365  if(Smod3!=0)
366  Sdiv3++;
367  else
368  Smod3=3;
369 
370 
371  signals_in_row = 3;
372 
373  for(i=0; i<=Sdiv3; i++)
374  {
375  if(i==Sdiv3)
376  signals_in_row=Smod3;
377 
378  while(read_line(fp, line, &line_no))
379  {
380  /* if line does not include index and time read next line */
381  if(sscanf(line, "%d %e", &index, &time)!=2)
382  continue;
383 
384  /* if not subsequent index */
385  if(index!=old_index+1)
386  if(index==0)
387  /* beginning of the next set of signals */
388  {
389  if(i==0)
390  {
391  /* store information necessary to compute the time resolution */
392  sp->min_time_delta = time;
393  sp->start_time = time;
394  }
395 
396  /* set and check # of valid input samples */
397  if(i<2)
398  sp->indices_nr=old_index+1;
399  else
400  if(sp->indices_nr!=old_index+1)
401  {
402  printf("Warning !!!\n");
403  printf("Numbers of samples in different signal sets do not match.");
404  printf("Possible error in input data file.");
405  sp->indices_nr=MIN(old_index+1, sp->indices_nr);
406  }
407 
408  old_index=0;
409 
410  goto next_signals;
411  }
412  else
413  continue;
414 
415  if((i==1) && (index==1))
416  /* compute the time resolution */
417  sp->min_time_delta = time - sp->min_time_delta;
418 
419  old_index=index;
420  k=skip_arg(line, 2);
421 
422  /* read values of signals */
423  for(m=0; m<signals_in_row; m++)
424  {
425  if(sscanf(&line[k], "%le", &sig_val)!=1)
426  goto next_line;
427 
428  switch(method)
429  {
430  case COLLECT_BY_PHASE:
431  if(index==1)
432  sp->current_phase[(i-1)*3+m]=normalized_phase(sig_val);
433 
434  /* if phase close to the new threshold value
435  check if add new pulse to the list */
436  if(sig_val > sp->current_phase[(i-1)*3+m] +
438  add_signal_by_phase(sp, (i-1)*3+m, sig_val, time, index);
439  break;
440 
441  case COLLECT_BY_VOLTAGE:
442  /* if signal value greater than VOLTAGE_THRESHOLD
443  check if add new pulse to the list */
444  if(sig_val > param.volt_thresh)
445  add_signal_by_voltage(sp, (i-1)*3+m, sig_val, time, index);
446  break;
447 
448  case COLLECT_EDGES:
449  if(index==1) {
450  if(sig_val < param.nom_edge_thresh) {
451  sp->sig_initial[(i-1)*3+m] = 0;
452  expected_edge[m] = RISING_EDGE;
453  }
454  else {
455  sp->sig_initial[(i-1)*3+m] = 1;
456  expected_edge[m] = FALLING_EDGE;
457  }
458  }
459 
460  /* if phase close to the new threshold value
461  check if add new pulse to the list */
462  if(expected_edge[m] == RISING_EDGE) {
463  if(sig_val > param.nom_edge_thresh) {
464  if(add_edge(sp, (i-1)*3+m, sig_val, time, old_sig_val, old_time, index, old_index, expected_edge[m]))
465  expected_edge[m] = FALLING_EDGE;
466  }
467  }
468  else
469  if(expected_edge[m] == FALLING_EDGE) {
470  if(sig_val < param.nom_edge_thresh) {
471  if(add_edge(sp, (i-1)*3+m, sig_val, time, old_sig_val, old_time, index, old_index, expected_edge[m]))
472  expected_edge[m] = RISING_EDGE;
473  }
474  }
475  old_sig_val = sig_val;
476  old_time = time;
477  break;
478  }
479 
480 
481  k+=skip_arg(&line[k], 1);
482  }
483 next_line: ;
484  }
485 next_signals: ;
486  }
487 
488  if(Sdiv3==1)
489  sp->indices_nr=index;
490 
491  fclose(fp);
492 
493  if(method==COLLECT_BY_PHASE)
495 
496  return sp;
497 }
498 
499 
500 
501 int collect_values(SIGNALS *sp, char* filename, int collected)
502 {
503  FILE *fp;
504  int i,k,m, sig_nr;
505  PULSE** sig_tmp;
506 
507  int Sdiv3, Smod3;
508 
509  int line_no=0;
510  int signals_in_row, valid_value;
511 
512  double sig_val;
513 
514  int index, old_index=0;
515  float time;
516 
517  fp=fopen(filename, "r");
518  if(fp==NULL)
519  return 0;
520 
521 /* skip number of signals traced */
522  read_line(fp, line, &line_no);
523 
524 /* skip the number of the input with variable generator attached */
525  read_line(fp, line, &line_no);
526 
527 /* skip the names of signals given by the designer */
528  read_line(fp, line, &line_no);
529 
530 /* read the names of signals used in jspice simulations */
531  switch(collected)
532  {
533  case COLLECT_PHASE:
534  sp->jspice_phase_names=(char (*)[NAME_LENGTH])calloc(sp->signal_num,
535  NAME_LENGTH*sizeof(char));
536  break;
537 
538  case COLLECT_VOLTAGE:
539  sp->jspice_voltage_names=(char (*)[NAME_LENGTH])calloc(sp->signal_num,
540  NAME_LENGTH*sizeof(char));
541  break;
542  }
543 
544  read_line(fp, line, &line_no);
545  k=0;
546  for(m=0; m<sp->signal_num; m++)
547  {
548  if(collected==COLLECT_PHASE)
549  i=sscanf(&line[k], "%s", sp->jspice_phase_names[m]);
550 
551  if(collected==COLLECT_VOLTAGE)
552  i=sscanf(&line[k], "%s", sp->jspice_voltage_names[m]);
553 
554  if(i!=1)
555  {
556  printf("ERROR IN LINE: %d\n", line_no);
557  return 0;
558  }
559  k+=skip_arg(&line[k], 1);
560  }
561 
562 
563  sig_tmp=(PULSE**) calloc(sp->signal_num, sizeof(PULSE*));
564  for(k=0; k<sp->signal_num; k++)
565  sig_tmp[k]=sp->sig_bgn[k];
566 
567  Sdiv3=sp->signal_num/3;
568  Smod3=sp->signal_num%3;
569  if(Smod3!=0)
570  Sdiv3++;
571  else
572  Smod3=3;
573 
574  signals_in_row = 3;
575 
576  for(i=0; i<=Sdiv3; i++)
577  {
578  if(i==Sdiv3)
579  signals_in_row=Smod3;
580  while(read_line(fp, line, &line_no))
581  {
582  if(sscanf(line, "%d %e", &index, &time)!=2)
583  continue;
584  if(index!=old_index+1)
585  if(index==0)
586  {
587  old_index=0;
588  goto next_signals;
589  }
590  else
591  continue;
592  old_index=index;
593 
594  valid_value=0;
595  for(m=0; m<signals_in_row; m++)
596  {
597  sig_nr = (i-1)*3+m;
598  if(sig_tmp[sig_nr]!=NULL)
599  if(time==sig_tmp[sig_nr]->t)
600  valid_value=1;
601  }
602 
603  if(!valid_value)
604  continue;
605 
606  k=skip_arg(line, 2);
607 
608  for(m=0; m<signals_in_row; m++)
609  {
610  if(sscanf(&line[k], "%le", &sig_val)!=1)
611  break;
612 
613  sig_nr = (i-1)*3+m;
614  if(sig_tmp[sig_nr]!=NULL)
615  if(time==sig_tmp[sig_nr]->t)
616  {
617  switch(collected)
618  {
619  case COLLECT_PHASE:
620  sig_tmp[sig_nr]->phase=sig_val;
621  break;
622 
623  case COLLECT_VOLTAGE:
624  sig_tmp[sig_nr]->val=sig_val;
625  break;
626  }
627  sig_tmp[sig_nr]=sig_tmp[sig_nr]->next;
628  }
629  k+=skip_arg(&line[k], 1);
630  }
631  }
632 next_signals: ;
633  }
634 
635  fclose(fp);
636  return 1;
637 }
638 
639 
640 
641 static int verify_phase(SIGNALS *sp)
642 {
643  int k;
644  PULSE *pp, *last_pp;
645 
646  for(k=0; k<sp->signal_num; k++)
647  {
648  last_pp=sp->sig_bgn[k];
649  if(last_pp!=NULL)
650  pp=last_pp->next;
651  else
652  pp=NULL;
653 
654  while(pp!=NULL)
655  {
656  if(fabs(pp->phase - last_pp->phase)< param.min_pulse_phase_diff)
657  /* no 2*PI phase change between peaks
658  => smaller pulse removed from the list of pulses */
659  if(pp->val > last_pp->val)
660  {
661  /* remove first pulse */
662  if(last_pp->prev != NULL)
663  last_pp->prev->next = pp;
664  else
665  sp->sig_bgn[k]=pp;
666 
667  pp->prev = last_pp->prev;
668  free(last_pp);
669 
670  last_pp=pp;
671  pp=pp->next;
672  }
673  else
674  {
675  /* remove second pulse */
676  if(pp->next!=NULL)
677  pp->next->prev = last_pp;
678  last_pp->next=pp->next;
679  free(pp);
680  pp=last_pp->next;
681  }
682  else
683  {
684  last_pp=pp;
685  pp=pp->next;
686  }
687  }
688  }
689 }
690 
691 
692 
694 {
695  int k;
696  PULSE *pp_phase;
697  FILE *fp;
698 
699  TIME t10delta;
700  PHASE p10delta, pt0delta;
701 
702 
703  for(k=0; k<sp_phase->signal_num; k++)
704  {
705  pp_phase=sp_phase->sig_bgn[k];
706 
707  while(pp_phase!=NULL)
708  {
709  p10delta = pp_phase->p_above-pp_phase->p_below;
710  if(p10delta>0)
711  {
712  pt0delta = pp_phase->norm_phase + param.nom_phase_thresh -
713  pp_phase->p_below;
714  t10delta = pp_phase->t_above - pp_phase->t_below;
715  pp_phase->t= t10delta*(pt0delta/p10delta) + pp_phase->t_below;
716  }
717  else
718  if(pp_phase->t_above == pp_phase->t_below)
719  pp_phase->t=pp_phase->t_above;
720  else
721  pp_phase->t=(pp_phase->t_above + pp_phase->t_below)/2;
722  pp_phase->phase=pp_phase->norm_phase + param.nom_phase_thresh;
723  pp_phase=pp_phase->next;
724  }
725  }
726 
727  return 1;
728 }
729 
730 
731 
733 {
734  char phase_filename[NAME_LENGTH];
735  SIGNALS *sp;
736 
737  sp=collect_pulses(filename, COLLECT_BY_VOLTAGE);
738  if(sp!=NULL)
739  {
740  strcpy(phase_filename, filename);
741  strcat(phase_filename, param.phase_ext);
742  if(collect_values(sp, phase_filename, COLLECT_PHASE))
743  verify_phase(sp);
744  }
745 
746  return sp;
747 }
748 
749 
751 {
752  char phase_filename[NAME_LENGTH];
753  SIGNALS *sp;
754 
755  strcpy(phase_filename, filename);
756  strcat(phase_filename, param.phase_ext);
757 
758  sp=collect_pulses(phase_filename, COLLECT_BY_PHASE);
759  if(sp!=NULL)
760  if(param.interpolate)
762 
763  return sp;
764 }
765 
766 
768 {
769  char voltage_filename[NAME_LENGTH];
770  SIGNALS *sp;
771 
772  strcpy(voltage_filename, filename);
773 
774  sp=collect_pulses(voltage_filename, COLLECT_EDGES);
775 
776 #if 0
777  if(sp!=NULL)
778  if(param.interpolate)
780 #endif
781 
782  return sp;
783 }
784 
785 
786 
788 {
789  int i;
790  PULSE *pp, *ppf;
791  ASYNC_CHECK *tmp_check, *next_check;
792 
793  if(sp==NULL)
794  return;
795 
796  for(i=0; i<sp->signal_num; i++)
797  {
798 /* SRW ** error here, these are not atomically allocated.
799  if(sp->signal_names!=NULL)
800  free(sp->signal_names[i]);
801  if(sp->jspice_voltage_names!=NULL)
802  free(sp->jspice_voltage_names[i]);
803  if(sp->jspice_phase_names!=NULL)
804  free(sp->jspice_phase_names[i]);
805 */
806  if(sp->sig_log!=NULL)
807  free(sp->sig_log[i]);
808 
809  if(sp->sig_bgn!=NULL)
810  {
811  pp=sp->sig_bgn[i];
812  while(pp!=NULL)
813  {
814  ppf=pp;
815  pp=pp->next;
816  free(ppf);
817  }
818  }
819  }
820 
821  next_check=tmp_check=sp->async_check_list;
822  while(tmp_check!=NULL)
823  {
824  next_check=tmp_check->next;
825  free(tmp_check);
826  tmp_check=next_check;
827  }
828 
829  free(sp->signal_names);
830  free(sp->jspice_voltage_names);
831  free(sp->jspice_phase_names);
832  free(sp->sig_log);
833  free(sp->sig_bgn);
834 
835  free(sp->current_phase);
836  free(sp->last_index);
837  free(sp->clk_times);
838  free(sp->check_index);
839 }
TIME * clk_times
Definition: constype.h:431
#define COLLECT_PHASE
Definition: constype.h:41
struct async_checkpoint * next
Definition: constype.h:353
struct PULSE_DESC * next
Definition: constype.h:298
#define COLLECT_EDGES
Definition: constype.h:46
TIME t
Definition: constype.h:284
int direction
Definition: constype.h:313
struct PULSE_DESC * prev
Definition: constype.h:299
SIGNALS * collect_pulses_by_phase(char *filename)
Definition: collect.c:750
int * last_index
Definition: constype.h:428
SIGNALS * collect_edges(char *filename)
Definition: collect.c:767
TIME exact_time
Definition: constype.h:316
TIME min_time_delta
Definition: constype.h:393
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
#define LONG_LINE_LENGTH
Definition: constype.h:5
int interpolate
Definition: constype.h:99
PULSE ** sig_end
Definition: constype.h:408
int var_in_nr
Definition: constype.h:390
char(* jspice_phase_names)[NAME_LENGTH]
Definition: constype.h:387
int skip_arg(char *line, int arg_num)
Definition: lineread.c:54
EDGE ** sig_edge_bgn
Definition: constype.h:412
int signal_num
Definition: constype.h:366
static SIGNALS * collect_pulses(char *filename, int method)
Definition: collect.c:245
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
PHASE * current_phase
Definition: constype.h:424
#define COLLECT_BY_PHASE
Definition: constype.h:44
int inter_num
Definition: constype.h:375
PHASE min_pulse_phase_diff
Definition: constype.h:111
PHASE min_phase_thresh
Definition: constype.h:86
PARAMETERS param
Definition: init.c:10
PHASE p_above
Definition: constype.h:295
double * delta
Definition: points.c:14
#define COLLECT_BY_VOLTAGE
Definition: constype.h:45
SIGNALS * collect_pulses_by_voltage(char *filename)
Definition: collect.c:732
static int read_line(FILE *fp, char *line, int *line_no)
Definition: collect.c:10
#define M_SET
Definition: constype.h:10
int outs_num
Definition: constype.h:378
PHASE nom_phase_thresh
Definition: constype.h:82
#define NAME_LENGTH
Definition: constype.h:3
static PHASE normalized_phase(PHASE p_val)
Definition: collect.c:231
static int verify_phase(SIGNALS *sp)
Definition: collect.c:641
#define INIT_PROGRAM
Definition: constype.h:244
struct EDGE_DESC * prev
Definition: constype.h:320
int collect_values(SIGNALS *sp, char *filename, int collected)
Definition: collect.c:501
int clk_num
Definition: constype.h:369
static void add_signal_by_phase(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, int sig_index)
Definition: collect.c:70
LOGIC ** sig_log
Definition: constype.h:439
int program
Definition: constype.h:193
float PHASE
Definition: constype.h:55
int indices_nr
Definition: constype.h:399
char phase_ext[NAME_LENGTH]
Definition: constype.h:159
EDGE ** sig_edge_end
Definition: constype.h:416
int index
Definition: constype.h:310
static void add_signal_by_voltage(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, int sig_index)
Definition: collect.c:22
TIME t_above
Definition: constype.h:293
PHASE p_below
Definition: constype.h:294
static char line[LONG_LINE_LENGTH]
Definition: collect.c:7
#define HS_PROGRAM
Definition: constype.h:243
TIME start_time
Definition: constype.h:396
float TIME
Definition: constype.h:54
#define RISING_EDGE
Definition: constype.h:50
VOLTAGE volt_thresh
Definition: constype.h:103
double nom_edge_thresh
Definition: constype.h:208
static void remove_not_complete_pulses(SIGNALS *sp)
Definition: collect.c:205
char(* jspice_voltage_names)[NAME_LENGTH]
Definition: constype.h:384
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
static int add_edge(SIGNALS *sp, int sig_num, double sig_val, TIME sig_time, double old_sig_val, TIME old_sig_time, int sig_index, int old_sig_index, int direction)
Definition: collect.c:165
#define FALLING_EDGE
Definition: constype.h:51
int * sig_initial
Definition: constype.h:420
int ins_num
Definition: constype.h:372
int interpolate_phase_thresh_time(SIGNALS *sp_phase)
Definition: collect.c:693
void free_data(SIGNALS *sp)
Definition: collect.c:787
#define MIN(x, y)
Definition: constype.h:58
static char filename[LINE_LENGTH]
Definition: optimize.c:35
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
struct EDGE_DESC * next
Definition: constype.h:319
#define COLLECT_VOLTAGE
Definition: constype.h:42