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

📄 cost.c

📁 用C实现的基于O-tree的ic设计布图布线工具源代码,有相关文档
💻 C
字号:
#include "struct.h"void compute_area(struct OT *ot) {  int i, maxx=0, maxy=0;  extern int area, real_area;  for (i=0;i<ot->n;i++) {    int x,y,w,h;    struct V *p=&ver[ot->perm[i]];    if (ot->orient[i]%2) w=p->l->h, h=p->l->w;    else w=p->l->w, h=p->l->h;    x=ot->x[i]+w; y=ot->y[i]+h;    if (x>maxx) maxx=x;    if (y>maxy) maxy=y;  }  real_area=area=maxx*maxy;  // ratio bias function  if (maxx>maxy) area+=(int)pow((double)maxx,CO1);  else area+=(int)pow((double)maxy,CO1);  // if (maxx>maxy) area+=maxx*maxx; else area+=maxy*maxy;}// proportional io pad locationvoid compute_wirelen(struct OT *ot) {  int i, maxx=0, maxy=0, sx, sy, ox, oy;  float px, py;  extern int area, wirelen;  for (i=0;i<ot->n;i++) {    int x,y,w,h;    struct V *p=&ver[ot->perm[i]];    if (ot->orient[i]%2) w=p->l->h, h=p->l->w;    else w=p->l->w, h=p->l->h;    x=ot->x[i]+w; y=ot->y[i]+h;    if (x>maxx) maxx=x;    if (y>maxy) maxy=y;  }  sx=maxx>parent->w?maxx:parent->w;  sy=maxy>parent->h?maxy:parent->h;  for (i=0;i<net_count;i++) { struct E *p=&edg[i]; p->m=p->x=p->y=0; p->x1=p->y1=MAXINT; p->x2=p->y2=MININT; }  // IO pad  ox=(sx-maxx)/2; oy=(sy-maxy)/2;  px=(float)maxx/(float)parent->w;  py=(float)maxy/(float)parent->h;  for (i=0;i<parent->n;i++) {    struct E *p=vp[pin_count+i]->e;    int x=ox+(int)(px*(float)parent->lp[i].x), y=oy+(int)(py*(float)parent->lp[i].y);    p->m++; p->x+=x; p->y+=y;    if (x<p->x1) p->x1=x; if (y<p->y1) p->y1=y;    if (x>p->x2) p->x2=x; if (y>p->y2) p->y2=y;  }  // pins  for (i=0;i<ot->n;i++) {    struct V *p=&ver[ot->perm[i]];    int x1=ox+ot->x[i], y1=oy+ot->y[i], w=p->l->w, h=p->l->h, j;    for (j=0;j<p->l->n;j++) {      struct E *q=p->p[j]->e;      int x, y, dx=p->l->lp[j].x, dy=p->l->lp[j].y;      switch (ot->orient[i]) {        case 0: x=x1+dx; y=y1+dy; break;        case 1: x=x1+dy; y=y1+dx; break;        case 2: x=x1+w-dx; y=y1+dy; break;        case 3: x=x1+h-dy; y=y1+dx; break;        case 4: x=x1+dx; y=y1+h-dy; break;        case 5: x=x1+dy; y=y1+w-dx; break;        case 6: x=x1+w-dx; y=y1+h-dy; break;        case 7: x=x1+h-dy; y=y1+w-dx; break;      }      q->m++; q->x+=x; q->y+=y;      if (x<q->x1) q->x1=x; if (y<q->y1) q->y1=y;      if (x>q->x2) q->x2=x; if (y>q->y2) q->y2=y;    }  }  // compute wirelen  for (i=wirelen=0;i<net_count;i++) {    struct E *p=&edg[i];    wirelen+=(p->x2-p->x1+p->y2-p->y1);  }}void compute_cost(struct OT *ot) {  extern int area, wirelen, real_area;  extern float newp;  compute_area(ot);  compute_wirelen(ot);  cost=newp*((float)real_area)/normArea+(1.0-newp)*((float)wirelen)/normWL;}

⌨️ 快捷键说明

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