source: trunk/lib/vci_ring_target/caba/source/include/vci_ring_target.h @ 16

Last change on this file since 16 was 16, checked in by simerabe, 14 years ago

updating lib components

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