Beispiel #1
0
static uint64_t calculate_next(struct AspeedTimer *t)
{
    uint64_t next = 0;
    uint32_t rate = calculate_rate(t);

    while (!next) {
        /* We don't know the relationship between the values in the match
         * registers, so sort using MAX/MIN/zero. We sort in that order as the
         * timer counts down to zero. */
        uint64_t seq[] = {
            calculate_time(t, MAX(t->match[0], t->match[1])),
            calculate_time(t, MIN(t->match[0], t->match[1])),
            calculate_time(t, 0),
        };
        uint64_t reload_ns;
        uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

        if (now < seq[0]) {
            next = seq[0];
        } else if (now < seq[1]) {
            next = seq[1];
        } else if (now < seq[2]) {
            next = seq[2];
        } else if (t->reload) {
            reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate);
            t->start = now - ((now - t->start) % reload_ns);
        } else {
            /* no reload value, return 0 */
            break;
        }
    }

    return next;
}
Beispiel #2
0
/** \brief Substract one day from the calendar */
static void tmg_cal_sub_one_day (GtkSatModule *mod)
{
    gdouble jd;

    jd = calculate_time(mod);
    jd -= 1;
    mod->tmgCdnum = jd;
    tmg_update_widgets(mod);
}
int dsk1interrupt(void) {
	request_desc_p target, prev;
	disk_desc *ptr;
	int ticks;
	double seek_time, rotate_time, transfer_time;
	STATWORD ps;

	disable(ps);
	ptr = (disk_desc *)devtab[DISK1].dvioblk;
	if(!ptr) {
		restore(ps);
		return SYSERR;
	}

	if(!ptr -> request_head) {
		disk1_preempt = MAXINT;
		restore(ps);
		return OK;
	}

	for(target = ptr -> request_head, prev = NULL;target -> next;prev = target, target = target -> next); 
	if(prev != NULL)
		prev -> next = NULL;
	else
		ptr -> request_head = NULL;

	if(target -> type == READ_OPERATION) {
		ptr -> no_of_reads++;
		memncpy(target -> buffer, ptr -> disk + target -> block_no * ptr -> block_size, ptr -> block_size * target -> count);
	}
	else {
		ptr -> no_of_writes++;
		memncpy(ptr -> disk + target -> block_no * ptr -> block_size, target -> buffer, ptr -> block_size * target -> count);
	}
	ptr -> head_sector = target -> block_no + target -> count;
	ready(target -> process_id, RESCHNO);
	freemem(target, sizeof(request_desc));

	// Disk Schedule
	dskschedule(ptr, PA4_DISK_SCHEDULE);
	
	if(ptr -> request_head) {
		for(target = ptr -> request_head;target -> next;target = target -> next);
		calculate_time(ptr, target -> block_no, &seek_time, &rotate_time);
		calculate_transfer_time(ptr, target -> block_no, target -> count, &transfer_time);
		ticks = ms_to_ticks(seek_time + rotate_time + transfer_time);
		target -> ticks = ticks;
		disk1_preempt = ticks;
	}
	else
		disk1_preempt = MAXINT;

	restore(ps);
	return OK;
}
/*
 * dskread() is responsible for serving each read request.
 * It does:
 *     check simple parameter integrity,
 *     calculate seek time, rotate time, and transfer time
 *     insert the current request into each queue
 *     schedule the interrupt related to this request
 *     make the current process into block state.
 * This function supports multiple continuous blocks.
 * Please notice that when calling this function, block_no + count does not have to
 * exceed the last block number. This function does not guarantee that block_no + count
 * does not exceed.
 * parameter:
 *     pdev:		device descriptor
 *     buffer:		a buffer to store read blocks
 *     block_no:	the start block number to be read
 *     count:		the number of continuous blocks to be read
 */
