Changeset 150


Ignore:
Timestamp:
May 2, 2011, 9:20:32 AM (13 years ago)
Author:
alain
Message:

bug fixing

Location:
trunk/modules/vci_vdspin_initiator_wrapper/caba/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_vdspin_initiator_wrapper/caba/source/include/vci_vdspin_initiator_wrapper.h

    r148 r150  
    6666        CMD_IDLE,
    6767        CMD_BROADCAST,
    68         CMD_RW,
     68        CMD_READ,
     69        CMD_WRITE,
    6970        CMD_WDATA,
    7071    };
     
    7475        RSP_IDLE,
    7576        RSP_READ,               
     77        RSP_WRITE,     
    7678    };
    7779
     
    105107    void genMoore();
    106108
     109public:
     110    void print_trace();
     111
    107112};
    108113
  • trunk/modules/vci_vdspin_initiator_wrapper/caba/source/src/vci_vdspin_initiator_wrapper.cpp

    r148 r150  
    9595        // - A single flit VCI broadcast packet is translated to
    9696        //   a 2 flits DSPIN command.
     97        // A DSPIN flit is written in the fifo_cmd in all states
     98        // but a VCI flit is consumed only in the CMD_READ,
     99        // CMD_BROACAST,  and CMD_WDATA states.
    97100        //////////////////////////////////////////////////////////////
    98101
     
    101104
    102105        // r_cmd_fsm, cmd_fifo_write and cmd_fifo_data
     106        cmd_fifo_write = false;         // default value
     107
    103108        switch(r_cmd_fsm) {
    104109            case CMD_IDLE:              // write first DSPIN flit into fifo_cmd
     
    110115                    sc_uint<dspin_cmd_width> srcid   = (sc_uint<dspin_cmd_width>)p_vci.srcid.read();
    111116                    sc_uint<dspin_cmd_width> trdid   = (sc_uint<dspin_cmd_width>)p_vci.trdid.read();
    112                     if ( address & 0x3 )        // VCI broacast command
     117                    sc_uint<dspin_cmd_width> cmd     = (sc_uint<dspin_cmd_width>)p_vci.cmd.read();
     118
     119                    bool is_broadcast = ( (address & 0x3) != 0);
     120                    bool is_read = ((cmd == vci_param::CMD_READ) || (cmd == vci_param::CMD_LOCKED_READ));
     121
     122                    if ( vci_param::N == 40 ) address = address >> 1;
     123                    else                      address = address << (39 - vci_param::N);             
     124
     125                    if ( is_broadcast ) // VCI broacast command
    113126                    {
    114127                        r_cmd_fsm     = CMD_BROADCAST;
    115                         cmd_fifo_data = ((address & 0xFFFFF00000) >> 1) |
    116                                         (srcid << 5) | (trdid << 1) | 0x0000000001;             
     128                        cmd_fifo_data = (address      & 0x7FFFF80000) |
     129                                        ((srcid << 5) & 0x000007FFE0) |
     130                                        ((trdid << 1) & 0x000000001E) |
     131                                                        0x0000000001;           
    117132                    }
    118                     else                        // VCI READ or WRITE command
    119                     {
    120                         r_cmd_fsm     = CMD_RW;
    121                         cmd_fifo_data = (address >> 1) & 0x788888888E;
     133                    else if (is_read )                  // VCI READ  command
     134                    {
     135                        r_cmd_fsm     = CMD_READ;
     136                        cmd_fifo_data = address & 0x7FFFFFFFFE;
     137                    }
     138                    else                                // VCI WRITE command
     139                    {
     140                        r_cmd_fsm     = CMD_WRITE;
     141                        cmd_fifo_data = address & 0x7FFFFFFFFE;
    122142                    }
    123143                }
    124                 else
    125                 {
    126                     cmd_fifo_write = false;
    127                 }
    128144                break;
    129145            }
     
    135151                    sc_uint<dspin_cmd_width> data = (sc_uint<dspin_cmd_width>)p_vci.wdata.read();
    136152                    sc_uint<dspin_cmd_width> be   = (sc_uint<dspin_cmd_width>)p_vci.be.read();
    137                     cmd_fifo_data    = (data & 0x00FFFFFFFF) | ((be & 0x3) << 32) | 0x8000000000;
     153                    cmd_fifo_data    = (data       & 0x00FFFFFFFF) |
     154                                       ((be << 32) & 0x0300000000) |
     155                                                     0x8000000000;
    138156                    r_cmd_fsm = CMD_IDLE;
    139157                }
    140                 else
    141                 {
    142                     cmd_fifo_write = false;
    143                 }
    144158                break;
    145159            }
    146             case CMD_RW:                // write second DSPIN flit in case of read/write
     160            case CMD_READ:      // write second DSPIN flit in case of read/write
     161            case CMD_WRITE:
    147162            {
    148163                if( p_vci.cmdval && r_fifo_cmd.wok() )
     
    154169                    sc_uint<dspin_cmd_width> plen    = (sc_uint<dspin_cmd_width>)p_vci.plen.read();
    155170                    sc_uint<dspin_cmd_width> be      = (sc_uint<dspin_cmd_width>)p_vci.be.read();
    156                     cmd_fifo_data       = ((be & 0xF) << 1) |
    157                                           ((trdid & 0xFF) << 5) |
    158                                           ((plen & 0xFF) << 13) |
    159                                           ((cmd & 0x3) << 23) |
    160                                           ((srcid & 0x3FFF) << 25) |
    161                                           0x1000000000;
    162                     if( (cmd == vci_param::CMD_READ) ||
    163                         (cmd == vci_param::CMD_LOCKED_READ) )   r_cmd_fsm = CMD_IDLE;
    164                     else                                        r_cmd_fsm = CMD_WDATA;
     171                    cmd_fifo_data       = ((be    << 1 ) & 0x000000001E) |
     172                                          ((trdid << 5 ) & 0x0000001FE0) |
     173                                          ((plen  << 13) & 0x00001FE000) |
     174                                          ((cmd   << 23) & 0x0001800000) |
     175                                          ((srcid << 25) & 0x7FFE000000) ;
     176                    if ( p_vci.contig.read() ) cmd_fifo_data = cmd_fifo_data | 0x0000400000 ;
     177                    if ( p_vci.cons.read()   ) cmd_fifo_data = cmd_fifo_data | 0x0000200000 ;
     178
     179                    if( r_cmd_fsm == CMD_READ )  // read command
     180                    {
     181                        r_cmd_fsm = CMD_IDLE;
     182                        cmd_fifo_data = cmd_fifo_data    | 0x8000000000 ;
     183                    }
     184                    else                        // write command
     185                    {
     186                        r_cmd_fsm = CMD_WDATA;
     187                    }
    165188                }
    166                 else
    167                 {
    168                     cmd_fifo_write = false;
    169                 }
    170189                break;
    171190            }
     
    177196                    sc_uint<dspin_cmd_width> data = (sc_uint<dspin_cmd_width>)p_vci.wdata.read();
    178197                    sc_uint<dspin_cmd_width> be   = (sc_uint<dspin_cmd_width>)p_vci.be.read();
    179                     cmd_fifo_data    = (data & 0xFFFFFFFF) | ((be & 0xF) << 32);
     198                    cmd_fifo_data    = (data       & 0x00FFFFFFFF) |
     199                                       ((be << 32) & 0x0F00000000) ;
     200                                       
    180201                    if ( p_vci.eop.read() )
    181202                    {
     
    184205                    }
    185206                }               
    186                 else
    187                 {
    188                     cmd_fifo_write = false;
    189                 }
    190207                break;
    191208            }
     
    202219        // The FIFO output is analysed and translated to a VCI packet
    203220        //////////////////////////////////////////////////////////////
    204         // - A N+2 flits DSPIN read response packet is translated
     221        // - A N+1 flits DSPIN read response packet is translated
    205222        //   to a N flits VCI response.
    206223        // - A single flit DSPIN write response packet is translated
    207224        //   to a single flit VCI response.
     225        // A valid DSPIN flit in the fifo_rsp is always consumed   
     226        // in the CMD_IDLE state, but no VCI flit is transmitted.
     227        // The VCI flits are sent in the RSP_READ & RSP_WRITE states.
    208228        //////////////////////////////////////////////////////////////
    209229
     
    213233
    214234        // r_rsp_fsm, rsp_fifo_read
     235        rsp_fifo_read = false;          // default value
     236
    215237        switch(r_rsp_fsm) {
    216238            case RSP_IDLE:
    217239            {
    218                 if( r_fifo_rsp.rok() && p_vci.rspack )
     240                if( r_fifo_rsp.rok() )
    219241                {
    220242                    rsp_fifo_read = true;
    221                     if ( (r_fifo_rsp.read() & 0x000020000) == 0 )  // read response
    222                     {
    223                         r_rsp_buf = r_fifo_rsp.read();
    224                         r_rsp_fsm = RSP_READ;
    225                     }
     243                    r_rsp_buf = r_fifo_rsp.read();
     244                    if ( (r_fifo_rsp.read() & 0x000020000) == 0 )  r_rsp_fsm = RSP_READ;
     245                    else                                           r_rsp_fsm = RSP_WRITE;
    226246                }
    227                 else
    228                 {
    229                     rsp_fifo_read = false;
    230                 }
    231            
    232247                break;
    233248            }
    234249            case RSP_READ:             
    235250            {
    236                 if( r_fifo_rsp.rok() && p_vci.rspack )
     251                if( r_fifo_rsp.rok() && p_vci.rspack.read() )
    237252                {
    238253                    rsp_fifo_read = true;
    239254                    if ( (r_fifo_rsp.read() & 0x100000000) ) r_rsp_fsm = RSP_IDLE;
    240255                }
    241                 else
    242                 {
    243                     rsp_fifo_read = false;
    244                 }
    245256                break;
     257            }
     258            case RSP_WRITE:
     259            {
     260                if ( p_vci.rspack.read() ) r_rsp_fsm = RSP_IDLE;
    246261            }
    247262        } // end switch r_rsp_fsm
     
    258273{
    259274        // VCI CMD interface
    260         if ( r_cmd_fsm.read() == CMD_IDLE )     p_vci.cmdack = false;
    261         else                                    p_vci.cmdack = r_fifo_cmd.wok();
     275        if ( ( r_cmd_fsm.read() == CMD_IDLE ) || ( r_cmd_fsm.read() == CMD_WRITE ) )
     276        {
     277            p_vci.cmdack = false;
     278        }
     279        else
     280        {
     281            p_vci.cmdack = r_fifo_cmd.wok();
     282        }
    262283
    263284        // VCI RSP interface
    264285        if ( r_rsp_fsm.read() == RSP_IDLE )
    265286        {
    266             if ( r_fifo_rsp.rok() && (r_fifo_rsp.read() & 0x000020000) ) //  valid RSP WRITE
    267             {
    268                 p_vci.rspval = true;
    269                 p_vci.rdata  = 0;
    270                 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_fifo_rsp.read() & 0x0FFFC0000) >> 18);
    271                 p_vci.rtrdid = (sc_uint<vci_param::T>)((r_fifo_rsp.read() & 0x00000FF00) >> 8);
    272                 p_vci.rpktid = 0;
    273                 p_vci.rerror = (sc_uint<vci_param::E>)((r_fifo_rsp.read() & 0x000030000) >> 16);
    274                 p_vci.reop   = true;
    275             }
    276             else
    277             {
    278                 p_vci.rspval = false;
    279             }
    280         }
    281         else            // Next flit of a RSP READ
    282         {           
    283             if ( r_fifo_rsp.rok() )                                     //  valid RSP READ
    284             {
    285                 p_vci.rspval = true;
    286                 p_vci.rdata  = (sc_uint<4*vci_param::B>)(r_fifo_rsp.read() & 0x0FFFFFFFF);
    287                 p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read()   & 0x0FFFC0000) >> 18);
    288                 p_vci.rtrdid = (sc_uint<vci_param::T>)((r_rsp_buf.read()   & 0x00000FF00) >> 8);
    289                 p_vci.rpktid = 0;
    290                 p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read()   & 0x000030000) >> 16);
    291                 p_vci.reop   = ((r_fifo_rsp.read() & 0x100000000) == 0x100000000);
    292             }
    293             else
    294             {
    295                 p_vci.rspval = false;
    296             }
    297         }
     287            p_vci.rspval = false;
     288        }
     289        else if ( r_rsp_fsm.read() == RSP_WRITE )
     290        {
     291            p_vci.rspval = true;
     292            p_vci.rdata  = 0;
     293            p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read() & 0x0FFFC0000) >> 18);
     294            p_vci.rtrdid = (sc_uint<vci_param::T>)((r_rsp_buf.read() & 0x00000FF00) >> 8);
     295            p_vci.rpktid = 0;
     296            p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read() & 0x000030000) >> 16);
     297            p_vci.reop   = true;
     298        }
     299        else if ( r_rsp_fsm.read() == RSP_READ )
     300        {
     301            p_vci.rspval = true;
     302            p_vci.rdata  = (sc_uint<8*vci_param::B>)(r_fifo_rsp.read() & 0x0FFFFFFFF);
     303            p_vci.rsrcid = (sc_uint<vci_param::S>)((r_rsp_buf.read()   & 0x0FFFC0000) >> 18);
     304            p_vci.rtrdid = (sc_uint<vci_param::T>)((r_rsp_buf.read()   & 0x00000FF00) >> 8);
     305            p_vci.rpktid = 0;
     306            p_vci.rerror = (sc_uint<vci_param::E>)((r_rsp_buf.read()   & 0x000030000) >> 16);
     307            p_vci.reop   = ((r_fifo_rsp.read() & 0x100000000) == 0x100000000);
     308        }
    298309
    299310        // DSPIN_OUT interface
     
    305316
    306317}; // end genMoore
     318
     319/////////////////////////
     320tmpl(void)::print_trace()
     321{
     322    const char* cmd_str[] = {
     323    "CMD_IDLE     ",
     324    "CMD_BROADCAST",
     325    "CMD_READ     ",
     326    "CMD_WRITE    ",
     327    "CMD_WDATA    ",
     328    };
     329    const char* rsp_str[] = {
     330    "RSP_IDLE     ",
     331    "RSP_READ     ",
     332    "RSP_WRITE    ",
     333    };
     334
     335    std::cout << name() << " : " << cmd_str[r_cmd_fsm.read()]
     336                        << " | " << rsp_str[r_rsp_fsm.read()]
     337                        << " | fifo_cmd = " << r_fifo_cmd.filled_status()
     338                        << " | fifo_rsp = " << r_fifo_rsp.filled_status()
     339                        << std::endl;
     340}
    307341
    308342}} // end namespace
Note: See TracChangeset for help on using the changeset viewer.