Changeset 580 for trunk


Ignore:
Timestamp:
Nov 23, 2013, 6:19:53 PM (10 years ago)
Author:
alain
Message:

Fixing a bug in target FSM when using 64 bits data width.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp

    r522 r580  
    3232#include "vci_block_device_tsar.h"
    3333
     34#define DEBUG_BDEV   0
     35
    3436namespace soclib { namespace caba {
    3537
     
    6567            r_trdid = p_vci_target.trdid.read();
    6668            r_pktid = p_vci_target.pktid.read();
    67             r_tdata = p_vci_target.wdata.read();
    6869            sc_dt::sc_uint<vci_param::N> address = p_vci_target.address.read();
    6970
     
    9697            else if(  read && (cell == BLOCK_DEVICE_SIZE) )       r_target_fsm = T_READ_SIZE;
    9798            else if(  read && (cell == BLOCK_DEVICE_BLOCK_SIZE) ) r_target_fsm = T_READ_BLOCK;
     99
     100            // get write data value for both 32 bits and 64 bits data width
     101            if( (vci_param::B == 8) and (p_vci_target.be.read() == 0xF0) )
     102                r_tdata = (uint32_t)(p_vci_target.wdata.read()>>32);
     103            else
     104                r_tdata = p_vci_target.wdata.read();
    98105        }
    99106        break;
     
    102109    case T_WRITE_BUFFER:
    103110    {
    104         if (p_vci_target.rspack.read() ) {
    105 #ifdef SOCLIB_MODULE_DEBUG
    106             std::cout << "vci_bd WRITE_BUFFER " << r_tdata.read()
    107                 << " status " << r_initiator_fsm.read() << std::endl;
     111            if (p_vci_target.rspack.read() )
     112        {
     113            if (r_initiator_fsm.read() == M_IDLE)
     114            {
     115
     116#if DEBUG_BDEV
     117std::cout << "  <BDEV_TGT WRITE_BUFFER> value = " << r_tdata.read() << std::endl;
    108118#endif
    109             if (r_initiator_fsm.read() == M_IDLE)
    110             {
    111119                r_buf_address = (uint64_t)r_tdata.read();
    112120                r_target_fsm  = T_IDLE;
    113             }
     121                }
    114122        }
    115123        break;
     
    118126    case T_WRITE_BUFFER_EXT:
    119127    {
    120         if (p_vci_target.rspack.read() ) {
    121 #ifdef SOCLIB_MODULE_DEBUG
    122             std::cout << "vci_bd WRITE_BUFFER_EXT " << r_tdata.read()
    123                 << " status " << r_initiator_fsm.read() << std::endl;
     128        if (p_vci_target.rspack.read() )
     129        {
     130            if (r_initiator_fsm.read() == M_IDLE)
     131            {
     132
     133#if DEBUG_BDEV
     134std::cout << "  <BDEV_TGT WRITE_BUFFER_EXT> value = " << r_tdata.read() << std::endl;
    124135#endif
    125             if (r_initiator_fsm.read() == M_IDLE)
    126             {
    127                 r_buf_address = r_buf_address.read() +
    128                             (((uint64_t)r_tdata.read())<<32);
     136                r_buf_address = r_buf_address.read() + (((uint64_t)r_tdata.read())<<32);
    129137                r_target_fsm  = T_IDLE;
    130             }
     138            }
    131139        }
    132140        break;
     
    135143    case T_WRITE_COUNT:
    136144    {
    137         if (p_vci_target.rspack.read() ) {
    138 #ifdef SOCLIB_MODULE_DEBUG
    139             std::cout << "vci_bd WRITE_COUNT " << r_tdata.read() <<
    140                 " status " << r_initiator_fsm.read() << std::endl;
     145        if (p_vci_target.rspack.read() )
     146        {
     147            if (r_initiator_fsm.read() == M_IDLE)
     148            {
     149
     150#if DEBUG_BDEV
     151std::cout << "  <BDEV_TGT WRITE_COUNT> value = " << r_tdata.read() << std::endl;
    141152#endif
    142             if (r_initiator_fsm.read() == M_IDLE)
    143             {
    144153                r_nblocks    = (uint32_t)r_tdata.read();
    145154                r_target_fsm = T_IDLE;
    146155            }
    147         }
     156        }
    148157        break;
    149158    }
     
    151160    case T_WRITE_LBA:
    152161    {
    153         if (p_vci_target.rspack.read() ) {
    154 #ifdef SOCLIB_MODULE_DEBUG
    155             std::cout << "vci_bd WRITE_LBA " << r_tdata.read() <<
    156                 " status " << r_initiator_fsm.read() << std::endl;
     162        if (p_vci_target.rspack.read() )
     163        {
     164            if (r_initiator_fsm.read() == M_IDLE)
     165            {
     166
     167#if DEBUG_BDEV
     168std::cout << "  <BDEV_TGT WRITE_LBA> value = " << r_tdata.read() << std::endl;
    157169#endif
    158             if (r_initiator_fsm.read() == M_IDLE) {
    159170                r_lba        = (uint32_t)r_tdata.read();
    160171                r_target_fsm = T_IDLE;
    161172            }
    162         }
     173        }
    163174        break;
    164175    }
     
    168179        if ( p_vci_target.rspack.read() ) 
    169180        {
    170 #ifdef SOCLIB_MODULE_DEBUG
    171             std::cout << "vci_bd WRITE_OP " << r_tdata.read() <<
    172                 " status " << r_initiator_fsm.read();
    173 #endif
    174181            if ( ((uint32_t)r_tdata.read() == BLOCK_DEVICE_READ) and
    175182                 (r_initiator_fsm.read() == M_IDLE) )
    176183            {
     184
     185#if DEBUG_BDEV
     186std::cout << "  <BDEV_TGT WRITE_LBA> value = READ" << std::endl;
     187#endif
    177188                r_read = true;
    178189                r_go   = true;
    179 #ifdef SOCLIB_MODULE_DEBUG
    180                 std::cout << " READ";
    181 #endif
    182190            }
    183191            else if ( ((uint32_t)r_tdata.read() == BLOCK_DEVICE_WRITE) and
    184192                      (r_initiator_fsm.read() == M_IDLE) )
    185193            {
     194
     195#if DEBUG_BDEV
     196std::cout << "  <BDEV_TGT WRITE_LBA> value = WRITE" << std::endl;
     197#endif
    186198                r_read = false;
    187199                r_go   = true;
    188 #ifdef SOCLIB_MODULE_DEBUG
    189                 std::cout << " WRITE";
     200            }
     201            else
     202            {
     203
     204#if DEBUG_BDEV
     205std::cout << "  <BDEV_TGT WRITE_LBA> value = SOFT RESET" << std::endl;
    190206#endif
    191             }
    192             else
    193             {
    194207                r_go   = false;
    195208            }
    196209            r_target_fsm = T_IDLE;
    197 #ifdef SOCLIB_MODULE_DEBUG
    198             std::cout << std::endl;
    199 #endif
    200210        }
    201211        break;
     
    206216        if ( p_vci_target.rspack.read() )
    207217        {
    208 #ifdef SOCLIB_MODULE_DEBUG
    209             std::cout << "vci_bd WRITE_IRQEN " << r_tdata.read()
    210                 << " status " << r_initiator_fsm.read() << std::endl;
     218
     219#if DEBUG_BDEV
     220std::cout << "  <BDEV_TGT WRITE_IRQEN> value = " << r_tdata.read() << std::endl;
    211221#endif
    212222            r_target_fsm = T_IDLE;
     
    289299            {
    290300                r_initiator_fsm = M_READ_ERROR;
    291 #ifdef SOCLIB_MODULE_DEBUG
    292                 std::cout << "vci_bd M_READ_ERROR" << std::endl;
    293 #endif
    294301            }
    295302            else   
    296303            {
    297304                r_burst_count   = 0;
    298                 r_words_count    = 0;
     305                r_words_count   = 0;
    299306                r_initiator_fsm = M_READ_BURST;
    300307            }
     
    389396            {
    390397                r_initiator_fsm = M_READ_ERROR;
    391 #ifdef SOCLIB_MODULE_DEBUG
    392                 std::cout << "vci_bd M_READ_ERROR" << std::endl;
    393 #endif
    394398            }
    395399            else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or
     
    399403                {
    400404                    r_initiator_fsm = M_READ_SUCCESS;
    401 #ifdef SOCLIB_MODULE_DEBUG
    402                     std::cout << "vci_bd M_READ_SUCCESS" << std::endl;
    403 #endif
    404405                }
    405406                else                                              // last burst not last block
     
    480481                {
    481482                    r_initiator_fsm = M_WRITE_ERROR;
    482 #ifdef SOCLIB_MODULE_DEBUG
    483                     std::cout << "vci_bd M_WRITE_ERROR" << std::endl;
    484 #endif
    485483                }
    486484                else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or
     
    512510            {
    513511                r_initiator_fsm = M_WRITE_ERROR;
    514 #ifdef SOCLIB_MODULE_DEBUG
    515                 std::cout << "vci_bd M_WRITE_ERROR" << std::endl;
    516 #endif
    517512            }
    518513            else if ( r_block_count.read() == r_nblocks.read() - 1 )
    519514            {
    520515                r_initiator_fsm = M_WRITE_SUCCESS;
    521 #ifdef SOCLIB_MODULE_DEBUG
    522                 std::cout << "vci_bd M_WRITE_SUCCESS" << std::endl;
    523 #endif
    524516            }
    525517            else
     
    693685          (r_initiator_fsm == M_READ_ERROR)    ||
    694686          (r_initiator_fsm == M_WRITE_ERROR) ) && 
    695          r_irq_enable.read() ) {
    696 #ifdef SOCLIB_MODULE_DEBUG
    697                 std::cout << "vci_bd send IRQ" << std::endl;
     687         r_irq_enable.read() )
     688    {
     689
     690#if DEBUG_BDEV
     691std::cout << "  <BDEV_INI send IRQ>" << std::endl;
    698692#endif
    699693                p_irq = true;
    700     } else                                 p_irq = false;
     694    }
     695    else
     696    {
     697        p_irq = false;
     698    }
    701699} // end GenMoore()
    702700
     
    817815} // end constructor
    818816
     817/////////////////////////////////
    819818tmpl(/**/)::~VciBlockDeviceTsar()
    820819{
     
    828827        const char* initiator_str[] =
    829828    {
    830                 "IDLE",
    831 
    832                 "READ_BLOCK",
    833                 "READ_BURST",
    834                 "READ_CMD",
    835                 "READ_RSP",
    836                 "READ_SUCCESS",
    837                 "READ_ERROR",
    838 
    839                 "WRITE_BURST",
    840                 "WRITE_CMD",
    841                 "WRITE_RSP",
    842                 "WRITE_BLOCK",
    843                 "WRITE_SUCCESS",
    844                 "WRITE_ERROR",
     829                "INI_IDLE",
     830
     831                "INI_READ_BLOCK",
     832                "INI_READ_BURST",
     833                "INI_READ_CMD",
     834                "INI_READ_RSP",
     835                "INI_READ_SUCCESS",
     836                "INI_READ_ERROR",
     837
     838                "INI_WRITE_BURST",
     839                "INI_WRITE_CMD",
     840                "INI_WRITE_RSP",
     841                "INI_WRITE_BLOCK",
     842                "INI_WRITE_SUCCESS",
     843                "INI_WRITE_ERROR",
    845844        };
    846845        const char* target_str[] =
    847846    {
    848                 "IDLE",
    849                 "WRITE_BUFFER",
    850                 "READ_BUFFER",
    851                 "WRITE_BUFFER_EXT",
    852                 "READ_BUFFER_EXT",
    853                 "WRITE_COUNT",
    854                 "READ_COUNT",
    855                 "WRITE_LBA",
    856                 "READ_LBA",
    857                 "WRITE_OP",
    858                 "READ_STATUS",
    859                 "WRITE_IRQEN",
    860                 "READ_IRQEN",
    861                 "READ_SIZE",
    862                 "READ_BLOCK",
    863                 "READ_ERROR",
    864                 "WRITE_ERROR ",
     847                "TGT_IDLE",
     848                "TGT_WRITE_BUFFER",
     849                "TGT_READ_BUFFER",
     850                "TGT_WRITE_BUFFER_EXT",
     851                "TGT_READ_BUFFER_EXT",
     852                "TGT_WRITE_COUNT",
     853                "TGT_READ_COUNT",
     854                "TGT_WRITE_LBA",
     855                "TGT_READ_LBA",
     856                "TGT_WRITE_OP",
     857                "TGT_READ_STATUS",
     858                "TGT_WRITE_IRQEN",
     859                "TGT_READ_IRQEN",
     860                "TGT_READ_SIZE",
     861                "TGT_READ_BLOCK",
     862                "TGT_READ_ERROR",
     863                "TGT_WRITE_ERROR ",
    865864        };
    866865
    867         std::cout << "BDEV_TGT : " << target_str[r_target_fsm.read()]
    868                   << "  BDEV_INI : " << initiator_str[r_initiator_fsm.read()]
    869           << "  buf = " << std::hex << r_buf_address.read()
    870                   << "  block = " << std::dec << r_block_count.read()
    871                   << "  burst = " << r_burst_count.read()
    872                   << "  word  = " << r_words_count.read() <<std::endl;
     866        std::cout << "BDEV " << name()
     867              << " : " << target_str[r_target_fsm.read()]
     868                      << " / " << initiator_str[r_initiator_fsm.read()]
     869              << " / buf = " << std::hex << r_buf_address.read()
     870              << " / lba = " << std::hex << r_lba.read()
     871                      << " / block_count = " << std::dec << r_block_count.read()
     872                      << " / burst_count = " << r_burst_count.read()
     873                      << " / word_count = " << r_words_count.read() <<std::endl;
    873874}
    874875
Note: See TracChangeset for help on using the changeset viewer.