int dskread(struct devsw *pdev, char *buffer, int block_no, int count) {
	disk_desc *ptr;
	double seek_time = 0.0;
	double rotate_time = 0.0;
	double read_time = 0.0;
	int code, ticks;
	request_desc_p request;
	STATWORD ps;
	
	disable(ps);
	if(!pdev || !buffer || count <= 0) {
		restore(ps);
		return SYSERR;
	}
	
	ptr = (disk_desc *)pdev -> dvioblk;	
	if(block_no < 0 || block_no + count > ptr -> logical_blocks) {
		restore(ps);
		return SYSERR;
	}

	request = (request_desc_p)getmem(sizeof(request_desc));
	if(request == (request_desc_p)SYSERR) {
		restore(ps);
		return (int)request;
	}

	if(!ptr -> request_head) {
		calculate_time(ptr, block_no, &seek_time, &rotate_time);
		calculate_transfer_time(ptr, block_no, count, &read_time);
		ticks = ms_to_ticks(seek_time + rotate_time + read_time);
		if(pdev == &devtab[DISK0])
			disk0_preempt = ticks;
		else if(pdev == &devtab[DISK1])
			disk1_preempt = ticks;
		request -> ticks = ticks;
	}
	//kprintf("\n------------dsk read\n");
	request -> type = READ_OPERATION;
	request -> block_no = block_no;
	request -> process_id = currpid;
	request -> buffer = buffer;
	request -> count = count;
	request -> next = ptr -> request_head;
	ptr -> request_head = request;
	//kprintf("\n req buf is %s\n", request->buffer);
	restore(ps);
	if(dskresched() == SYSERR) {
		return SYSERR;
	}
	
	return OK;
}
int main(int argc,char *argv[])
{
	char data[1002];
	int no_of_input;
//	printf("Enter the input\n");
	scanf("%d",&no_of_input);
	getchar();
	int i=0;
	for(i=0;i<no_of_input;i++)
	{
		fgets(data,1002,stdin);
		int time=calculate_time(data);
//		puts(data);
		printf("%d\n",time);
	}
	return 0;
}
/**
 * \brief Set new date and time callback.
 * \param widget The widget that was modified.
 * \param data Pointer to the GtkSatModule structure.
 *
 * This function is called when the user changes the date or time in the time
 * controller. If we are in manual time control mode, the function reads the
 * date and time set in the control widget and calculates the new time for
 * the module. The function does nothing in real time and simulated real
 * time modes.
 */
