Revision 51 wattch/power.c

View differences:

power.c
244 244
static double fast_cycles = 0;
245 245
static double last_switch_time = 0;
246 246
static double cycle_count = 0;
247
#define SWITCH_CYCLES 30
248
static int speed_delay[SWITCH_CYCLES];
247 249

  
248 250
static double max_cycle_power_cc1 = 0.0;
249 251
static double max_cycle_power_cc2 = 0.0;
......
369 371
{
370 372
  double window_af_b, lsq_af_b, regfile_af_b, resultbus_af_b;
371 373
  double current;
374
  int speed_idx;
372 375

  
373 376
#ifdef DYNAMIC_AF
374 377
  window_af_b = compute_af(window_num_pop_count_cycle,window_total_pop_count_cycle,data_width);
......
803 806
  }
804 807

  
805 808
  if(init_count >= SUM_OVER) {
809
      // Update speed
810
    speed_grade = speed_delay[SWITCH_CYCLES - 1];
811
    for (speed_idx = 0; speed_idx < SWITCH_CYCLES-1; speed_idx++) {
812

  
813
        speed_delay[speed_idx+1] = speed_delay[speed_idx];
814
    }
815

  
806 816
    diff_dispatch_sum -= hist_dispatch[hist_idx];
807 817
    diff_commit_sum -= hist_commit[hist_idx];
808 818

  
809
    //printf("dispatch_sum=%6f, commit_sum=%6f, diff_dispatch=%6f, diff_commit=%6f\n", diff_dispatch_sum, diff_commit_sum, diff_dispatch, diff_commit);
810
    //printf("slow_cycles=%d, fast_cycles=%d\n", slow_cycles, fast_cycles);
811

  
812 819
    if( diff_commit_sum < diff_dispatch_sum ) {
813
        //printf("dispatch_sum=%6f, commit_sum=%6f, diff_dispatch=%6f, diff_commit=%6f\n", diff_dispatch_sum, diff_commit_sum, diff_dispatch, diff_commit);
814
        speed_grade = 0;
820
        speed_delay[0] = 0;
815 821
    }
816 822
    else if( diff_commit_sum >= diff_dispatch_sum ) {
817
        //printf("dispatch_sum=%6f, commit_sum=%6f, diff_dispatch=%6f, diff_commit=%6f\n", diff_dispatch_sum, diff_commit_sum, diff_dispatch, diff_commit);
818
        speed_grade = 1;
823
        speed_delay[0] = 1;
819 824
    }
820 825

  
821 826
    if(speed_grade == 0) {
......
825 830
        fast_cycles++;
826 831
    }
827 832

  
828
  }
829
  if(init_count < SUM_OVER) {
833
  } else {
830 834
    init_count++;
831 835
    fast_cycles++;
836

  
837
    for (speed_idx = 0; speed_idx < SWITCH_CYCLES; speed_idx++) {
838
        speed_delay[speed_idx] = 1;
839
    }
832 840
  }
833 841

  
834 842
//  if (diff_commit <= diff_dispatch) {

Also available in: Unified diff