Changeset 284 for trunk/modules/vci_vdspin_initiator_wrapper/caba/source
- Timestamp:
- Dec 11, 2012, 6:19:35 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_vdspin_initiator_wrapper/caba/source/src/vci_vdspin_initiator_wrapper.cpp
r186 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 */ … … 32 32 33 33 //////////////////////////////////////////////////////////://////////////////////////////// 34 tmpl(/**/)::VciVdspinInitiatorWrapper(sc_module_name name,35 size_tcmd_fifo_depth,36 size_trsp_fifo_depth)37 : soclib::caba::BaseModule(name),34 tmpl(/**/)::VciVdspinInitiatorWrapper(sc_module_name name, 35 size_t cmd_fifo_depth, 36 size_t rsp_fifo_depth) 37 : soclib::caba::BaseModule(name), 38 38 p_clk("p_clk"), 39 39 p_resetn("p_resetn"), … … 43 43 r_cmd_fsm("r_cmd_fsm"), 44 44 r_rsp_fsm("r_rsp_fsm"), 45 r_fifo_cmd("r_fifo_cmd", cmd_fifo_depth),46 r_fifo_rsp("r_fifo_rsp", rsp_fifo_depth)47 {48 SC_METHOD (transition);49 dont_initialize();50 sensitive << p_clk.pos();51 SC_METHOD (genMoore);52 dont_initialize();53 sensitive << p_clk.neg();54 55 assert( (dspin_cmd_width == 40) && "The DSPIN CMD flit width must have 40 bits");56 assert( (dspin_rsp_width == 33) && "The DSPIN RSP flit width must have 33 bits");57 assert( (vci_param::N <= 40) && "The VCI ADDRESS field cannot have more than 40 bits");58 assert( (vci_param::B == 4) && "The VCI DATA filds must have 32 bits");59 assert( (vci_param::K == 8) && "The VCI PLEN field cannot have more than 8 bits");60 assert( (vci_param::S <= 14) && "The VCI SRCID field cannot have more than 8 bits");61 assert( (vci_param::T <= 8) && "The VCI TRDID field cannot have more than 8 bits");62 assert( (vci_param::E == 2) && "The VCI RERROR field cannot have more than 2 bits");63 64 } // end constructor45 r_fifo_cmd("r_fifo_cmd", cmd_fifo_depth), 46 r_fifo_rsp("r_fifo_rsp", rsp_fifo_depth) 47 { 48 SC_METHOD (transition); 49 dont_initialize(); 50 sensitive << p_clk.pos(); 51 SC_METHOD (genMoore); 52 dont_initialize(); 53 sensitive << p_clk.neg(); 54 55 assert( (dspin_cmd_width == 40) && "The DSPIN CMD flit width must have 40 bits"); 56 assert( (dspin_rsp_width == 33) && "The DSPIN RSP flit width must have 33 bits"); 57 assert( (vci_param::N <= 40) && "The VCI ADDRESS field cannot have more than 40 bits"); 58 assert( (vci_param::B == 4) && "The VCI DATA filds must have 32 bits"); 59 assert( (vci_param::K == 8) && "The VCI PLEN field cannot have more than 8 bits"); 60 assert( (vci_param::S <= 14) && "The VCI SRCID field cannot have more than 8 bits"); 61 assert( (vci_param::T <= 8) && "The VCI TRDID field cannot have more than 8 bits"); 62 assert( (vci_param::E == 2) && "The VCI RERROR field cannot have more than 2 bits"); 63 64 } // end constructor 65 65 66 66 ///////////////////////// 67 67 tmpl(void)::transition() 68 68 { 69 sc_uint<dspin_cmd_width>cmd_fifo_data;70 boolcmd_fifo_write;71 boolcmd_fifo_read;72 73 sc_uint<dspin_rsp_width>rsp_fifo_data;74 boolrsp_fifo_write;75 boolrsp_fifo_read;76 77 if (p_resetn == false) 78 { 79 r_fifo_cmd.init();80 r_fifo_rsp.init();81 r_cmd_fsm = CMD_IDLE;82 r_rsp_fsm = RSP_IDLE;83 return;84 } // end reset85 86 /////////////////////////////////////////////////////////////87 // VCI command packet to DSPIN command packet88 // The VCI packet is analysed, translated,89 // and the DSPIN packet is stored in the fifo_cmd90 /////////////////////////////////////////////////////////////91 // - A N flits VCI write command packet is translated92 // to a N+2 flits DSPIN command.93 // - A single flit VCI read command packet is translated94 // to a 2 flits DSPIN command.95 // - A single flit VCI broadcast packet is translated to96 // a 2 flits DSPIN command.97 // A DSPIN flit is written in the fifo_cmd in all states98 // but a VCI flit is consumed only in the CMD_READ,99 // CMD_BROACAST, and CMD_WDATA states.100 //////////////////////////////////////////////////////////////101 102 // cmd_fifo_read103 cmd_fifo_read = p_dspin_out.read.read();104 105 // r_cmd_fsm, cmd_fifo_write and cmd_fifo_data106 cmd_fifo_write = false;// default value107 108 switch(r_cmd_fsm) {109 case CMD_IDLE:// write first DSPIN flit into fifo_cmd110 { 111 if( p_vci.cmdval && r_fifo_cmd.wok() ) 112 { 113 cmd_fifo_write = true;69 sc_uint<dspin_cmd_width> cmd_fifo_data; 70 bool cmd_fifo_write; 71 bool cmd_fifo_read; 72 73 sc_uint<dspin_rsp_width> rsp_fifo_data; 74 bool rsp_fifo_write; 75 bool rsp_fifo_read; 76 77 if (p_resetn == false) 78 { 79 r_fifo_cmd.init(); 80 r_fifo_rsp.init(); 81 r_cmd_fsm = CMD_IDLE; 82 r_rsp_fsm = RSP_IDLE; 83 return; 84 } // end reset 85 86 ///////////////////////////////////////////////////////////// 87 // VCI command packet to DSPIN command packet 88 // The VCI packet is analysed, translated, 89 // and the DSPIN packet is stored in the fifo_cmd 90 ///////////////////////////////////////////////////////////// 91 // - A N flits VCI write command packet is translated 92 // to a N+2 flits DSPIN command. 93 // - A single flit VCI read command packet is translated 94 // to a 2 flits DSPIN command. 95 // - A single flit VCI broadcast packet is translated to 96 // a 2 flits DSPIN command. 97 // A DSPIN flit is written in the fifo_cmd in all states 98 // but a VCI flit is consumed only in the CMD_READ, 99 // CMD_BROACAST, and CMD_WDATA states. 100 ////////////////////////////////////////////////////////////// 101 102 // cmd_fifo_read 103 cmd_fifo_read = p_dspin_out.read.read(); 104 105 // r_cmd_fsm, cmd_fifo_write and cmd_fifo_data 106 cmd_fifo_write = false; // default value 107 108 switch(r_cmd_fsm) { 109 case CMD_IDLE: // write first DSPIN flit into fifo_cmd 110 { 111 if( p_vci.cmdval && r_fifo_cmd.wok() ) 112 { 113 cmd_fifo_write = true; 114 114 sc_uint<dspin_cmd_width> address = (sc_uint<dspin_cmd_width>)p_vci.address.read(); 115 115 sc_uint<dspin_cmd_width> srcid = (sc_uint<dspin_cmd_width>)p_vci.srcid.read(); … … 121 121 122 122 if ( vci_param::N == 40 ) address = address >> 1; 123 else address = address << (39 - vci_param::N); 124 125 if ( is_broadcast ) // VCI broacast command123 else address = address << (39 - vci_param::N); 124 125 if ( is_broadcast ) // VCI broacast command 126 126 { 127 127 r_cmd_fsm = CMD_BROADCAST; 128 128 cmd_fifo_data = (address & 0x7FFFF80000LL) | 129 ((srcid << 5) & 0x000007FFE0LL) | 130 ((trdid << 1) & 0x000000001ELL) | 131 0x0000000001LL; 132 } 133 else if (is_read ) // VCI READ command134 { 135 r_cmd_fsm = CMD_READ;129 ((srcid << 5) & 0x000007FFE0LL) | 130 ((trdid << 1) & 0x000000001ELL) | 131 0x0000000001LL; 132 } 133 else if (is_read ) // VCI READ command 134 { 135 r_cmd_fsm = CMD_READ; 136 136 cmd_fifo_data = address & 0x7FFFFFFFFELL; 137 }138 else // VCI WRITE command139 { 140 r_cmd_fsm = CMD_WRITE;137 } 138 else // VCI WRITE command 139 { 140 r_cmd_fsm = CMD_WRITE; 141 141 cmd_fifo_data = address & 0x7FFFFFFFFELL; 142 }143 }144 break;145 }146 case CMD_BROADCAST:// write second DSPIN flit in case of broadcast147 { 148 if( p_vci.cmdval && r_fifo_cmd.wok() ) 142 } 143 } 144 break; 145 } 146 case CMD_BROADCAST: // write second DSPIN flit in case of broadcast 147 { 148 if( p_vci.cmdval && r_fifo_cmd.wok() ) 149 149 { 150 150 cmd_fifo_write = true; 151 151 sc_uint<dspin_cmd_width> data = (sc_uint<dspin_cmd_width>)p_vci.wdata.read(); 152 152 sc_uint<dspin_cmd_width> be = (sc_uint<dspin_cmd_width>)p_vci.be.read(); 153 cmd_fifo_data = (data & 0x00FFFFFFFFLL) | 153 cmd_fifo_data = (data & 0x00FFFFFFFFLL) | 154 154 ((be << 32) & 0x0300000000LL) | 155 0x8000000000LL; 155 0x8000000000LL; 156 156 r_cmd_fsm = CMD_IDLE; 157 157 } 158 158 break; 159 159 } 160 case CMD_READ: // write second DSPIN flit in case of read/write160 case CMD_READ: // write second DSPIN flit in case of read/write 161 161 case CMD_WRITE: 162 162 { 163 if( p_vci.cmdval && r_fifo_cmd.wok() ) 164 { 165 cmd_fifo_write = true;163 if( p_vci.cmdval && r_fifo_cmd.wok() ) 164 { 165 cmd_fifo_write = true; 166 166 sc_uint<dspin_cmd_width> srcid = (sc_uint<dspin_cmd_width>)p_vci.srcid.read(); 167 sc_uint<dspin_cmd_width> pktid = (sc_uint<dspin_cmd_width>)p_vci.pktid.read(); 167 168 sc_uint<dspin_cmd_width> trdid = (sc_uint<dspin_cmd_width>)p_vci.trdid.read(); 168 169 sc_uint<dspin_cmd_width> cmd = (sc_uint<dspin_cmd_width>)p_vci.cmd.read(); 169 170 sc_uint<dspin_cmd_width> plen = (sc_uint<dspin_cmd_width>)p_vci.plen.read(); 170 171 sc_uint<dspin_cmd_width> be = (sc_uint<dspin_cmd_width>)p_vci.be.read(); 171 cmd_fifo_data = ((be << 1 ) & 0x000000001ELL) | 172 ((trdid << 5 ) & 0x0000001FE0LL) | 173 ((plen << 13) & 0x00001FE000LL) | 174 ((cmd << 23) & 0x0001800000LL) | 175 ((srcid << 25) & 0x7FFE000000LL) ; 172 cmd_fifo_data = ((be << 1 ) & 0x000000001ELL) | 173 ((pktid << 5 ) & 0x00000001E0LL) | 174 ((trdid << 9 ) & 0x0000001E00LL) | 175 ((plen << 13) & 0x00001FE000LL) | 176 ((cmd << 23) & 0x0001800000LL) | 177 ((srcid << 25) & 0x7FFE000000LL) ; 176 178 if ( p_vci.contig.read() ) cmd_fifo_data = cmd_fifo_data | 0x0000400000LL ; 177 179 if ( p_vci.cons.read() ) cmd_fifo_data = cmd_fifo_data | 0x0000200000LL ; … … 182 184 cmd_fifo_data = cmd_fifo_data | 0x8000000000LL ; 183 185 } 184 else // write command186 else // write command 185 187 { 186 188 r_cmd_fsm = CMD_WDATA; 187 189 } 188 }189 break;190 } 191 case CMD_WDATA:192 { 193 if( p_vci.cmdval && r_fifo_cmd.wok() ) 194 { 195 cmd_fifo_write = true;190 } 191 break; 192 } 193 case CMD_WDATA: 194 { 195 if( p_vci.cmdval && r_fifo_cmd.wok() ) 196 { 197 cmd_fifo_write = true; 196 198 sc_uint<dspin_cmd_width> data = (sc_uint<dspin_cmd_width>)p_vci.wdata.read(); 197 199 sc_uint<dspin_cmd_width> be = (sc_uint<dspin_cmd_width>)p_vci.be.read(); 198 cmd_fifo_data = (data & 0x00FFFFFFFFLL) | 199 ((be << 32) & 0x0F00000000LL) ;200 200 cmd_fifo_data = (data & 0x00FFFFFFFFLL) | 201 ((be << 32) & 0x0F00000000LL) ; 202 201 203 if ( p_vci.eop.read() ) 202 204 { … … 204 206 r_cmd_fsm = CMD_IDLE; 205 207 } 206 } 208 } 207 209 break; 208 210 } 209 } // end switch r_cmd_fsm210 211 // fifo_cmd212 if((cmd_fifo_write == true) && (cmd_fifo_read == false)) { r_fifo_cmd.simple_put(cmd_fifo_data); } 213 if((cmd_fifo_write == true) && (cmd_fifo_read == true)) { r_fifo_cmd.put_and_get(cmd_fifo_data); } 214 if((cmd_fifo_write == false) && (cmd_fifo_read == true)) { r_fifo_cmd.simple_get(); }215 216 //////////////////////////////////////////////////////////////217 // DSPIN response packet to VCI response packet218 // The DSPIN packet is stored in the fifo_rsp219 // The FIFO output is analysed and translated to a VCI packet220 //////////////////////////////////////////////////////////////221 // - A N+1 flits DSPIN read response packet is translated222 // to a N flits VCI response.223 // - A single flit DSPIN write response packet is translated224 // to a single flit VCI response.225 // A valid DSPIN flit in the fifo_rsp is always consumed226 // in the CMD_IDLE state, but no VCI flit is transmitted.227 // The VCI flits are sent in the RSP_READ & RSP_WRITE states.228 //////////////////////////////////////////////////////////////229 230 // rsp_fifo_write, rsp_fifo_data231 rsp_fifo_write = p_dspin_in.write.read();232 rsp_fifo_data = p_dspin_in.data.read();233 234 // r_rsp_fsm, rsp_fifo_read235 rsp_fifo_read = false; // default value236 237 switch(r_rsp_fsm) {238 case RSP_IDLE:239 { 240 if( r_fifo_rsp.rok() )241 { 242 rsp_fifo_read = true;211 } // end switch r_cmd_fsm 212 213 // fifo_cmd 214 if((cmd_fifo_write == true) && (cmd_fifo_read == false)) { r_fifo_cmd.simple_put(cmd_fifo_data); } 215 if((cmd_fifo_write == true) && (cmd_fifo_read == true)) { r_fifo_cmd.put_and_get(cmd_fifo_data); } 216 if((cmd_fifo_write == false) && (cmd_fifo_read == true)) { r_fifo_cmd.simple_get(); } 217 218 ////////////////////////////////////////////////////////////// 219 // DSPIN response packet to VCI response packet 220 // The DSPIN packet is stored in the fifo_rsp 221 // The FIFO output is analysed and translated to a VCI packet 222 ////////////////////////////////////////////////////////////// 223 // - A N+1 flits DSPIN read response packet is translated 224 // to a N flits VCI response. 225 // - A single flit DSPIN write response packet is translated 226 // to a single flit VCI response. 227 // A valid DSPIN flit in the fifo_rsp is always consumed 228 // in the CMD_IDLE state, but no VCI flit is transmitted. 229 // The VCI flits are sent in the RSP_READ & RSP_WRITE states. 230 ////////////////////////////////////////////////////////////// 231 232 // rsp_fifo_write, rsp_fifo_data 233 rsp_fifo_write = p_dspin_in.write.read(); 234 rsp_fifo_data = p_dspin_in.data.read(); 235 236 // r_rsp_fsm, rsp_fifo_read 237 rsp_fifo_read = false; // default value 238 239 switch(r_rsp_fsm) { 240 case RSP_IDLE: 241 { 242 if( r_fifo_rsp.rok() ) 243 { 244 rsp_fifo_read = true; 243 245 r_rsp_buf = r_fifo_rsp.read(); 244 246 if ( (r_fifo_rsp.read() & 0x000020000LL) == 0 ) r_rsp_fsm = RSP_READ; 245 else r_rsp_fsm = RSP_WRITE;246 }247 break;248 } 249 case RSP_READ: 250 {251 if( r_fifo_rsp.rok() && p_vci.rspack.read() )252 { 253 rsp_fifo_read = true;247 else r_rsp_fsm = RSP_WRITE; 248 } 249 break; 250 } 251 case RSP_READ: 252 { 253 if( r_fifo_rsp.rok() && p_vci.rspack.read() ) 254 { 255 rsp_fifo_read = true; 254 256 if ( (r_fifo_rsp.read() & 0x100000000LL) ) r_rsp_fsm = RSP_IDLE; 255 }256 break;257 } 258 break; 257 259 } 258 260 case RSP_WRITE: … … 260 262 if ( p_vci.rspack.read() ) r_rsp_fsm = RSP_IDLE; 261 263 } 262 } // end switch r_rsp_fsm263 264 // fifo_rsp265 if((rsp_fifo_write == true) && (rsp_fifo_read == false)) { r_fifo_rsp.simple_put(rsp_fifo_data); } 266 if((rsp_fifo_write == true) && (rsp_fifo_read == true)) { r_fifo_rsp.put_and_get(rsp_fifo_data); } 267 if((rsp_fifo_write == false) && (rsp_fifo_read == true)) { r_fifo_rsp.simple_get(); }264 } // end switch r_rsp_fsm 265 266 // fifo_rsp 267 if((rsp_fifo_write == true) && (rsp_fifo_read == false)) { r_fifo_rsp.simple_put(rsp_fifo_data); } 268 if((rsp_fifo_write == true) && (rsp_fifo_read == true)) { r_fifo_rsp.put_and_get(rsp_fifo_data); } 269 if((rsp_fifo_write == false) && (rsp_fifo_read == true)) { r_fifo_rsp.simple_get(); } 268 270 269 271 }; // end transition … … 272 274 tmpl(void)::genMoore() 273 275 { 274 // VCI CMD interface275 if ( ( r_cmd_fsm.read() == CMD_IDLE ) || ( r_cmd_fsm.read() == CMD_WRITE ) ) 276 { 277 p_vci.cmdack = false; 278 } 279 else276 // VCI CMD interface 277 if ( ( r_cmd_fsm.read() == CMD_IDLE ) || ( r_cmd_fsm.read() == CMD_WRITE ) ) 278 { 279 p_vci.cmdack = false; 280 } 281 else 280 282 { 281 283 p_vci.cmdack = r_fifo_cmd.wok(); 282 284 } 283 285 284 // VCI RSP interface285 if ( r_rsp_fsm.read() == RSP_IDLE )286 // VCI RSP interface 287 if ( r_rsp_fsm.read() == RSP_IDLE ) 286 288 { 287 289 p_vci.rspval = false; … … 290 292 { 291 293 p_vci.rspval = true; 292 p_vci.rdata = 0;294 p_vci.rdata = 0; 293 295 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read() & 0x0FFFC0000LL) >> 18); 294 p_vci.r trdid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x00000FF00LL) >> 8);295 p_vci.r pktid = 0;296 p_vci.rpktid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x000000F00LL) >> 8); 297 p_vci.rtrdid = (sc_uint<vci_param::P>)((r_rsp_buf.read() & 0x00000F000LL) >> 12); 296 298 p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read() & 0x000030000LL) >> 16); 297 299 p_vci.reop = true; … … 302 304 p_vci.rdata = (sc_uint<8*vci_param::B>)(r_fifo_rsp.read() & 0x0FFFFFFFFLL); 303 305 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read() & 0x0FFFC0000LL) >> 18); 304 p_vci.r trdid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x00000FF00LL) >> 8);305 p_vci.r pktid = 0;306 p_vci.rpktid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x000000F00LL) >> 8); 307 p_vci.rtrdid = (sc_uint<vci_param::P>)((r_rsp_buf.read() & 0x00000F000LL) >> 12); 306 308 p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read() & 0x000030000LL) >> 16); 307 p_vci.reop = ((r_fifo_rsp.read() & 0x100000000LL) == 0x100000000LL); 308 } 309 310 // DSPIN_OUT interface311 p_dspin_out.write = r_fifo_cmd.rok();312 p_dspin_out.data = r_fifo_cmd.read();313 314 // DSPIN_IN interface315 p_dspin_in.read= r_fifo_rsp.wok();309 p_vci.reop = ((r_fifo_rsp.read() & 0x100000000LL) == 0x100000000LL); 310 } 311 312 // DSPIN_OUT interface 313 p_dspin_out.write = r_fifo_cmd.rok(); 314 p_dspin_out.data = r_fifo_cmd.read(); 315 316 // DSPIN_IN interface 317 p_dspin_in.read = r_fifo_rsp.wok(); 316 318 317 319 }; // end genMoore … … 334 336 335 337 std::cout << name() << " : " << cmd_str[r_cmd_fsm.read()] 336 << " | " << rsp_str[r_rsp_fsm.read()] 338 << " | " << rsp_str[r_rsp_fsm.read()] 337 339 << " | fifo_cmd = " << r_fifo_cmd.filled_status() 338 340 << " | fifo_rsp = " << r_fifo_rsp.filled_status()
Note: See TracChangeset
for help on using the changeset viewer.