static void tmg_time_set(GtkWidget * widget, gpointer data)
{
    GtkSatModule   *mod = GTK_SAT_MODULE(data);
    gdouble         slider;
    gdouble         jd;

    (void)widget;               /* avoid unused parameter compiler warning */

    /* update time only if we are in manual time control */
    if (!mod->throttle && !mod->reset)
    {
        jd = calculate_time(mod);

        /* get slider offset */
        slider = gtk_range_get_value(GTK_RANGE(mod->tmgSlider));

        mod->tmgCdnum = jd + slider;
    }
}
Beispiel #7
0
main()
{
  double predeclength, wordlinelength, bitlinelength;

  double regfile_power, regfile_decoder, regfile_wordline, regfile_wordline16, regfile_wordline33, regfile_bitline;

  int scale_factor;
  int data_width;
  int rports, wports;

  int switch_arg;

  printf("1. Simple Register File\n");
  printf("2. Simple Cache Structure\n");
  printf("3. Simple CAM Structure\n");
  printf("4. Complex Cache (Auto-Sized)\n");

  scanf("%d",&switch_arg);

  printf("note these are MAX powers (assuming full switching)\n");

  switch(switch_arg){
    case 1:
      {
	printf("Enter Reg File Params:\n");
	printf("Number of Registers: ");
	scanf("%d",&num_regs);
	printf("Data Width: ");
	scanf("%d",&data_width);
	printf("Number of Read Ports: ");
	scanf("%d",&rports);
	printf("Number of Write Ports: ");
	scanf("%d",&wports);
	
	printf("%d-entryx%d-width,%d-rdport,%d-wrport: %f (W)\n",num_regs,data_width,rports,wports,simple_array_power(num_regs,data_width,rports,wports,0));
	printf(" decode_power (W): %f\n",simple_array_decoder_power(num_regs,data_width,rports,wports,0));
	printf(" wordline_power (W): %f\n",simple_array_wordline_power(num_regs,data_width,rports,wports,0));
	printf(" bitline_power (W): %f\n",simple_array_bitline_power(num_regs,data_width,rports,wports,0));
	break;
      }

    case 2:
      {
	printf("Enter Cache Params:\n");
	printf("Size of cache: ");
	scanf("%d",&num_regs);
	printf("Data Width: ");
	scanf("%d",&data_width);
	printf("Number of Read Ports: ");
	scanf("%d",&rports);
	printf("Number of Write Ports: ");
	scanf("%d",&wports);
	
	printf("%d-entryx%d-width,%d-rdport,%d-wrport: %f (W)\n",num_regs,data_width,rports,wports,simple_array_power(num_regs,data_width,rports,wports,1));
	printf(" decode_power (W): %f\n",simple_array_decoder_power(num_regs,data_width,rports,wports,1));
	printf(" wordline_power (W): %f\n",simple_array_wordline_power(num_regs,data_width,rports,wports,1));
	printf(" bitline_power (W): %f\n",simple_array_bitline_power(num_regs,data_width,rports,wports,1));
	break;
      }

    case 3:
      {
	printf("Enter CAM Params:\n");
	printf("Entries in CAM: ");
	scanf("%d",&num_regs);
	printf("Tag Width: ");
	scanf("%d",&data_width);
	printf("Number of Read Ports: ");
	scanf("%d",&rports);
	printf("Number of Write Ports: ");
	scanf("%d",&wports);
	
	printf("%d-entryx%d-tagwidth,%d-rdport,%d-wrport: %f (W)\n",num_regs,data_width,rports,wports,cam_array(num_regs,data_width,rports,wports));
	printf(" tagdrive_power (W): %f\n",cam_tagdrive(num_regs,data_width,rports,wports));
	printf(" tagmatch_power (W): %f\n",cam_tagmatch(num_regs,data_width,rports,wports));
	break;
      }

    case 4:
      {
	int nsets, bsize, assoc,res_memport, tagsize;
	int ndwl, ndbl, nspd, ntwl, ntbl, ntspd, c,b,a,cache, rowsb, colsb, trowsb, tcolsb;
	double cache_decoder, cache_wordline, cache_bitline, 
	  cache_senseamp, cache_tagarray, total_cache_power;
	time_result_type time_result;
	time_parameter_type time_parameters;
	int va_size = 48;

	printf("Enter Cache Params:\n");
	printf("Number of Sets in cache: ");
	scanf("%d",&nsets);
	printf("Block Size (bytes): ");
	scanf("%d",&bsize);
	printf("Associativity: ");
	scanf("%d",&assoc);
	printf("Number of Memory Ports: ");
	scanf("%d",&res_memport);

	printf("note tagarray size is estimated based on assuming 48-bit virtual addresses\n");

	cache = 1;

	time_parameters.cache_size = nsets * bsize * assoc; /* C */
	time_parameters.block_size = bsize; /* B */
	time_parameters.associativity = assoc; /* A */
	time_parameters.number_of_sets = nsets; /* C/(B*A) */

	calculate_time(&time_result,&time_parameters);
	output_data(&time_result,&time_parameters);

	ndwl=time_result.best_Ndwl;
	ndbl=time_result.best_Ndbl;
	nspd=time_result.best_Nspd;
	ntwl=time_result.best_Ntwl;
	ntbl=time_result.best_Ntbl;
	ntspd=time_result.best_Ntspd;
	c = time_parameters.cache_size;
	b = time_parameters.block_size;
	a = time_parameters.associativity; 

	rowsb = c/(8*b*a*ndbl*nspd);
	colsb = 8*b*a*nspd/ndwl;

	tagsize = va_size - ((int)logtwo(nsets) + (int)logtwo(bsize));
	trowsb = c/(8*b*a*ntbl*ntspd);
	tcolsb = a * (tagsize + 1 + 6) * ntspd/ntwl;

	predeclength = rowsb * (RegCellHeight + WordlineSpacing);
	wordlinelength = colsb *  (RegCellWidth + BitlineSpacing);
	bitlinelength = rowsb * (RegCellHeight + WordlineSpacing);

	cache_decoder = res_memport*ndwl*ndbl*array_decoder_power(rowsb,colsb,predeclength,1,1,cache);
	cache_wordline = res_memport*ndwl*ndbl*array_wordline_power(rowsb,colsb,wordlinelength,1,1,cache);
	cache_bitline = res_memport*ndwl*ndbl*array_bitline_power(rowsb,colsb,bitlinelength,1,1,cache);
	cache_senseamp = res_memport*ndwl*ndbl*senseamp_power(colsb);
	cache_tagarray = res_memport*ntwl*ntbl*(simple_array_power(trowsb,tcolsb,1,1,cache));
	
	total_cache_power = cache_decoder + cache_wordline + cache_bitline + cache_senseamp + cache_tagarray;

	fprintf(stderr,"%d KB %d-way cache (%d-byte block size):\n",c,a,b);
	fprintf(stderr,"ndwl == %d, ndbl == %d, nspd == %d\n",ndwl,ndbl,nspd);
	fprintf(stderr,"%d sets of %d rows x %d cols\n",ndwl*ndbl,rowsb,colsb);
	fprintf(stderr,"tagsize == %d\n",tagsize);
	fprintf(stderr,"\nntwl == %d, ntbl == %d, ntspd == %d\n",ntwl,ntbl,ntspd);
	fprintf(stderr,"%d sets of %d rows x %d cols\n",ntwl*ntbl,trowsb,tcolsb);
	
	printf("Total Power (W): %f\n",total_cache_power);
	printf(" decode_power (W): %f\n",cache_decoder);
	printf(" wordline_power (W): %f\n",cache_wordline);
	printf(" bitline_power (W): %f\n",cache_bitline);
	printf(" senseamp_power (W): %f\n",cache_senseamp);
	printf(" tagarray_power (W): %f\n",cache_tagarray);
	break;
      }
 default:

  }


}
Beispiel #8
0
int main( int argc, char *argv[] )
{
    int32     k;
    char      *tsuf;
    timing_t  start;
    timing_t  end;
    timing_t  diff;
    real32    time;
    real32    secs;
    carray_t  haystack;
    hthread_t *threads;
    arg_t     *args;

    // Allocate the threads structure
    threads = (hthread_t*)malloc( tarsize * sizeof(hthread_t) );

    // Allocate the argument structures
    args    = (arg_t*)malloc( tarsize * sizeof(arg_t) );

    // Create arrays for the search string
    carray_fromstr( &haystack, beowulf );
    carray_concatstr( &haystack, britannica1 );
    carray_concatstr( &haystack, britannica2 );
    carray_concatstr( &haystack, britannica3 );
    carray_concatstr( &haystack, caesar );
    carray_concatstr( &haystack, hamlet );
    carray_concatstr( &haystack, huckfinn );
    carray_concatstr( &haystack, illiad );
    carray_concatstr( &haystack, macbeth );
    carray_concatstr( &haystack, pride );
    carray_concatstr( &haystack, sense );
    carray_concatstr( &haystack, tomsawyer );
    carray_concatstr( &haystack, twist );
    carray_concatstr( &haystack, ulysses );
    carray_concatstr( &haystack, venice );


    // Create all of the thread arguments
    for( k = 0; k < tarsize; k++ )
    {
        args[k].search = &haystack;
        args[k].found  = 0;
        carray_fromstr( &args[k].target, tar[k] );
        boyermoore_init( &args[k].bm, &args[k].target );
    }

    // Create worker threads for all of the search strings
    timing_get( &start );
    for( k = 0; k < tarsize; k++ )
    {
        hthread_create( &threads[k], NULL, search, &args[k] );
    }

    // Wait for all of the worker threads to complete
    for( k = 0; k < tarsize; k++ )
    {
        hthread_join( threads[k], (void*)&args[k].found );
    }
    timing_get( &end );
    timing_diff(diff,end,start);
    secs = timing_sec(diff);
    calculate_time( &tsuf, &time, secs );
    printf( "Test Finished: %.2f %s\n", time, tsuf );

    // Show the results and destroy the thread arguments
    for( k = 0; k < tarsize; k++ )
    {
        printf( "Thread %d found %d matches of the string '%s'\n", k, args[k].found, tar[k] );
        boyermoore_destroy( &args[k].bm );
        carray_destroy( &args[k].target );
    }

    // Exit the program
    return 0;
}
Beispiel #9
0
total_result_type
cacti_interface (int cache_size,
		 int line_size,
		 int associativity,
		 int rw_ports,
		 int excl_read_ports,
		 int excl_write_ports,
		 int single_ended_read_ports,
		 int banks,
		 double tech_node,
		 int output_width,
		 int specific_tag,
		 int tag_width, int access_mode, int pure_sram)
{
  int C, B, A, ERP, EWP, RWP, NSER;
  double tech;
  double logbanks;
  double logbanksfloor;
  int seq_access = 0;
  int fast_access = 0;
  int bits_output = output_width;
  int nr_args = 9;
  double NSubbanks = (double) banks;

  double ratioofbankstoports;

  extern int force_tag, force_tag_size;



  total_result_type endresult;
  endresult.result.subbanks = 0.0;

  result_type result;
  arearesult_type arearesult;
  area_type arearesult_subbanked;
  parameter_type parameters;

  /* input parameters:
     C B A ERP EWP */

  /*dt: make sure we're using some simple leakage reduction */
  dualVt = FALSE;

//#ifdef XCACTI
  //parameters.latchsa    = 0;
  //parameters.ignore_tag = 0;
//#endif
  force_tag = 0;
  parameters.force_tag = 0;

  if (specific_tag)
    {
      force_tag = 1;
      force_tag_size = tag_width;
      parameters.force_tag = 1;
      parameters.tag_size = tag_width;
      //parameters.ignore_tag = 1;
    }


  switch (access_mode)
    {
    case 0:
      seq_access = fast_access = FALSE;
      break;
    case 1:
      seq_access = TRUE;
      fast_access = FALSE;
      break;
    case 2:
      seq_access = FALSE;
      fast_access = TRUE;
      break;
    }

  C = cache_size;
  A = associativity;
  B = line_size;
  if ((B < 1))
    {
      printf ("Block size must >=1\n");
      return endresult;
      //exit(1);
    }

  if ((B * 8 < bits_output))
    {
      printf ("Block size must be at least %d\n", bits_output / 8);
      return endresult;
      //exit(1);
    }


  tech = tech_node;
  if ((tech <= 0))
    {
      printf ("Feature size must be > 0\n");
      return endresult;
      //exit(1);
    }
  if ((tech > 0.8))
    {
      printf ("Feature size must be <= 0.80 (um)\n");
      return endresult;
      //exit(1);
    }

  if (nr_args == 6)
    {
      RWP = 1;
      ERP = 0;
      EWP = 0;
      NSER = 0;
    }
  else if (nr_args == 8)
    {
      RWP = 1;
      ERP = 0;
      EWP = 0;
      NSER = 0;
      bits_output = output_width;
      seq_access = 1;
    }
  else if (nr_args == 9)
    {
      RWP = rw_ports;
      ERP = excl_read_ports;
      EWP = excl_write_ports;
      NSER = single_ended_read_ports;
    }
  else if (nr_args >= 10)
    {
      RWP = rw_ports;
      ERP = excl_read_ports;
      EWP = excl_write_ports;
      NSER = single_ended_read_ports;
      seq_access = 1;
    }
  if ((RWP < 0) || (EWP < 0) || (ERP < 0))
    {
      printf ("Ports must >=0\n");
      return endresult;
      //exit(1);
    }
  if (RWP > 2)
    {
      printf ("Maximum of 2 read/write ports\n");
      return endresult;
      //exit(1);
    }
  if ((RWP + ERP + EWP) < 1)
    {
      printf ("Must have at least one port\n");
      return endresult;
      //exit(1);
    }

  if (NSubbanks < 1)
    {
      printf
	("Number of subbanks should be greater than or equal to 1 and should be a power of 2\n");
      return endresult;
      //exit(1);
    }

  logbanks = logtwo ((double) (NSubbanks));
  logbanksfloor = floor (logbanks);

  if (logbanks > logbanksfloor)
    {
      printf
	("Number of subbanks should be greater than or equal to 1 and should be a power of 2\n");
      return endresult;
      //exit(1);
    }

  if (C == B * A)
    {
      parameters.fully_assoc = 1;
      A = C / B;
    }
  else
    {
      parameters.fully_assoc = 0;
    }


  C = cache_size / ((int) (NSubbanks));
  if ((C < 64))
    {
      printf ("Cache size must >=64\n");
      return endresult;
      //exit(1);
    }

  //A = C/B;
  if (A > 16)
    {
      parameters.fully_assoc = 1;
      A = 16;
    }

  /*if ((associativity == 0) || (A == C/B)) {
     A = C/B;
     parameters.fully_assoc = 1;
     } else {
     if (associativity == 1)
     {
     A=1;
     parameters.fully_assoc = 0;
     }
     else
     {
     parameters.fully_assoc = 0;
     A = associativity;
     if ((A < 1)) {
     printf("Associativity must >= 1\n");
     return endresult;
     //exit(1);
     }
     assoc = logtwo((double)(A));
     assocfloor = floor(assoc);

     if(assoc > assocfloor){
     printf("Associativity should be a power of 2\n");
     return endresult;
     //exit(1);
     }

     if ((A > 32)) {
     printf("Associativity must <= 32\n or try FA (fully associative)\n");
     return endresult;
     //exit(1);
     }
     }
     }

     if (C/(B*A)<=1 && !parameters.fully_assoc) {
     //printf("Number of sets is too small:\n  Need to either increase cache size, or decrease associativity or block size\n  (or use fully associative cache)\n");
     //return endresult;
     A = C/B;
     parameters.fully_assoc = 1;
     //exit(1);
     } */

  printf ("\n########### Printing input for params for testing...###");
  printf ("\n C = %d, B = %d, A = %d", C, B, A);
  printf ("\n RWP = %d, ERP = %d, EWP = %d, NSER = %d", RWP, ERP, EWP, NSER);
  printf
    ("\n banks = %d, tech = %f, bits_output = %d, fast_access = %d, pure_sram = %d",
     banks, tech, bits_output, fast_access, pure_sram);
  printf ("\n force_tag = %d, force_tag_size = %d", force_tag,
	  force_tag_size);
  printf ("\n #################\n");

  parameters.cache_size = C;
  parameters.block_size = B;

  parameters.nr_bits_out = bits_output;
  /*dt: testing sequential access mode */
  if (seq_access)
    {
      parameters.tag_associativity = A;
      parameters.data_associativity = 1;
      parameters.sequential_access = 1;
    }
  else
    {
      parameters.tag_associativity = parameters.data_associativity = A;
      parameters.sequential_access = 0;
    }
  if (fast_access)
    {
      parameters.fast_access = 1;
    }
  else
    {
      parameters.fast_access = 0;
    }
  parameters.num_readwrite_ports = RWP;
  parameters.num_read_ports = ERP;
  parameters.num_write_ports = EWP;
  parameters.NSubbanks = banks;
  parameters.num_single_ended_read_ports = NSER;
  parameters.number_of_sets = C / (B * A);
  parameters.fudgefactor = .8 / tech;
  parameters.tech_size = (double) tech;
  parameters.pure_sram = pure_sram;
  //If multiple banks and multiple ports are specified, then if number of banks/total number
  //of ports > 1 then assume that the multiple ports are implemented via the multiple banks.
  //Also assume that each bank has only 1 RWP port. There are some problems with this logic that
  //will be fixed in v5.0
  ratioofbankstoports = NSubbanks / (RWP + ERP + EWP);
  if (ratioofbankstoports >= 1.0)
    {
      //We assume that each bank has 1 RWP port.
      parameters.num_readwrite_ports = 1;
      parameters.num_read_ports = 0;
      parameters.num_write_ports = 0;
      parameters.num_single_ended_read_ports = 0;
    }

  if (parameters.number_of_sets < 1)
    {
      printf ("Less than one set...\n");
      return endresult;
      //exit(1);
    }

  parameters.VddPow = 4.5 / (pow (parameters.fudgefactor, (2.0 / 3.0)));
  if (parameters.VddPow < 0.7)
    parameters.VddPow = 0.7;
  if (parameters.VddPow > 5.0)
    parameters.VddPow = 5.0;

  printf ("\n##### Printing parameters for testing...#####\n");
  output_params (&parameters);

  init_tech_params_default_process ();	//v4.1: First initialize all tech variables
  //to 0.8 micron values. init_tech_params function below then reinitializes tech variables to
  //given process values
  init_tech_params (parameters.tech_size);
  calculate_time (&result, &arearesult, &arearesult_subbanked, &parameters,
		  &NSubbanks);

  //v4.1: No longer using calculate_area function as area has already been
  //computed for the given tech node

  /*arearesult.dataarray_area.scaled_area = calculate_area(arearesult.dataarray_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.datapredecode_area.scaled_area = calculate_area(arearesult.datapredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.datacolmuxpredecode_area.scaled_area = calculate_area(arearesult.datacolmuxpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.datacolmuxpostdecode_area.scaled_area = calculate_area(arearesult.datacolmuxpostdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.datawritesig_area.scaled_area = (parameters.num_readwrite_ports+parameters.num_read_ports+parameters.num_write_ports)*calculate_area(arearesult.datawritesig_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;

     arearesult.tagarray_area.scaled_area = calculate_area(arearesult.tagarray_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.tagpredecode_area.scaled_area = calculate_area(arearesult.tagpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.tagcolmuxpredecode_area.scaled_area = calculate_area(arearesult.tagcolmuxpredecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.tagcolmuxpostdecode_area.scaled_area = calculate_area(arearesult.tagcolmuxpostdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.tagoutdrvdecode_area.scaled_area = calculate_area(arearesult.tagoutdrvdecode_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;
     arearesult.tagoutdrvsig_area.scaled_area = (parameters.num_readwrite_ports+parameters.num_read_ports+parameters.num_write_ports)*
     calculate_area(arearesult.tagoutdrvsig_area,parameters.fudgefactor)*CONVERT_TO_MMSQUARE;

     arearesult.perc_data = 100*area_all_dataramcells/(arearesult.totalarea*CONVERT_TO_MMSQUARE);
     arearesult.perc_tag  = 100*area_all_tagramcells/(arearesult.totalarea*CONVERT_TO_MMSQUARE);
     arearesult.perc_cont = 100*(arearesult.totalarea*CONVERT_TO_MMSQUARE-area_all_dataramcells-area_all_tagramcells)/(arearesult.totalarea*CONVERT_TO_MMSQUARE);
     arearesult.sub_eff   = (area_all_dataramcells+area_all_tagramcells)*100/(arearesult.totalarea/100000000.0);
     arearesult.total_eff = (NSubbanks)*(area_all_dataramcells+area_all_tagramcells)*100/
     (calculate_area(arearesult_subbanked,parameters.fudgefactor)*CONVERT_TO_MMSQUARE);
     arearesult.totalarea *= CONVERT_TO_MMSQUARE;
     arearesult.subbankarea = calculate_area(arearesult_subbanked,parameters.fudgefactor)*CONVERT_TO_MMSQUARE; */

  arearesult.dataarray_area.scaled_area =
    arearesult.dataarray_area.height * arearesult.dataarray_area.width *
    CONVERT_TO_MMSQUARE;
  arearesult.datapredecode_area.scaled_area =
    arearesult.datapredecode_area.height *
    arearesult.datapredecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.datacolmuxpredecode_area.scaled_area =
    arearesult.datacolmuxpredecode_area.height *
    arearesult.datacolmuxpredecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.datacolmuxpostdecode_area.scaled_area =
    arearesult.datacolmuxpostdecode_area.height *
    arearesult.datacolmuxpostdecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.datawritesig_area.scaled_area =
    (parameters.num_readwrite_ports + parameters.num_read_ports +
     parameters.num_write_ports) * arearesult.datawritesig_area.height *
    arearesult.datawritesig_area.width * CONVERT_TO_MMSQUARE;

  arearesult.tagarray_area.scaled_area =
    arearesult.tagarray_area.height * arearesult.tagarray_area.width *
    CONVERT_TO_MMSQUARE;
  arearesult.tagpredecode_area.scaled_area =
    arearesult.tagpredecode_area.height * arearesult.tagpredecode_area.width *
    CONVERT_TO_MMSQUARE;
  arearesult.tagcolmuxpredecode_area.scaled_area =
    arearesult.tagcolmuxpredecode_area.height *
    arearesult.tagcolmuxpredecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.tagcolmuxpostdecode_area.scaled_area =
    arearesult.tagcolmuxpostdecode_area.height *
    arearesult.tagcolmuxpostdecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.tagoutdrvdecode_area.scaled_area =
    arearesult.tagoutdrvdecode_area.height *
    arearesult.tagoutdrvdecode_area.width * CONVERT_TO_MMSQUARE;
  arearesult.tagoutdrvsig_area.scaled_area =
    (parameters.num_readwrite_ports + parameters.num_read_ports +
     parameters.num_write_ports) * arearesult.tagoutdrvsig_area.height *
    arearesult.tagoutdrvsig_area.width * CONVERT_TO_MMSQUARE;

  arearesult.perc_data =
    100 * area_all_dataramcells / (arearesult.totalarea *
				   CONVERT_TO_MMSQUARE);
  arearesult.perc_tag =
    100 * area_all_tagramcells / (arearesult.totalarea * CONVERT_TO_MMSQUARE);
  arearesult.perc_cont =
    100 * (arearesult.totalarea * CONVERT_TO_MMSQUARE -
	   area_all_dataramcells -
	   area_all_tagramcells) / (arearesult.totalarea *
				    CONVERT_TO_MMSQUARE);
  arearesult.sub_eff =
    (area_all_dataramcells +
     area_all_tagramcells) * 100 / (arearesult.totalarea / 100000000.0);
  arearesult.total_eff =
    (NSubbanks) * (area_all_dataramcells +
		   area_all_tagramcells) * 100 /
    (arearesult_subbanked.height * arearesult_subbanked.width *
     CONVERT_TO_MMSQUARE);
  arearesult.totalarea *= CONVERT_TO_MMSQUARE;
  arearesult.subbankarea =
    arearesult_subbanked.height * arearesult_subbanked.width *
    CONVERT_TO_MMSQUARE;


  if (result.bitline_delay_data < 0.0)
    {
      result.bitline_delay_data = 10 ^ -12;
    }
  if (result.bitline_delay_tag < 0.0)
    {
      result.bitline_delay_tag = 10 ^ -13;
    }
  endresult.result = result;
  endresult.result.subbanks = banks;
  endresult.area = arearesult;
  endresult.params = parameters;

  return endresult;
}
Beispiel #10
0
static void apm_battery_apm_get_power_status(struct apm_power_info *info)
{
	union power_supply_propval status;
	union power_supply_propval capacity, time_to_full, time_to_empty;

	mutex_lock(&apm_mutex);
	find_main_battery();
	if (!main_battery) {
		mutex_unlock(&apm_mutex);
		return;
	}

	/* status */

	if (MPSY_PROP(STATUS, &status))
		status.intval = POWER_SUPPLY_STATUS_UNKNOWN;

	/* ac line status */
#ifdef CONFIG_ARCH_BCM4760
	{
		union power_supply_propval online;

		MPSY_PROP(ONLINE, &online);
		if(online.intval){
			info->ac_line_status = APM_AC_ONLINE;
		} else {
			info->ac_line_status = APM_AC_OFFLINE;
		}
	}
#else
	if ((status.intval == POWER_SUPPLY_STATUS_CHARGING) ||
	    (status.intval == POWER_SUPPLY_STATUS_NOT_CHARGING) ||
	    (status.intval == POWER_SUPPLY_STATUS_FULL))
		info->ac_line_status = APM_AC_ONLINE;
	else
		info->ac_line_status = APM_AC_OFFLINE;
#endif
	/* battery life (i.e. capacity, in percents) */

	if (MPSY_PROP(CAPACITY, &capacity) == 0) {
		info->battery_life = capacity.intval;
	} else {
		/* try calculate using energy */
		info->battery_life = calculate_capacity(SOURCE_ENERGY);
		/* if failed try calculate using charge instead */
		if (info->battery_life == -1)
			info->battery_life = calculate_capacity(SOURCE_CHARGE);
		if (info->battery_life == -1)
			info->battery_life = calculate_capacity(SOURCE_VOLTAGE);
	}

	/* charging status */

	if (status.intval == POWER_SUPPLY_STATUS_CHARGING) {
		info->battery_status = APM_BATTERY_STATUS_CHARGING;
	} else {
		if (info->battery_life > 50)
			info->battery_status = APM_BATTERY_STATUS_HIGH;
		else if (info->battery_life > 5)
			info->battery_status = APM_BATTERY_STATUS_LOW;
		else
			info->battery_status = APM_BATTERY_STATUS_CRITICAL;
	}
	info->battery_flag = info->battery_status;

	/* time */

	info->units = APM_UNITS_MINS;

	if (status.intval == POWER_SUPPLY_STATUS_CHARGING) {
		if (!MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full) ||
				!MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full))
			info->time = time_to_full.intval / 60;
		else
			info->time = calculate_time(status.intval);
	} else {
		if (!MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty) ||
			      !MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty))
			info->time = time_to_empty.intval / 60;
		else
			info->time = calculate_time(status.intval);
	}

	mutex_unlock(&apm_mutex);
}
Beispiel #11
0
static void apm_battery_apm_get_power_status(struct apm_power_info *info)
{
	union power_supply_propval status;
	union power_supply_propval capacity, time_to_full, time_to_empty;

	mutex_lock(&apm_mutex);
	find_main_battery();
	if (!main_battery) {
		mutex_unlock(&apm_mutex);
		return;
	}

	

	if (MPSY_PROP(STATUS, &status))
		status.intval = POWER_SUPPLY_STATUS_UNKNOWN;

	

	if ((status.intval == POWER_SUPPLY_STATUS_CHARGING) ||
	    (status.intval == POWER_SUPPLY_STATUS_NOT_CHARGING) ||
	    (status.intval == POWER_SUPPLY_STATUS_FULL))
		info->ac_line_status = APM_AC_ONLINE;
	else
		info->ac_line_status = APM_AC_OFFLINE;

	

	if (MPSY_PROP(CAPACITY, &capacity) == 0) {
		info->battery_life = capacity.intval;
	} else {
		
		info->battery_life = calculate_capacity(SOURCE_ENERGY);
		
		if (info->battery_life == -1)
			info->battery_life = calculate_capacity(SOURCE_CHARGE);
		if (info->battery_life == -1)
			info->battery_life = calculate_capacity(SOURCE_VOLTAGE);
	}

	

	if (status.intval == POWER_SUPPLY_STATUS_CHARGING) {
		info->battery_status = APM_BATTERY_STATUS_CHARGING;
	} else {
		if (info->battery_life > 50)
			info->battery_status = APM_BATTERY_STATUS_HIGH;
		else if (info->battery_life > 5)
			info->battery_status = APM_BATTERY_STATUS_LOW;
		else
			info->battery_status = APM_BATTERY_STATUS_CRITICAL;
	}
	info->battery_flag = info->battery_status;

	

	info->units = APM_UNITS_MINS;

	if (status.intval == POWER_SUPPLY_STATUS_CHARGING) {
		if (!MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full) ||
				!MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full))
			info->time = time_to_full.intval / 60;
		else
			info->time = calculate_time(status.intval);
	} else {
		if (!MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty) ||
			      !MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty))
			info->time = time_to_empty.intval / 60;
		else
			info->time = calculate_time(status.intval);
	}

	mutex_unlock(&apm_mutex);
}