- Timestamp:
- Nov 10, 2014, 12:16:07 PM (10 years ago)
- Location:
- branches/reconfiguration/modules/dspin_router/caba/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/reconfiguration/modules/dspin_router/caba/source/include/dspin_router.h
r854 r873 84 84 }; 85 85 86 // Black-Hole position 87 enum 88 { 89 BH_NONE, 90 BH_N, 91 BH_NE, 92 BH_E, 93 BH_SE, 94 BH_S, 95 BH_SW, 96 BH_W, 97 BH_NW 98 }; 99 86 100 protected: 87 101 SC_HAS_PROCESS(DspinRouter); … … 137 151 bool m_broadcast_supported; 138 152 int m_disable_mask; 153 int m_blackhole_pos; 139 154 140 155 // methods 141 156 void transition(); 142 157 void genMoore(); 143 int xfirst_route( sc_uint<flit_width> data ); 158 int xfirst_route( size_t xdest, size_t ydest ); 159 int recovery_route( size_t xdest, size_t ydest ); 160 int route( sc_uint<flit_width> data ); 144 161 int broadcast_route( int iter, int source, sc_uint<flit_width> data ); 145 162 bool is_broadcast( sc_uint<flit_width> data ); … … 147 164 public: 148 165 149 void set_disable_mask( int mask ); 150 void print_trace(); 166 void set_disable_mask( int mask ) 167 { 168 m_disable_mask = mask; 169 } 170 171 void set_blackhole_pos( int pos ) 172 { 173 m_blackhole_pos = pos; 174 } 175 176 void print_trace(); 151 177 }; 152 178 -
branches/reconfiguration/modules/dspin_router/caba/source/src/dspin_router.cpp
r854 r873 117 117 118 118 /////////////////////////////////////////////////// 119 tmpl(int)::xfirst_route( sc_uint<flit_width> data ) 120 { 121 size_t xdest = (size_t)(data >> m_x_shift) & m_x_mask; 122 size_t ydest = (size_t)(data >> m_y_shift) & m_y_mask; 119 tmpl(int)::xfirst_route( size_t xdest, size_t ydest ) 120 { 123 121 return (xdest < m_local_x ? REQ_WEST : 124 122 (xdest > m_local_x ? REQ_EAST : 125 123 (ydest < m_local_y ? REQ_SOUTH : 126 124 (ydest > m_local_y ? REQ_NORTH : REQ_LOCAL)))); 125 } 126 127 /////////////////////////////////////////////////// 128 tmpl(int)::recovery_route( size_t xdest, size_t ydest ) 129 { 130 int bhpos = m_blackhole_pos; 131 if ( xdest > m_local_x ) { 132 if ( (bhpos == BH_NE) || (bhpos == BH_E) || (bhpos == BH_SE) || 133 (bhpos == BH_S) ) { 134 return REQ_EAST; 135 } 136 else if ( bhpos == BH_N ) { 137 if ( (m_local_y == 1) || (m_local_x == 0) || (ydest >= m_local_y) || 138 (xdest > (m_local_x + 1)) ) { 139 return REQ_EAST; 140 } 141 else { 142 return REQ_WEST; 143 } 144 } 145 else if ( bhpos == BH_NW ) { 146 if ( (m_local_y == 1) || (ydest >= m_local_y) || 147 (xdest > (m_local_x + 2)) ) { 148 return REQ_EAST; 149 } 150 else { 151 return REQ_SOUTH; 152 } 153 } 154 else if ( bhpos == BH_W ) { 155 if ( (m_local_y == 0) || (ydest > m_local_y)) { 156 return REQ_NORTH; 157 } 158 else { 159 return REQ_SOUTH; 160 } 161 } 162 else if ( bhpos == BH_SW ) { 163 if ( (ydest <= m_local_y) || (xdest > (m_local_x + 1)) ) { 164 return REQ_EAST; 165 } 166 else { 167 return REQ_NORTH; 168 } 169 } 170 std::cout << "error: unexpected condition in function " 171 << __FILE__ << ":" << __func__ << " +" << __LINE__ 172 << std::endl; 173 exit(1); 174 } // end if (xdest > m_local_x) 175 else if ( xdest < m_local_x ) { 176 if ( (bhpos == BH_N) || (bhpos == BH_NW) || (bhpos == BH_W) || 177 (bhpos == BH_SW) || (bhpos == BH_S) ) { 178 return REQ_WEST; 179 } 180 else if ( bhpos == BH_NE ) { 181 if ( (xdest < (m_local_x - 1)) || (ydest >= m_local_y) ) { 182 return REQ_WEST; 183 } 184 else { 185 return REQ_SOUTH; 186 } 187 } 188 else if ( bhpos == BH_SE ) { 189 if ( (m_local_x == 1) && (ydest > (m_local_y + 1)) ) { 190 return REQ_NORTH; 191 } 192 else { 193 return REQ_WEST; 194 } 195 } 196 else if ( bhpos == BH_E ) { 197 if ( (m_local_y == 0) || 198 ((m_local_x == 1) && (ydest > m_local_y)) ) { 199 return REQ_NORTH; 200 } 201 else { 202 return REQ_SOUTH; 203 } 204 } 205 std::cout << "error: unexpected condition in function " 206 << __FILE__ << ":" << __func__ << " +" << __LINE__ 207 << std::endl; 208 exit(1); 209 } // end if (xdest < m_local_x) 210 else if ( ydest > m_local_y ) { 211 if ( bhpos != BH_S ) { 212 return REQ_NORTH; 213 } 214 else if ( m_local_x != 0 ) { 215 return REQ_WEST; 216 } 217 else { 218 return REQ_EAST; 219 } 220 } // end if (ydest > m_local_y) 221 else if ( ydest < m_local_y ) { 222 if ( bhpos != BH_N ) { 223 return REQ_SOUTH; 224 } 225 else if ( m_local_x != 0) { 226 return REQ_WEST; 227 } 228 else { 229 return REQ_EAST; 230 } 231 } // end if (ydest < m_local_y) 232 return REQ_LOCAL; 233 } 234 235 /////////////////////////////////////////////////// 236 tmpl(int)::route( sc_uint<flit_width> data ) 237 { 238 size_t xdest = (size_t)(data >> m_x_shift) & m_x_mask; 239 size_t ydest = (size_t)(data >> m_y_shift) & m_y_mask; 240 if ( m_blackhole_pos == BH_NONE ) { 241 return xfirst_route(xdest, ydest); 242 } 243 else { 244 return recovery_route(xdest, ydest); 245 } 127 246 } 128 247 … … 182 301 } 183 302 184 /////////////////////////////////////////////////////////185 tmpl(void)::set_disable_mask( int mask )186 {187 m_disable_mask = mask;188 }189 190 303 ///////////////////////// 191 304 tmpl(void)::print_trace() … … 265 378 r_fifo_out[i].init(); 266 379 } 380 381 set_blackhole_pos(BH_NONE); 267 382 return; 268 383 } … … 327 442 else // unicast 328 443 { 329 req_in[i] = xfirst_route(r_fifo_in[i].read().data);444 req_in[i] = route(r_fifo_in[i].read().data); 330 445 r_index_in[i] = req_in[i]; 331 446 r_fsm_in[i] = INFSM_REQ;
Note: See TracChangeset
for help on using the changeset viewer.