source: branches/v5/modules/dspin_local_ring_fast_c/caba/source/include/dspin_half_gateway_initiator_fast_c.h @ 357

Last change on this file since 357 was 357, checked in by simerabe, 11 years ago

fixbug : test on eop in case of single_flit coherence request

File size: 22.5 KB
Line 
1
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     : Februrary 2011
24 * Copyright: UPMC - LIP6
25 */
26#ifndef DSPIN_HALF_GATEWAY_INITIATOR_FAST_H
27#define DSPIN_HALF_GATEWAY_INITIATOR_FAST_H
28
29#include "caba_base_module.h"
30#include "generic_fifo.h"
31#include "mapping_table.h"
32#include "ring_signals_fast.h"
33#include "dspin_interface.h"
34
35#define  BRDCST_TGT_MASK  0xFFFFFFFFE1ULL
36#define  HI_DEBUG
37
38namespace soclib { namespace caba {
39
40namespace {
41
42const char *ring_cmd_fsm_state_str_hi[] = {
43        "CMD_IDLE",
44        "OWNER",
45        "BDC_FIRST",
46        "BDC_SECOND",
47        "SENDING",
48};
49
50#ifdef HI_DEBUG
51
52const char *ring_rsp_fsm_state_str_hi[] = {
53        "RSP_IDLE",
54        "ALLOC",
55        "NALLOC",
56};
57#endif
58
59}
60template<typename vci_param, int ring_cmd_data_size, int ring_rsp_data_size>
61class DspinHalfGatewayInitiatorFastC
62{
63
64typedef LocalRingSignals ring_signal_t;
65typedef DspinInput<ring_cmd_data_size>   cmd_in_t;
66typedef DspinOutput<ring_rsp_data_size>  rsp_out_t;
67
68private:
69       
70        enum ring_rsp_fsm_state_e {
71                RSP_IDLE,    // waiting for first flit of a response packet
72                ALLOC,      // next flit of a local rsp packet
73                NALLOC,     // next flit of a ring rsp packet
74            };
75       
76        enum ring_cmd_fsm_state_e {
77                CMD_IDLE,           
78                OWNER, 
79                BDC_FIRST,
80                BDC_SECOND,     
81                SENDING,
82                PREEMPT,                   
83            };
84       
85        // structural parameters
86        std::string         m_name;
87        bool                m_alloc_init;
88
89       
90        // internal fifos
91        GenericFifo<uint64_t > m_cmd_fifo;     // fifo for the local command packet
92        GenericFifo<uint64_t > m_rsp_fifo;     // fifo for the local response packet
93       
94        // routing table
95        soclib::common::AddressDecodingTable<uint32_t, bool> m_lt;
96
97        uint64_t r_brdcst_save; 
98        uint32_t m_srcid;
99        uint32_t m_nb_target;
100        uint32_t m_x_width;
101        uint32_t m_y_width;
102
103        // internal registers
104        sc_core::sc_signal<bool>     r_preempt;         // ring preempted, priority to gate init.
105        sc_core::sc_signal<uint32_t> r_cpt_tgt;         // target id for sequential broadcast
106        sc_core::sc_signal<uint32_t> r_ring_cmd_fsm;    // ring command packet FSM (distributed)
107        sc_core::sc_signal<uint32_t> r_ring_rsp_fsm;    // ring response packet FSM
108
109public :
110
111#define __renRegGateInit(x) x((((std::string) name)+"_" #x).c_str())
112
113DspinHalfGatewayInitiatorFastC(
114        const char     *name,
115        bool            alloc_init,
116        const int       &wrapper_fifo_depth,
117        const soclib::common::MappingTable &mt,
118        const soclib::common::IntTab &ringid,
119        const uint32_t &nb_target,
120        const uint32_t &x_width,
121        const uint32_t &y_width)
122      : m_name(name),
123        m_alloc_init(alloc_init),
124        m_cmd_fifo(((std::string) name)+"m_cmd_fifo", wrapper_fifo_depth),
125        m_rsp_fifo(((std::string) name)+"m_rsp_fifo", wrapper_fifo_depth),
126        m_lt(mt.getIdLocalityTable(ringid)),
127        m_nb_target(nb_target),
128        m_x_width(x_width),
129        m_y_width(y_width),
130        __renRegGateInit(r_cpt_tgt),
131        __renRegGateInit(r_ring_cmd_fsm),
132        __renRegGateInit(r_ring_rsp_fsm)
133 { } //  end constructor
134
135
136void reset()
137{
138        if(m_alloc_init)
139                r_ring_cmd_fsm = OWNER;
140        else
141                r_ring_cmd_fsm = CMD_IDLE;
142
143        r_ring_rsp_fsm = RSP_IDLE;
144        m_cmd_fifo.init();
145        m_rsp_fifo.init();
146
147}
148
149void transition(const cmd_in_t &p_gate_cmd_in, const rsp_out_t &p_gate_rsp_out, const ring_signal_t p_ring_in, cmd_str &init_cmd, bool &init_rsp_val, const bool tga)     
150{
151
152        bool      cmd_fifo_get = false;
153        bool      cmd_fifo_put = false;
154        uint64_t  cmd_fifo_data = 0;
155
156        bool      rsp_fifo_put = false;
157        uint64_t  rsp_fifo_data = 0;
158
159
160//////////// VCI CMD FSM /////////////////////////
161
162        if (p_gate_cmd_in.write.read()) {
163                cmd_fifo_data = (uint64_t) p_gate_cmd_in.data.read();
164                cmd_fifo_put =  m_cmd_fifo.wok();
165        }
166
167        bool rsp_fifo_get = p_gate_rsp_out.read.read();
168
169//////////// RING CMD FSM /////////////////////////
170        switch( r_ring_cmd_fsm ) 
171        {
172                case CMD_IDLE: 
173                { 
174                        bool eop = ( (int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1);
175                        // tga : target gate allocated
176                        if(m_cmd_fifo.rok())
177                        {
178#ifdef HI_DEBUG
179   std::cout << std::dec << sc_time_stamp() << " - " << m_name
180                         << " - ring_cmd_fsm  = " << ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm] 
181                         << " - fifo ROK : " << m_cmd_fifo.rok()
182                         << " - fifo _data : " << std::hex << m_cmd_fifo.read()
183                         << " - in grant : " << p_ring_in.cmd_grant
184                         << " - in tga : " << tga
185                         << " - in wok : " << p_ring_in.cmd_r
186                         << " - in data : " << p_ring_in.cmd_data
187
188                         << std::endl;
189#endif
190                                r_preempt    = tga;
191
192                                if (m_cmd_fifo.read() & 0x1 == 0x1) // broadcast
193                                {
194                                        if (tga || p_ring_in.cmd_grant)
195                                        {
196                                                r_cpt_tgt      = 0;                   
197                                                r_brdcst_save  = m_cmd_fifo.read() & BRDCST_TGT_MASK; // save first flit of brdcst
198                                                r_ring_cmd_fsm = BDC_FIRST;
199                                        }
200                                }
201                                else    if (tga)
202                                        {
203
204                                                cmd_fifo_get   = p_ring_in.cmd_r;
205                                                if (eop)
206                                                        r_ring_cmd_fsm = CMD_IDLE;
207                                                else
208                                                        r_ring_cmd_fsm = SENDING;
209                                                break;
210                                        }
211
212                                        if(p_ring_in.cmd_grant)
213                                        {
214                                                r_ring_cmd_fsm = SENDING;
215                                        }
216
217                        }
218                }
219                break;
220
221                case OWNER:
222                        if ( m_cmd_fifo.rok()) // && p_ring_in.cmd_wok.read() )
223                        {
224#ifdef HI_DEBUG
225   std::cout << std::dec << sc_time_stamp() << " - " << m_name
226                         << " - ring_cmd_fsm  = " << ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm] 
227                         << " - fifo ROK : " << m_cmd_fifo.rok()
228                         << " - in grant : " << p_ring_in.cmd_grant
229                         << " - in wok : " << p_ring_in.cmd_r
230                         << " - fifo data : " << std::hex << m_cmd_fifo.read()
231                         << std::endl;
232#endif       
233
234                                bool eop = ( (int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1);
235
236                                if (m_cmd_fifo.read() & 0x1 == 0x1) // broadcast
237                                {
238                                        r_cpt_tgt      = 0;                   
239                                        r_brdcst_save  = m_cmd_fifo.read() & BRDCST_TGT_MASK; // save first flit of brdcst
240                                        r_ring_cmd_fsm = BDC_FIRST;                                       
241                                } 
242//
243                                else
244                                {
245                                        if ( eop && p_ring_in.cmd_r ) 
246                                         {
247                                                cmd_fifo_get = true;
248                                                if ( p_ring_in.cmd_grant )
249                                                        r_ring_cmd_fsm = OWNER;
250                                                else
251                                                        r_ring_cmd_fsm = CMD_IDLE;
252                                         } 
253                                       
254                                         if (!eop || !p_ring_in.cmd_r) 
255                                         {
256                                                cmd_fifo_get = p_ring_in.cmd_r;
257                                                r_ring_cmd_fsm = SENDING;
258                                         }
259
260                                }
261             
262                        }   
263                        else if ( !p_ring_in.cmd_grant)
264                                r_ring_cmd_fsm = CMD_IDLE; 
265                break;
266
267                case BDC_FIRST:
268                       
269#ifdef HI_DEBUG
270        std::cout << std::dec << sc_time_stamp() << " - " << m_name
271                  << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm] 
272                  << " - fifo ROK : " << m_cmd_fifo.rok()
273                  << " - in grant : " << p_ring_in.cmd_grant 
274                  << " - preempt : " << r_preempt
275                  << " - in wok : " << p_ring_in.cmd_r
276                  << " - cpt_tgt : " << r_cpt_tgt.read()
277                  << " - fifo data : " << std::hex << m_cmd_fifo.read()
278                  << std::endl;
279
280#endif
281
282                        if (p_ring_in.cmd_r)                                 
283                        {
284                                if (r_cpt_tgt.read() == 0)
285                                {
286                                        cmd_fifo_get = true;
287                                }
288                                r_ring_cmd_fsm = BDC_SECOND;
289                        }
290                break;
291
292                case BDC_SECOND:
293#ifdef HI_DEBUG
294        std::cout << std::dec << sc_time_stamp() << " - " << m_name
295                  << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm] 
296                  << " - fifo ROK : " << m_cmd_fifo.rok()
297                  << " - in grant : " << p_ring_in.cmd_grant 
298                  << " - preempt : " << r_preempt
299                  << " - in wok : " << p_ring_in.cmd_r
300                  << " - fifo data : " << std::hex << m_cmd_fifo.read()
301                  << std::endl;
302
303#endif
304
305                        if(m_cmd_fifo.rok() && p_ring_in.cmd_r)
306                        { 
307                                if(r_cpt_tgt.read() == m_nb_target - 1)
308                                {
309                                        cmd_fifo_get = true; 
310
311                                        if ( !r_preempt && p_ring_in.cmd_grant )
312                                        {
313                                                r_ring_cmd_fsm = OWNER; 
314                                        }
315                                        else    //r_preempt || !p_ring_in.cmd_grant   
316                                        {
317                                                r_ring_cmd_fsm = CMD_IDLE;
318                                        }
319                                }
320                                else
321                                {
322                                        r_cpt_tgt      = r_cpt_tgt + 1;
323                                        r_ring_cmd_fsm = BDC_FIRST;
324                                }
325
326                        }
327                break;
328
329                case SENDING:   
330#ifdef HI_DEBUG
331if(m_cmd_fifo.rok())
332   std::cout << std::dec << sc_time_stamp() << " - " << m_name
333                         << " - ring_cmd_fsm  = " << ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm] 
334                         << " - fifo ROK : " << m_cmd_fifo.rok()
335                         << " - in grant : " << p_ring_in.cmd_grant
336                         << " - in wok : " << p_ring_in.cmd_r
337                         << " - fifo data : " << std::hex << m_cmd_fifo.read()
338                         << std::endl;
339#endif                 
340
341
342                        if(m_cmd_fifo.rok() && p_ring_in.cmd_r ) 
343                        {
344                                cmd_fifo_get = true; 
345                                bool eop = ((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1;
346                                if (eop) 
347                                { 
348                                        if (!r_preempt && p_ring_in.cmd_grant )
349                                                r_ring_cmd_fsm = OWNER; 
350                                        else   
351                                                r_ring_cmd_fsm = CMD_IDLE; 
352                                }       
353                        }     
354                break;
355
356        } // end switch ring cmd fsm
357 
358/////////// RING RSP FSM ////////////////////////
359   
360        switch( r_ring_rsp_fsm ) 
361        {
362                case RSP_IDLE: 
363
364                {
365                        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)));
366                        bool islocal      = !m_lt[rsrcid];
367                        bool reop         = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1;
368
369
370
371                        if (p_ring_in.rsp_w)
372                        {
373#ifdef HI_DEBUG
374   std::cout << std::dec << sc_time_stamp() << " - " << m_name
375              << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_hi[r_ring_rsp_fsm]
376              << " - in preempt : " << p_ring_in.rsp_preempt
377              << " - in rok : " << p_ring_in.rsp_w
378              << " - in data : " << std::hex << p_ring_in.rsp_data
379              << " - rsrcid : " << rsrcid
380              << " - isloc : " << islocal
381              << " - in wok : " << p_ring_in.rsp_r
382              << " - fifo wok : " << m_rsp_fifo.wok()
383              << " - reop : " << reop
384              << std::endl;
385#endif
386                                if(islocal) 
387                                {   
388                                        rsp_fifo_put  = m_rsp_fifo.wok();
389                                        rsp_fifo_data = p_ring_in.rsp_data;
390
391                                        if (reop && m_rsp_fifo.wok())
392                                                r_ring_rsp_fsm = RSP_IDLE;
393                                        else
394                                                r_ring_rsp_fsm = ALLOC;
395                                }
396
397                                else  // !islocal
398                                {
399
400                                        if (reop && p_ring_in.rsp_r)
401                                                r_ring_rsp_fsm = RSP_IDLE;
402                                        else
403                                                r_ring_rsp_fsm = NALLOC;
404                                }
405                        }
406                        else // !p_ring_in.rsp_w
407                                r_ring_rsp_fsm = RSP_IDLE;
408                }
409                break;
410
411                case ALLOC:
412                {
413                        bool reop     = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1;
414#ifdef HI_DEBUG
415if(p_ring_in.rsp_w || p_ring_in.rsp_preempt)
416   std::cout << std::dec << sc_time_stamp() << " - " << m_name
417              << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_hi[r_ring_rsp_fsm] 
418              << " - in preempt : " << p_ring_in.rsp_preempt
419              << " - in rok : " << p_ring_in.rsp_w
420              << " - in wok : " << p_ring_in.rsp_r
421              << " - in data : " << std::hex << p_ring_in.rsp_data
422              << " - fifo wok : " << m_rsp_fifo.wok()   
423              << " - reop : " << reop
424              << std::endl;
425#endif
426
427
428                        if(p_ring_in.rsp_preempt) break;
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
436                                if(p_ring_in.rsp_palloc)
437                                        r_ring_rsp_fsm = NALLOC;
438                                else
439                                        r_ring_rsp_fsm = RSP_IDLE;             
440                        }
441                        else //  !p_ring_in.rsp_w || !m_rsp_fifo.wok() || !reop
442                        {
443
444                                rsp_fifo_put  = p_ring_in.rsp_w && m_rsp_fifo.wok();
445                                rsp_fifo_data = p_ring_in.rsp_data;
446                                r_ring_rsp_fsm = ALLOC;             
447                        }
448                } 
449                break;
450
451                case NALLOC:     
452                {
453
454#ifdef HI_DEBUG
455if(p_ring_in.rsp_w)
456   std::cout << std::dec << sc_time_stamp() << " - " << m_name
457                         << " - ring_rsp_fsm  = " << ring_rsp_fsm_state_str_hi[r_ring_rsp_fsm] 
458                         << " - in rok : " << p_ring_in.rsp_w
459                         << " - fifo wok : " <<  m_rsp_fifo.wok()   
460                         << " - in wok : " << p_ring_in.rsp_r
461                         << " - in data : " << std::hex << p_ring_in.rsp_data
462                         << std::endl;
463#endif
464
465                        bool reop  = ((p_ring_in.rsp_data >> (ring_rsp_data_size - 1)) & 0x1) == 1;
466
467
468                        if (p_ring_in.rsp_w && reop && p_ring_in.rsp_r)
469                        {
470                                r_ring_rsp_fsm = RSP_IDLE; 
471                        }
472                        else
473                        {
474                                r_ring_rsp_fsm = NALLOC;
475                        }
476                }
477                break;
478
479        } // end switch rsp fsm
480
481
482    ////////////////////////
483    //  fifos update      //
484   ////////////////////////
485
486//-- keep trace on ring traffic
487        init_cmd.cmdval  = cmd_fifo_get;
488        init_cmd.flit    = m_cmd_fifo.read();
489        init_cmd.state   = ring_cmd_fsm_state_str_hi[r_ring_cmd_fsm];
490
491        //init_cmd_val = cmd_fifo_get;
492        init_rsp_val = rsp_fifo_put;
493// local cmd fifo update
494        if (  cmd_fifo_put &&  cmd_fifo_get ) m_cmd_fifo.put_and_get(cmd_fifo_data);
495        else if (  cmd_fifo_put && !cmd_fifo_get ) m_cmd_fifo.simple_put(cmd_fifo_data);
496        else if ( !cmd_fifo_put &&  cmd_fifo_get ) m_cmd_fifo.simple_get();
497       
498// local rsp fifo update
499        if (  rsp_fifo_put &&  rsp_fifo_get ) m_rsp_fifo.put_and_get(rsp_fifo_data);
500        else if (  rsp_fifo_put && !rsp_fifo_get ) m_rsp_fifo.simple_put(rsp_fifo_data);
501        else if ( !rsp_fifo_put &&  rsp_fifo_get ) m_rsp_fifo.simple_get();
502     
503}  // end Transition()
504
505///////////////////////////////////////////////////////////////////
506void genMoore(cmd_in_t &p_gate_cmd_in, rsp_out_t &p_gate_rsp_out)
507///////////////////////////////////////////////////////////////////
508{
509        p_gate_rsp_out.write = m_rsp_fifo.rok();
510        p_gate_rsp_out.data  = (sc_dt::sc_uint<ring_rsp_data_size>) m_rsp_fifo.read();
511
512        p_gate_cmd_in.read= m_cmd_fifo.wok();
513
514} // end genMoore
515
516/////////////////////////////////////////////////////////////////////////////////////////////////
517void update_ring_signals(ring_signal_t p_ring_in, ring_signal_t &p_ring_out, bool tga, bool &iga)
518/////////////////////////////////////////////////////////////////////////////////////////////////
519// palloc may have 2 values :
520// palloc = 2 : means Target Gate still allocated
521// global state for targets :  TG  TL0  TL1   TL2  ... TLn
522//                              A   N    N     P2       N
523//                              A   N    N     N        N
524// palloc = 1 : means Target Gate free (not allocated)
525// global state for targets :  TG  TL0  TL1   TL2  ... TLn
526//                              A   N    N     P2       N
527//                              N   N    N     P1       N                       
528//                              I   I    I     I        I                                                               
529// TLi not allocated, in case of preempt and last flit, needs to test value of palloc
530// if palloc=1      => next state : IDLE (TG not allocated)
531// else (palloc2=2) => next state : NALLOC (TG still Allocated)
532{   
533        switch( r_ring_cmd_fsm ) 
534        {
535                case CMD_IDLE:
536                {
537                        bool brdcst = (m_cmd_fifo.read() & 0x1 == 0x1);
538
539                        p_ring_out.cmd_grant     = !m_cmd_fifo.rok() && p_ring_in.cmd_grant;
540
541                        if (m_cmd_fifo.rok() && tga && !brdcst) 
542                        {
543                                p_ring_out.cmd_preempt = 1; 
544                                p_ring_out.cmd_palloc  = 1; 
545                                p_ring_out.cmd_header  = 1; 
546                                p_ring_out.cmd_w       = 1;
547                                p_ring_out.cmd_data    = m_cmd_fifo.read();
548                        }
549                        else
550                        {
551                                p_ring_out.cmd_preempt = 0; 
552                                p_ring_out.cmd_palloc  = 0; 
553                                p_ring_out.cmd_header  = 0; 
554                                p_ring_out.cmd_w       = p_ring_in.cmd_w;
555                                p_ring_out.cmd_data    = p_ring_in.cmd_data;
556                        }
557
558                }
559                break;
560       
561                case OWNER:   
562                {     
563                        bool eop = ((int) ((m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1);
564                        bool brdcst = (m_cmd_fifo.read() & 0x1 == 0x1);     
565 
566                        p_ring_out.cmd_grant = (!m_cmd_fifo.rok() || (eop && p_ring_in.cmd_r)) ; 
567
568                        p_ring_out.cmd_preempt = 0;
569                        p_ring_out.cmd_header  = 0;
570                        p_ring_out.cmd_palloc  = 0;
571                        p_ring_out.cmd_w       = m_cmd_fifo.rok() && !brdcst;
572                        p_ring_out.cmd_data    = m_cmd_fifo.read();
573                }
574                break;
575
576                case BDC_FIRST:
577                        if(r_preempt)
578                        {
579                                p_ring_out.cmd_header  = 1;
580                                p_ring_out.cmd_palloc  = 1+(tga ? 1:0);
581                                p_ring_out.cmd_preempt = 1;
582                                p_ring_out.cmd_grant   = p_ring_in.cmd_grant;
583                        }
584                        else
585                        {
586                                p_ring_out.cmd_header  = 0;
587                                p_ring_out.cmd_palloc  = 0;
588                                p_ring_out.cmd_preempt = 0;
589                                p_ring_out.cmd_grant   = false;
590                        }
591
592                        p_ring_out.cmd_w     = true;
593                        p_ring_out.cmd_data  = r_brdcst_save | ((((uint64_t) r_cpt_tgt.read()) & 0xF) << 0x1);   
594                break;
595               
596                case BDC_SECOND:
597
598                        if (r_preempt)
599                        {
600                                p_ring_out.cmd_grant  = p_ring_in.cmd_grant;
601                                p_ring_out.cmd_palloc = 1+(tga ? 1:0);
602                               
603                                p_ring_out.cmd_preempt = m_cmd_fifo.rok(); //&& tga;
604                                p_ring_out.cmd_header  = 0;
605                               
606                                if ( m_cmd_fifo.rok() )
607                                {
608                                        p_ring_out.cmd_w     = 1; //m_cmd_fifo.rok();
609                                        p_ring_out.cmd_data  = m_cmd_fifo.read();
610                                }
611                                else
612                                {
613                                        // if init local has finished, tga = 0
614                                        // init gate remains the only initiator, then w = 0
615                                        p_ring_out.cmd_w     = p_ring_in.cmd_w && tga; 
616                                        p_ring_out.cmd_data  = p_ring_in.cmd_data;
617                                }
618                        }
619                        else
620                        {
621                                // si on est dans cet etat, c'est qu'on n'utilise pas le cmd_preempt mais le gnt.
622                                p_ring_out.cmd_preempt= 0;
623                                p_ring_out.cmd_header = 0;
624                                p_ring_out.cmd_palloc = 0;
625                                p_ring_out.cmd_w      = m_cmd_fifo.rok();
626                                p_ring_out.cmd_data   = m_cmd_fifo.read();
627                                p_ring_out.cmd_grant  = m_cmd_fifo.rok() && p_ring_in.cmd_r && (r_cpt_tgt.read() == m_nb_target - 1);
628                        }
629                break;
630       
631                case SENDING: 
632                { 
633
634                        if (r_preempt)
635                        {
636                                p_ring_out.cmd_grant  = p_ring_in.cmd_grant;
637                                p_ring_out.cmd_palloc = 1+(tga ? 1:0);
638                               
639                                p_ring_out.cmd_preempt = m_cmd_fifo.rok(); //&& tga;
640                                p_ring_out.cmd_header  = 0;
641                               
642                                if ( m_cmd_fifo.rok() )
643                                {
644                                        p_ring_out.cmd_w     = 1; //m_cmd_fifo.rok();
645                                        p_ring_out.cmd_data  = m_cmd_fifo.read();
646                                }
647                                else
648                                {
649                                        // if init local has finished, tga = 0
650                                        // init gate remains the only initiator, then w = 0
651                                        p_ring_out.cmd_w     = p_ring_in.cmd_w && tga; 
652                                        p_ring_out.cmd_data  = p_ring_in.cmd_data;
653                                }
654                        }
655                        else
656                        {
657                                bool eop = ((int) (m_cmd_fifo.read() >> (ring_cmd_data_size - 1) ) & 0x1) == 1;
658                                // si on est dans cet etat, c'est qu'on n'utilise pas le cmd_preempt mais le gnt.
659                                p_ring_out.cmd_preempt= 0;
660                                p_ring_out.cmd_header = 0;
661                                p_ring_out.cmd_palloc = 0;
662                                p_ring_out.cmd_w      = m_cmd_fifo.rok();
663                                p_ring_out.cmd_data   = m_cmd_fifo.read();
664                                p_ring_out.cmd_grant  = m_cmd_fifo.rok() && p_ring_in.cmd_r && eop;
665                        }
666                }
667                break;
668       
669        } // end switch
670
671        p_ring_out.cmd_r       = p_ring_in.cmd_r;
672
673        p_ring_out.rsp_w       = p_ring_in.rsp_w;
674        p_ring_out.rsp_data    = p_ring_in.rsp_data;
675
676        p_ring_out.rsp_grant   = p_ring_in.rsp_grant;
677
678        p_ring_out.rsp_palloc  = p_ring_in.rsp_palloc;
679        p_ring_out.rsp_preempt = p_ring_in.rsp_preempt;
680        p_ring_out.rsp_header  = p_ring_in.rsp_header;
681
682
683        switch( r_ring_rsp_fsm ) 
684        {
685                case RSP_IDLE: 
686                {
687                        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)));
688                        bool islocal      = !m_lt[rsrcid];
689
690                        iga = false;
691
692                        if(p_ring_in.rsp_w && islocal) 
693                                p_ring_out.rsp_r = m_rsp_fifo.wok();
694                        else
695                                p_ring_out.rsp_r = p_ring_in.rsp_r;
696                }
697                break;
698       
699                case ALLOC:
700                        iga = true;
701
702                        if (!p_ring_in.rsp_preempt)
703                                p_ring_out.rsp_r =  m_rsp_fifo.wok();   
704                        else
705                                p_ring_out.rsp_r = p_ring_in.rsp_r;
706                break;
707       
708                case NALLOC:
709                        iga = false;
710                        p_ring_out.rsp_r = p_ring_in.rsp_r;
711                break;   
712        } // end switch
713
714
715} // end update_ring_signals
716
717};
718
719}} // end namespace
720
721#endif // DSPIN_HALF_GATEWAY_INITIATOR_FAST_H
722
Note: See TracBrowser for help on using the repository browser.