[326] | 1 | /* SOCLIB_LGPL_HEADER_BEGIN |
---|
| 2 | * |
---|
| 3 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
| 4 | * |
---|
| 5 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
| 6 | * under the terms of the GNU Lesser General Public License as published |
---|
| 7 | * by the Free Software Foundation; version 2.1 of the License. |
---|
| 8 | * |
---|
| 9 | * SoCLib is distributed in the hope that it will be useful, but |
---|
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 12 | * Lesser General Public License for more details. |
---|
| 13 | * |
---|
| 14 | * You should have received a copy of the GNU Lesser General Public |
---|
| 15 | * License along with SoCLib; if not, write to the Free Software |
---|
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 17 | * 02110-1301 USA |
---|
| 18 | * |
---|
| 19 | * SOCLIB_LGPL_HEADER_END |
---|
| 20 | * |
---|
| 21 | * Author : Abdelmalek SI MERABET |
---|
| 22 | * Date : February 2013 |
---|
| 23 | * Copyright: UPMC - LIP6 |
---|
| 24 | */ |
---|
| 25 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 26 | // Ring : Broadcast-inval : 2 flits l2(1)->l1(n) // |
---|
| 27 | //--------------------------------------------------------------------------- |
---|
| 28 | // 1st flit | eop |xmin |xmax |ymin |ymax | memcid | lid* |1| |
---|
| 29 | // (40) (1) (5) (5) (5) (5) (14) (4) (1) |
---|
| 30 | //--------------------------------------------------------------------------- |
---|
| 31 | // next flit | eop |res| trdid | nline | |
---|
| 32 | // (40) (1) (1) (4) (34) |
---|
| 33 | //--------------------------------------------------------------------------- |
---|
| 34 | // *lid : local id (port number on ring) for sequential broadcast |
---|
| 35 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 36 | // Ring : Multicast-inval 2 flits (l2->l1) // |
---|
| 37 | //---------------------------------------------------------------------------- |
---|
| 38 | // 1st flit | eop | procid |res| memcid | trdid | type |0| |
---|
| 39 | // (40) (1) (14) (3) (14) (4) (3) (1) |
---|
| 40 | //---------------------------------------------------------------------------- |
---|
| 41 | // next flit | eop |res | nline | |
---|
| 42 | // (40) (1) (5) (34) |
---|
| 43 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 44 | // Ring : Multicast-update 2+N flits l2(1)->l1(n) // |
---|
| 45 | //---------------------------------------------------------------------------- |
---|
| 46 | // 1st flit | eop | procid |res| memcid | trdid | type |0| |
---|
| 47 | // (40) (1) (14) (3) (14) (4) (3) (1) |
---|
| 48 | //---------------------------------------------------------------------------- |
---|
| 49 | // next flit | eop |res| wdidx | nline | |
---|
| 50 | // (40) (1) (1) (4) (34) |
---|
| 51 | //---------------------------------------------------------------------------- |
---|
| 52 | // next flits | eop | res | be | wdata | |
---|
| 53 | // (40) (1) (3) (4) (32) |
---|
| 54 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 55 | // Ring : Cleanup Ack 1 flit l2(1)-l1(n) // |
---|
| 56 | //---------------------------------------------------------------------------- |
---|
| 57 | // 1st flit | eop | procid |res| set | way | type |0| |
---|
| 58 | // (40) (1) (14) (1) (16) (4) (3) (1) |
---|
| 59 | //---------------------------------------------------------------------------- |
---|
| 60 | // Type | cleanup ACK | Update/Inval | Data/instr | |
---|
| 61 | // (3) (1) (1) (1) |
---|
| 62 | //////////////////////////////////////////////////////////////////// |
---|
| 63 | // Ring : cleanup 2 flits l1(n)->l2(1) // |
---|
| 64 | //------------------------------------------------------------------ |
---|
| 65 | // 1st flit | eop | clustid*| procid | nline | way | type | |
---|
| 66 | // (33) (1) (10) (14) (2) (4) (2) |
---|
| 67 | // next flit | eop | nline | |
---|
| 68 | // (33) (1) (32) |
---|
| 69 | ///////////////////////////////////////////////////////////////////// |
---|
| 70 | // Ring : multicast ack 1 flit l1(n)->l2(1) // |
---|
| 71 | //------------------------------------------------------------------ |
---|
| 72 | // 1st flit | eop | clustid*| res | trdid | type | |
---|
| 73 | // (33) (1) (10) (16) (4) (2) |
---|
| 74 | //------------------------------------------------------------------ |
---|
| 75 | // Type | cleanup/MulticastACK | Data/instr | |
---|
| 76 | // (2) (1) (1) |
---|
| 77 | // *clusterid : identifiy cluster id of the dest memory cache. |
---|
| 78 | // all memory caches have the same Identifier in their clusters. |
---|
| 79 | //------------------------------------------------------------------ |
---|
| 80 | |
---|
| 81 | #ifndef SOCLIB_CABA_DSPIN_SIMPLE_RING_INITIATOR_FAST_C_H |
---|
| 82 | #define SOCLIB_CABA_DSPIN_SIMPLE_RING_INITIATOR_FAST_C_H |
---|
| 83 | |
---|
| 84 | #include "generic_fifo.h" |
---|
| 85 | #include "mapping_table.h" |
---|
| 86 | #include "ring_signals_fast.h" |
---|
| 87 | #include "dspin_interface.h" |
---|
| 88 | |
---|
| 89 | #define I_DEBUG |
---|
| 90 | |
---|
| 91 | namespace soclib { namespace caba { |
---|
| 92 | |
---|
| 93 | namespace { |
---|
| 94 | |
---|
| 95 | const char *ring_cmd_fsm_state_str_si[] = { |
---|
| 96 | "CMD_IDLE", |
---|
| 97 | "DEFAULT", |
---|
| 98 | "BDC_FIRST", |
---|
| 99 | "BDC_SECOND", |
---|
| 100 | "KEEP", |
---|
| 101 | }; |
---|
| 102 | |
---|
| 103 | #ifdef I_DEBUG |
---|
| 104 | |
---|
| 105 | const char *ring_rsp_fsm_state_str_si[] = { |
---|
| 106 | "RSP_IDLE", |
---|
| 107 | "LOCAL", |
---|
| 108 | "RING", |
---|
| 109 | }; |
---|
| 110 | #endif |
---|
| 111 | } // end namespace |
---|
| 112 | |
---|
| 113 | template<typename vci_param, int ring_cmd_data_size, int ring_rsp_data_size> |
---|
| 114 | class DspinSimpleRingInitiatorFastC |
---|
| 115 | { |
---|
| 116 | |
---|
| 117 | typedef SimpleRingSignals ring_signal_t; |
---|
| 118 | typedef DspinInput<ring_cmd_data_size> cmd_in_t; |
---|
| 119 | typedef DspinOutput<ring_rsp_data_size> rsp_out_t; |
---|
| 120 | |
---|
| 121 | private: |
---|
| 122 | enum ring_rsp_fsm_state_e { |
---|
| 123 | RSP_IDLE, // waiting for first flit of a response packet |
---|
| 124 | LOCAL, // next flit of a local rsp packet |
---|
| 125 | RING, // next flit of a ring rsp packet |
---|
| 126 | }; |
---|
| 127 | |
---|
| 128 | enum ring_cmd_fsm_state_e { |
---|
| 129 | CMD_IDLE, |
---|
| 130 | DEFAULT, |
---|
| 131 | BDC_FIRST, |
---|
| 132 | BDC_SECOND, |
---|
| 133 | KEEP, |
---|
| 134 | }; |
---|
| 135 | |
---|
| 136 | // structural parameters |
---|
| 137 | std::string m_name; |
---|
| 138 | bool m_alloc_init; |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | // internal fifos |
---|
| 142 | GenericFifo<uint64_t > m_cmd_fifo; // fifo for the local command packet |
---|
| 143 | GenericFifo<uint64_t > m_rsp_fifo; // fifo for the local response packet |
---|
| 144 | |
---|
| 145 | // routing table |
---|
| 146 | //soclib::common::AddressMaskingTable<uint32_t> m_rt; |
---|
| 147 | //soclib::common::AddressDecodingTable<uint32_t, bool> m_lt; |
---|
| 148 | |
---|
| 149 | uint64_t r_brdcst_save; |
---|
| 150 | //uint32_t m_srcid; |
---|
| 151 | uint32_t m_nb_target; |
---|
| 152 | |
---|
| 153 | sc_core::sc_signal<uint32_t> r_cpt_tgt; // target id for sequential broadcast |
---|
| 154 | sc_core::sc_signal<uint32_t> r_ring_cmd_fsm; // ring command (l2->l1) packet FSM |
---|
| 155 | sc_core::sc_signal<uint32_t> r_ring_rsp_fsm; // ring response (l1->l2) packet FSM |
---|
| 156 | |
---|
| 157 | public : |
---|
| 158 | |
---|
| 159 | #define __renRegInitS(x) x((((std::string) name)+"_" #x).c_str()) |
---|
| 160 | |
---|
| 161 | DspinSimpleRingInitiatorFastC( |
---|
| 162 | const char *name, |
---|
| 163 | bool alloc_init, |
---|
| 164 | const int &wrapper_fifo_depth, |
---|
| 165 | const uint32_t &nb_target) |
---|
| 166 | : m_name(name), |
---|
| 167 | m_alloc_init(alloc_init), |
---|
| 168 | m_cmd_fifo(((std::string) name)+"m_cmd_fifo", wrapper_fifo_depth), |
---|
| 169 | m_rsp_fifo(((std::string) name)+"m_rsp_fifo", wrapper_fifo_depth), |
---|
| 170 | //m_rt(mt.getIdMaskingTable(ringid.level())), |
---|
| 171 | //m_lt(mt.getIdLocalityTable(ringid)), |
---|
| 172 | //m_srcid(srcid), |
---|
| 173 | m_nb_target(nb_target), |
---|
| 174 | __renRegInitS(r_cpt_tgt), |
---|
| 175 | __renRegInitS(r_ring_cmd_fsm), |
---|
| 176 | __renRegInitS(r_ring_rsp_fsm) |
---|
| 177 | |
---|
| 178 | {} // end constructor |
---|
| 179 | |
---|
| 180 | void reset() |
---|
| 181 | { |
---|
| 182 | if(m_alloc_init) |
---|
| 183 | r_ring_cmd_fsm = DEFAULT; |
---|
| 184 | else |
---|
| 185 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 186 | |
---|
| 187 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 188 | m_cmd_fifo.init(); |
---|
| 189 | m_rsp_fifo.init(); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | void transition(const cmd_in_t &p_cmd_in, const rsp_out_t &p_rsp_out, const ring_signal_t p_ring_in, cmd_str &init_cmd, bool &init_rsp_val) |
---|
| 193 | { |
---|
| 194 | |
---|
| 195 | bool cmd_fifo_get = false; |
---|
| 196 | bool cmd_fifo_put = false; |
---|
| 197 | uint64_t cmd_fifo_data = 0; |
---|
| 198 | |
---|
| 199 | bool rsp_fifo_put = false; |
---|
| 200 | uint64_t rsp_fifo_data = 0; |
---|
| 201 | |
---|
| 202 | //////////// ACCESS DSPIN FIFOS /////////////////// |
---|
| 203 | if (p_cmd_in.write.read()) { |
---|
| 204 | #ifdef I_DEBUG |
---|
| 205 | std::cout << sc_time_stamp() << " -- " << m_name << " -- DSPIN FIFO" |
---|
| 206 | << " -- cmd in rok : " << p_cmd_in.write |
---|
| 207 | << " -- in data : " << std::hex << p_cmd_in.data.read() |
---|
| 208 | << " -- fifo wok : " << m_cmd_fifo.wok() |
---|
| 209 | << std::endl; |
---|
| 210 | #endif |
---|
| 211 | cmd_fifo_data = (uint64_t) p_cmd_in.data.read(); |
---|
| 212 | cmd_fifo_put = m_cmd_fifo.wok(); |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | bool rsp_fifo_get = p_rsp_out.read.read(); |
---|
| 216 | //////////// RING CMD FSM ///////////////////////// |
---|
| 217 | switch( r_ring_cmd_fsm ) |
---|
| 218 | { |
---|
| 219 | case CMD_IDLE: |
---|
| 220 | #ifdef I_DEBUG |
---|
| 221 | std::cout << sc_time_stamp() << " -- " << m_name << " -- r_ring_cmd_fsm : CMD_IDLE " |
---|
| 222 | << " -- in grant : " << p_ring_in.cmd_grant |
---|
| 223 | << " -- fifo rok : " << m_cmd_fifo.rok() |
---|
| 224 | << " -- fifo data : " << std::hex << m_cmd_fifo.read() |
---|
| 225 | << std::endl; |
---|
| 226 | #endif |
---|
| 227 | if ( p_ring_in.cmd_grant && m_cmd_fifo.rok() ) |
---|
| 228 | { |
---|
| 229 | |
---|
| 230 | |
---|
| 231 | if (m_cmd_fifo.read() & 0x1 == 0x1) // broadcast |
---|
| 232 | { |
---|
| 233 | r_cpt_tgt = 0; |
---|
| 234 | r_brdcst_save = m_cmd_fifo.read(); // save first flit of brdcst |
---|
| 235 | r_ring_cmd_fsm = BDC_FIRST; |
---|
| 236 | |
---|
| 237 | } else { |
---|
| 238 | r_ring_cmd_fsm = KEEP; |
---|
| 239 | } |
---|
| 240 | } |
---|
| 241 | break; |
---|
| 242 | |
---|
| 243 | case DEFAULT: |
---|
| 244 | |
---|
| 245 | if ( m_cmd_fifo.rok()) // && p_ring_in.cmd_wok.read() ) |
---|
| 246 | { |
---|
| 247 | #ifdef I_DEBUG |
---|
| 248 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 249 | << " -- r_ring_cmd_fsm : DEFAULT " |
---|
| 250 | << " -- in grant : " << p_ring_in.cmd_grant |
---|
| 251 | << " -- fifo rok : " << m_cmd_fifo.rok() |
---|
| 252 | << " -- fifo_cmd_data : " << std::hex << m_cmd_fifo.read() |
---|
| 253 | << std::endl; |
---|
| 254 | #endif |
---|
| 255 | bool eop = ( (int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 256 | |
---|
| 257 | if (m_cmd_fifo.read() & 0x1 == 0x1) // broadcast |
---|
| 258 | { |
---|
| 259 | r_cpt_tgt = 0; |
---|
| 260 | r_brdcst_save = m_cmd_fifo.read(); // save first flit of brdcst |
---|
| 261 | r_ring_cmd_fsm = BDC_FIRST; |
---|
| 262 | } |
---|
| 263 | // |
---|
| 264 | else |
---|
| 265 | { |
---|
| 266 | if ( eop && p_ring_in.cmd_r ) |
---|
| 267 | { |
---|
| 268 | cmd_fifo_get = true; |
---|
| 269 | if ( p_ring_in.cmd_grant ) |
---|
| 270 | r_ring_cmd_fsm = DEFAULT; |
---|
| 271 | else |
---|
| 272 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | if (!eop || !p_ring_in.cmd_r) |
---|
| 276 | { |
---|
| 277 | cmd_fifo_get = p_ring_in.cmd_r; |
---|
| 278 | r_ring_cmd_fsm = KEEP; |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | } |
---|
| 284 | else if ( !p_ring_in.cmd_grant) |
---|
| 285 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 286 | break; |
---|
| 287 | |
---|
| 288 | case BDC_FIRST: |
---|
| 289 | |
---|
| 290 | #ifdef I_DEBUG |
---|
| 291 | std::cout << sc_time_stamp() << " -- " << m_name << " -- r_ring_cmd_fsm : BDC_FIRST " |
---|
| 292 | << " -- in grant : " << p_ring_in.cmd_grant |
---|
| 293 | << " -- cpt_tgt : " << r_cpt_tgt |
---|
| 294 | << " -- fifo rok : " << m_cmd_fifo.rok() |
---|
| 295 | << " -- in wok : " << p_ring_in.cmd_r |
---|
| 296 | << " -- fifo_cmd_data : " << std::hex << m_cmd_fifo.read() |
---|
| 297 | << std::endl; |
---|
| 298 | #endif |
---|
| 299 | |
---|
| 300 | if (p_ring_in.cmd_r) |
---|
| 301 | { |
---|
| 302 | if (r_cpt_tgt.read() == 0) |
---|
| 303 | { |
---|
| 304 | cmd_fifo_get = true; |
---|
| 305 | } |
---|
| 306 | r_ring_cmd_fsm = BDC_SECOND; |
---|
| 307 | } |
---|
| 308 | break; |
---|
| 309 | |
---|
| 310 | case BDC_SECOND: |
---|
| 311 | #ifdef I_DEBUG |
---|
| 312 | std::cout << sc_time_stamp() << " -- " << m_name << " -- r_ring_cmd_fsm : BDC_SECOND " |
---|
| 313 | << " -- in grant : " << p_ring_in.cmd_grant |
---|
| 314 | << " -- fifo rok : " << m_cmd_fifo.rok() |
---|
| 315 | << " -- in wok : " << p_ring_in.cmd_r |
---|
| 316 | << " -- fifo_cmd_data : " << std::hex << m_cmd_fifo.read() |
---|
| 317 | << std::endl; |
---|
| 318 | #endif |
---|
| 319 | if(m_cmd_fifo.rok() && p_ring_in.cmd_r) |
---|
| 320 | { |
---|
| 321 | if(r_cpt_tgt.read() == m_nb_target - 1) |
---|
| 322 | { |
---|
| 323 | cmd_fifo_get = true; |
---|
| 324 | |
---|
| 325 | if ( p_ring_in.cmd_grant ) |
---|
| 326 | r_ring_cmd_fsm = DEFAULT; |
---|
| 327 | else |
---|
| 328 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 329 | } |
---|
| 330 | else |
---|
| 331 | { |
---|
| 332 | r_cpt_tgt = r_cpt_tgt + 1; |
---|
| 333 | r_ring_cmd_fsm = BDC_FIRST; |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | } |
---|
| 337 | break; |
---|
| 338 | |
---|
| 339 | case KEEP: |
---|
| 340 | #ifdef I_DEBUG |
---|
| 341 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
| 342 | << " - r_ring_cmd_fsm = " << ring_cmd_fsm_state_str_si[r_ring_cmd_fsm] |
---|
| 343 | << " -- in grant : " << p_ring_in.cmd_grant |
---|
| 344 | << " -- fifo ROK : " << m_cmd_fifo.rok() |
---|
| 345 | << " -- in wok : " << p_ring_in.cmd_r |
---|
| 346 | << " -- fifo data : " << std::hex << m_cmd_fifo.read() |
---|
| 347 | << std::endl; |
---|
| 348 | #endif |
---|
| 349 | if(m_cmd_fifo.rok() && p_ring_in.cmd_r ) |
---|
| 350 | { |
---|
| 351 | cmd_fifo_get = true; |
---|
| 352 | if (((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1) // 39 |
---|
| 353 | { |
---|
| 354 | if ( p_ring_in.cmd_grant ) |
---|
| 355 | r_ring_cmd_fsm = DEFAULT; |
---|
| 356 | else |
---|
| 357 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | break; |
---|
| 361 | |
---|
| 362 | } // end switch ring cmd fsm |
---|
| 363 | |
---|
| 364 | /////////// RING RSP FSM //////////////////////// |
---|
| 365 | |
---|
| 366 | switch( r_ring_rsp_fsm ) |
---|
| 367 | { |
---|
| 368 | case RSP_IDLE: |
---|
| 369 | { |
---|
| 370 | |
---|
| 371 | //uint32_t rsrcid = (uint32_t) ((sc_dt::sc_uint<vci_param::S>) ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) << (vci_param::S))); |
---|
| 372 | bool islocal = true; // m_lt[rsrcid] && (m_rt[rsrcid] == m_srcid); |
---|
| 373 | bool reop = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1; |
---|
| 374 | #ifdef I_DEBUG |
---|
| 375 | if(p_ring_in.rsp_w) { |
---|
| 376 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
| 377 | << " - r_ring_rsp_fsm = " << ring_rsp_fsm_state_str_si[r_ring_rsp_fsm] |
---|
| 378 | << " -- in rok : " << p_ring_in.rsp_w |
---|
| 379 | << " -- in wok : " << p_ring_in.rsp_r |
---|
| 380 | << " -- fifo wok : " << m_rsp_fifo.wok() |
---|
| 381 | << " -- in data : " << std::hex << p_ring_in.rsp_data |
---|
| 382 | << std::endl; |
---|
| 383 | } |
---|
| 384 | #endif |
---|
| 385 | |
---|
| 386 | if (p_ring_in.rsp_w && islocal) |
---|
| 387 | { |
---|
| 388 | |
---|
| 389 | rsp_fifo_put = m_rsp_fifo.wok(); |
---|
| 390 | rsp_fifo_data = p_ring_in.rsp_data; |
---|
| 391 | |
---|
| 392 | if (reop && m_rsp_fifo.wok()) |
---|
| 393 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 394 | else |
---|
| 395 | r_ring_rsp_fsm = LOCAL; |
---|
| 396 | |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | else if (p_ring_in.rsp_w && !islocal) |
---|
| 400 | { |
---|
| 401 | |
---|
| 402 | if (reop && p_ring_in.rsp_r) |
---|
| 403 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 404 | else |
---|
| 405 | r_ring_rsp_fsm = RING; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | else // !p_ring_in.rsp_w |
---|
| 409 | { |
---|
| 410 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | break; |
---|
| 414 | |
---|
| 415 | case LOCAL: |
---|
| 416 | { |
---|
| 417 | #ifdef I_DEBUG |
---|
| 418 | if(p_ring_in.rsp_w) |
---|
| 419 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
| 420 | << " - r_ring_rsp_fsm = " << ring_rsp_fsm_state_str_si[r_ring_rsp_fsm] |
---|
| 421 | << " -- in rok : " << p_ring_in.rsp_w |
---|
| 422 | << " -- in wok : " << p_ring_in.rsp_r |
---|
| 423 | << " -- fifo wok : " << m_rsp_fifo.wok() |
---|
| 424 | << " -- in data : " << std::hex << p_ring_in.rsp_data |
---|
| 425 | << std::endl; |
---|
| 426 | #endif |
---|
| 427 | |
---|
| 428 | bool reop = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1; |
---|
| 429 | |
---|
| 430 | if (p_ring_in.rsp_w && m_rsp_fifo.wok() && reop) |
---|
| 431 | { |
---|
| 432 | |
---|
| 433 | rsp_fifo_put = true; |
---|
| 434 | rsp_fifo_data = p_ring_in.rsp_data; |
---|
| 435 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 436 | } |
---|
| 437 | if (!p_ring_in.rsp_w || !m_rsp_fifo.wok() || !reop) |
---|
| 438 | { |
---|
| 439 | |
---|
| 440 | rsp_fifo_put = p_ring_in.rsp_w && m_rsp_fifo.wok(); |
---|
| 441 | rsp_fifo_data = p_ring_in.rsp_data; |
---|
| 442 | r_ring_rsp_fsm = LOCAL; |
---|
| 443 | } |
---|
| 444 | } |
---|
| 445 | break; |
---|
| 446 | |
---|
| 447 | case RING: |
---|
| 448 | { |
---|
| 449 | #ifdef I_DEBUG |
---|
| 450 | if(p_ring_in.rsp_w) |
---|
| 451 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
| 452 | << " - r_ring_rsp_fsm = " << ring_rsp_fsm_state_str_si[r_ring_rsp_fsm] |
---|
| 453 | << " -- in rok : " << p_ring_in.rsp_w |
---|
| 454 | << " -- in wok : " << p_ring_in.rsp_r |
---|
| 455 | << " -- fifo wok : " << m_rsp_fifo.wok() |
---|
| 456 | << " -- in data : " << std::hex << p_ring_in.rsp_data |
---|
| 457 | << std::endl; |
---|
| 458 | #endif |
---|
| 459 | bool reop = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1; |
---|
| 460 | |
---|
| 461 | if (p_ring_in.rsp_w && reop && p_ring_in.rsp_r) |
---|
| 462 | { |
---|
| 463 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 464 | } |
---|
| 465 | else |
---|
| 466 | { |
---|
| 467 | r_ring_rsp_fsm = RING; |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | break; |
---|
| 471 | |
---|
| 472 | } // end switch rsp fsm |
---|
| 473 | |
---|
| 474 | //////////////////////// |
---|
| 475 | // fifos update // |
---|
| 476 | //////////////////////// |
---|
| 477 | //-- to keep trace on ring traffic : a valid initiator command is being sent |
---|
| 478 | init_cmd.cmdval = cmd_fifo_get; |
---|
| 479 | init_cmd.flit = m_cmd_fifo.read(); |
---|
| 480 | init_cmd.state = ring_cmd_fsm_state_str_si[r_ring_cmd_fsm]; |
---|
| 481 | |
---|
| 482 | //init_cmd_val = cmd_fifo_get; |
---|
| 483 | init_rsp_val = rsp_fifo_put; |
---|
| 484 | // local cmd fifo update |
---|
| 485 | if ( cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.put_and_get(cmd_fifo_data); |
---|
| 486 | else if ( cmd_fifo_put && !cmd_fifo_get ) m_cmd_fifo.simple_put(cmd_fifo_data); |
---|
| 487 | else if ( !cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.simple_get(); |
---|
| 488 | |
---|
| 489 | // local rsp fifo update |
---|
| 490 | if ( rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.put_and_get(rsp_fifo_data); |
---|
| 491 | else if ( rsp_fifo_put && !rsp_fifo_get ) m_rsp_fifo.simple_put(rsp_fifo_data); |
---|
| 492 | else if ( !rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.simple_get(); |
---|
| 493 | |
---|
| 494 | } // end Transition() |
---|
| 495 | |
---|
| 496 | /////////////////////////////////////////////////////////////////// |
---|
| 497 | void genMoore(cmd_in_t &p_cmd_in, rsp_out_t &p_rsp_out) |
---|
| 498 | /////////////////////////////////////////////////////////////////// |
---|
| 499 | { |
---|
| 500 | p_rsp_out.write = m_rsp_fifo.rok(); |
---|
| 501 | p_rsp_out.data = (sc_dt::sc_uint<ring_rsp_data_size>) m_rsp_fifo.read(); |
---|
| 502 | |
---|
| 503 | p_cmd_in.read= m_cmd_fifo.wok(); |
---|
| 504 | |
---|
| 505 | } // end genMoore |
---|
| 506 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 507 | void update_ring_signals(ring_signal_t p_ring_in, ring_signal_t &p_ring_out) |
---|
| 508 | //////////////////////////////////////////////////////////////////////////// |
---|
| 509 | { |
---|
| 510 | switch( r_ring_cmd_fsm ) |
---|
| 511 | { |
---|
| 512 | case CMD_IDLE: |
---|
| 513 | p_ring_out.cmd_grant = p_ring_in.cmd_grant && !m_cmd_fifo.rok(); |
---|
| 514 | |
---|
| 515 | p_ring_out.cmd_w = p_ring_in.cmd_w; |
---|
| 516 | p_ring_out.cmd_data = p_ring_in.cmd_data; |
---|
| 517 | break; |
---|
| 518 | |
---|
| 519 | case DEFAULT: |
---|
| 520 | { |
---|
| 521 | bool eop = ((int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 522 | bool brdcst = (m_cmd_fifo.read() & 0x1 == 0x1); |
---|
| 523 | |
---|
| 524 | p_ring_out.cmd_grant = (!m_cmd_fifo.rok() || (eop && p_ring_in.cmd_r)) ; |
---|
| 525 | |
---|
| 526 | p_ring_out.cmd_w = m_cmd_fifo.rok() && !brdcst; |
---|
| 527 | p_ring_out.cmd_data = m_cmd_fifo.read(); |
---|
| 528 | } |
---|
| 529 | break; |
---|
| 530 | |
---|
| 531 | case BDC_FIRST: |
---|
| 532 | p_ring_out.cmd_grant = false; |
---|
| 533 | p_ring_out.cmd_w = true; |
---|
| 534 | p_ring_out.cmd_data = r_brdcst_save | ((((uint64_t) r_cpt_tgt.read()) & 0xF) << 0x1); |
---|
| 535 | break; |
---|
| 536 | |
---|
| 537 | case BDC_SECOND: |
---|
| 538 | p_ring_out.cmd_grant = m_cmd_fifo.rok() && p_ring_in.cmd_r && (r_cpt_tgt.read() == m_nb_target - 1); |
---|
| 539 | p_ring_out.cmd_w = m_cmd_fifo.rok(); |
---|
| 540 | p_ring_out.cmd_data = m_cmd_fifo.read(); |
---|
| 541 | |
---|
| 542 | break; |
---|
| 543 | |
---|
| 544 | case KEEP: |
---|
| 545 | { |
---|
| 546 | int cmd_fifo_eop = (int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1)) & 0x1) ; //39 |
---|
| 547 | p_ring_out.cmd_grant = m_cmd_fifo.rok() && p_ring_in.cmd_r && (cmd_fifo_eop == 1); |
---|
| 548 | |
---|
| 549 | p_ring_out.cmd_w = m_cmd_fifo.rok(); |
---|
| 550 | p_ring_out.cmd_data = m_cmd_fifo.read(); |
---|
| 551 | } |
---|
| 552 | break; |
---|
| 553 | |
---|
| 554 | } // end switch |
---|
| 555 | |
---|
| 556 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
| 557 | |
---|
| 558 | p_ring_out.rsp_grant = p_ring_in.rsp_grant; |
---|
| 559 | p_ring_out.rsp_w = p_ring_in.rsp_w; |
---|
| 560 | p_ring_out.rsp_data = p_ring_in.rsp_data; |
---|
| 561 | |
---|
| 562 | switch( r_ring_rsp_fsm ) |
---|
| 563 | { |
---|
| 564 | case RSP_IDLE: |
---|
| 565 | { |
---|
| 566 | |
---|
| 567 | //uint32_t rsrcid = (uint32_t) ((sc_dt::sc_uint<vci_param::S>) ((p_ring_in.rsp_data >> (ring_rsp_data_size-m_x_width-m_y_width - 1)) << (vci_param::S-m_x_width-m_y_width))); |
---|
| 568 | bool islocal = true; //m_lt[rsrcid] && (m_rt[rsrcid] == m_srcid); |
---|
| 569 | |
---|
| 570 | if(p_ring_in.rsp_w && islocal) |
---|
| 571 | p_ring_out.rsp_r = m_rsp_fifo.wok(); |
---|
| 572 | else |
---|
| 573 | p_ring_out.rsp_r = p_ring_in.rsp_r; |
---|
| 574 | } |
---|
| 575 | break; |
---|
| 576 | |
---|
| 577 | case LOCAL: |
---|
| 578 | p_ring_out.rsp_r = m_rsp_fifo.wok(); |
---|
| 579 | break; |
---|
| 580 | |
---|
| 581 | case RING: |
---|
| 582 | p_ring_out.rsp_r = p_ring_in.rsp_r; |
---|
| 583 | break; |
---|
| 584 | } // end switch |
---|
| 585 | |
---|
| 586 | |
---|
| 587 | } // end update_ring_signals |
---|
| 588 | |
---|
| 589 | }; |
---|
| 590 | |
---|
| 591 | }} // end namespace |
---|
| 592 | #endif // SOCLIB_CABA_DSPIN_SIMPLE_RING_INITIATOR_FAST_C_H |
---|
| 593 | |
---|
| 594 | |
---|