source: trunk/lib/vci_ring_initiator/caba/source/include/vci_ring_initiator.h @ 35

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

fixing bug : multi-inclusion control

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