⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 area.c.svn-base

📁 模拟多核状态下龙芯处理器的功能
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
/*------------------------------------------------------------
 *                              CACTI 4.0
 *         Copyright 2005 Hewlett-Packard Development Corporation
 *                         All Rights Reserved
 *
 * Permission to use, copy, and modify this software and its documentation is
 * hereby granted only under the following terms and conditions.  Both the
 * above copyright notice and this permission notice must appear in all copies
 * of the software, derivative works or modified versions, and any portions
 * thereof, and both notices must appear in supporting documentation.
 *
 * Users of this software agree to the terms and conditions set forth herein, and
 * hereby grant back to Hewlett-Packard Company and its affiliated companies ("HP")
 * a non-exclusive, unrestricted, royalty-free right and license under any changes, 
 * enhancements or extensions  made to the core functions of the software, including 
 * but not limited to those affording compatibility with other hardware or software
 * environments, but excluding applications which incorporate this software.
 * Users further agree to use their best efforts to return to HP any such changes,
 * enhancements or extensions that they make and inform HP of noteworthy uses of
 * this software.  Correspondence should be provided to HP at:
 *
 *                       Director of Intellectual Property Licensing
 *                       Office of Strategy and Technology
 *                       Hewlett-Packard Company
 *                       1501 Page Mill Road
 *                       Palo Alto, California  94304
 *
 * This software may be distributed (but not offered for sale or transferred
 * for compensation) to third parties, provided such third parties agree to
 * abide by the terms and conditions of this notice.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND HP DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL HP 
 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 *------------------------------------------------------------*/

#include <math.h>
#include "def.h"
#include "areadef.h"
#include "stdio.h"
#include "basic_circuit.h"
#include <stdlib.h>

extern int force_tag, force_tag_size;//Added by Shyam 

//v4.1: Earlier all the dimensions (length/width/thickness) of the transistors and wires
//were calculated for the 0.8 micron process and then scaled to the input techology. Now
//all dimensions are calculated directly for the input technology, so area no longer needs to 
//be scaled to the input technology.

double
logtwo_area (double x)
{
  if (x <= 0)
    printf ("%e\n", x);
  return ((double) (log (x) / log (2.0)));
}

//double
//calculate_area (area_type module_area,double techscaling_factor)
//{
  //return (module_area.height * module_area.width * (1 / techscaling_factor) *
	  //(1 / techscaling_factor));
//}

area_type
inverter_area (double Widthp,double Widthn)
{
  double Width_n, Width_p;
  area_type invarea;
  int foldp = 0, foldn = 0;
  if (Widthp > 10.0 / FUDGEFACTOR)
    {
      Widthp = Widthp / 2, foldp = 1;
    }
  if (Widthn > 10.0 / FUDGEFACTOR)
    {
      Widthn = Widthn / 2, foldn = 1;
    }
  invarea.height = Widthp + Widthn + Widthptondiff + 2 * Widthtrack;
  Width_n =
    (foldn) ? (3 * Widthcontact +
	       2 * (Wpoly + 2 * ptocontact)) : (2 * Widthcontact + Wpoly +
						2 * ptocontact);
  Width_p =
    (foldp) ? (3 * Widthcontact +
	       2 * (Wpoly + 2 * ptocontact)) : (2 * Widthcontact + Wpoly +
						2 * ptocontact);
  invarea.width = MAX (Width_n, Width_p);
  return (invarea);
}

area_type
subarraymem_area (int C,int B,int A,int Ndbl,int Ndwl,double Nspd,int RWP,int ERP,int EWP,int NSER,double techscaling_factor)	/* returns area of subarray */
{
  area_type memarea;
  int noof_rows, noof_colns;

  //v4.1: Fixing double->int type conversion problems. EPSILON is added below to make sure
  //the final int value is the correct one 
  //noof_rows = (C / (B * A * Ndbl * Nspd));
  //noof_colns = (8 * B * A * Nspd / Ndwl);
  noof_rows = (int)((C / (B * A * Ndbl * Nspd)) + EPSILON);
  noof_colns = (int)((8 * B * A * Nspd / Ndwl) + EPSILON);

  memarea.height = ceil((double)(noof_rows)/16.0)*stitch_ramv+(BitHeight1x1+Widthtrack*2*(RWP+ERP+EWP-1))*noof_rows;
  memarea.width  = noof_colns*(BitWidth1x1+(Widthtrack*2*(RWP+(ERP-NSER)+EWP-1)+Widthtrack*NSER));
	/* dt
	was : memarea.height = ceil((double)(noof_rows)/16.0)*stitch_ramv+(BitHeight16x2+2*Widthtrack*2*(RWP+ERP+EWP-1))*ceil((double)(noof_rows)/2.0);
		  memarea.width  = ceil((double)(noof_colns)/16.0)*(BitWidth16x2+16*(Widthtrack*2*(RWP+(ERP-NSER)+EWP-1)+Widthtrack*NSER));
	now : use single cell for width and height
	*/

  //area_all_dataramcells =
    //Ndwl * Ndbl * calculate_area (memarea, techscaling_factor) * CONVERT_TO_MMSQUARE;
  area_all_dataramcells = Ndwl * Ndbl * memarea.height * memarea.width * CONVERT_TO_MMSQUARE;
  return (memarea);
}

