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

📄 check_rr_graph.c

📁 fpga设计评估软件
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "util.h"#include "vpr_types.h"#include "globals.h"#include "rr_graph.h"#include "check_rr_graph.h"/********************** Local defines and types *****************************/#define BUF_FLAG 1#define PTRANS_FLAG 2#define BUF_AND_PTRANS_FLAG 3/*********************** Subroutines local to this module *******************/static boolean rr_node_is_global_clb_ipin (int inode);static void check_pass_transistors (int from_node); /************************ Subroutine definitions ****************************/void check_rr_graph (enum e_route_type route_type, int num_switch) {/* This routine sanity checks the routing resource graph to see that it has * * no repeated edges between two nodes, that there are no disconnected      * * routing resource nodes, and that the attributes of each node are         * * reasonable.                                                              */ int *num_edges_from_current_to_node;   /* [0..num_rr_nodes-1] */ int *total_edges_to_node;              /* [0..num_rr_nodes-1] */ char *switch_types_from_current_to_node;  /* [0..num_rr_nodes-1] */ int inode, iedge, to_node, num_edges; short switch_type; t_rr_type rr_type, to_rr_type;  total_edges_to_node = (int *) my_calloc (num_rr_nodes, sizeof (int));  num_edges_from_current_to_node = (int *) my_calloc (num_rr_nodes,                                       sizeof (int)); switch_types_from_current_to_node = (char *) my_calloc (num_rr_nodes,                                      sizeof (char)); for (inode=0;inode<num_rr_nodes;inode++) {    rr_type = rr_node[inode].type;    num_edges = rr_node[inode].num_edges;    check_node (inode, route_type);    /* Check all the connectivity (edges, etc.) information.                    */    for (iedge=0;iedge<num_edges;iedge++) {       to_node = rr_node[inode].edges[iedge];       if (to_node < 0 || to_node >= num_rr_nodes) {          printf ("Error in check_rr_graph:  node %d has an edge %d.\n"                  "Edge is out of range.\n", inode, to_node);          exit (1);       }       num_edges_from_current_to_node[to_node]++;       total_edges_to_node[to_node]++;       switch_type = rr_node[inode].switches[iedge];       if (switch_type < 0 || switch_type >= num_switch) {          printf ("Error in check_rr_graph:  node %d has a switch type %d.\n"                  "Switch type is out of range.\n", inode, switch_type);          exit (1);       }       if (switch_inf[switch_type].buffered)           switch_types_from_current_to_node[to_node] |= BUF_FLAG;       else          switch_types_from_current_to_node[to_node] |= PTRANS_FLAG;    }  /* End for all edges of node. */    for (iedge=0;iedge<num_edges;iedge++) {       to_node = rr_node[inode].edges[iedge];       if (num_edges_from_current_to_node[to_node] > 1) {          to_rr_type = rr_node[to_node].type;          if ((to_rr_type != CHANX && to_rr_type != CHANY) ||                 (rr_type != CHANX && rr_type != CHANY)) {             printf ("Error in check_rr_graph:  node %d connects to node %d "                     "%d times.\n", inode, to_node,                      num_edges_from_current_to_node[to_node]);             exit (1);          }         /* Between two wire segments.  Two connections are legal only if  *          * one connection is a buffer and the other is a pass transistor. */          else if (num_edges_from_current_to_node[to_node] != 2 ||                       switch_types_from_current_to_node[to_node] !=                        BUF_AND_PTRANS_FLAG) {             printf ("Error in check_rr_graph:  node %d connects to node %d "                     "%d times.\n", inode, to_node,                      num_edges_from_current_to_node[to_node]);             exit (1);          }       }       num_edges_from_current_to_node[to_node] = 0;       switch_types_from_current_to_node[to_node] = 0;    }  /* Slow test below.  Leave commented out most of the time. */#ifdef DEBUG    check_pass_transistors (inode);#endif }    /* End for all rr_nodes *//* I built a list of how many edges went to everything in the code above -- * * now I check that everything is reachable.                                */ for (inode=0;inode<num_rr_nodes;inode++) {    rr_type = rr_node[inode].type;    if (rr_type != SOURCE) {       if (total_edges_to_node[inode] < 1 &&               !rr_node_is_global_clb_ipin(inode)) {     /* A global CLB input pin will not have any edges, and neither will  *      * a SOURCE.  Anything else is an error.                             */          printf ("Error in check_rr_graph:  node %d has no fanin.\n", inode);          exit (1);       }    }    else {   /* SOURCE.  No fanin for now; change if feedthroughs allowed. */       if (total_edges_to_node[inode] != 0) {          printf ("Error in check_rr_graph:  SOURCE node %d has a fanin\n"                  "\tof %d, expected 0.\n", inode, total_edges_to_node[inode]);          exit (1);       }    } } free (num_edges_from_current_to_node); free (total_edges_to_node); free (switch_types_from_current_to_node);}static boolean rr_node_is_global_clb_ipin (int inode) {/* Returns TRUE if inode refers to a global CLB input pin node.   */ int ipin;  if (rr_node[inode].type != IPIN)     return (FALSE); if (rr_node[inode].xlow == 0 || rr_node[inode].xlow == nx+1 ||      rr_node[inode].ylow == 0 || rr_node[inode].ylow == ny+1)   /* I/O pad */    return (FALSE);  ipin = rr_node[inode].ptc_num; return (is_global_clb_pin[ipin]);}void check_node (int inode, enum e_route_type route_type) {/* This routine checks that the rr_node is inside the grid and has a valid  * * pin number, etc.                                                         */ int xlow, ylow, xhigh, yhigh, ptc_num, capacity; t_rr_type rr_type; int nodes_per_chan, tracks_per_node, num_edges, cost_index; float C, R; rr_type = rr_node[inode].type; xlow = rr_node[inode].xlow; xhigh = rr_node[inode].xhigh; ylow = rr_node[inode].ylow; yhigh = rr_node[inode].yhigh; ptc_num = rr_node[inode].ptc_num; capacity = rr_node[inode].capacity; if (xlow > xhigh || ylow > yhigh) {    printf ("Error in check_node:  rr endpoints are (%d,%d) and (%d,%d).\n",            xlow, ylow, xhigh, yhigh);    exit (1); } if (xlow < 0 || xhigh > nx+1 || ylow < 0 || yhigh > ny+1) {    printf ("Error in check_node:  rr endpoints, (%d,%d) and (%d,%d), \n"            "are out of range.\n", xlow, ylow, xhigh, yhigh);    exit (1); } if (ptc_num < 0) {    printf ("Error in check_node.  Inode %d (type %d) had a ptc_num\n"            "of %d.\n", inode, rr_type, ptc_num);    exit (1); }/* Check that the segment is within the array and such. */ switch (rr_type) { case SOURCE: case SINK: case IPIN: case OPIN:    if (xlow != xhigh || ylow != yhigh) {       printf ("Error in check_node:  Node %d (type %d) has endpoints of\n"            "(%d,%d) and (%d,%d)\n", inode, rr_type, xlow, ylow, xhigh, yhigh);       exit (1);    }    if (clb[xlow][ylow].type != CLB && clb[xlow][ylow].type != IO) {       printf ("Error in check_node:  Node %d (type %d) is at an illegal\n"               " clb location (%d, %d).\n", inode, rr_type, xlow, ylow);       exit (1);    }    break;  case CHANX:    if (xlow < 1 || xhigh > nx || yhigh > ny || yhigh != ylow) {       printf("Error in check_node:  CHANX out of range.\n");       printf("Endpoints: (%d,%d) and (%d,%d)\n", xlow, ylow, xhigh, yhigh);       exit(1);    }    if (route_type == GLOBAL && xlow != xhigh) {       printf ("Error in check_node:  node %d spans multiple channel segments\n"               "which is not allowed with global routing.\n", inode);       exit (1);    }    break;  case CHANY:    if (xhigh > nx || ylow < 1 || yhigh > ny || xlow != xhigh) {       printf("Error in check_node:  CHANY out of range.\n");       printf("Endpoints: (%d,%d) and (%d,%d)\n", xlow, ylow, xhigh, yhigh);       exit(1);    }    if (route_type == GLOBAL && ylow != yhigh) {       printf ("Error in check_node:  node %d spans multiple channel segments\n"               "which is not allowed with global routing.\n", inode);       exit (1);    }    break;  default:    printf("Error in check_node:  Unexpected segment type: %d\n", rr_type);    exit(1); } /* Check that it's capacities and such make sense. */  switch (rr_type) { 

⌨️ 快捷键说明

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