source: branches/v5/modules/dspin_local_ring_fast_c/caba/source/include/dspin_half_gateway_initiator_fast_c.sv @ 326

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

introducing 2 new components : simple and local ring interconnect using dspin interface

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