area_type
decodemem_row (int C,int B,int A,int Ndbl,double Nspd,int Ndwl,int RWP,int ERP,int EWP)	/* returns area of post decode */
{
  int noof_colns, numstack;
  double decodeNORwidth;
  double desiredrisetime, Cline, Rpdrive, psize, nsize;
  area_type decinv, worddriveinv, postdecodearea;

  /*
  How many bit columns do we have in each subarray?
  Since our basic unit is the byte, we have 8 bits to the byte.
  Each Block is made up of B bytes -> 8*B
  If we have associativity A, then all the ways are mapped to one wordline -> 8*B*A
  If we mapped more than one set to each wordline (if Nspd > 1) than the wordline is longer again -> 8*B*A*Nspd
  If we have subdivided the global wordline into segments (if Ndwl > 1) than the local wordline is shorter -> 8*B*A*Nspd/Ndwl
  */
  //v4.1: Fixing double->int type conversion problems. EPSILON is added below to make sure
  //the final int value is the correct one 
  //noof_colns = 8 * B * A * Nspd / Ndwl;
  noof_colns = (int) (8 * B * A * Nspd / Ndwl + EPSILON);
  desiredrisetime = krise * log ((double) (noof_colns)) / 2.0;
  Cline = (2 * Wmemcella * Leff * Cgatepass + Cwordmetal) * noof_colns;
  Rpdrive = desiredrisetime / (Cline * log (VSINV) * -1.0);
  psize = Rpchannelon / Rpdrive;
  if (psize > Wworddrivemax)
    {
      psize = Wworddrivemax;
    }
  numstack =
    (int)ceil ((1.0 / 3.0) * logtwo_area ((double)
		       ((double) C / (double) (B * A * Ndbl * Nspd))));
  if (numstack == 0)
    numstack = 1;
  if (numstack > 5)
    numstack = 5;
  switch (numstack)
    {
    case 1:
      decodeNORwidth = WidthNOR1;
      break;
    case 2:
      decodeNORwidth = WidthNOR2;
      break;
    case 3:
      decodeNORwidth = WidthNOR3;
      break;
    case 4:
      decodeNORwidth = WidthNOR4;
      break;
    case 5:
      decodeNORwidth = WidthNOR4;
      break;
    default:
      printf ("error:numstack=%d\n", numstack);
      printf ("Cacti does not support a series stack of %d transistors !\n",
	      numstack);
      exit(0);
      break;

    }
  nsize = psize * Wdecinvn / Wdecinvp;
  decinv = inverter_area (Wdecinvp, Wdecinvn);
  worddriveinv = inverter_area (psize, nsize);
  /*
	was: postdecodearea.height = (BitHeight16x2+2*Widthtrack*2*(RWP+ERP+EWP-1));
  */
  postdecodearea.height = (2*BitHeight1x1+2*Widthtrack*2*(RWP+ERP+EWP-1));
  postdecodearea.width =
    (decodeNORwidth + decinv.height + worddriveinv.height) * (RWP + ERP +
							      EWP);
  return (postdecodearea);
}

//v4.1: Making noof_rows double since the variable colns_datasubarray is function area
//was made double and is used as an argument corresponding to noof_rows in function calls 
//to predecode_area
//area_type
//predecode_area (int noof_rows,int RWP,int ERP,int EWP)	/*returns the area of predecode */
area_type
predecode_area (double noof_rows,int RWP,int ERP,int EWP)
/* this puts the different predecode blocks for the different ports side by side and does not put them as an array or something */

{
  area_type predecode, predecode_temp;
  int N3to8;
  //v4.1: noof_rows can be less than 1 now since because Nspd can be a fraction. When
  //noof_rows is less than 1 making N3to8 1. This is not clean and needs to be fixed later. 
  if(noof_rows < 1) 
	N3to8 = 1;
  else 
	//v4.1: using integer casting below 
	//N3to8 = ceil ((1.0 / 3.0) * logtwo_area ((double) (noof_rows)));
      N3to8 = (int) (ceil ((1.0 / 3.0) * logtwo_area ((double) (noof_rows))));
  if (N3to8 == 0)
    {
      N3to8 = 1;
    }

  switch (N3to8)
    {
    case 1:
      predecode_temp.height = Predec_height1;
      predecode_temp.width = Predec_width1;
      break;
    case 2:
      predecode_temp.height = Predec_height2;
      predecode_temp.width = Predec_width2;
      break;
    case 3:
      predecode_temp.height = Predec_height3;
      predecode_temp.width = Predec_width3;
      break;
    case 4:
      predecode_temp.height = Predec_height4;
      predecode_temp.width = Predec_width4;
      break;
    case 5:
      predecode_temp.height = Predec_height5;
      predecode_temp.width = Predec_width5;
      break;
    case 6:
      predecode_temp.height = Predec_height6;
      predecode_temp.width = Predec_width6;
      break;
    default:
      printf ("error:N3to8=%d\n", N3to8);
      exit (0);

    }

  predecode.height = predecode_temp.height;
  predecode.width = predecode_temp.width * (RWP + ERP + EWP);
  return (predecode);
}

