malt-wr
result.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "constype.h"
#include "timelogic.h"
Include dependency graph for result.c:

Go to the source code of this file.

Macros

#define PHASE_TYPE   0
 
#define TIME_TYPE   1
 
#define VOLTAGE_TYPE   2
 

Functions

int print_signals (SIGNALS *sp, char *filename)
 
int print_edges (SIGNALS *sp, char *filename)
 
void print_delays (FILE *fp, SIGNALS *sp, INPUTS *ip)
 
static void compute_min_max_voltage (SIGNALS *sp, MIN_MAX_AVR *result)
 
void print_voltages (FILE *fp, MIN_MAX_AVR *peak_volt)
 
int print_with_clk (SIGNALS *sp, FILE *fp)
 
int print_async_signals (SIGNALS *sp, FILE *fp)
 
int print_holdsetup (char *filename, SIGNALS *sp_good, SIGNALS *sp_bad, HOLDSETUP *holdset, int hold1setup0)
 
int print_xy_propagation (FILE *fp, SIGNALS *sp, int input_nr, int in_clk_cycle, int out_clk_cycle)
 
static int print_interpolated_time (SIGNALS *sp_phase, char *filename)
 
static int print_interpolated_signals (SIGNALS *sp_phase, char *filename)
 
static int print_interpolated_time_phase (SIGNALS *sp_phase, char *filename)
 
static void set_min_max_avr (MIN_MAX_AVR *mma, double new_val, int type)
 
int print_phase_peak_signals (SIGNALS *sp_phase, SIGNALS *sp_peak, char *filename)
 
int interpolate_signal (SIGNALS *sp_phase, char *filename)
 

Macro Definition Documentation

#define PHASE_TYPE   0

Definition at line 576 of file result.c.

#define TIME_TYPE   1

Definition at line 577 of file result.c.

#define VOLTAGE_TYPE   2

Definition at line 578 of file result.c.

Function Documentation

static void compute_min_max_voltage ( SIGNALS sp,
MIN_MAX_AVR result 
)
static

Definition at line 115 of file result.c.

116 {
117  int k, pulse_nr=0;
118  PULSE *pp;
119 
120  result->v.min=10.0; /* 10 V */
121  result->v.max=0;
122  result->v.avr=0;
123 
124  for(k=0; k<sp->signal_num; k++)
125  {
126  pp=sp->sig_bgn[k];
127 
128  while(pp!=NULL)
129  {
130  result->v.avr += pp->val;
131  pulse_nr++;
132  if(pp->val<result->v.min)
133  result->v.min = pp->val;
134  if(pp->val>result->v.max)
135  result->v.max = pp->val;
136  pp=pp->next;
137  }
138  }
139  if(pulse_nr!=0)
140  result->v.avr/=pulse_nr;
141  else
142  result->v.min = 0;
143 }
struct PULSE_DESC * next
Definition: constype.h:298
struct MIN_MAX_AVR::@2 v
TIME avr
Definition: constype.h:483
PULSE ** sig_bgn
Definition: constype.h:404
TIME max
Definition: constype.h:484
int signal_num
Definition: constype.h:366
TIME min
Definition: constype.h:482
double val
Definition: constype.h:287
int interpolate_signal ( SIGNALS sp_phase,
char *  filename 
)

Definition at line 812 of file result.c.

813 {
814  char outfile[NAME_LENGTH];
815 
817 
818  strcpy(outfile, filename);
819  strcat(outfile, param.period_ext);
820  return print_interpolated_signals(sp_phase, outfile);
821 }
PARAMETERS param
Definition: init.c:10
#define NAME_LENGTH
Definition: constype.h:3
static int print_interpolated_signals(SIGNALS *sp_phase, char *filename)
Definition: result.c:498
char period_ext[NAME_LENGTH]
Definition: constype.h:172
int interpolate_phase_thresh_time(SIGNALS *sp_phase)
Definition: collect.c:693
static char filename[LINE_LENGTH]
Definition: optimize.c:35
int print_async_signals ( SIGNALS sp,
FILE *  fp 
)

Definition at line 254 of file result.c.

