00001 #include <assert.h>
00002 #include "util.h"
00003 #include "vpr_types.h"
00004 #include "globals.h"
00005 #include "rr_graph.h"
00006 #include "rr_graph_util.h"
00007 #include "rr_graph2.h"
00008 #include "rr_graph_timing_params.h"
00009
00010
00011
00012
00013
00014
00015 void
00016 add_rr_graph_C_from_switches(float C_ipin_cblock)
00017 {
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 int inode, iedge, switch_index, to_node, maxlen;
00033 int icblock, isblock, iseg_low, iseg_high;
00034 float Cin, Cout;
00035 t_rr_type from_rr_type, to_rr_type;
00036 boolean *cblock_counted;
00037 float *buffer_Cin;
00038 boolean buffered;
00039 float *Couts_to_add;
00040
00041 maxlen = max(nx, ny) + 1;
00042 cblock_counted = (boolean *) my_calloc(maxlen, sizeof(boolean));
00043 buffer_Cin = (float *)my_calloc(maxlen, sizeof(float));
00044
00045 for(inode = 0; inode < num_rr_nodes; inode++)
00046 {
00047
00048 from_rr_type = rr_node[inode].type;
00049
00050 if(from_rr_type == CHANX || from_rr_type == CHANY)
00051 {
00052
00053 for(iedge = 0; iedge < rr_node[inode].num_edges; iedge++)
00054 {
00055
00056 to_node = rr_node[inode].edges[iedge];
00057 to_rr_type = rr_node[to_node].type;
00058
00059 if(to_rr_type == CHANX || to_rr_type == CHANY)
00060 {
00061
00062 switch_index =
00063 rr_node[inode].switches[iedge];
00064 Cin = switch_inf[switch_index].Cin;
00065 Cout = switch_inf[switch_index].Cout;
00066 buffered =
00067 switch_inf[switch_index].buffered;
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 if(!buffered && inode < to_node)
00087 {
00088 rr_node[inode].C += Cin;
00089 rr_node[to_node].C += Cout;
00090 }
00091
00092 else if(buffered)
00093 {
00094
00095 if(rr_node[to_node].drivers !=
00096 SINGLE)
00097 {
00098
00099
00100 rr_node[to_node].C +=
00101 Cout;
00102 }
00103 isblock =
00104 seg_index_of_sblock(inode,
00105 to_node);
00106 buffer_Cin[isblock] =
00107 max(buffer_Cin[isblock], Cin);
00108 }
00109
00110 }
00111
00112 else if(to_rr_type == IPIN)
00113 {
00114
00115
00116
00117
00118
00119
00120 icblock =
00121 seg_index_of_cblock(from_rr_type,
00122 to_node);
00123 if(cblock_counted[icblock] == FALSE)
00124 {
00125 rr_node[inode].C += C_ipin_cblock;
00126 cblock_counted[icblock] = TRUE;
00127 }
00128 }
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 if(from_rr_type == CHANX)
00145 {
00146 iseg_low = rr_node[inode].xlow;
00147 iseg_high = rr_node[inode].xhigh;
00148 }
00149 else
00150 {
00151 iseg_low = rr_node[inode].ylow;
00152 iseg_high = rr_node[inode].yhigh;
00153 }
00154
00155 for(icblock = iseg_low; icblock <= iseg_high; icblock++)
00156 {
00157 cblock_counted[icblock] = FALSE;
00158 }
00159
00160 for(isblock = iseg_low - 1; isblock <= iseg_high;
00161 isblock++)
00162 {
00163 rr_node[inode].C += buffer_Cin[isblock];
00164 buffer_Cin[isblock] = 0.;
00165 }
00166
00167 }
00168
00169 else if(from_rr_type == OPIN)
00170 {
00171
00172 for(iedge = 0; iedge < rr_node[inode].num_edges; iedge++)
00173 {
00174 switch_index = rr_node[inode].switches[iedge];
00175
00176 to_node = rr_node[inode].edges[iedge];
00177 to_rr_type = rr_node[to_node].type;
00178 assert(to_rr_type == CHANX
00179 || to_rr_type == CHANY);
00180 if(rr_node[to_node].drivers != SINGLE)
00181 {
00182 Cout = switch_inf[switch_index].Cout;
00183 to_node = rr_node[inode].edges[iedge];
00184 rr_node[to_node].C += Cout;
00185 }
00186 }
00187 }
00188
00189 }
00190
00191
00192
00193
00194
00195 Couts_to_add = (float *)my_calloc(num_rr_nodes, sizeof(float));
00196 for(inode = 0; inode < num_rr_nodes; inode++)
00197 {
00198 for(iedge = 0; iedge < rr_node[inode].num_edges; iedge++)
00199 {
00200 switch_index = rr_node[inode].switches[iedge];
00201 to_node = rr_node[inode].edges[iedge];
00202 to_rr_type = rr_node[to_node].type;
00203 if(to_rr_type == CHANX || to_rr_type == CHANY)
00204 {
00205 if(rr_node[to_node].drivers == SINGLE)
00206 {
00207
00208 if(Couts_to_add[to_node] != 0)
00209 {
00210
00211
00212
00213 if(Couts_to_add[to_node] !=
00214 switch_inf[switch_index].Cout)
00215 {
00216 printf
00217 ("Error: A single driver resource (%i) is driven by different Cout's (%e!=%e)\n",
00218 to_node,
00219 Couts_to_add
00220 [to_node],
00221 switch_inf
00222 [switch_index].Cout);
00223 exit(1);
00224 }
00225 }
00226 Couts_to_add[to_node] =
00227 switch_inf[switch_index].Cout;
00228
00229 }
00230 }
00231 }
00232 }
00233 for(inode = 0; inode < num_rr_nodes; inode++)
00234 {
00235 rr_node[inode].C += Couts_to_add[inode];
00236 }
00237 free(Couts_to_add);
00238 free(cblock_counted);
00239 free(buffer_Cin);
00240 }