Changeset 284 for trunk/modules/vci_vdspin_target_wrapper/caba/source/src
- Timestamp:
- Dec 11, 2012, 6:19:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_vdspin_target_wrapper/caba/source/src/vci_vdspin_target_wrapper.cpp
r185 r284 5 5 * 6 6 * SOCLIB_LGPL_HEADER_BEGIN 7 * 7 * 8 8 * This file is part of SoCLib, GNU LGPLv2.1. 9 * 9 * 10 10 * SoCLib is free software; you can redistribute it and/or modify it 11 11 * under the terms of the GNU Lesser General Public License as published 12 12 * by the Free Software Foundation; version 2.1 of the License. 13 * 13 * 14 14 * SoCLib is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 17 * Lesser General Public License for more details. 18 * 18 * 19 19 * You should have received a copy of the GNU Lesser General Public 20 20 * License along with SoCLib; if not, write to the Free Software 21 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 22 * 02110-1301 USA 23 * 23 * 24 24 * SOCLIB_LGPL_HEADER_END 25 25 */ … … 34 34 35 35 //////////////////////////////////////////////////////////://////////////////////////////// 36 tmpl(/**/)::VciVdspinTargetWrapper(sc_module_name 37 size_tcmd_fifo_depth,38 size_trsp_fifo_depth)39 36 tmpl(/**/)::VciVdspinTargetWrapper(sc_module_name name, 37 size_t cmd_fifo_depth, 38 size_t rsp_fifo_depth) 39 : soclib::caba::BaseModule(name), 40 40 p_clk("p_clk"), 41 41 p_resetn("p_resetn"), … … 45 45 r_cmd_fsm("r_cmd_fsm"), 46 46 r_rsp_fsm("r_rsp_fsm"), 47 48 47 r_fifo_cmd("r_fifo_cmd", cmd_fifo_depth), 48 r_fifo_rsp("r_fifo_rsp", rsp_fifo_depth) 49 49 { 50 51 52 53 54 55 50 SC_METHOD (transition); 51 dont_initialize(); 52 sensitive << p_clk.pos(); 53 SC_METHOD (genMoore); 54 dont_initialize(); 55 sensitive << p_clk.neg(); 56 56 57 57 assert( (dspin_cmd_width == 40) && "The DSPIN CMD flit width must have 40 bits"); 58 58 assert( (dspin_rsp_width == 33) && "The DSPIN RSP flit width must have 33 bits"); 59 assert( (vci_param::N <= 40) && "The VCI ADDRESS field cannot have more than 40 bits"); 59 assert( (vci_param::N <= 40) && "The VCI ADDRESS field cannot have more than 40 bits"); 60 60 assert( (vci_param::B == 4) && "The VCI DATA filds must have 32 bits"); 61 61 assert( (vci_param::K == 8) && "The VCI PLEN field cannot have more than 8 bits"); … … 69 69 tmpl(void)::transition() 70 70 { 71 sc_uint<dspin_cmd_width>cmd_fifo_data;72 boolcmd_fifo_write;73 boolcmd_fifo_read;74 75 sc_uint<dspin_rsp_width>rsp_fifo_data;76 boolrsp_fifo_write;77 boolrsp_fifo_read;78 79 if (p_resetn == false) 80 { 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 // - A N flits VCI read response packet is translated96 97 // In the RSP_IDLE state, the first DSPIN flit is written98 // in fifo_rsp , but no VCI flit is consumed. The VCI flits99 100 101 102 103 104 105 106 rsp_fifo_write = false; 107 108 109 case RSP_IDLE:// write first DSPIN flit into rsp_fifo110 { 111 if( p_vci.rspval && r_fifo_rsp.wok() ) 71 sc_uint<dspin_cmd_width> cmd_fifo_data; 72 bool cmd_fifo_write; 73 bool cmd_fifo_read; 74 75 sc_uint<dspin_rsp_width> rsp_fifo_data; 76 bool rsp_fifo_write; 77 bool rsp_fifo_read; 78 79 if (p_resetn == false) 80 { 81 r_fifo_cmd.init(); 82 r_fifo_rsp.init(); 83 r_cmd_fsm = CMD_IDLE; 84 r_rsp_fsm = RSP_IDLE; 85 return; 86 } // end reset 87 88 ///////////////////////////////////////////////////////////// 89 // VCI response packet to DSPIN response packet. 90 // The VCI packet is analysed, translated, 91 // and the DSPIN packet is stored in the fifo_rsp 92 ///////////////////////////////////////////////////////////// 93 // - A single flit VCI write response packet is translated 94 // to a single flit DSPIN response. 95 // - A N flits VCI read response packet is translated 96 // to a N+1 flits DSPIN response 97 // In the RSP_IDLE state, the first DSPIN flit is written 98 // in fifo_rsp , but no VCI flit is consumed. The VCI flits 99 // are consumed in the RSP_READ or RSP_WRITE states. 100 ////////////////////////////////////////////////////////////// 101 102 // rsp_fifo_read 103 rsp_fifo_read = p_dspin_out.read.read(); 104 105 // r_rsp_fsm, rsp_fifo_write and rsp_fifo_data 106 rsp_fifo_write = false; // default value 107 108 switch(r_rsp_fsm) { 109 case RSP_IDLE: // write first DSPIN flit into rsp_fifo 110 { 111 if( p_vci.rspval && r_fifo_rsp.wok() ) 112 112 { 113 113 bool is_read = ( (p_vci.rerror.read() & 0x2) == 0); 114 114 115 115 rsp_fifo_write = true; 116 116 rsp_fifo_data = (((sc_uint<dspin_rsp_width>)p_vci.rsrcid.read()) << 18) | 117 117 (((sc_uint<dspin_rsp_width>)p_vci.rerror.read()) << 16) | 118 (((sc_uint<dspin_rsp_width>)p_vci.rtrdid.read()) << 8); 119 if ( is_read ) 118 (((sc_uint<dspin_rsp_width>)p_vci.rtrdid.read()) << 12) | 119 (((sc_uint<dspin_rsp_width>)p_vci.rpktid.read()) << 8); 120 if ( is_read ) 120 121 { 121 122 r_rsp_fsm = RSP_READ; … … 126 127 r_rsp_fsm = RSP_WRITE; 127 128 } 128 129 130 } 131 case RSP_READ:// write DSPIN data flit in case of read132 { 129 } 130 break; 131 } 132 case RSP_READ: // write DSPIN data flit in case of read 133 { 133 134 if( p_vci.rspval && r_fifo_rsp.wok() ) 134 135 { 135 136 rsp_fifo_write = true; 136 137 rsp_fifo_data = ((sc_uint<dspin_rsp_width>)p_vci.rdata.read()); 137 if ( p_vci.reop ) 138 if ( p_vci.reop ) 138 139 { 139 140 rsp_fifo_data = rsp_fifo_data | 0x100000000LL; … … 149 150 break; 150 151 } 151 152 153 154 if((rsp_fifo_write == true) && (rsp_fifo_read == false)) { r_fifo_rsp.simple_put(rsp_fifo_data); } 155 if((rsp_fifo_write == true) && (rsp_fifo_read == true)) { r_fifo_rsp.put_and_get(rsp_fifo_data); } 156 152 } // end switch r_cmd_fsm 153 154 // fifo_rsp 155 if((rsp_fifo_write == true) && (rsp_fifo_read == false)) { r_fifo_rsp.simple_put(rsp_fifo_data); } 156 if((rsp_fifo_write == true) && (rsp_fifo_read == true)) { r_fifo_rsp.put_and_get(rsp_fifo_data); } 157 if((rsp_fifo_write == false) && (rsp_fifo_read == true)) { r_fifo_rsp.simple_get(); } 157 158 158 159 ////////////////////////////////////////////////////////////// 159 160 161 160 // DSPIN command packet to VCI command packet 161 // The DSPIN packet is stored in the fifo_rsp 162 // The FIFO output is analysed and translated to a VCI packet 162 163 ////////////////////////////////////////////////////////////// 163 164 // - A 2 flits DSPIN broadcast command is translated … … 166 167 // to a 1 flit VCI read command. 167 168 // - A N+2 flits DSPIN write command is translated 168 // to a N flits VCI write command. 169 // The VCI flits are sent in the CMD_READ, CMD_WDATA 170 // & CMD_BROADCAST states. 169 // to a N flits VCI write command. 170 // The VCI flits are sent in the CMD_READ, CMD_WDATA 171 // & CMD_BROADCAST states. 171 172 // The r_cmd_buf0 et r_cmd_buf1 buffers are used to store 172 173 // the two first DSPIN flits (in case of write). 173 174 ////////////////////////////////////////////////////////////// 174 175 175 176 177 178 179 180 cmd_fifo_read = false; 181 182 183 184 { 185 176 // cmd_fifo_write, cmd_fifo_data 177 cmd_fifo_write = p_dspin_in.write.read(); 178 cmd_fifo_data = p_dspin_in.data.read(); 179 180 // r_cmd_fsm, cmd_fifo_read 181 cmd_fifo_read = false; // default value 182 183 switch(r_cmd_fsm) { 184 case CMD_IDLE: 185 { 186 if( r_fifo_cmd.rok() ) 186 187 { 187 188 bool is_broadcast = ( (r_fifo_cmd.read() & 0x1) == 0x1); 188 189 189 190 r_cmd_buf0 = r_fifo_cmd.read(); 190 cmd_fifo_read = true; 191 r_cmd_buf0 = r_fifo_cmd.read(); // save address 191 192 if ( is_broadcast ) r_cmd_fsm = CMD_BROADCAST; 192 else 193 194 195 } 196 197 198 193 else r_cmd_fsm = CMD_RW; 194 } 195 break; 196 } 197 case CMD_BROADCAST: 198 { 199 if( r_fifo_cmd.rok() && p_vci.cmdack ) 199 200 { 200 201 cmd_fifo_read = true; … … 205 206 case CMD_RW: 206 207 { 207 208 { 209 210 r_cmd_buf1 = r_fifo_cmd.read(); 208 if( r_fifo_cmd.rok() ) 209 { 210 cmd_fifo_read = true; 211 r_cmd_buf1 = r_fifo_cmd.read(); // save command parameters 211 212 // read command if EOP 212 213 if ( (r_fifo_cmd.read() & 0x8000000000LL) ) r_cmd_fsm = CMD_READ; 213 else 214 else r_cmd_fsm = CMD_WDATA; 214 215 r_flit_count = 0; 215 216 216 } 217 break; 217 218 } 218 219 case CMD_READ: … … 223 224 case CMD_WDATA: 224 225 { 225 226 { 227 if ( (r_cmd_buf1.read() & 0x0000200000LL) == 0 ) 228 229 if ( (r_fifo_cmd.read() & 0x8000000000LL) ) 230 231 break; 232 } 233 234 235 236 if((cmd_fifo_write == true) && (cmd_fifo_read == false)) { r_fifo_cmd.simple_put(cmd_fifo_data); } 237 if((cmd_fifo_write == true) && (cmd_fifo_read == true)) { r_fifo_cmd.put_and_get(cmd_fifo_data); } 238 226 if( r_fifo_cmd.rok() && p_vci.cmdack.read() ) 227 { 228 if ( (r_cmd_buf1.read() & 0x0000200000LL) == 0 ) r_flit_count = r_flit_count + 1; 229 cmd_fifo_read = true; 230 if ( (r_fifo_cmd.read() & 0x8000000000LL) ) r_cmd_fsm = CMD_IDLE; 231 } 232 break; 233 } 234 } // end switch r_cmd_fsm 235 236 // fifo_cmd 237 if((cmd_fifo_write == true) && (cmd_fifo_read == false)) { r_fifo_cmd.simple_put(cmd_fifo_data); } 238 if((cmd_fifo_write == true) && (cmd_fifo_read == true)) { r_fifo_cmd.put_and_get(cmd_fifo_data); } 239 if((cmd_fifo_write == false) && (cmd_fifo_read == true)) { r_fifo_cmd.simple_get(); } 239 240 240 241 }; // end transition … … 243 244 tmpl(void)::genMoore() 244 245 { 245 246 if ( r_rsp_fsm.read() == RSP_IDLE ) 247 elsep_vci.rspack = r_fifo_rsp.wok();248 249 250 246 // VCI RSP interface 247 if ( r_rsp_fsm.read() == RSP_IDLE ) p_vci.rspack = false; 248 else p_vci.rspack = r_fifo_rsp.wok(); 249 250 // VCI CMD interface 251 if ( (r_cmd_fsm.read() == CMD_IDLE) || (r_cmd_fsm.read() == CMD_RW) ) 251 252 { 252 253 p_vci.cmdval = false; 253 254 } 254 else if ( r_cmd_fsm.read() == CMD_BROADCAST ) 255 else if ( r_cmd_fsm.read() == CMD_BROADCAST ) // VCI CMD broadcast 255 256 { 256 257 if ( r_fifo_cmd.rok() ) … … 258 259 sc_uint<dspin_cmd_width> minmax = r_cmd_buf0.read() & 0x7FFFF80000LL; 259 260 if ( vci_param::N == 40 ) minmax = (minmax << 1); 260 else minmax = (minmax >> (39 - vci_param::N) );261 else minmax = (minmax >> (39 - vci_param::N) ); 261 262 p_vci.cmdval = true; 262 263 p_vci.address = (sc_uint<vci_param::N>)minmax | 0x3; 263 264 p_vci.cmd = vci_param::CMD_WRITE; 264 265 p_vci.wdata = (sc_uint<8*vci_param::B>)(r_fifo_cmd.read() & 0x00FFFFFFFFLL); … … 266 267 p_vci.srcid = (sc_uint<vci_param::S>)((r_cmd_buf0.read() & 0x000007FFE0LL) >> 5); 267 268 p_vci.trdid = (sc_uint<vci_param::T>)((r_cmd_buf0.read() & 0x000000001ELL) >> 1); 268 269 p_vci.pktid = 0; 269 270 p_vci.plen = vci_param::B; 270 271 p_vci.contig = true; … … 274 275 else 275 276 { 276 277 } 278 } 279 else if ( r_cmd_fsm.read() == CMD_READ ) 280 { 277 p_vci.cmdval = false; 278 } 279 } 280 else if ( r_cmd_fsm.read() == CMD_READ ) // VCI CMD read 281 { 281 282 sc_uint<vci_param::N> address; 282 283 if ( vci_param::N == 40 ) address = (r_cmd_buf0.read() << 1); 283 else address = (r_cmd_buf0.read() >> (39 - vci_param::N) ); 284 else address = (r_cmd_buf0.read() >> (39 - vci_param::N) ); 284 285 p_vci.cmdval = true; 285 286 p_vci.address = address; 286 287 p_vci.cmd = (sc_uint<2>)((r_cmd_buf1.read() & 0x0001800000LL) >> 23); 287 288 p_vci.wdata = 0; 288 289 p_vci.be = (sc_uint<vci_param::B>)((r_cmd_buf1.read() & 0x000000001ELL) >> 1); 289 290 p_vci.srcid = (sc_uint<vci_param::S>)((r_cmd_buf1.read() & 0x7FFE000000LL) >> 25); 290 p_vci. trdid = (sc_uint<vci_param::T>)((r_cmd_buf1.read() & 0x0000001FE0LL) >> 5);291 p_vci.pktid = 0;291 p_vci.pktid = (sc_uint<vci_param::P>)((r_cmd_buf1.read() & 0x00000001E0LL) >> 5); 292 p_vci.trdid = (sc_uint<vci_param::T>)((r_cmd_buf1.read() & 0x0000001E00LL) >> 9); 292 293 p_vci.plen = (sc_uint<vci_param::K>)((r_cmd_buf1.read() & 0x00001FE000LL) >> 13); 293 294 p_vci.contig = ((r_cmd_buf1.read() & 0x0000400000LL) != 0); 294 295 p_vci.cons = ((r_cmd_buf1.read() & 0x0000200000LL) != 0); 295 296 p_vci.eop = true; 296 297 else if ( r_cmd_fsm.read() == CMD_WDATA ) 298 { 299 if ( r_fifo_cmd.rok() ) 297 } 298 else if ( r_cmd_fsm.read() == CMD_WDATA ) // VCI write command 299 { 300 if ( r_fifo_cmd.rok() ) 300 301 { 301 302 sc_uint<vci_param::N> address; 302 303 if ( vci_param::N == 40 ) address = (r_cmd_buf0.read() << 1); 303 else address = (r_cmd_buf0.read() >> (39 - vci_param::N) ); 304 else address = (r_cmd_buf0.read() >> (39 - vci_param::N) ); 304 305 p_vci.cmdval = true; 305 306 p_vci.cmd = (sc_uint<2>)((r_cmd_buf1.read() 307 p_vci.wdata = (sc_uint<8*vci_param::B>)(r_fifo_cmd.read()& 0x00FFFFFFFFLL);308 p_vci.be = (sc_uint<vci_param::B>)((r_fifo_cmd.read()& 0x0F00000000LL) >> 32);309 p_vci.srcid = (sc_uint<vci_param::S>)((r_cmd_buf1.read() 310 p_vci. trdid = (sc_uint<vci_param::T>)((r_cmd_buf1.read() & 0x0000001FE0LL) >> 5);311 p_vci.pktid = 0;312 p_vci.plen = (sc_uint<vci_param::K>)((r_cmd_buf1.read() & 0x00001FE000LL) >> 13);306 p_vci.address = address + (r_flit_count.read()*vci_param::B); 307 p_vci.cmd = (sc_uint<2>)((r_cmd_buf1.read() & 0x0001800000LL) >> 23); 308 p_vci.wdata = (sc_uint<8*vci_param::B>)(r_fifo_cmd.read() & 0x00FFFFFFFFLL); 309 p_vci.be = (sc_uint<vci_param::B>)((r_fifo_cmd.read() & 0x0F00000000LL) >> 32); 310 p_vci.srcid = (sc_uint<vci_param::S>)((r_cmd_buf1.read() & 0x7FFE000000LL) >> 25); 311 p_vci.pktid = (sc_uint<vci_param::P>)((r_cmd_buf1.read() & 0x00000001E0LL) >> 5); 312 p_vci.trdid = (sc_uint<vci_param::T>)((r_cmd_buf1.read() & 0x0000001E00LL) >> 9); 313 p_vci.plen = (sc_uint<vci_param::K>)((r_cmd_buf1.read() & 0x00001FE000LL) >> 13); 313 314 p_vci.contig = ((r_cmd_buf1.read() & 0x0000400000LL) != 0); 314 315 p_vci.cons = ((r_cmd_buf1.read() & 0x0000200000LL) != 0); 315 p_vci.eop = ((r_fifo_cmd.read() & 0x8000000000LL) == 0x8000000000LL); 316 p_vci.eop = ((r_fifo_cmd.read() & 0x8000000000LL) == 0x8000000000LL); 316 317 } 317 318 else 318 319 { 319 320 } 321 } 322 323 324 325 326 327 328 320 p_vci.cmdval = false; 321 } 322 } 323 324 // DSPIN_OUT interface 325 p_dspin_out.write = r_fifo_rsp.rok(); 326 p_dspin_out.data = r_fifo_rsp.read(); 327 328 // DSPIN_IN interface 329 p_dspin_in.read = r_fifo_cmd.wok(); 329 330 330 331 }; // end genMoore … … 346 347 }; 347 348 std::cout << name() << " : " << cmd_str[r_cmd_fsm.read()] 348 << " | " << rsp_str[r_rsp_fsm.read()] 349 << " | " << rsp_str[r_rsp_fsm.read()] 349 350 << " | fifo_cmd = " << r_fifo_cmd.filled_status() 350 351 << " | fifo_rsp = " << r_fifo_rsp.filled_status() 351 352 << std::endl; 352 353 } 353 354
Note: See TracChangeset
for help on using the changeset viewer.