Changeset 98 for trunk/modules
- Timestamp:
- Sep 29, 2010, 2:32:06 PM (14 years ago)
- Location:
- trunk/modules/vci_synthetic_initator/caba
- Files:
-
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_synthetic_initator/caba/metadata/vci_synthetic_initiator.sd
r96 r98 4 4 classname = 'soclib::caba::VciSyntheticInitiator', 5 5 tmpl_parameters = [parameter.Module('vci_param', default = 'caba:vci_param'),], 6 header_files = ['../source/include/vci_synthetic_initiator.h',], 7 implementation_files = ['../source/src/vci_synthetic_initiator.cpp',], 6 header_files = ['../sources/include/vci_synthetic_initiator.h', 7 ], 8 implementation_files = ['../sources/src/vci_synthetic_initiator.cpp',], 8 9 uses = [Uses('caba:base_module'), 9 Uses('common:loader'),10 10 Uses('common:mapping_table'), 11 11 Uses('caba:generic_fifo'), … … 14 14 Port('caba:bit_in', 'p_resetn', auto = 'resetn'), 15 15 Port('caba:clock_in', 'p_clk', auto = 'clock'),], 16 instance_parameters = [ 17 parameter.Module('mt'), 18 parameter.IntTab('vci_index'), 19 parameter.Int('length'), 20 parameter.Float('rho'), 21 parameter.Int('depth'), 22 parameter.Int('xmesh'), 23 parameter.Int('ymesh'), 24 parameter.Int('bc_period', default = 0), 25 parameter.Int('xmin', default = 0), 26 parameter.Int('xmax', default = 0), 27 parameter.Int('ymin', default = 0), 28 parameter.Int('ymax', default = 0), 29 ], 30 extensions = [ 31 'dsx:get_ident=' 32 'vci_ini_index:p_vci:mt,' 33 ], 16 34 ) 35 -
trunk/modules/vci_synthetic_initator/caba/sources/include/vci_synthetic_initiator.h
r96 r98 32 32 33 33 #include <systemc> 34 #include <inttypes.h> 35 #include "generic_fifo.h" 36 #include "vci_initiator.h" 37 #include "soclib_endian.h" 38 #include "caba_base_module.h" 39 #include "int_tab.h" 40 #include "mapping_table.h" 34 41 35 42 namespace soclib { namespace caba { … … 40 47 : public soclib::caba::BaseModule 41 48 { 42 typedef uint32_t addr_t; 49 //typedef sc_dt::sc_uint<40> addr_t; 50 typedef typename vci_param::fast_addr_t vci_addr_t; 43 51 typedef uint32_t data_t; 44 52 typedef uint32_t tag_t; … … 46 54 typedef uint32_t be_t; 47 55 typedef uint32_t copy_t; 56 57 // Type of the addr_t and access of the fields 58 typedef union{ 59 PACKED_BITFIELD( 60 vci_addr_t srcid:vci_param::S, 61 vci_addr_t null:(8*sizeof(vci_addr_t)-(2*vci_param::S)), 62 ) normal_address; 63 PACKED_BITFIELD( 64 vci_addr_t xmin:vci_param::S, 65 vci_addr_t xmax:vci_param::S, 66 vci_addr_t ymin:vci_param::S, 67 vci_addr_t ymax:vci_param::S, 68 vci_addr_t null_:(8*sizeof(vci_addr_t)-(4*vci_param::S)), 69 vci_addr_t bc:2, 70 ) broadcast_address; 71 } addr_t; 48 72 49 73 … … 75 99 VciSyntheticInitiator( 76 100 sc_module_name name, 101 const soclib::common::MappingTable &mt, 102 const soclib::common::IntTab &vci_index, 77 103 size_t length, // Packet length (flit numbers) 78 104 float rho, // Packets ratio on the network 79 105 size_t depth, // Fifo depth 80 size_t x, // X location of the synthetic initiator81 size_t y, // Y location of the synthetic initiator82 106 size_t xmesh, 83 107 size_t ymesh, 84 size_t bc_period, // Broadcast period, if no broadcast => 0 85 size_t xmin, 86 size_t xmax, 87 size_t ymin, 88 size_t ymax, 89 const soclib::common::IntTab &vci_index 108 size_t bc_period = 0, // Broadcast period, if no broadcast => 0 109 size_t xmin = 0, 110 size_t xmax = 0, 111 size_t ymin = 0, 112 size_t ymax = 0, 90 113 ); 91 114 … … 101 124 102 125 // Component attributes 103 const size_t m_length; // Number of flits of a packet126 const size_t m_length; // Number of words to write 104 127 const size_t m_rho; // Rate of packets in the network wanted 105 128 const size_t m_depth; // Fifo depth 106 const size_t m_x; // X location107 const size_t m_y; // Y location108 129 const size_t m_xmesh; 109 130 const size_t m_ymesh; … … 113 134 const size_t m_ymin; 114 135 const size_t m_ymax; 136 const size_t m_srcid; 137 const size_t m_coord; 115 138 116 size_t m_count; 117 size_t m_npackets; // Total number of packets already sent 139 size_t m_count; // Numbers of words sent 140 size_t m_npackets; // Total number of packets already sent 141 uint64_t m_start_latency1; // Start time of sending packet wanted 142 uint64_t m_start_latency2; // Start time of sending packet 143 addr_t m_address_to_send; // Address to send the write command 144 float m_rhos; // Effective Rho during the simulation 145 size_t m_bc_nrsp; // Expected number of responses for a broadcast command 118 146 119 147 // Fifo transmitting date to the VCI FSM 120 148 GenericFifo<uint64_t> m_date_fifo; 121 149 122 sc_signal<int> r_vci_fsm;150 sc_signal<int> r_vci_fsm; 123 151 124 sc_signal<size_t> r_index;152 sc_signal<size_t> r_index; 125 153 126 sc_signal<bool> r_broadcast_req;154 sc_signal<bool> r_broadcast_req; 127 155 128 156 }; // end class VciSyntheticInitiator -
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.