255 {
256  int sig_nr;
257  MIN_MAX_AVR peak_volt;
258  int current_index, min_step, min_sig_nr;
259  PULSE **last_pulse;
260 
261  int k;
262  PULSE *pp;
263 
264 
265  fprintf(fp, "simulation step = %.2f ps\nsimulation length = %.2f ps\n\n",
266  sp->min_time_delta*1.0e12,
267  (sp->indices_nr-1)*(sp->min_time_delta*1.0e12));
268 
269 
270  fprintf(fp, "SIGNALS TRACED:\n");
272  {
273  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
274  fprintf(fp, "%s\t<=>\t%s,\t%s\n",
275  sp->signal_names[sig_nr],
276  sp->jspice_voltage_names[sig_nr],
277  sp->jspice_phase_names[sig_nr]);
278  }
279  else
280  {
281  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
282  fprintf(fp, "%s\t<=>\t%s\n",
283  sp->signal_names[sig_nr],
284  sp->jspice_phase_names[sig_nr]);
285  }
286  fprintf(fp, "\n\n");
287 
288 
289  fprintf(fp, "TIME\t\t");
290 
291  for(sig_nr=0; sig_nr<sp->ins_num+sp->inter_num; sig_nr++)
292  fprintf(fp, "\t%s", sp->signal_names[sig_nr]);
293  fprintf(fp, "\n\n");
294 
295  last_pulse = (PULSE**)calloc(sp->signal_num, sizeof(PULSE*));
296  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
297  last_pulse[sig_nr] = sp->sig_bgn[sig_nr];
298 
299  current_index = 0;
300  do
301  {
302  min_step = sp->indices_nr+1;
303  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
304  {
305  if(last_pulse[sig_nr]==NULL)
306  continue;
307 
308  if(last_pulse[sig_nr]->index-current_index < min_step)
309  {
310  min_step = last_pulse[sig_nr]->index-current_index;
311  min_sig_nr = sig_nr;
312  }
313  }
314 
315  if(min_step == sp->indices_nr+1)
316  break;
317 
318  current_index = last_pulse[min_sig_nr]->index;
319 
320  if(min_sig_nr<sp->ins_num+sp->inter_num)
321  {
322  fprintf(fp, "%.2f\t\t", last_pulse[min_sig_nr]->t*1.0e12);
323  for(sig_nr=0; sig_nr<sp->ins_num+sp->inter_num; sig_nr++)
324  {
325  if(last_pulse[sig_nr]==NULL)
326  fprintf(fp, "\t0");
327  else
328  if(last_pulse[sig_nr]->index==current_index)
329  {
330  fprintf(fp, "\t1");
331  last_pulse[sig_nr]=last_pulse[sig_nr]->next;
332  }
333  else
334  fprintf(fp, "\t0");
335  }
336  }
337  else
338  {
339  fprintf(fp, "%.2f\t\t%s", last_pulse[min_sig_nr]->t*1.0e12,
340  sp->signal_names[min_sig_nr]);
341  for(sig_nr=0; sig_nr<sp->ins_num+sp->inter_num; sig_nr++)
342  {
343  if(last_pulse[sig_nr]!=NULL)
344  {
345  if(last_pulse[sig_nr]->prev!=NULL)
346  fprintf(fp, "\t %.2f",
347  (last_pulse[min_sig_nr]->t - last_pulse[sig_nr]->prev->t)*1.0e12);
348  else
349  fprintf(fp, "\t-");
350  }
351  else
352  {
353  if(sp->sig_end[sig_nr]!=NULL)
354  fprintf(fp, "\t %.2f",
355  (last_pulse[min_sig_nr]->t - sp->sig_end[sig_nr]->t)*1.0e12);
356  else
357  fprintf(fp, "\t-");
358  }
359  }
360  last_pulse[min_sig_nr] = last_pulse[min_sig_nr]->next;
361  }
362  fprintf(fp, "\n\n");
363  }
364  while(1);
365 
366 
368  {
369  compute_min_max_voltage(sp, &peak_volt);
370  print_voltages(fp, &peak_volt);
371  }
372 
373  return 1;
374 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
TIME min_time_delta
Definition: constype.h:393
PULSE ** sig_bgn
Definition: constype.h:404
int index
Definition: constype.h:285
PULSE ** sig_end
Definition: constype.h:408
char(* jspice_phase_names)[NAME_LENGTH]
Definition: constype.h:387
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
int inter_num
Definition: constype.h:375
static void compute_min_max_voltage(SIGNALS *sp, MIN_MAX_AVR *result)
Definition: result.c:115
PARAMETERS param
Definition: init.c:10
#define COLLECT_BY_VOLTAGE
Definition: constype.h:45
int indices_nr
Definition: constype.h:399
int pulse_extraction_method
Definition: constype.h:78
char(* jspice_voltage_names)[NAME_LENGTH]
Definition: constype.h:384
int ins_num
Definition: constype.h:372
void print_voltages(FILE *fp, MIN_MAX_AVR *peak_volt)
Definition: result.c:146
void print_delays ( FILE *  fp,
SIGNALS sp,
INPUTS ip 
)

Definition at line 78 of file result.c.

79 {
80  INPUTS *np=ip;
81  DELAYS *dp;
82  int i,k;
83 
84  fprintf(fp, "DELAYS:\n\n");
85  for(i=sp->clk_num; i<sp->clk_num+sp->ins_num; i++)
86  fprintf(fp, "%s\t", sp->signal_names[i]);
87  fprintf(fp, "delay (input clk_cycle)\n\n");
88 
89  while(np!=NULL)
90  {
91  for(i=0; i<sp->ins_num; i++)
92  fprintf(fp, "%d\t", np->input_val[i]);
93 
94  dp=np->delay;
95  i=1;
96  while(dp!=NULL)
97  {
98  if(i==4)
99  {
100  fprintf(fp, "\n");
101  for(k=0; k<sp->ins_num; k++)
102  fprintf(fp, "\t");
103  i=1;
104  }
105  fprintf(fp, "%.3f ps\t(%d)\t", dp->delta*1.0e12, dp->clk_cycle);
106  i++;
107  dp=dp->next;
108  }
109  fprintf(fp, "\n\n");
110  np=np->next;
111  }
112 }
int clk_cycle
Definition: constype.h:505
struct INPUTS_DESC * next
Definition: constype.h:516
int * input_val
Definition: constype.h:513
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
DELAYS * delay
Definition: constype.h:514
TIME delta
Definition: constype.h:504
int clk_num
Definition: constype.h:369
struct DELAYS_DESC * next
Definition: constype.h:506
int ins_num
Definition: constype.h:372
int print_edges ( SIGNALS sp,
char *  filename 
)

Definition at line 42 of file result.c.

43 {
44  int k;
45  EDGE *pp;
46  FILE *fp;
47 
48  fp=fopen(filename, "w");
49  if(fp==NULL)
50  return 0;
51 
52  for(k=0; k<sp->signal_num; k++)
53  {
54  fprintf(fp, "%s\n\n", sp->signal_names[k]);
55 
56  pp=sp->sig_edge_bgn[k];
57 
58  fprintf(fp, "edge\ttime\n");
59  while(pp!=NULL)
60  {
61  fprintf(fp, "%s\t%.2f ps\n",
62  (pp->direction?("F"):("R")),
63  pp->exact_time*1.0e12
64  );
65  pp=pp->next;
66  }
67 
68  fprintf(fp, "\n\n");
69  }
70 
71  fclose(fp);
72 
73  return 1;
74 }
int direction
Definition: constype.h:313
TIME exact_time
Definition: constype.h:316
EDGE ** sig_edge_bgn
Definition: constype.h:412
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
static char filename[LINE_LENGTH]
Definition: optimize.c:35
struct EDGE_DESC * next
Definition: constype.h:319
int print_holdsetup ( char *  filename,
SIGNALS sp_good,
SIGNALS sp_bad,
HOLDSETUP holdset,
int  hold1setup0 
)

Definition at line 379 of file result.c.

381 {
382  FILE *fp;
383  int k;
384 
385  fp=fopen(filename, "a");
386  if(fp==NULL)
387  return 0;
388 
389  if(hold1setup0)
390  {
391  printf("HOLD TIME");
392  fprintf(fp, "HOLD TIME");
393  }
394  else
395  {
396  printf("SETUP TIME");
397  fprintf(fp, "SETUP TIME");
398  }
399 
400  printf("= %.2f ps\n", holdset->delta*1.0e12);
401  fprintf(fp, "= %.2f ps\n", holdset->delta*1.0e12);
402 
403  printf("on input: %s\n", sp_good->signal_names[holdset->input]);
404  fprintf(fp, "on input: %s\n", sp_good->signal_names[holdset->input]);
405  printf("clk cycle: %d\n", holdset->cycle);
406  fprintf(fp, "clk cycle: %d\n", holdset->cycle);
407 
408 
409  printf("for:\n");
410  fprintf(fp,"for:\n");
411 
412  for(k=sp_good->clk_num; k<sp_good->clk_num+sp_good->ins_num; k++)
413  {
414  printf("\t%s = %d\n", sp_good->signal_names[k],
415  sp_good->sig_log[k][holdset->cycle].val);
416  fprintf(fp,"\t%s = %d\n", sp_good->signal_names[k],
417  sp_good->sig_log[k][holdset->cycle].val);
418  }
419 
420  printf("proper output:\n\t%s = %d\n",
421  sp_good->signal_names[sp_good->signal_num-1],
422  sp_good->sig_log[sp_good->signal_num-1][holdset->cycle+1].val);
423  fprintf(fp,"proper output:\n\t%s = %d\n",
424  sp_good->signal_names[sp_good->signal_num-1],
425  sp_good->sig_log[sp_good->signal_num-1][holdset->cycle+1].val);
426 
427  printf("false output:\n\t%s = %d\n\n",
428  sp_bad->signal_names[sp_bad->signal_num-1],
429  sp_bad->sig_log[sp_bad->signal_num-1][holdset->cycle+1].val);
430  fprintf(fp,"false output:\n\t%s = %d\n\n",
431  sp_bad->signal_names[sp_bad->signal_num-1],
432  sp_bad->sig_log[sp_bad->signal_num-1][holdset->cycle+1].val);
433 
434  if(sp_good->sig_log[sp_good->signal_num-1][holdset->cycle+1].val>0)
435  {
436  if(hold1setup0)
437  {
438  printf("HOLD PROPAGATION DELAY = ");
439  fprintf(fp,"HOLD PROPAGATION DELAY = ");
440  }
441  else
442  {
443  printf("SETUP PROPAGATION DELAY = ");
444  fprintf(fp,"SETUP PROPAGATION DELAY = ");
445  }
446  printf("%.1f ps\n",
447  sp_good->sig_log[sp_good->signal_num-1][holdset->cycle+1].delta[0]*1.0e12);
448  fprintf(fp, "%.1f ps\n",
449  sp_good->sig_log[sp_good->signal_num-1][holdset->cycle+1].delta[0]*1.0e12);
450  }
451 
452 
453  fclose(fp);
454  return 1;
455 }
int signal_num
Definition: constype.h:366
TIME * delta
Definition: constype.h:332
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
TIME delta
Definition: constype.h:466
int input
Definition: constype.h:472
int val
Definition: constype.h:329
int clk_num
Definition: constype.h:369
LOGIC ** sig_log
Definition: constype.h:439
int ins_num
Definition: constype.h:372
static char filename[LINE_LENGTH]
Definition: optimize.c:35
int cycle
Definition: constype.h:469
static int print_interpolated_signals ( SIGNALS sp_phase,
char *  filename 
)
static

Definition at line 498 of file result.c.

499 {
500  int k;
501  PULSE *pp_phase;
502  FILE *fp;
503  char outfile[NAME_LENGTH];
504 
505  for(k=0; k<sp_phase->signal_num; k++)
506  {
507  strcpy(outfile, filename);
508  strcat(outfile, ".");
509  strcat(outfile, sp_phase->signal_names[k]);
510 
511  fp=fopen(outfile, "w");
512  if(fp==NULL)
513  {
514  printf("Cannot open file: %s\n", outfile);
515  continue;
516  }
517 
518  pp_phase=sp_phase->sig_bgn[k];
519  while(pp_phase!=NULL)
520  {
521  if(pp_phase->next!=NULL)
522  fprintf(fp, "%.5f\n", (pp_phase->next->t-pp_phase->t)*1.0e12);
523  pp_phase=pp_phase->next;
524  }
525  fclose(fp);
526  }
527 
528  return 1;
529 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
PULSE ** sig_bgn
Definition: constype.h:404
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
#define NAME_LENGTH
Definition: constype.h:3
static char filename[LINE_LENGTH]
Definition: optimize.c:35
static int print_interpolated_time ( SIGNALS sp_phase,
char *  filename 
)
static

Definition at line 468 of file result.c.

469 {
470  int k;
471  PULSE *pp_phase;
472  FILE *fp;
473 
474  fp=fopen(filename, "w");
475  if(fp==NULL)
476  return 0;
477 
478  for(k=0; k<sp_phase->signal_num; k++)
479  {
480  fprintf(fp, "%s\n\n", sp_phase->signal_names[k]);
481 
482  pp_phase=sp_phase->sig_bgn[k];
483 
484  while(pp_phase!=NULL)
485  {
486  fprintf(fp, "%.5f\n", pp_phase->t*1.0e12);
487 
488  pp_phase=pp_phase->next;
489  }
490  fprintf(fp, "\n\n");
491  }
492  fclose(fp);
493 
494  return 1;
495 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
PULSE ** sig_bgn
Definition: constype.h:404
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
static char filename[LINE_LENGTH]
Definition: optimize.c:35
static int print_interpolated_time_phase ( SIGNALS sp_phase,
char *  filename 
)
static

Definition at line 532 of file result.c.

533 {
534  int k;
535  PULSE *pp_phase;
536  FILE *fp;
537 
538  fp=fopen(filename, "w");
539  if(fp==NULL)
540  return 0;
541 
542 
543  for(k=0; k<sp_phase->signal_num; k++)
544  {
545  fprintf(fp, "%s\n\n", sp_phase->signal_names[k]);
546 
547  pp_phase=sp_phase->sig_bgn[k];
548 
549  fprintf(fp, "PHASE BELOW\t");
550  fprintf(fp, "PHASE ABOVE\t");
551  fprintf(fp, "PHASE THRESH\t");
552  fprintf(fp, "TIME BELOW\t");
553  fprintf(fp, "TIME ABOVE\t");
554  fprintf(fp, "TIME THRESH\n");
555 
556  while(pp_phase!=NULL)
557  {
558  fprintf(fp, "%.2f\t\t", pp_phase->p_below);
559  fprintf(fp, "%.2f\t\t", pp_phase->p_above);
560  fprintf(fp, "%.2f\t\t", pp_phase->norm_phase+param.nom_phase_thresh);
561  fprintf(fp, "%.2f\t\t", pp_phase->t_below*1.0e12);
562  fprintf(fp, "%.2f\t\t", pp_phase->t_above*1.0e12);
563  fprintf(fp, "%.2f\n", pp_phase->t*1.0e12);
564 
565  pp_phase=pp_phase->next;
566  }
567  fprintf(fp, "\n\n");
568  }
569  fclose(fp);
570 
571  return 1;
572 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
PULSE ** sig_bgn
Definition: constype.h:404
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
PARAMETERS param
Definition: init.c:10
PHASE p_above
Definition: constype.h:295
PHASE nom_phase_thresh
Definition: constype.h:82
TIME t_above
Definition: constype.h:293
PHASE p_below
Definition: constype.h:294
static char filename[LINE_LENGTH]
Definition: optimize.c:35
TIME t_below
Definition: constype.h:292
PHASE norm_phase
Definition: constype.h:291
int print_phase_peak_signals ( SIGNALS sp_phase,
SIGNALS sp_peak,
char *  filename 
)

Definition at line 612 of file result.c.

613 {
614  int k, i, pulse_nr;
615  PULSE *pp_phase, *pp_peak;
616  FILE *fp;
617  int OK=1;
618 
619  TIME tdelta;
620  PHASE pdelta;
621  VOLTAGE vdelta;
622  MIN_MAX_AVR t2peak, phaseper, peakper, v2peak, p2phase, p2thresh;
623 
624 
625  if(sp_peak->signal_num != sp_phase->signal_num)
626  {
627  printf("Error !\n");
628  printf("Numbers of signals defined in voltage and phase files do not match!\n");
629  return 0;
630  }
631 
632  if(sp_peak->min_time_delta != sp_phase->min_time_delta)
633  {
634  printf("Error !\n");
635  printf("Time resolutions defined in voltage and phase files do not match!\n");
636  return 0;
637  }
638 
639  fp=fopen(filename, "w");
640  if(fp==NULL)
641  return 0;
642 
643 
644  for(k=0; k<sp_peak->signal_num; k++)
645  {
646  fprintf(fp, "%s\n\n", sp_peak->signal_names[k]);
647 
648  t2peak.t.min = phaseper.t.min = peakper.t.min = 1.0;
649  t2peak.t.max = phaseper.t.max = peakper.t.max = -1.0;
650  t2peak.t.avr = phaseper.t.avr = peakper.t.avr = 0.0;
651  p2phase.p.min = p2thresh.p.min = 2*M_PI;
652  p2phase.p.max = p2thresh.p.max = -2*M_PI;
653  p2phase.p.avr = p2thresh.p.avr = 0.0;
654  v2peak.v.min = 1.0;
655  v2peak.v.max = -1.0;
656  v2peak.v.avr = 0;
657 
658 
659  pp_phase=sp_phase->sig_bgn[k];
660  pp_peak=sp_peak->sig_bgn[k];
661 
662 
663  fprintf(fp, "PHASE TIME\t\t\t\t\t\t\t");
664  fprintf(fp, "PHASE VOLTAGE\t\t");
665  fprintf(fp, "PEAK PHASE\t\t");
666  fprintf(fp, "PHASE\n");
667 
668  fprintf(fp, "\tTO PEAK\t\t");
669  fprintf(fp, "PHASE PERIOD\t");
670  fprintf(fp, "PEAK PERIOD\t\t\t");
671  fprintf(fp, "TO PEAK\t\t\t");
672  fprintf(fp, "TO PHASE\t\t");
673  fprintf(fp, "TO THRESHOLD\n\n");
674 
675  pulse_nr=0;
676  while(pp_phase!=NULL)
677  {
678  if(pp_peak==NULL)
679  {
680  printf("PULSE COLLECTION METHODS COMPARISON:\n");
681  printf("Warning !\n");
682  printf("Numbers of pulses in signal %s do not match.\n\n",
683  sp_peak->signal_names[k]);
684  OK=0;
685  break;
686  }
687 
688  fprintf(fp, "%.2f ps \t\t\t\t\t\t\t", pp_phase->t*1.0e12);
689  fprintf(fp, "%.1f uV \t\t", pp_phase->val*1.0e+6);
690  fprintf(fp, "%.2f\t\t\t", pp_peak->phase);
691  fprintf(fp, "%.2f", pp_phase->phase);
692  fprintf(fp, "\n");
693 
694  tdelta = pp_phase->t-pp_peak->t;
695  fprintf(fp, "\t%.2f ps \t", tdelta*1.0e12);
696  set_min_max_avr(&t2peak, tdelta, TIME_TYPE);
697 
698  if(pp_phase->next!=NULL)
699  {
700  tdelta = pp_phase->next->t-pp_phase->t;
701  fprintf(fp, "%.2f ps \t", tdelta*1.0e12);
702  set_min_max_avr(&phaseper, tdelta, TIME_TYPE);
703  }
704  else
705  fprintf(fp, "\t\t\t\t");
706 
707  if(pp_peak->next!=NULL)
708  {
709  tdelta = pp_peak->next->t-pp_peak->t;
710  fprintf(fp, "%.2f ps \t\t\t", tdelta*1.0e12);
711  set_min_max_avr(&peakper, tdelta, TIME_TYPE);
712  }
713  else
714  fprintf(fp, "\t\t");
715 
716  vdelta = pp_phase->val-pp_peak->val;
717  fprintf(fp, "%.1f uV \t\t", vdelta*1.0e+6);
718  set_min_max_avr(&v2peak, vdelta, VOLTAGE_TYPE);
719 
720  pdelta = pp_peak->phase-pp_phase->phase;
721  fprintf(fp, "%.2f\t\t\t", pdelta);
722  set_min_max_avr(&p2phase, pdelta, PHASE_TYPE);
723 
724  pdelta = pp_phase->phase-(pp_phase->norm_phase+param.nom_phase_thresh);
725  fprintf(fp, "%.2f", pdelta);
726  set_min_max_avr(&p2thresh, pdelta, PHASE_TYPE);
727  fprintf(fp, "\n");
728 
729  pulse_nr++;
730  pp_phase=pp_phase->next;
731  pp_peak=pp_peak->next;
732  }
733 
734  for(i=0; i<131; i++)
735  fprintf(fp, "-");
736  fprintf(fp, "\n");
737 
738  if(pulse_nr!=0)
739  {
740  t2peak.t.avr/=pulse_nr;
741  p2phase.p.avr/=pulse_nr;
742  p2thresh.p.avr/=pulse_nr;
743  v2peak.v.avr/=pulse_nr;
744  }
745  if(pulse_nr>1)
746  {
747  phaseper.t.avr/=(pulse_nr-1);
748  peakper.t.avr/=(pulse_nr-1);
749  }
750 
751  fprintf(fp, "AVR\t");
752  if(pulse_nr!=0)
753  fprintf(fp, "%.2f ps \t", t2peak.t.avr*1.0e+12);
754  else
755  fprintf(fp, "\t\t");
756  if(pulse_nr>1)
757  fprintf(fp, "%.2f ps \t%.2f ps \t\t\t",
758  phaseper.t.avr*1.0e+12,
759  peakper.t.avr*1.0e+12);
760  if(pulse_nr!=0)
761  {
762  fprintf(fp, "%.1f uV \t\t", v2peak.v.avr*1.0e6);
763  fprintf(fp, "%.2f\t\t\t", p2phase.p.avr);
764  fprintf(fp, "%.2f", p2thresh.p.avr);
765  }
766  fprintf(fp, "\n");
767 
768  fprintf(fp, "MIN\t");
769  if(pulse_nr!=0)
770  fprintf(fp, "%.2f ps \t", t2peak.t.min*1.0e+12);
771  else
772  fprintf(fp, "\t\t");
773  if(pulse_nr>1)
774  fprintf(fp, "%.2f ps \t%.2f ps \t\t\t",
775  phaseper.t.min*1.0e+12,
776  peakper.t.min*1.0e+12);
777  if(pulse_nr!=0)
778  {
779  fprintf(fp, "%.1f uV \t\t", v2peak.v.min*1.0e6);
780  fprintf(fp, "%.2f\t\t\t", p2phase.p.min);
781  fprintf(fp, "%.2f", p2thresh.p.min);
782  }
783  fprintf(fp, "\n");
784 
785  fprintf(fp, "MAX\t");
786  if(pulse_nr!=0)
787  fprintf(fp, "%.2f ps \t", t2peak.t.max*1.0e+12);
788  else
789  fprintf(fp, "\t\t");
790  if(pulse_nr>1)
791  fprintf(fp, "%.2f ps \t%.2f ps \t\t\t",
792  phaseper.t.max*1.0e+12,
793  peakper.t.max*1.0e+12);
794  if(pulse_nr!=0)
795  {
796  fprintf(fp, "%.1f uV \t\t", v2peak.v.max*1.0e6);
797  fprintf(fp, "%.2f\t\t\t", p2phase.p.max);
798  fprintf(fp, "%.2f", p2thresh.p.max);
799  }
800  fprintf(fp, "\n");
801 
802  fprintf(fp, "\n\n");
803  }
804 
805  fclose(fp);
806 
807  return OK;
808 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
struct MIN_MAX_AVR::@2 v
TIME min_time_delta
Definition: constype.h:393
TIME avr
Definition: constype.h:483
PULSE ** sig_bgn
Definition: constype.h:404
TIME max
Definition: constype.h:484
#define TIME_TYPE
Definition: result.c:577
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
PARAMETERS param
Definition: init.c:10
PHASE nom_phase_thresh
Definition: constype.h:82
static void set_min_max_avr(MIN_MAX_AVR *mma, double new_val, int type)
Definition: result.c:581
struct MIN_MAX_AVR::@0 t
float PHASE
Definition: constype.h:55
struct MIN_MAX_AVR::@1 p
TIME min
Definition: constype.h:482
float TIME
Definition: constype.h:54
float VOLTAGE
Definition: constype.h:56
#define PHASE_TYPE
Definition: result.c:576
static char filename[LINE_LENGTH]
Definition: optimize.c:35
#define VOLTAGE_TYPE
Definition: result.c:578
PHASE phase
Definition: constype.h:288
double val
Definition: constype.h:287
PHASE norm_phase
Definition: constype.h:291
int print_signals ( SIGNALS sp,
char *  filename 
)

Definition at line 9 of file result.c.

10 {
11  int k;
12  PULSE *pp;
13  FILE *fp;
14 
15  fp=fopen(filename, "w");
16  if(fp==NULL)
17  return 0;
18 
19  for(k=0; k<sp->signal_num; k++)
20  {
21  fprintf(fp, "%s\n\n", sp->signal_names[k]);
22 
23  pp=sp->sig_bgn[k];
24 
25  while(pp!=NULL)
26  {
27  fprintf(fp, "%.2f ps\t%.2f uV\t%.2f\n", pp->t*1.0e12,
28  pp->val*1.0e+6,
29  pp->phase);
30  pp=pp->next;
31  }
32 
33  fprintf(fp, "\n\n");
34  }
35 
36  fclose(fp);
37 
38  return 1;
39 }
struct PULSE_DESC * next
Definition: constype.h:298
TIME t
Definition: constype.h:284
PULSE ** sig_bgn
Definition: constype.h:404
int signal_num
Definition: constype.h:366
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
static char filename[LINE_LENGTH]
Definition: optimize.c:35
PHASE phase
Definition: constype.h:288
double val
Definition: constype.h:287
void print_voltages ( FILE *  fp,
MIN_MAX_AVR peak_volt 
)

Definition at line 146 of file result.c.

147 {
148  fprintf(fp, "PEAK VOLTAGES:\n\n");
149  fprintf(fp, "min - %.2f uV\n", peak_volt->v.min*1.0e6);
150  fprintf(fp, "max - %.2f uV\n", peak_volt->v.max*1.0e6);
151  fprintf(fp, "avr - %.2f uV\n", peak_volt->v.avr*1.0e6);
152 }
struct MIN_MAX_AVR::@2 v
TIME avr
Definition: constype.h:483
TIME max
Definition: constype.h:484
TIME min
Definition: constype.h:482
int print_with_clk ( SIGNALS sp,
FILE *  fp 
)

Definition at line 155 of file result.c.

156 {
157  int clk_cycle, sig_nr;
158  int tval = 0;
159  int next_line;
160  INPUTS *ip;
161  MIN_MAX_AVR peak_volt;
162 
163  fprintf(fp, "CIRCUIT NAME:\t%s\n\n", param.circuit_name);
164  fprintf(fp, "simulation step = %.2f ps\nsimulation length = %.2f ps\n\n",
165  sp->min_time_delta*1.0e12,
166  (sp->indices_nr-1)*(sp->min_time_delta*1.0e12));
167 
168  fprintf(fp, "SIGNALS TRACED:\n");
170  {
171  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
172  fprintf(fp, "%s\t<=>\t%s,\t%s\n",
173  sp->signal_names[sig_nr],
174  sp->jspice_voltage_names[sig_nr],
175  sp->jspice_phase_names[sig_nr]);
176  }
177  else
178  {
179  for(sig_nr=0; sig_nr<sp->signal_num; sig_nr++)
180  fprintf(fp, "%s\t<=>\t%s\n",
181  sp->signal_names[sig_nr],
182  sp->jspice_phase_names[sig_nr]);
183  }
184  fprintf(fp, "\n\n");
185 
186 
187  fprintf(fp, "CYCLE\tCLK\tPERIOD\t");
188 
189  for(sig_nr=1; sig_nr<sp->signal_num; sig_nr++)
190  fprintf(fp, "\t%s", sp->signal_names[sig_nr]);
191  fprintf(fp, "\n");
192 
193  for(clk_cycle=0; clk_cycle<sp->clk_cycles_nr; clk_cycle++)
194  {
195  if(clk_cycle!=0)
196  fprintf(fp, "\t%.2f\t\t", sp->clk_times[clk_cycle]*1.0e12);
197  else
198  fprintf(fp, "\t\t\t");
199 
200  for(sig_nr=1; sig_nr<sp->signal_num; sig_nr++)
201  if(sp->sig_log[sig_nr][clk_cycle].val>0)
202  fprintf(fp, "\t +%.2f", sp->sig_log[sig_nr][clk_cycle].delta[0]*1.0e12);
203  else
204  fprintf(fp, "\t");
205  fprintf(fp, "\n");
206 
207  tval = 1;
208  while(1) {
209  next_line = 0;
210  for(sig_nr=1; sig_nr<sp->signal_num; sig_nr++)
211  if(sp->sig_log[sig_nr][clk_cycle].val>tval)
212  next_line = 1;
213 
214  if(!next_line)
215  break;
216 
217  fprintf(fp, "\t\t\t");
218  for(sig_nr=1; sig_nr<sp->signal_num; sig_nr++)
219  if(sp->sig_log[sig_nr][clk_cycle].val>tval)
220  fprintf(fp, "\t +%.2f",
221  sp->sig_log[sig_nr][clk_cycle].delta[tval]*1.0e12);
222  else
223  fprintf(fp, "\t");
224  fprintf(fp, "\n");
225 
226  tval++;
227  }
228 
229  if((clk_cycle!=0) && (clk_cycle != sp->clk_cycles_nr-1))
230  fprintf(fp,"%d\t\t%.2f\t", clk_cycle,
231  (sp->clk_times[clk_cycle+1] - sp->clk_times[clk_cycle])*1.0e12);
232  else
233  fprintf(fp,"%d\t\t\t", clk_cycle);
234  for(sig_nr=1; sig_nr<sp->signal_num; sig_nr++)
235  fprintf(fp, "\t%d", sp->sig_log[sig_nr][clk_cycle].val);
236  fprintf(fp, "\n");
237  }
238 
239  fprintf(fp, "\n\n");
240  if((ip=compute_delays(sp))!=NULL)
241  print_delays(fp, sp, ip);
242 
244  {
245  compute_min_max_voltage(sp, &peak_volt);
246  print_voltages(fp, &peak_volt);
247  }
248 
249  return 1;
250 }
TIME * clk_times
Definition: constype.h:431
char circuit_name[NAME_LENGTH]
Definition: constype.h:184
TIME min_time_delta
Definition: constype.h:393
char(* jspice_phase_names)[NAME_LENGTH]
Definition: constype.h:387
int clk_cycles_nr
Definition: constype.h:434
int signal_num
Definition: constype.h:366
TIME * delta
Definition: constype.h:332
char(* signal_names)[NAME_LENGTH]
Definition: constype.h:381
static void compute_min_max_voltage(SIGNALS *sp, MIN_MAX_AVR *result)
Definition: result.c:115
PARAMETERS param
Definition: init.c:10
#define COLLECT_BY_VOLTAGE
Definition: constype.h:45
int val
Definition: constype.h:329
LOGIC ** sig_log
Definition: constype.h:439
int indices_nr
Definition: constype.h:399
void print_delays(FILE *fp, SIGNALS *sp, INPUTS *ip)
Definition: result.c:78
INPUTS * compute_delays(SIGNALS *sp)
Definition: timelogic.c:125
int pulse_extraction_method
Definition: constype.h:78
char(* jspice_voltage_names)[NAME_LENGTH]
Definition: constype.h:384
void print_voltages(FILE *fp, MIN_MAX_AVR *peak_volt)
Definition: result.c:146
int print_xy_propagation ( FILE *  fp,
SIGNALS sp,
int  input_nr,
int  in_clk_cycle,
int  out_clk_cycle 
)

Definition at line 458 of file result.c.

460 {
461  fprintf(fp, "%.4f\t",
462  sp->sig_log[sp->clk_num+input_nr-1][in_clk_cycle].delta[0]*1.0e12);
463  fprintf(fp, "%.4f\n",
464  sp->sig_log[sp->signal_num-1][out_clk_cycle].delta[0]*1.0e12);
465 }
int signal_num
Definition: constype.h:366
TIME * delta
Definition: constype.h:332
int clk_num
Definition: constype.h:369
LOGIC ** sig_log
Definition: constype.h:439
static void set_min_max_avr ( MIN_MAX_AVR mma,
double  new_val,
int  type 
)
static

Definition at line 581 of file result.c.

582 {
583  switch(type)
584  {
585  case TIME_TYPE:
586  if(new_val< mma->t.min)
587  mma->t.min = new_val;
588  if(new_val > mma->t.max)
589  mma->t.max = new_val;
590  mma->t.avr += new_val;
591  break;
592 
593  case PHASE_TYPE:
594  if(new_val< mma->p.min)
595  mma->p.min = new_val;
596  if(new_val > mma->p.max)
597  mma->p.max = new_val;
598  mma->p.avr += new_val;
599  break;
600 
601  case VOLTAGE_TYPE:
602  if(new_val< mma->v.min)
603  mma->v.min = new_val;
604  if(new_val > mma->v.max)
605  mma->v.max = new_val;
606  mma->v.avr += new_val;
607  break;
608  }
609 }
struct MIN_MAX_AVR::@2 v
TIME avr
Definition: constype.h:483
TIME max
Definition: constype.h:484
#define TIME_TYPE
Definition: result.c:577
struct MIN_MAX_AVR::@0 t
struct MIN_MAX_AVR::@1 p
TIME min
Definition: constype.h:482
#define PHASE_TYPE
Definition: result.c:576
#define VOLTAGE_TYPE
Definition: result.c:578