Changeset 98 for trunk/modules/vci_synthetic_initator/caba/sources/src
- Timestamp:
- Sep 29, 2010, 2:32:06 PM (14 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_synthetic_initator/caba/sources/src/vci_synthetic_initiator.cpp
r96 r98 45 45 tmpl(/**/)::VciSyntheticInitiator( 46 46 sc_module_name name, 47 const soclib::common::MappingTable &mt, 48 const soclib::common::IntTab &vci_index, 47 49 size_t length, // Packet length (flit numbers) 48 50 float rho, // Packets ratio on the network 49 51 size_t depth, // Fifo depth 50 size_t x, //51 size_t y, //52 52 size_t xmesh, 53 53 size_t ymesh, 54 size_t bc_period , // Broadcast period, if no broadcast => 055 size_t xmin ,56 size_t xmax ,57 size_t ymin ,58 size_t ymax 54 size_t bc_period = 0, // Broadcast period, if no broadcast => 0 55 size_t xmin = 0, 56 size_t xmax = 0, 57 size_t ymin = 0, 58 size_t ymax = 0 59 59 ) 60 60 … … 65 65 p_vci("vci_ini"), 66 66 67 m_srcid_ini( mtc.indexForId(vci_ini_index) ), 67 m_srcid( mt.indexForId(vci_index) ), 68 m_coord(vci_index[1]), 68 69 // FIFOs 69 70 m_length(length), … … 80 81 m_ymax(ymax), 81 82 m_date_fifo("m_date_fifo", depth), 82 r_ tgt_cmd_fsm("r_tgt_cmd_fsm"),83 r_vci_fsm("r_vci_fsm"), 83 84 { 84 85 … … 102 103 103 104 /////////////////////////////////// 104 tmpl( void)::destAdress(size_t X_local, size_t Y_local, size_t &X_dest, size_t &Y_dest)105 tmpl(size_t)::destAdress() 105 106 /////////////////////////////////// 106 107 { 107 X_dest = (size_t) ((rand())%m_xmesh); 108 Y_dest = (size_t) ((rand())%m_ymesh); 108 size_t dest; 109 do{ 110 dest = (size_t) (rand() % (m_xmesh * m_ymesh)); 111 } while(dest == m_srcid); 112 return dest ; 109 113 } 114 115 116 /////////////////////////////////// 117 // tmpl(void)::destAdress(/*size_t X_local, size_t Y_local,*/ size_t &X_dest, size_t &Y_dest) 118 /////////////////////////////////// 119 // { 120 // size_t x_dest_calc, y_dest_calc; 121 // do{ 122 // x_dest_calc = (rand()%m_xmesh); 123 // y_dest_calc = (rand()%m_ymesh); 124 // } while((x_dest_calc = m_x) && (y_dest_calc == m_y)); 125 // } 110 126 111 127 ////////////////////////////////// … … 113 129 ////////////////////////////////// 114 130 { 115 //using soclib::common::uint32_log2;116 131 // RESET 117 132 if ( ! p_resetn.read() ) { 118 //srand(time(NULL)); 119 // Initializing FSMs 120 r_tgt_cmd_fsm = TGT_CMD_IDLE; 121 122 // initializing FIFOs and communication Buffers 123 133 // Initializing seed for random numbers generation 134 srand(time(NULL)); 135 136 // Initializing FSMs 137 r_vci_fsm = VCI_IDLE; 138 139 // Initializing FIFOs 124 140 m_date_fifo.init(); 125 141 … … 139 155 case VCI_IDLE: 140 156 { 157 if (m_date_fifo.rok()){ 158 if (r_broadcast_req.read()){ 159 r_vci_fsm = VCI_BC_SEND ; 160 } else { 161 r_vci_fsm = VCI_SINGLE_SEND ; 162 destAdress(); 163 m_count = 0; 164 } 165 } 141 166 break; 142 167 } … … 144 169 case VCI_SINGLE_SEND: 145 170 { 171 if (p_vci.cmdack.read()){ 172 m_count++; 173 if (m_count == m_length-1) { 174 m_start_latency1 = m_date_fifo.read(); 175 m_start_latency2 = m_cpt_cycles; 176 r_vci_fsm = VCI_SINGLE_RECEIVE ; 177 } else { 178 r_vci_fsm = VCI_SINGLE_SEND ; 179 } 180 } 146 181 break; 147 182 } … … 149 184 case VCI_SINGLE_RECEIVE: 150 185 { 151 if (p_vci.cmdack.read()) { 152 // LATENCY 186 if (p_vci.rspval.read()) { 187 m_start_latency1 = m_date_fifo.read(); 188 m_start_latency2 = m_cpt_cycles; 189 m_npackets++; 190 date_fifo_get = true; 153 191 r_vci_fsm = VCI_IDLE ; 154 192 } … … 158 196 case VCI_BC_SEND: 159 197 { 198 m_address_to_send.broadcast_address.xmin = m_xmin; 199 m_address_to_send.broadcast_address.xmax = m_xmax; 200 m_address_to_send.broadcast_address.ymin = m_ymin; 201 m_address_to_send.broadcast_address.ymax = m_ymax; 202 m_address_to_send.broadcast_address.bc = 0x3; 203 m_bc_nrsp = (m_xmax - m_xmin) * (m_ymax - m_ymin); 204 r_vci_fsm = VCI_BC_SEND; 160 205 break; 161 206 } … … 163 208 case VCI_BC_RECEIVE: 164 209 { 165 r_broadcast_req = false; 210 if (p_vci.rspval.read()){ 211 if (m_bc_nrsp == 0) { 212 r_broadcast_req = false; 213 r_vci_fsm = VCI_IDLE ; 214 } else { 215 m_bc_nrsp--; 216 r_vci_fsm = VCI_BC_RECEIVE ; 217 } 218 } 166 219 break; 167 220 } … … 170 223 171 224 /////////////////// Filling fifo 172 if( ){225 if( (rhos < m_rho) && (rand()/RAND_MAX) ){ 173 226 if (m_date_fifo.wok()){ 174 227 date_fifo_put = true ; … … 190 243 } 191 244 } 192 245 246 m_rhos = (float) ((m_npackets * m_length) / m_cpt_cycles) ; 193 247 194 248 m_cpt_cycles++; … … 203 257 { 204 258 //////////////////////////////////////////////////////////// 205 // Command signals on the p_vci _ixrport259 // Command signals on the p_vci port 206 260 //////////////////////////////////////////////////////////// 207 p_vci.cmd = vci_param::CMD_ READ;261 p_vci.cmd = vci_param::CMD_WRITE; 208 262 p_vci.be = 0xF; 209 263 p_vci.pktid = 0; 210 p_vci.srcid = m_srcid _ixr;264 p_vci.srcid = m_srcid; 211 265 p_vci.cons = false; 212 266 p_vci.wrap = false; … … 227 281 p_vci.trdid = 0; 228 282 p_vci.eop = false; 283 p_vci.rspack = false; 229 284 break; 230 285 } … … 232 287 case VCI_SINGLE_SEND: 233 288 { 234 p_vci.cmdval = true ; 289 p_vci.cmdval = true; 290 p_vci.address = (typename vci_param::addr_t)(m_address_to_send+(m_count*4)); 291 p_vci.plen = m_length*4; 292 p_vci.wdata = 0; 293 p_vci.trdid = 0; 294 if (m_count == m_length - 1 ) { 295 p_vci.eop = true; 296 } else { 297 p_vci.eop = false; 298 } 299 p_vci.rspack = false; 235 300 break; 236 301 } … … 238 303 case VCI_SINGLE_RECEIVE: 239 304 { 240 break; 305 p_vci.cmdval = false; 306 p_vci.address = 0; 307 p_vci.plen = 0; 308 p_vci.wdata = 0; 309 p_vci.trdid = 0; 310 p_vci.eop = false; 311 p_vci.rspack = true; 312 break; 241 313 } 242 314 /////////////////// 243 315 case VCI_BC_SEND: 244 316 { 317 p_vci.cmdval = true; 318 p_vci.address = (typename vci_param::addr_t) m_address_to_send; 319 p_vci.plen = 4; 320 p_vci.wdata = 0; 321 p_vci.trdid = 0; 322 p_vci.eop = true; 323 p_vci.rspack = false; 245 324 break; 246 325 } … … 248 327 case VCI_BC_RECEIVE: 249 328 { 329 p_vci.cmdval = false; 330 p_vci.address = 0; 331 p_vci.plen = 0; 332 p_vci.wdata = 0; 333 p_vci.trdid = 0; 334 p_vci.eop = false; 335 p_vci.rspack = true; 250 336 break; 251 337 }
Note: See TracChangeset
for help on using the changeset viewer.