[8] | 1 | /* -*- c++ -*- |
---|
| 2 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
| 3 | * |
---|
| 4 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
| 5 | * |
---|
| 6 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
| 7 | * under the terms of the GNU Lesser General Public License as published |
---|
| 8 | * by the Free Software Foundation; version 2.1 of the License. |
---|
| 9 | * |
---|
| 10 | * SoCLib is distributed in the hope that it will be useful, but |
---|
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 13 | * Lesser General Public License for more details. |
---|
| 14 | * |
---|
| 15 | * You should have received a copy of the GNU Lesser General Public |
---|
| 16 | * License along with SoCLib; if not, write to the Free Software |
---|
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 18 | * 02110-1301 USA |
---|
| 19 | * |
---|
| 20 | * SOCLIB_LGPL_HEADER_END |
---|
| 21 | * |
---|
| 22 | * Author : Abdelmalek SI MERABET |
---|
| 23 | * Date : March 2010 |
---|
| 24 | * |
---|
| 25 | * Copyright: UPMC - LIP6 |
---|
| 26 | */ |
---|
[35] | 27 | #ifndef SOCLIB_CABA_VCI_RING_TARGET_H |
---|
| 28 | #define SOCLIB_CABA_VCI_RING_TARGET_H |
---|
| 29 | |
---|
[8] | 30 | #include "vci_initiator.h" |
---|
| 31 | #include "generic_fifo.h" |
---|
| 32 | #include "mapping_table.h" |
---|
| 33 | #include "ring_signals_2.h" |
---|
| 34 | |
---|
[16] | 35 | //#define T_DEBUG |
---|
| 36 | //#define TR_DEBUG |
---|
[8] | 37 | //#define T_DEBUG_FSM |
---|
| 38 | |
---|
| 39 | namespace soclib { namespace caba { |
---|
| 40 | #ifdef T_DEBUG_FSM |
---|
| 41 | namespace { |
---|
| 42 | const char *vci_cmd_fsm_state_str_t[] = { |
---|
| 43 | "CMD_FIRST_HEADER", |
---|
| 44 | "CMD_SECOND_HEADER", |
---|
| 45 | "WDATA", |
---|
| 46 | }; |
---|
| 47 | const char *vci_rsp_fsm_state_str_t[] = { |
---|
| 48 | "RSP_HEADER", |
---|
| 49 | "RSP_DATA", |
---|
| 50 | }; |
---|
| 51 | const char *ring_rsp_fsm_state_str_t[] = { |
---|
| 52 | "RSP_IDLE", |
---|
| 53 | "DEFAULT", |
---|
| 54 | "KEEP", |
---|
| 55 | }; |
---|
| 56 | const char *ring_cmd_fsm_state_str_t[] = { |
---|
| 57 | "CMD_IDLE", |
---|
| 58 | "BROADCAST_0", |
---|
| 59 | "BROADCAST_1", |
---|
| 60 | "LOCAL", |
---|
| 61 | "RING", |
---|
| 62 | }; |
---|
| 63 | } |
---|
| 64 | #endif |
---|
| 65 | |
---|
| 66 | template<typename vci_param, int ring_cmd_data_size, int ring_rsp_data_size> |
---|
| 67 | class VciRingTarget |
---|
| 68 | { |
---|
| 69 | |
---|
| 70 | typedef typename vci_param::fast_addr_t vci_addr_t; |
---|
| 71 | typedef RingSignals2 ring_signal_t; |
---|
| 72 | typedef soclib::caba::VciInitiator<vci_param> vci_initiator_t; |
---|
| 73 | |
---|
| 74 | private: |
---|
| 75 | enum vci_cmd_fsm_state_e { |
---|
| 76 | CMD_FIRST_HEADER, // first flit for a ring cmd packet (read or write) |
---|
| 77 | CMD_SECOND_HEADER, // second flit for a ring cmd packet |
---|
| 78 | WDATA, // data flit for a ring cmd write packet |
---|
| 79 | }; |
---|
| 80 | |
---|
| 81 | enum vci_rsp_fsm_state_e { |
---|
| 82 | RSP_HEADER, // first flit for a ring rsp packet (read or write) |
---|
| 83 | DATA, // next flit for a ring rsp packet |
---|
| 84 | }; |
---|
| 85 | |
---|
| 86 | enum ring_cmd_fsm_state_e { |
---|
| 87 | CMD_IDLE, // waiting for first flit of a command packet |
---|
| 88 | BROADCAST_0, |
---|
| 89 | BROADCAST_1, |
---|
| 90 | LOCAL, // next flit of a local cmd packet |
---|
| 91 | RING, // next flit of a ring cmd packet |
---|
| 92 | }; |
---|
| 93 | |
---|
| 94 | // cmd token allocation fsm |
---|
| 95 | enum ring_rsp_fsm_state_e { |
---|
| 96 | RSP_IDLE, |
---|
| 97 | DEFAULT, |
---|
| 98 | KEEP, |
---|
| 99 | }; |
---|
| 100 | |
---|
| 101 | // structural parameters |
---|
| 102 | bool m_alloc_target; |
---|
| 103 | int m_tgtid; |
---|
| 104 | std::string m_name; |
---|
| 105 | |
---|
| 106 | // internal registers |
---|
[44] | 107 | sc_core::sc_signal<int> r_ring_cmd_fsm; // ring command packet FSM |
---|
| 108 | sc_core::sc_signal<int> r_ring_rsp_fsm; // ring response packet FSM |
---|
| 109 | sc_core::sc_signal<int> r_vci_cmd_fsm; // vci command packet FSM |
---|
| 110 | sc_core::sc_signal<int> r_vci_rsp_fsm; // vci response packet FSM |
---|
[8] | 111 | |
---|
[44] | 112 | sc_core::sc_signal<sc_dt::sc_uint<vci_param::S> > r_srcid; |
---|
| 113 | sc_core::sc_signal<sc_dt::sc_uint<2> > r_cmd; |
---|
| 114 | sc_core::sc_signal<sc_dt::sc_uint<vci_param::T> > r_trdid; |
---|
| 115 | sc_core::sc_signal<sc_dt::sc_uint<vci_param::P> > r_pktid; |
---|
| 116 | sc_core::sc_signal<sc_dt::sc_uint<vci_param::K> > r_plen; |
---|
| 117 | sc_core::sc_signal<sc_dt::sc_uint<1> > r_contig; |
---|
| 118 | sc_core::sc_signal<sc_dt::sc_uint<1> > r_const; |
---|
| 119 | sc_core::sc_signal<sc_dt::sc_uint<vci_param::N> > r_addr; |
---|
[8] | 120 | |
---|
| 121 | // internal fifos |
---|
| 122 | GenericFifo<uint64_t > m_cmd_fifo; // fifo for the local command paquet |
---|
| 123 | GenericFifo<uint64_t > m_rsp_fifo; // fifo for the local response paquet |
---|
| 124 | |
---|
| 125 | // routing table |
---|
| 126 | soclib::common::AddressDecodingTable<vci_addr_t, int> m_rt; |
---|
| 127 | // locality table |
---|
| 128 | soclib::common::AddressDecodingTable<vci_addr_t, bool> m_lt; |
---|
| 129 | |
---|
| 130 | bool trace(int sc_time_stamp) |
---|
| 131 | { |
---|
| 132 | int time_stamp=0; |
---|
| 133 | char *ctime_stamp= getenv("FROM_CYCLE"); |
---|
| 134 | |
---|
| 135 | if (ctime_stamp) time_stamp=atoi(ctime_stamp); |
---|
| 136 | |
---|
| 137 | return sc_time_stamp >= time_stamp; |
---|
| 138 | |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | public : |
---|
| 142 | |
---|
| 143 | VciRingTarget( |
---|
| 144 | const char *name, |
---|
| 145 | bool alloc_target, |
---|
| 146 | const int &wrapper_fifo_depth, |
---|
| 147 | const soclib::common::MappingTable &mt, |
---|
| 148 | const soclib::common::IntTab &ringid, |
---|
| 149 | const int &tgtid) |
---|
| 150 | : m_name(name), |
---|
| 151 | m_alloc_target(alloc_target), |
---|
| 152 | m_cmd_fifo("m_cmd_fifo", wrapper_fifo_depth), |
---|
| 153 | m_rsp_fifo("m_rsp_fifo", wrapper_fifo_depth), |
---|
| 154 | m_rt(mt.getRoutingTable<typename vci_param::fast_addr_t>(ringid)), |
---|
| 155 | m_lt(mt.getLocalityTable<typename vci_param::fast_addr_t>(ringid)), |
---|
| 156 | m_tgtid(tgtid), |
---|
| 157 | r_ring_cmd_fsm("r_ring_cmd_fsm"), |
---|
| 158 | r_ring_rsp_fsm("r_ring_rsp_fsm"), |
---|
| 159 | r_vci_cmd_fsm("r_vci_cmd_fsm"), |
---|
| 160 | r_vci_rsp_fsm("r_vci_rsp_fsm"), |
---|
| 161 | r_srcid("r_srcid"), |
---|
| 162 | r_cmd("r_cmd"), |
---|
| 163 | r_trdid("r_trdid"), |
---|
| 164 | r_pktid("r_pktid"), |
---|
| 165 | r_plen("r_plen"), |
---|
| 166 | r_contig("r_contig"), |
---|
| 167 | r_const("r_const"), |
---|
| 168 | r_addr("r_addr") |
---|
| 169 | |
---|
| 170 | {} // end constructor |
---|
| 171 | |
---|
| 172 | void reset() |
---|
| 173 | { |
---|
| 174 | if(m_alloc_target) |
---|
| 175 | r_ring_rsp_fsm = DEFAULT; |
---|
| 176 | else |
---|
| 177 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 178 | |
---|
| 179 | r_vci_cmd_fsm = CMD_FIRST_HEADER; |
---|
| 180 | r_vci_rsp_fsm = RSP_HEADER; |
---|
| 181 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 182 | m_cmd_fifo.init(); |
---|
| 183 | m_rsp_fifo.init(); |
---|
| 184 | } |
---|
| 185 | void transition(const vci_initiator_t &p_vci, const ring_signal_t p_ring_in) |
---|
| 186 | { |
---|
| 187 | |
---|
| 188 | bool cmd_fifo_get = false; |
---|
| 189 | bool cmd_fifo_put = false; |
---|
| 190 | uint64_t cmd_fifo_data = 0; |
---|
| 191 | |
---|
| 192 | bool rsp_fifo_get = false; |
---|
| 193 | bool rsp_fifo_put = false; |
---|
| 194 | uint64_t rsp_fifo_data = 0; |
---|
| 195 | |
---|
| 196 | #ifdef T_DEBUG_FSM |
---|
[16] | 197 | if( trace(sc_time_stamp())) |
---|
| 198 | std::cout << sc_time_stamp() << " - " << m_name |
---|
| 199 | << " - vci cmd = " << vci_cmd_fsm_state_str_t[r_vci_cmd_fsm] |
---|
| 200 | << " - vci rsp = " << vci_rsp_fsm_state_str_t[r_vci_rsp_fsm] |
---|
| 201 | << " - ring cmd = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
| 202 | << " - ring rsp = " << ring_rsp_fsm_state_str_t[r_ring_rsp_fsm] |
---|
| 203 | << std::endl; |
---|
[8] | 204 | #endif |
---|
| 205 | |
---|
| 206 | //////////// VCI CMD FSM ///////////////////////// |
---|
| 207 | switch ( r_vci_cmd_fsm ) |
---|
| 208 | { |
---|
| 209 | |
---|
| 210 | case CMD_FIRST_HEADER: |
---|
| 211 | if (m_cmd_fifo.rok() == true) |
---|
| 212 | { |
---|
| 213 | #ifdef T_DEBUG |
---|
| 214 | if( trace(sc_time_stamp())) |
---|
| 215 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 216 | << " -- r_vci_cmd_fsm -- CMD_FIRST_HEADER " |
---|
| 217 | << " -- fifo_rok : " << m_cmd_fifo.rok() |
---|
| 218 | << " -- fifo_data : " << std::hex << m_cmd_fifo.read() |
---|
| 219 | << std::endl; |
---|
| 220 | #endif |
---|
| 221 | |
---|
| 222 | cmd_fifo_get = true; |
---|
| 223 | |
---|
| 224 | if (m_cmd_fifo.read() & 0x1 == 0x1) // broadcast |
---|
| 225 | { |
---|
[44] | 226 | r_addr = (sc_dt::sc_uint<vci_param::N>) 0x3; |
---|
| 227 | r_srcid = (sc_dt::sc_uint<vci_param::S>) (m_cmd_fifo.read() >> 20); |
---|
| 228 | r_cmd = (sc_dt::sc_uint<2>) 0x2; |
---|
| 229 | r_contig = (sc_dt::sc_uint<1>) 0x1; |
---|
| 230 | r_const = (sc_dt::sc_uint<1>) 0x0; |
---|
| 231 | r_plen = (sc_dt::sc_uint<vci_param::K>) 0x04; |
---|
| 232 | r_pktid = (sc_dt::sc_uint<vci_param::P>) 0x0; |
---|
| 233 | r_trdid = (sc_dt::sc_uint<vci_param::T>) ((m_cmd_fifo.read() >> 16) & 0xF); |
---|
[8] | 234 | |
---|
| 235 | r_vci_cmd_fsm = WDATA; |
---|
| 236 | } |
---|
| 237 | else |
---|
| 238 | { |
---|
[44] | 239 | r_addr = (sc_dt::sc_uint<vci_param::N>) (m_cmd_fifo.read() << 1); |
---|
[8] | 240 | r_vci_cmd_fsm = CMD_SECOND_HEADER; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | } // end if rok |
---|
| 245 | break; |
---|
| 246 | |
---|
| 247 | case CMD_SECOND_HEADER: |
---|
| 248 | if ( m_cmd_fifo.rok() ) |
---|
| 249 | { |
---|
| 250 | |
---|
| 251 | #ifdef T_DEBUG |
---|
| 252 | if( trace(sc_time_stamp())) |
---|
| 253 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 254 | << " -- r_vci_cmd_fsm -- CMD_SECOND_HEADER " |
---|
| 255 | << " -- r_addr : " << std::hex << r_addr |
---|
| 256 | << " -- fifo_rok : " << m_cmd_fifo.rok() |
---|
| 257 | << " -- fifo_data : " << m_cmd_fifo.read() |
---|
| 258 | << " -- vci cmdack : " << p_vci.cmdack.read() |
---|
| 259 | << std::endl; |
---|
| 260 | #endif |
---|
| 261 | if(((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1) // read command |
---|
| 262 | { |
---|
| 263 | |
---|
| 264 | if (p_vci.cmdack.read()) |
---|
| 265 | { |
---|
| 266 | |
---|
| 267 | cmd_fifo_get = true; |
---|
| 268 | r_vci_cmd_fsm = CMD_FIRST_HEADER; |
---|
| 269 | } |
---|
| 270 | } |
---|
| 271 | else // write command |
---|
| 272 | { |
---|
[16] | 273 | |
---|
[8] | 274 | cmd_fifo_get = true; |
---|
[44] | 275 | r_srcid = (sc_dt::sc_uint<vci_param::S>) (m_cmd_fifo.read() >> 20) ; |
---|
| 276 | r_cmd = (sc_dt::sc_uint<2>) ((m_cmd_fifo.read() >> 18) & 0x3); |
---|
| 277 | r_contig = (sc_dt::sc_uint<1>) ((m_cmd_fifo.read() >> 17) & 0x1); |
---|
| 278 | r_const = (sc_dt::sc_uint<1>) ((m_cmd_fifo.read() >> 16) & 0x1); |
---|
| 279 | r_plen = (sc_dt::sc_uint<vci_param::K>) ((m_cmd_fifo.read() >> 8) & 0xFF); |
---|
| 280 | r_pktid = (sc_dt::sc_uint<vci_param::P>) ((m_cmd_fifo.read() >> 4) & 0xF); |
---|
| 281 | r_trdid = (sc_dt::sc_uint<vci_param::T>) (m_cmd_fifo.read() & 0xF); |
---|
[8] | 282 | r_vci_cmd_fsm = WDATA; |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | break; |
---|
| 286 | |
---|
| 287 | case WDATA: |
---|
| 288 | #ifdef T_DEBUG |
---|
| 289 | if( trace(sc_time_stamp())) |
---|
| 290 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 291 | << " -- r_vci_cmd_fsm -- WDATA " |
---|
| 292 | << " -- vci_cmdack : " << p_vci.cmdack.read() |
---|
| 293 | << " -- fifo_rok : " << m_cmd_fifo.rok() |
---|
| 294 | << " -- fifo_data : " << std::hex << m_cmd_fifo.read() |
---|
| 295 | << " -- r_plen : " << r_plen.read() |
---|
| 296 | << std::endl; |
---|
| 297 | #endif |
---|
| 298 | if ( p_vci.cmdack.read() && m_cmd_fifo.rok() ) |
---|
| 299 | { |
---|
| 300 | |
---|
| 301 | cmd_fifo_get = true; |
---|
[44] | 302 | sc_dt::sc_uint<1> contig = r_contig; |
---|
[8] | 303 | if(contig == 0x1) |
---|
| 304 | r_addr = r_addr.read() + vci_param::B ; |
---|
| 305 | if(( (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1) |
---|
| 306 | r_vci_cmd_fsm = CMD_FIRST_HEADER; |
---|
| 307 | else |
---|
| 308 | r_vci_cmd_fsm = WDATA; |
---|
| 309 | } // end if cmdack |
---|
| 310 | break; |
---|
| 311 | |
---|
| 312 | } // end switch r_vci_cmd_fsm |
---|
| 313 | |
---|
| 314 | /////////// VCI RSP FSM ///////////////////////// |
---|
| 315 | switch ( r_vci_rsp_fsm ) |
---|
| 316 | { |
---|
| 317 | case RSP_HEADER: |
---|
| 318 | #ifdef T_DEBUG |
---|
| 319 | if( trace(sc_time_stamp())) |
---|
| 320 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 321 | << " -- r_vci_rsp_fsm -- RSP_HEADER " |
---|
| 322 | << " -- fifo_rsp_wok : " << m_rsp_fifo.wok() |
---|
| 323 | << " -- vci_rspval : " << p_vci.rspval.read() |
---|
| 324 | << " -- rsrcid : " << std::hex << p_vci.rsrcid.read() |
---|
| 325 | << " -- rerror : " << p_vci.rerror.read() |
---|
| 326 | << std::endl; |
---|
| 327 | #endif |
---|
[16] | 328 | if((p_vci.rspval.read() == true) && (m_rsp_fifo.wok())) |
---|
| 329 | { |
---|
| 330 | |
---|
[8] | 331 | rsp_fifo_data = (((uint64_t) p_vci.rsrcid.read() & 0x3FFF) << 12) | |
---|
| 332 | (((uint64_t) p_vci.rerror.read() & 0x1) << 8) | |
---|
| 333 | (((uint64_t) p_vci.rpktid.read() & 0xF) << 4) | |
---|
| 334 | ((uint64_t) p_vci.rtrdid.read() & 0xF); |
---|
| 335 | rsp_fifo_put = true; |
---|
| 336 | r_vci_rsp_fsm = DATA; |
---|
| 337 | } |
---|
| 338 | break; |
---|
| 339 | |
---|
| 340 | case DATA: |
---|
[16] | 341 | #ifdef T_DEBUG |
---|
[8] | 342 | if( trace(sc_time_stamp())) |
---|
| 343 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 344 | << " -- r_vci_rsp_fsm -- RSP_DATA " |
---|
| 345 | << " -- fifo_rsp_wok : " << m_rsp_fifo.wok() |
---|
| 346 | << " -- vci_rspval : " << p_vci.rspval.read() |
---|
| 347 | << " -- rdata : " << std::hex << p_vci.rdata.read() |
---|
| 348 | << " -- reop : " << p_vci.reop.read() |
---|
| 349 | << std::endl; |
---|
[16] | 350 | #endif |
---|
| 351 | if((p_vci.rspval.read() == true) && (m_rsp_fifo.wok())) |
---|
| 352 | { |
---|
[8] | 353 | |
---|
[16] | 354 | |
---|
[8] | 355 | rsp_fifo_put = true; |
---|
| 356 | rsp_fifo_data = (uint64_t) p_vci.rdata.read(); |
---|
| 357 | |
---|
| 358 | if (p_vci.reop.read()) |
---|
| 359 | { |
---|
| 360 | rsp_fifo_data = rsp_fifo_data | (((uint64_t) 0x1) << (ring_rsp_data_size-1)) ; |
---|
| 361 | r_vci_rsp_fsm = RSP_HEADER; |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | break; |
---|
| 365 | |
---|
| 366 | } // end switch r_vci_rsp_fsm |
---|
| 367 | |
---|
| 368 | //////////// RING RSP FSM (distributed) ///////////////////////// |
---|
| 369 | |
---|
| 370 | switch( r_ring_rsp_fsm ) |
---|
| 371 | { |
---|
| 372 | case RSP_IDLE: |
---|
| 373 | #ifdef TR_DEBUG |
---|
| 374 | if( trace(sc_time_stamp())) |
---|
| 375 | std::cout << sc_time_stamp() << " -- " << m_name << " -- ring_rsp_fsm : RSP_IDLE" |
---|
| 376 | << " -- fifo rok : " << m_rsp_fifo.rok() |
---|
| 377 | << " -- in rok : " << p_ring_in.rsp_w |
---|
| 378 | << " -- in wok : " << p_ring_in.rsp_r |
---|
| 379 | << " -- in rsp grant : " << p_ring_in.rsp_grant |
---|
| 380 | << " -- in rsp data : " << p_ring_in.rsp_data |
---|
| 381 | << std::endl; |
---|
| 382 | #endif |
---|
| 383 | if ( p_ring_in.rsp_grant && m_rsp_fifo.rok() ) |
---|
| 384 | |
---|
| 385 | r_ring_rsp_fsm = KEEP; |
---|
| 386 | |
---|
| 387 | break; |
---|
| 388 | |
---|
| 389 | case DEFAULT: |
---|
| 390 | |
---|
| 391 | if ( m_rsp_fifo.rok()) |
---|
| 392 | { |
---|
| 393 | #ifdef TR_DEBUG |
---|
| 394 | if( trace(sc_time_stamp())) |
---|
| 395 | std::cout << sc_time_stamp() << " -- " << m_name << " -- ring_rsp_fsm : DEFAULT " |
---|
| 396 | << " -- fifo data : " << std::hex << m_rsp_fifo.read() |
---|
| 397 | << std::endl; |
---|
| 398 | #endif |
---|
| 399 | rsp_fifo_get = p_ring_in.rsp_r; //true; |
---|
| 400 | r_ring_rsp_fsm = KEEP; |
---|
| 401 | } |
---|
| 402 | else if ( !p_ring_in.rsp_grant ) |
---|
| 403 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 404 | break; |
---|
| 405 | |
---|
| 406 | case KEEP: |
---|
| 407 | |
---|
| 408 | if(m_rsp_fifo.rok() && p_ring_in.rsp_r) |
---|
| 409 | { |
---|
| 410 | #ifdef TR_DEBUG |
---|
| 411 | if( trace(sc_time_stamp())) |
---|
| 412 | std::cout << sc_time_stamp() << " -- " << m_name << " -- ring_rsp_fsm : KEEP " |
---|
| 413 | << " -- fifo rok : " << m_rsp_fifo.rok() |
---|
| 414 | << " -- in wok : " << p_ring_in.rsp_r |
---|
| 415 | << " -- fifo data : " << std::hex << m_rsp_fifo.read() |
---|
| 416 | << std::endl; |
---|
| 417 | #endif |
---|
| 418 | rsp_fifo_get = true; |
---|
| 419 | if ((int) ((m_rsp_fifo.read() >> 32 ) & 0x1) == 1) |
---|
| 420 | { |
---|
| 421 | if ( p_ring_in.rsp_grant ) |
---|
| 422 | r_ring_rsp_fsm = DEFAULT; |
---|
| 423 | else |
---|
| 424 | r_ring_rsp_fsm = RSP_IDLE; |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | break; |
---|
| 428 | |
---|
| 429 | } // end switch ring cmd fsm |
---|
| 430 | |
---|
| 431 | /////////// RING CMD FSM //////////////////////// |
---|
| 432 | switch( r_ring_cmd_fsm ) |
---|
| 433 | { |
---|
| 434 | |
---|
| 435 | case CMD_IDLE: |
---|
| 436 | { // for variable scope |
---|
| 437 | |
---|
| 438 | vci_addr_t rtgtid = (vci_addr_t) ((p_ring_in.cmd_data >> 1) << 2); |
---|
| 439 | bool islocal = m_lt[rtgtid] && (m_rt[rtgtid] == (vci_addr_t) m_tgtid); |
---|
| 440 | bool brdcst = (p_ring_in.cmd_data & 0x1) == 0X1 ; |
---|
| 441 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 442 | |
---|
| 443 | #ifdef TR_DEBUG |
---|
| 444 | if( trace(sc_time_stamp())) |
---|
| 445 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 446 | << " - ring_cmd_fsm -- CMD_IDLE " |
---|
| 447 | << " - in rok : " << p_ring_in.cmd_w |
---|
| 448 | << " - isloc : " << islocal |
---|
| 449 | << " - addr : " << std::hex << rtgtid |
---|
| 450 | << " - brdcst : " << brdcst |
---|
| 451 | << " - in wok : " << p_ring_in.cmd_r |
---|
| 452 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
| 453 | << " - eop : " << eop |
---|
| 454 | << std::endl; |
---|
| 455 | #endif |
---|
| 456 | if(p_ring_in.cmd_w && !eop && brdcst && !m_cmd_fifo.wok()) { |
---|
| 457 | r_ring_cmd_fsm = BROADCAST_0; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | if(p_ring_in.cmd_w && !eop && brdcst && m_cmd_fifo.wok()) { |
---|
| 461 | r_ring_cmd_fsm = BROADCAST_1; |
---|
| 462 | cmd_fifo_put = true; |
---|
| 463 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 464 | |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | if (p_ring_in.cmd_w && !eop && !brdcst && islocal) { |
---|
| 468 | r_ring_cmd_fsm = LOCAL; |
---|
| 469 | cmd_fifo_put = m_cmd_fifo.wok(); |
---|
| 470 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 471 | |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | if (p_ring_in.cmd_w && !eop && !brdcst && !islocal) { |
---|
| 475 | r_ring_cmd_fsm = RING; |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | if (!p_ring_in.cmd_w || eop) { |
---|
| 479 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | break; |
---|
| 485 | |
---|
| 486 | case BROADCAST_0: |
---|
| 487 | |
---|
| 488 | #ifdef TR_DEBUG |
---|
| 489 | if( trace(sc_time_stamp())) |
---|
| 490 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 491 | << " -- ring_cmd_fsm -- BROADCAST_0 " |
---|
| 492 | << " -- ringin cmd rok : " << p_ring_in.cmd_w |
---|
| 493 | << " -- ringin cmd wok : " << p_ring_in.cmd_r |
---|
| 494 | << " -- ringin data : " << std::hex << p_ring_in.cmd_data |
---|
| 495 | << " -- fifo cmd wok : " << m_cmd_fifo.wok() |
---|
| 496 | << std::endl; |
---|
| 497 | #endif |
---|
| 498 | if ( m_cmd_fifo.wok() ) |
---|
| 499 | { |
---|
| 500 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 501 | r_ring_cmd_fsm = BROADCAST_1; |
---|
| 502 | |
---|
| 503 | } else { |
---|
| 504 | r_ring_cmd_fsm = BROADCAST_0; |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | break; |
---|
| 508 | |
---|
| 509 | case BROADCAST_1: |
---|
| 510 | { |
---|
| 511 | #ifdef TR_DEBUG |
---|
| 512 | if( trace(sc_time_stamp())) |
---|
| 513 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 514 | << " -- ring_cmd_fsm -- BROADCAST_1 " |
---|
| 515 | << " -- ringin cmd rok : " << p_ring_in.cmd_w |
---|
| 516 | << " -- ringin cmd wok : " << p_ring_in.cmd_r |
---|
| 517 | << " -- ringin data : " << std::hex << p_ring_in.cmd_data |
---|
| 518 | << " -- fifo cmd wok : " << m_cmd_fifo.wok() |
---|
| 519 | << std::endl; |
---|
| 520 | #endif |
---|
| 521 | |
---|
| 522 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 523 | |
---|
| 524 | if ( p_ring_in.cmd_w && m_cmd_fifo.wok() && eop ) |
---|
| 525 | { |
---|
| 526 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 527 | cmd_fifo_put = 1; |
---|
| 528 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 529 | |
---|
| 530 | } |
---|
| 531 | else { |
---|
| 532 | r_ring_cmd_fsm = BROADCAST_1; |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | } |
---|
| 536 | break; |
---|
| 537 | |
---|
| 538 | case LOCAL: |
---|
| 539 | { |
---|
| 540 | |
---|
| 541 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 542 | #ifdef TR_DEBUG |
---|
| 543 | if( trace(sc_time_stamp())) |
---|
| 544 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 545 | << " -- ring_cmd_fsm -- LOCAL " |
---|
| 546 | << " -- in cmd rok : " << p_ring_in.cmd_w |
---|
| 547 | << " -- in cmd wok : " << p_ring_in.cmd_r |
---|
| 548 | << " -- in data : " << std::hex << p_ring_in.cmd_data |
---|
| 549 | << " -- fifo wok : " << m_cmd_fifo.wok() |
---|
| 550 | << " -- eop : " << eop |
---|
| 551 | << std::endl; |
---|
| 552 | #endif |
---|
| 553 | |
---|
| 554 | if ( p_ring_in.cmd_w && m_cmd_fifo.wok() && eop ) |
---|
| 555 | { |
---|
| 556 | |
---|
| 557 | cmd_fifo_put = true; |
---|
| 558 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 559 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 560 | |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | if ( !p_ring_in.cmd_w || !m_cmd_fifo.wok() || !eop ) |
---|
| 564 | { |
---|
| 565 | |
---|
| 566 | cmd_fifo_put = p_ring_in.cmd_w && m_cmd_fifo.wok(); |
---|
| 567 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
| 568 | r_ring_cmd_fsm = LOCAL; |
---|
| 569 | |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | break; |
---|
| 573 | |
---|
| 574 | case RING: |
---|
| 575 | { |
---|
| 576 | |
---|
| 577 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 578 | |
---|
| 579 | #ifdef TR_DEBUG |
---|
| 580 | if( trace(sc_time_stamp())) |
---|
| 581 | std::cout << sc_time_stamp() << " -- " << m_name |
---|
| 582 | << " -- ring_cmd_fsm -- RING " |
---|
| 583 | << " -- in cmd rok : " << p_ring_in.cmd_w |
---|
| 584 | << " -- in data : " << std::hex << p_ring_in.cmd_data |
---|
| 585 | << " -- in wok : " << p_ring_in.cmd_r |
---|
| 586 | << " -- eop : " << eop |
---|
| 587 | << std::endl; |
---|
| 588 | #endif |
---|
| 589 | if ( p_ring_in.cmd_w && eop ) { |
---|
| 590 | r_ring_cmd_fsm = CMD_IDLE; |
---|
| 591 | } |
---|
| 592 | else { |
---|
| 593 | r_ring_cmd_fsm = RING; |
---|
| 594 | } |
---|
| 595 | } |
---|
| 596 | break; |
---|
| 597 | |
---|
| 598 | } // end switch cmd fsm |
---|
| 599 | |
---|
| 600 | //////////////////////// |
---|
| 601 | // fifos update // |
---|
| 602 | //////////////////////// |
---|
| 603 | |
---|
| 604 | // local cmd fifo update |
---|
| 605 | if ( cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.put_and_get(cmd_fifo_data); |
---|
| 606 | else if ( cmd_fifo_put && !cmd_fifo_get ) m_cmd_fifo.simple_put(cmd_fifo_data); |
---|
| 607 | else if ( !cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.simple_get(); |
---|
| 608 | // local rsp fifo update |
---|
| 609 | if ( rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.put_and_get(rsp_fifo_data); |
---|
| 610 | else if ( rsp_fifo_put && !rsp_fifo_get ) m_rsp_fifo.simple_put(rsp_fifo_data); |
---|
| 611 | else if ( !rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.simple_get(); |
---|
| 612 | |
---|
| 613 | } // end Transition() |
---|
| 614 | |
---|
| 615 | /////////////////////////////////////////////////////////////////// |
---|
| 616 | void genMoore(vci_initiator_t &p_vci) |
---|
| 617 | /////////////////////////////////////////////////////////////////// |
---|
| 618 | { |
---|
| 619 | if( r_vci_rsp_fsm == RSP_HEADER ) |
---|
| 620 | p_vci.rspack = false; |
---|
| 621 | else |
---|
| 622 | p_vci.rspack = m_rsp_fifo.wok(); |
---|
| 623 | |
---|
| 624 | switch ( r_vci_cmd_fsm ) |
---|
| 625 | { |
---|
| 626 | case CMD_FIRST_HEADER: |
---|
| 627 | p_vci.cmdval = false; |
---|
| 628 | |
---|
| 629 | break; |
---|
| 630 | |
---|
| 631 | case CMD_SECOND_HEADER: |
---|
| 632 | if(((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1) // eop |
---|
| 633 | { |
---|
| 634 | p_vci.cmdval = m_cmd_fifo.rok(); |
---|
[44] | 635 | p_vci.address = (sc_dt::sc_uint<vci_param::N>) r_addr.read(); |
---|
| 636 | p_vci.cmd = (sc_dt::sc_uint<2>) ((m_cmd_fifo.read() >> 18) & 0x3); |
---|
[8] | 637 | p_vci.be = 0xF; |
---|
| 638 | p_vci.wdata = 0; |
---|
[44] | 639 | p_vci.pktid = (sc_dt::sc_uint<vci_param::P>) ((m_cmd_fifo.read() >> 4) & 0xF); |
---|
| 640 | p_vci.srcid = (sc_dt::sc_uint<vci_param::S>) (m_cmd_fifo.read() >> 20) ; |
---|
| 641 | p_vci.trdid = (sc_dt::sc_uint<vci_param::T>) (m_cmd_fifo.read() & 0xF); |
---|
| 642 | p_vci.plen = (sc_dt::sc_uint<vci_param::K>) ((m_cmd_fifo.read() >> 8) & 0xFF); |
---|
[8] | 643 | p_vci.eop = true; |
---|
[44] | 644 | sc_dt::sc_uint<1> cons = (sc_dt::sc_uint<1>) ((m_cmd_fifo.read() >> 16) & 0x1) ; |
---|
[8] | 645 | if (cons == 0x1) |
---|
| 646 | p_vci.cons = true; |
---|
| 647 | else |
---|
| 648 | p_vci.cons = false; |
---|
[44] | 649 | sc_dt::sc_uint<1> contig = (sc_dt::sc_uint<1>) ((m_cmd_fifo.read() >> 17) & 0x1); |
---|
[8] | 650 | if(contig == 0x1) |
---|
| 651 | p_vci.contig = true; |
---|
| 652 | else |
---|
| 653 | p_vci.contig = false; |
---|
| 654 | } |
---|
| 655 | else |
---|
| 656 | p_vci.cmdval = false; |
---|
| 657 | break; |
---|
| 658 | |
---|
| 659 | case WDATA: |
---|
| 660 | { // for variable scope |
---|
| 661 | |
---|
| 662 | p_vci.cmdval = m_cmd_fifo.rok(); |
---|
[44] | 663 | p_vci.address = (sc_dt::sc_uint<vci_param::N>) r_addr.read(); |
---|
| 664 | p_vci.be = (sc_dt::sc_uint<vci_param::B>)((m_cmd_fifo.read() >> 32) & 0xF); |
---|
[8] | 665 | p_vci.cmd = r_cmd; |
---|
[44] | 666 | p_vci.wdata = (sc_dt::sc_uint<32>)(m_cmd_fifo.read()); |
---|
[8] | 667 | p_vci.pktid = r_pktid; |
---|
| 668 | p_vci.srcid = r_srcid; |
---|
| 669 | p_vci.trdid = r_trdid; |
---|
| 670 | p_vci.plen = r_plen; |
---|
[44] | 671 | sc_dt::sc_uint<1> cons = r_const; |
---|
[8] | 672 | if (cons == 0x1) |
---|
| 673 | p_vci.cons = true; |
---|
| 674 | else |
---|
| 675 | p_vci.cons = false; |
---|
[44] | 676 | sc_dt::sc_uint<1> contig = r_contig; |
---|
[8] | 677 | if(contig == 0x1) |
---|
| 678 | p_vci.contig = true; |
---|
| 679 | else |
---|
| 680 | p_vci.contig = false; |
---|
| 681 | if(((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1) |
---|
| 682 | p_vci.eop = true; |
---|
| 683 | else |
---|
| 684 | p_vci.eop = false; |
---|
| 685 | } |
---|
| 686 | break; |
---|
| 687 | |
---|
| 688 | } // end switch fsm |
---|
| 689 | } // end genMoore |
---|
| 690 | |
---|
| 691 | /////////////////////////////////////////////////////////////////// |
---|
| 692 | void update_ring_signals(ring_signal_t p_ring_in, ring_signal_t &p_ring_out) |
---|
| 693 | /////////////////////////////////////////////////////////////////// |
---|
| 694 | { |
---|
| 695 | |
---|
| 696 | switch( r_ring_rsp_fsm ) |
---|
| 697 | { |
---|
| 698 | case RSP_IDLE: |
---|
| 699 | p_ring_out.rsp_grant = p_ring_in.rsp_grant && !m_rsp_fifo.rok(); |
---|
| 700 | |
---|
| 701 | p_ring_out.rsp_w = p_ring_in.rsp_w; |
---|
| 702 | p_ring_out.rsp_data = p_ring_in.rsp_data; |
---|
| 703 | |
---|
| 704 | p_ring_out.rsp_r = p_ring_in.rsp_r; |
---|
| 705 | break; |
---|
| 706 | |
---|
| 707 | case DEFAULT: |
---|
| 708 | p_ring_out.rsp_grant = !( m_rsp_fifo.rok()); |
---|
| 709 | |
---|
| 710 | p_ring_out.rsp_w = m_rsp_fifo.rok(); |
---|
| 711 | p_ring_out.rsp_data = m_rsp_fifo.read(); |
---|
| 712 | |
---|
| 713 | p_ring_out.rsp_r = 1; |
---|
| 714 | break; |
---|
| 715 | |
---|
| 716 | case KEEP: |
---|
| 717 | int rsp_fifo_eop = (int) ((m_rsp_fifo.read() >> 32) & 0x1); |
---|
| 718 | p_ring_out.rsp_grant = m_rsp_fifo.rok() && p_ring_in.rsp_r && (rsp_fifo_eop == 1); |
---|
| 719 | |
---|
| 720 | p_ring_out.rsp_w = m_rsp_fifo.rok(); |
---|
| 721 | p_ring_out.rsp_data = m_rsp_fifo.read(); |
---|
| 722 | |
---|
| 723 | p_ring_out.rsp_r = 1; |
---|
| 724 | |
---|
| 725 | break; |
---|
| 726 | |
---|
| 727 | } // end switch |
---|
| 728 | |
---|
| 729 | p_ring_out.cmd_w = p_ring_in.cmd_w; |
---|
| 730 | p_ring_out.cmd_data = p_ring_in.cmd_data; |
---|
| 731 | |
---|
| 732 | p_ring_out.cmd_grant = p_ring_in.cmd_grant; |
---|
| 733 | |
---|
| 734 | switch( r_ring_cmd_fsm ) |
---|
| 735 | { |
---|
| 736 | case CMD_IDLE: |
---|
| 737 | { |
---|
| 738 | vci_addr_t rtgtid = (vci_addr_t) ((p_ring_in.cmd_data >> 1) << 2); |
---|
| 739 | bool islocal = m_lt[rtgtid] && (m_rt[rtgtid] == (vci_addr_t) m_tgtid); |
---|
| 740 | bool brdcst = (p_ring_in.cmd_data & 0x1) == 0X1 ; |
---|
| 741 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
| 742 | |
---|
| 743 | if(p_ring_in.cmd_w && !eop && brdcst && !m_cmd_fifo.wok()) { |
---|
| 744 | p_ring_out.cmd_r = m_cmd_fifo.wok() && p_ring_in.cmd_r; |
---|
| 745 | } |
---|
| 746 | |
---|
| 747 | if(p_ring_in.cmd_w && !eop && brdcst && m_cmd_fifo.wok()) { |
---|
| 748 | p_ring_out.cmd_r = m_cmd_fifo.wok() && p_ring_in.cmd_r; |
---|
| 749 | |
---|
| 750 | } |
---|
| 751 | |
---|
| 752 | if (p_ring_in.cmd_w && !eop && !brdcst && islocal) { |
---|
| 753 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
| 754 | |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | if (p_ring_in.cmd_w && !eop && !brdcst && !islocal) { |
---|
| 758 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
| 759 | } |
---|
| 760 | |
---|
| 761 | if (!p_ring_in.cmd_w || eop) { |
---|
| 762 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | |
---|
| 766 | } |
---|
| 767 | break; |
---|
| 768 | |
---|
| 769 | case BROADCAST_0: |
---|
| 770 | p_ring_out.cmd_r = m_cmd_fifo.wok() && p_ring_in.cmd_r; |
---|
| 771 | break; |
---|
| 772 | |
---|
| 773 | case BROADCAST_1: |
---|
| 774 | p_ring_out.cmd_r = m_cmd_fifo.wok() && p_ring_in.cmd_r; |
---|
| 775 | break; |
---|
| 776 | |
---|
| 777 | case LOCAL: |
---|
| 778 | |
---|
| 779 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
| 780 | break; |
---|
| 781 | |
---|
| 782 | case RING: |
---|
| 783 | |
---|
| 784 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
| 785 | break; |
---|
| 786 | } // end switch |
---|
| 787 | |
---|
| 788 | } // end update_ring_signals |
---|
| 789 | |
---|
| 790 | }; |
---|
| 791 | |
---|
| 792 | }} // end namespace |
---|
[35] | 793 | #endif // SOCLIB_CABA_VCI_RING_TARGET_H |
---|
[8] | 794 | |
---|