Changeset 106 for trunk/modules/vci_synthetic_initator/caba/sources/src
- Timestamp:
- Oct 14, 2010, 2:58:27 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_synthetic_initator/caba/sources/src/vci_synthetic_initiator.cpp
r102 r106 29 29 30 30 #include "../include/vci_synthetic_initiator.h" 31 #include <iostream> 31 32 32 33 … … 48 49 const soclib::common::IntTab &vci_index, 49 50 const uint32_t length, // Packet length (flit numbers) 50 const float rho, // Packets ratio on the network 51 const uint32_t rho, // Packets ratio on the network 52 // const float rho, // Packets ratio on the network 51 53 const uint32_t depth, // Fifo depth 52 54 const uint32_t xmesh, … … 66 68 67 69 m_srcid( mt.indexForId(vci_index) ), 68 m_coord(vci_index[1]),69 70 // FIFOs 70 71 m_length(length), … … 104 105 /////////////////////////////////// 105 106 { 106 size_t dest; 107 do{ 108 dest = (size_t) (rand() % (m_xmesh * m_ymesh)); 109 } while(dest == m_srcid); 110 return dest ; 107 return (size_t) (rand() % (m_xmesh * m_ymesh)) ; 111 108 } 112 109 … … 123 120 // } 124 121 122 123 ////////////////////////////////// 124 tmpl(void)::print_trace() 125 ////////////////////////////////// 126 { 127 const char* state_str[] = { "IDLE", 128 "SINGLE_SEND", 129 "SINGLE_RECEIVE", 130 "BC_SEND", 131 "BC_RECEIVE" }; 132 133 std::cout << "Vci_Synthetic_Initiator " << name() 134 << " : " << m_cpt_cycles << " cycles " 135 << " : state = " << state_str[r_vci_fsm] 136 << " Adresse to send : " << m_address_to_send << std::endl; 137 } 138 139 ////////////////////////////////// 140 tmpl(void)::printStats() 141 ////////////////////////////////// 142 { 143 std::cout << m_cpt_cycles << " cycles, " << m_npackets << " packets sent" << std::endl; 144 } 145 125 146 ////////////////////////////////// 126 147 tmpl(void)::transition() 127 148 ////////////////////////////////// 128 149 { 129 150 // RESET … … 142 163 m_npackets = 0; 143 164 165 r_broadcast_req = false; 166 144 167 return; 145 168 } … … 148 171 bool date_fifo_get = false; 149 172 173 // if (m_cpt_cycles == 0) { 174 // m_rhos = 0.0 ; 175 // } else { 176 // m_rhos = static_cast<float>(m_npackets * m_length) / static_cast<float>(m_cpt_cycles) ; 177 // } 178 179 180 150 181 switch ( r_vci_fsm.read() ) { 151 182 183 std::cout << m_cpt_cycles << " cycles, " << m_npackets << " packets sent" << std::endl; 184 //printStats(); 152 185 ////////////////// 153 186 case VCI_IDLE: … … 155 188 if (m_date_fifo.rok()){ 156 189 if (r_broadcast_req.read()){ 190 m_address_to_send = (((((((((m_xmin << 5) | m_xmax ) << 5 ) | m_ymin ) << 5 ) | m_ymax ) << 5 ) << vci_param::N-(4*5) ) | 0x3) | 0 ; 157 191 r_vci_fsm = VCI_BC_SEND ; 158 192 } else { 159 193 r_vci_fsm = VCI_SINGLE_SEND ; 160 r_address_to_send = destAdress();194 m_address_to_send = destAdress() << 32-10; 161 195 m_count = 0; 162 196 } … … 168 202 { 169 203 if (p_vci.cmdack.read()){ 170 m_count++;171 204 if (m_count == m_length-1) { 172 205 m_start_latency1 = m_date_fifo.read(); … … 175 208 } else { 176 209 r_vci_fsm = VCI_SINGLE_SEND ; 210 m_count++; 177 211 } 178 212 } … … 187 221 m_npackets++; 188 222 date_fifo_get = true; 223 m_address_to_send = 0; 189 224 r_vci_fsm = VCI_IDLE ; 190 225 } … … 194 229 case VCI_BC_SEND: 195 230 { 196 r_address_to_send = (((((((((m_xmin << 5) & m_xmax ) << 5 ) & m_ymin ) << 5 ) & m_ymax ) << 5 ) << 17 ) & 0x3) | 0 ;197 //m_address_to_send.broadcast_address.xmin = m_xmin;198 //m_address_to_send.broadcast_address.xmax = m_xmax;199 //m_address_to_send.broadcast_address.ymin = m_ymin;200 //m_address_to_send.broadcast_address.ymax = m_ymax;201 //m_address_to_send.broadcast_address.bc = 0x3;202 231 m_bc_nrsp = (m_xmax - m_xmin) * (m_ymax - m_ymin); 203 232 r_vci_fsm = VCI_BC_SEND; … … 210 239 if (m_bc_nrsp == 0) { 211 240 r_broadcast_req = false; 241 m_address_to_send = 0; 212 242 r_vci_fsm = VCI_IDLE ; 213 243 } else { … … 221 251 222 252 223 /////////////////// Filling fifo224 if( ( m_rhos < m_rho) && (rand()/RAND_MAX) ){253 /////////////////// Filling fifo 254 if( ( (uint64_t)(m_rho*m_cpt_cycles) >= (uint64_t)(m_length*m_npackets*1000)) ){ 225 255 if (m_date_fifo.wok()){ 226 256 date_fifo_put = true ; 227 257 } 228 if (!r_broadcast_req.read() && (m_cpt_cycles % m_bc_period)){ 229 r_broadcast_req = true; 258 if (m_bc_period){ 259 if (!r_broadcast_req.read() && (m_cpt_cycles % m_bc_period)){ 260 r_broadcast_req = true; 261 } 230 262 } 231 263 } … … 243 275 } 244 276 245 m_rhos = (float) ((m_npackets * m_length) / m_cpt_cycles) ;246 247 277 m_cpt_cycles++; 248 278 … … 287 317 { 288 318 p_vci.cmdval = true; 289 p_vci.address = ( vci_addr_t)(r_address_to_send.read()+ (m_count*4));319 p_vci.address = (addr_t)(m_address_to_send + (m_count*4)); 290 320 p_vci.plen = m_length*4; 291 321 p_vci.wdata = 0; … … 315 345 { 316 346 p_vci.cmdval = true; 317 p_vci.address = ( vci_addr_t) r_address_to_send.read();347 p_vci.address = (addr_t) m_address_to_send; 318 348 p_vci.plen = 4; 319 349 p_vci.wdata = 0;
Note: See TracChangeset
for help on using the changeset viewer.