Changeset 287 for trunk/modules/vci_vdspin_initiator_wrapper
- Timestamp:
- Jan 15, 2013, 5:54:45 PM (12 years ago)
- Location:
- trunk/modules/vci_vdspin_initiator_wrapper/caba/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/vci_vdspin_initiator_wrapper/caba/source/include/vci_vdspin_initiator_wrapper.h
r150 r287 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 * 26 * Maintainers: alexandre.joannou@lip6.fr 27 * 25 28 */ 26 29 … … 41 44 // - VCI plen == 8 bits 42 45 // - VCI srcid <= 14 bits 43 // - VCI trdid <= 8bits44 // - VCI pktid field not transmitted45 // - VCI rerror == 2 bits46 // - VCI trdid <= 4 bits 47 // - VCI pktid <= 4 bits 48 // - VCI rerror == 1 bit 46 49 //////////////////////////////////////////////////////////////////////// 47 50 … … 60 63 template<typename vci_param, int dspin_cmd_width, int dspin_rsp_width> 61 64 class VciVdspinInitiatorWrapper 62 65 : public soclib::caba::BaseModule 63 66 { 64 // Command FSM 67 // Command FSM 65 68 enum fsm_state_cmd{ 66 67 68 69 70 69 CMD_IDLE, 70 CMD_BROADCAST, 71 CMD_READ, 72 CMD_WRITE, 73 CMD_WDATA, 71 74 }; 72 75 73 76 // Response FSM 74 77 enum fsm_state_rsp{ 75 76 RSP_READ, 77 RSP_WRITE, 78 RSP_IDLE, 79 RSP_DSPIN_SINGLE_FLIT, 80 RSP_DSPIN_MULTI_FLIT, 78 81 }; 79 82 … … 83 86 public: 84 87 // ports 85 sc_core::sc_in<bool> 86 sc_core::sc_in<bool> 87 soclib::caba::DspinOutput<dspin_cmd_width> 88 soclib::caba::DspinInput<dspin_rsp_width> 89 soclib::caba::VciTarget<vci_param> 88 sc_core::sc_in<bool> p_clk; 89 sc_core::sc_in<bool> p_resetn; 90 soclib::caba::DspinOutput<dspin_cmd_width> p_dspin_out; 91 soclib::caba::DspinInput<dspin_rsp_width> p_dspin_in; 92 soclib::caba::VciTarget<vci_param> p_vci; 90 93 91 94 // constructor / destructor 92 VciVdspinInitiatorWrapper( sc_module_name name,93 size_tcmd_fifo_depth,94 size_t rsp_fifo_depth);95 VciVdspinInitiatorWrapper( sc_module_name name, 96 size_t cmd_fifo_depth, 97 size_t rsp_fifo_depth ); 95 98 private: 96 99 // internal registers 97 sc_core::sc_signal<int> 98 sc_core::sc_signal<int> 99 sc_core::sc_signal<sc_uint<dspin_rsp_width> >r_rsp_buf;100 sc_core::sc_signal<int> r_cmd_fsm; 101 sc_core::sc_signal<int> r_rsp_fsm; 102 sc_core::sc_signal<sc_uint<dspin_rsp_width> > r_rsp_buf; 100 103 101 104 // fifos cmd and rsp 102 soclib::caba::GenericFifo<sc_uint<dspin_cmd_width> > 103 soclib::caba::GenericFifo<sc_uint<dspin_rsp_width> > 105 soclib::caba::GenericFifo<sc_uint<dspin_cmd_width> > r_fifo_cmd; 106 soclib::caba::GenericFifo<sc_uint<dspin_rsp_width> > r_fifo_rsp; 104 107 105 108 // methods systemc … … 113 116 114 117 }} // end namespace 115 118 116 119 #endif // VCI_VDSPIN_INITIATOR_WRAPPER_H_ 117 120 -
trunk/modules/vci_vdspin_initiator_wrapper/caba/source/src/vci_vdspin_initiator_wrapper.cpp
r284 r287 23 23 * 24 24 * SOCLIB_LGPL_HEADER_END 25 * 26 * Maintainers: alexandre.joannou@lip6.fr 27 * 25 28 */ 26 29 … … 31 34 #define tmpl(x) template<typename vci_param, int dspin_cmd_width, int dspin_rsp_width> x VciVdspinInitiatorWrapper<vci_param, dspin_cmd_width, dspin_rsp_width> 32 35 33 ////////////////////////////////////////////////////////// :////////////////////////////////34 tmpl(/**/)::VciVdspinInitiatorWrapper( sc_module_namename,35 size_tcmd_fifo_depth,36 size_t rsp_fifo_depth)37 :soclib::caba::BaseModule(name),38 39 40 41 42 43 44 45 r_fifo_cmd("r_fifo_cmd", cmd_fifo_depth),46 r_fifo_rsp("r_fifo_rsp", rsp_fifo_depth)36 ////////////////////////////////////////////////////////////////////////////////////////// 37 tmpl(/**/)::VciVdspinInitiatorWrapper( sc_module_name name, 38 size_t cmd_fifo_depth, 39 size_t rsp_fifo_depth ) 40 : soclib::caba::BaseModule(name), 41 p_clk("p_clk"), 42 p_resetn("p_resetn"), 43 p_dspin_out("p_dspin_out"), 44 p_dspin_in("p_dspin_in"), 45 p_vci("p_vci"), 46 r_cmd_fsm("r_cmd_fsm"), 47 r_rsp_fsm("r_rsp_fsm"), 48 r_fifo_cmd("r_fifo_cmd", cmd_fifo_depth), 49 r_fifo_rsp("r_fifo_rsp", rsp_fifo_depth) 47 50 { 48 51 SC_METHOD (transition); 49 52 dont_initialize(); 50 53 sensitive << p_clk.pos(); 54 51 55 SC_METHOD (genMoore); 52 56 dont_initialize(); … … 56 60 assert( (dspin_rsp_width == 33) && "The DSPIN RSP flit width must have 33 bits"); 57 61 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"); 62 assert( (vci_param::B == 4 ) && "The VCI DATA filds must have 32 bits"); 63 assert( (vci_param::K == 8 ) && "The VCI PLEN field cannot have more than 8 bits"); 64 assert( (vci_param::S <= 14) && "The VCI SRCID field cannot have more than 14 bits"); 65 assert( (vci_param::T <= 4 ) && "The VCI TRDID field cannot have more than 4 bits"); 66 assert( (vci_param::P <= 4 ) && "The VCI PKTID field cannot have more than 4 bits"); 67 assert( (vci_param::E <= 2 ) && "The VCI RERROR field cannot have more than 2 bits"); 63 68 64 69 } // end constructor … … 68 73 { 69 74 sc_uint<dspin_cmd_width> cmd_fifo_data; 70 bool cmd_fifo_write;71 bool cmd_fifo_read;75 bool cmd_fifo_write; 76 bool cmd_fifo_read; 72 77 73 78 sc_uint<dspin_rsp_width> rsp_fifo_data; 74 bool rsp_fifo_write;75 bool rsp_fifo_read;79 bool rsp_fifo_write; 80 bool rsp_fifo_read; 76 81 77 82 if (p_resetn == false) 78 83 { 79 84 r_fifo_cmd.init(); 80 85 r_fifo_rsp.init(); … … 123 128 else address = address << (39 - vci_param::N); 124 129 125 if ( is_broadcast ) 130 if ( is_broadcast ) // VCI broacast command 126 131 { 127 132 r_cmd_fsm = CMD_BROADCAST; … … 131 136 0x0000000001LL; 132 137 } 133 else if (is_read ) 138 else if (is_read ) // VCI READ command 134 139 { 135 140 r_cmd_fsm = CMD_READ; 136 141 cmd_fifo_data = address & 0x7FFFFFFFFELL; 137 142 } 138 else 143 else // VCI WRITE command 139 144 { 140 145 r_cmd_fsm = CMD_WRITE; … … 144 149 break; 145 150 } 146 case CMD_BROADCAST: // write second DSPIN flit in case of broadcast151 case CMD_BROADCAST: // write second DSPIN flit in case of broadcast 147 152 { 148 153 if( p_vci.cmdval && r_fifo_cmd.wok() ) … … 158 163 break; 159 164 } 160 case CMD_READ: // write second DSPIN flit in case of read/write165 case CMD_READ: // write second DSPIN flit in case of read/write 161 166 case CMD_WRITE: 162 167 { … … 179 184 if ( p_vci.cons.read() ) cmd_fifo_data = cmd_fifo_data | 0x0000200000LL ; 180 185 181 if( r_cmd_fsm == CMD_READ ) 186 if( r_cmd_fsm == CMD_READ ) // read command 182 187 { 183 188 r_cmd_fsm = CMD_IDLE; 184 189 cmd_fifo_data = cmd_fifo_data | 0x8000000000LL ; 185 190 } 186 else // write command191 else // write command 187 192 { 188 193 r_cmd_fsm = CMD_WDATA; … … 221 226 // The FIFO output is analysed and translated to a VCI packet 222 227 ////////////////////////////////////////////////////////////// 223 // - A N+1 flits DSPIN re ad response packet is translated228 // - A N+1 flits DSPIN response packet is translated 224 229 // to a N flits VCI response. 225 // - A single flit DSPIN writeresponse packet is translated226 // to a single flit VCI response .230 // - A single flit DSPIN response packet is translated 231 // to a single flit VCI response with RDATA = 0. 227 232 // A valid DSPIN flit in the fifo_rsp is always consumed 228 233 // in the CMD_IDLE state, but no VCI flit is transmitted. 229 // The VCI flits are sent in the RSP_READ & RSP_WRITE states. 234 // The VCI flits are sent in the RSP_DSPIN_SINGLE_FLIT & 235 // RSP_DSPIN_MULTI_FLIT states. 230 236 ////////////////////////////////////////////////////////////// 231 237 … … 235 241 236 242 // r_rsp_fsm, rsp_fifo_read 237 rsp_fifo_read = false; // default value 238 239 switch(r_rsp_fsm) { 243 rsp_fifo_read = false; // default value 244 245 switch(r_rsp_fsm) 246 { 240 247 case RSP_IDLE: 241 {242 if( r_fifo_rsp.rok() )243 {244 rsp_fifo_read = true;245 r_rsp_buf = r_fifo_rsp.read();246 if ( (r_fifo_rsp.read() & 0x000020000LL) == 0 ) r_rsp_fsm = RSP_READ;247 else r_rsp_fsm = RSP_WRITE;248 }249 break;250 }251 case RSP_READ:252 248 { 253 if( r_fifo_rsp.rok() && p_vci.rspack.read() ) 254 { 255 rsp_fifo_read = true; 256 if ( (r_fifo_rsp.read() & 0x100000000LL) ) r_rsp_fsm = RSP_IDLE; 257 } 258 break; 259 } 260 case RSP_WRITE: 261 { 262 if ( p_vci.rspack.read() ) r_rsp_fsm = RSP_IDLE; 263 } 249 if( r_fifo_rsp.rok() ) 250 { 251 rsp_fifo_read = true; 252 r_rsp_buf = r_fifo_rsp.read(); 253 if ( (r_fifo_rsp.read() & 0x100000000LL) == 0x100000000LL ) 254 r_rsp_fsm = RSP_DSPIN_SINGLE_FLIT; 255 else 256 r_rsp_fsm = RSP_DSPIN_MULTI_FLIT; 257 } 258 break; 259 } 260 case RSP_DSPIN_SINGLE_FLIT: 261 { 262 if ( p_vci.rspack.read() ) 263 r_rsp_fsm = RSP_IDLE; 264 break; 265 } 266 case RSP_DSPIN_MULTI_FLIT: 267 { 268 if( r_fifo_rsp.rok() && p_vci.rspack.read() ) 269 { 270 rsp_fifo_read = true; 271 if ( (r_fifo_rsp.read() & 0x100000000LL) == 0x100000000LL ) 272 r_rsp_fsm = RSP_IDLE; 273 } 274 break; 275 } 264 276 } // end switch r_rsp_fsm 265 277 … … 275 287 { 276 288 // VCI CMD interface 277 278 279 280 289 if ( ( r_cmd_fsm.read() == CMD_IDLE ) || ( r_cmd_fsm.read() == CMD_WRITE ) ) 290 { 291 p_vci.cmdack = false; 292 } 281 293 else 282 283 284 294 { 295 p_vci.cmdack = r_fifo_cmd.wok(); 296 } 285 297 286 298 // VCI RSP interface 287 299 if ( r_rsp_fsm.read() == RSP_IDLE ) 288 289 290 291 else if ( r_rsp_fsm.read() == RSP_WRITE)292 293 294 295 296 297 298 299 300 301 else if ( r_rsp_fsm.read() == RSP_READ)302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 300 { 301 p_vci.rspval = false; 302 } 303 else if ( r_rsp_fsm.read() == RSP_DSPIN_SINGLE_FLIT ) 304 { 305 p_vci.rspval = true; 306 p_vci.rdata = 0; 307 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read() & 0x0FFFC0000LL) >> 18); 308 p_vci.rpktid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x000000F00LL) >> 8); 309 p_vci.rtrdid = (sc_uint<vci_param::P>)((r_rsp_buf.read() & 0x00000F000LL) >> 12); 310 p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read() & 0x000030000LL) >> 16); 311 p_vci.reop = true; 312 } 313 else if ( r_rsp_fsm.read() == RSP_DSPIN_MULTI_FLIT ) 314 { 315 p_vci.rspval = r_fifo_rsp.rok(); 316 p_vci.rdata = (sc_uint<8*vci_param::B>)(r_fifo_rsp.read() & 0x0FFFFFFFFLL); 317 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read() & 0x0FFFC0000LL) >> 18); 318 p_vci.rpktid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x000000F00LL) >> 8); 319 p_vci.rtrdid = (sc_uint<vci_param::P>)((r_rsp_buf.read() & 0x00000F000LL) >> 12); 320 p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read() & 0x000030000LL) >> 16); 321 p_vci.reop = ((r_fifo_rsp.read() & 0x100000000LL) == 0x100000000LL); 322 } 323 324 // DSPIN_OUT interface 325 p_dspin_out.write = r_fifo_cmd.rok(); 326 p_dspin_out.data = r_fifo_cmd.read(); 327 328 // DSPIN_IN interface 329 p_dspin_in.read = r_fifo_rsp.wok(); 318 330 319 331 }; // end genMoore … … 330 342 }; 331 343 const char* rsp_str[] = { 332 "RSP_IDLE ",333 "RSP_ READ",334 "RSP_ WRITE",344 "RSP_IDLE ", 345 "RSP_DSPIN_SINGLE_FLIT", 346 "RSP_DSPIN_MULTI_FLIT ", 335 347 }; 336 348
Note: See TracChangeset
for help on using the changeset viewer.