//v4.1: Making noof_rows double since the variable colns_datasubarray is function area
//was made double and is used as an argument corresponding to noof_rows in function calls 
//to postdecode_area
area_type
postdecode_area (int noof_rows,int RWP,int ERP,int EWP)
{
  //v4.1:	Making decodeNORwidth double which is what it should be
  //int numstack, decodeNORwidth;
  int numstack;
  double decodeNORwidth;
  area_type postdecode, decinverter;
  decinverter = inverter_area (Wdecinvp, Wdecinvn);
  //v4.1: noof_rows can be less than 1 now since because Nspd can be a fraction. When
  //noof_rows is less than 1 making N3to8 1. This is not clean and needs to be fixed later. 
  if(noof_rows < 1) 
	numstack = 1;
  else
    //v4.1: using integer casting below 
	//numstack = ceil ((1.0 / 3.0) * logtwo_area ((double) (noof_rows)));
    numstack = (int) (ceil ((1.0 / 3.0) * logtwo_area ((double) (noof_rows))));
  if (numstack == 0)
    numstack = 1;
  if (numstack > 5)
    numstack = 5;
  switch (numstack)
    {
    case 1:
      decodeNORwidth = WidthNOR1;
      break;
    case 2:
      decodeNORwidth = WidthNOR2;
      break;
    case 3:
      decodeNORwidth = WidthNOR3;
      break;
    case 4:
      decodeNORwidth = WidthNOR4;
      break;
    case 5:
      decodeNORwidth = WidthNOR4;
      break;
    default:
      printf ("error:numstack=%d\n", numstack);
      printf ("Cacti does not support a series stack of %d transistors !\n",
	      numstack);
      exit (0);
      break;

    }
  postdecode.height =
    (BitHeight + Widthtrack * 2 * (RWP + ERP + EWP - 1)) * noof_rows;
  postdecode.width =
    (2 * decinverter.height + decodeNORwidth) * (RWP + ERP + EWP);
  return (postdecode);
}

area_type
colmux (int Ndbl,double Nspd,int RWP,int ERP,int EWP,int NSER)	/* gives the height of the colmux */
{
  area_type colmux_area;
  colmux_area.height =
    (2 * Wiso + 3 * (2 * Widthcontact + 1 / FUDGEFACTOR)) * (RWP + ERP + EWP);//Shyam: Need to understand what the +1 is for
  colmux_area.width =
    (BitWidth + Widthtrack * 2 * (RWP + (ERP - NSER) + EWP - 1) +
     Widthtrack * NSER);
  return (colmux_area);
}

area_type
precharge (int Ndbl,double Nspd,int RWP,int ERP,int EWP,int NSER)
{
  area_type precharge_area;
  if (Ndbl * Nspd > 1)
    {
      precharge_area.height =
	(Wbitpreequ + 2 * Wbitdropv + Wwrite + 2 * (2 * Widthcontact + 1 / FUDGEFACTOR) +
	 3 * Widthptondiff) * 0.5 * (RWP + EWP);
      precharge_area.width =
	2 * (BitWidth + Widthtrack * 2 * (RWP + (ERP - NSER) + EWP - 1) +
	     Widthtrack * NSER);
    }
  else
    {
      precharge_area.height =
	(Wbitpreequ + 2 * Wbitdropv + Wwrite + 2 * (2 * Widthcontact + 1 / FUDGEFACTOR) +
	 3 * Widthptondiff) * (RWP + EWP);
      precharge_area.width =
	BitWidth + Widthtrack * 2 * (RWP + (ERP - NSER) + EWP - 1) +
	Widthtrack * NSER;
    }
  return (precharge_area);
}

area_type
senseamp (int Ndbl,double Nspd,int RWP,int ERP,int EWP,int NSER)
{
  area_type senseamp_area;
  if (Ndbl * Nspd > 1)
    {
      senseamp_area.height = 0.5 * SenseampHeight * (RWP + ERP);
      senseamp_area.width =
	2 * (BitWidth + Widthtrack * 2 * (RWP + (ERP - NSER) + EWP - 1) +
	     Widthtrack * NSER);
    }
  else
    {
      senseamp_area.height = SenseampHeight * (RWP + ERP);
      senseamp_area.width =
	BitWidth + Widthtrack * 2 * (RWP + (ERP - NSER) + EWP - 1) +
	Widthtrack * NSER;
    }
  return (senseamp_area);
}

/* define OutdriveHeight OutdriveWidth DatainvHeight DatainvWidth */

area_type
subarraytag_area (int baddr,int C,int B,int A,int Ntdbl,int Ntdwl,int Ntspd,double NSubbanks,int RWP,int ERP,
		  int EWP,int NSER,double techscaling_factor)	/* returns area of subarray */
{
  area_type tagarea;
  int noof_rows, noof_colns, Tagbits;
  int conservative_NSER;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -