Ignore:
Timestamp:
Jun 12, 2013, 10:38:20 AM (11 years ago)
Author:
alain
Message:

Introducing support for several segments (required by tsar_generic_iob platform.

File:
1 edited

Legend:

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

    r401 r408  
    6666            r_pktid = p_vci_target.pktid.read();
    6767            sc_dt::sc_uint<vci_param::N> address = p_vci_target.address.read();
     68
     69            bool found = false;
     70            std::list<soclib::common::Segment>::iterator seg;
     71            for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ )
     72            {
     73                if ( seg->contains(address) ) found = true;
     74            }
     75 
    6876            bool                  read    = (p_vci_target.cmd.read() == vci_param::CMD_READ);
    6977            uint32_t              cell    = (uint32_t)((address & 0x3F)>>2);
    7078
    71             if     ( !read && !m_segment.contains(address) )      r_target_fsm = T_WRITE_ERROR;
    72             else if(  read && !m_segment.contains(address) )      r_target_fsm = T_READ_ERROR;
    73             else if( !read && !p_vci_target.eop.read() )          r_target_fsm = T_WRITE_ERROR;
    74             else if(  read && !p_vci_target.eop.read() )          r_target_fsm = T_READ_ERROR;
     79            if     ( !read && not found )                         r_target_fsm = T_WRITE_ERROR;
     80            else if(  read && not found )                         r_target_fsm = T_READ_ERROR;
     81            else if( !read && not p_vci_target.eop.read() )       r_target_fsm = T_WRITE_ERROR;
     82            else if(  read && not p_vci_target.eop.read() )       r_target_fsm = T_READ_ERROR;
    7583            else if( !read && (cell == BLOCK_DEVICE_BUFFER) )     r_target_fsm = T_WRITE_BUFFER;
    7684            else if(  read && (cell == BLOCK_DEVICE_BUFFER) )     r_target_fsm = T_READ_BUFFER;
     
    638646
    639647: caba::BaseModule(name),
    640         m_segment(mt.getSegment(tgtid)),
     648        m_seglist(mt.getSegmentList(tgtid)),
     649    m_nbseg(0),
    641650        m_srcid(mt.indexForId(srcid)),
    642651        m_words_per_block(block_size/4),
     
    658667    sensitive << p_clk.neg();
    659668
     669    std::list<soclib::common::Segment>::iterator seg;
     670    for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ )
     671    {
     672        m_nbseg++;
     673       
     674            if ( (seg->baseAddress() & 0x0000003F) != 0 )
     675            {
     676                    std::cout << "Error in component VciBlockDeviceTsar : " << name
     677                              << "The base address of segment " << seg->name()
     678                      << " must be multiple of 64 bytes" << std::endl;
     679                    exit(1);
     680            }
     681            if ( seg->size() < 64 )
     682            {
     683                    std::cout << "Error in component VciBlockDeviceTsar : " << name
     684                          << "The size of segment " << seg->name()
     685                      << " cannot be smaller than 64 bytes" << std::endl;
     686                    exit(1);
     687            }
     688    }
     689
     690    if( m_nbseg == 0 )
     691    {
     692                std::cout << "Error in component VciBlockDeviceTsar : " << name
     693                          << " No segment allocated" << std::endl;
     694                exit(1);
     695    }
     696
    660697    if( (block_size != 128)  &&
    661698        (block_size != 256)  &&
     
    665702        (block_size != 4096) )
    666703        {
    667                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    668                 std::cout << "The block size must be 128, 256, 512, 1024, 2048 or 4096 bytes" << std::endl;
     704                std::cout << "Error in component VciBlockDeviceTsar : " << name
     705                          << " The block size must be 128, 256, 512, 1024, 2048 or 4096 bytes"
     706                  << std::endl;
    669707                exit(1);
    670708        }
     709
    671710    if( (burst_size != 4 ) &&
    672711                (burst_size != 8 ) &&
     
    675714                (burst_size != 64) )
    676715        {
    677                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    678                 std::cout << "The burst size must be 4, 8, 16, 32 or 64 bytes" << std::endl;
     716                std::cout << "Error in component VciBlockDeviceTsar : " << name
     717                          << " The burst size must be 4, 8, 16, 32 or 64 bytes" << std::endl;
    679718                exit(1);
    680719        }
    681         if ( m_segment.size() < 64 )
     720
     721        if ( (vci_param::B != 4) and (vci_param::B != 8) )
    682722        {
    683                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    684                 std::cout << "The size of the segment cannot be smaller than 64 bytes" << std::endl;
     723                std::cout << "Error in component VciBlockDeviceTsar : " << name              
     724                          << " The VCI data fields must have 32 bits or 64 bits" << std::endl;
    685725                exit(1);
    686726        }
    687         if ( (m_segment.baseAddress() & 0x0000003F) != 0 )
    688         {
    689                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    690                 std::cout << "The base address of the segment must be multiple of 64 bytes" << std::endl;
    691                 exit(1);
    692         }
    693         if ( (vci_param::B != 4) and (vci_param::B != 8) )
    694         {
    695                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    696                 std::cout << "The VCI data fields must have 32 bits or 64 bits" << std::endl;
    697                 exit(1);
    698         }
     727
    699728        m_fd = ::open(filename.c_str(), O_RDWR);
    700729        if ( m_fd < 0 )
    701730        {
    702                 std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
    703                 std::cout << "Unable to open file " << filename << std::endl;
     731                std::cout << "Error in component VciBlockDeviceTsar : " << name
     732                          << " Unable to open file " << filename << std::endl;
    704733                exit(1);
    705734        }
    706735        m_device_size = lseek(m_fd, 0, SEEK_END) / block_size;
    707         if ( m_device_size > ((uint64_t)1<<32) )
     736
     737        if ( m_device_size > ((uint64_t)1<<vci_param::N ) )
    708738        {
    709                 std::cout << "Warning: block device " << name << std::endl;
    710                 std::cout << "The file " << filename << std::endl;
    711                 std::cout << "has more blocks than addressable with the 32 bits PIBUS address" << std::endl;
    712                 m_device_size = ((uint64_t)1<<32);
     739                std::cout << "Error in component VciBlockDeviceTsar" << name
     740                          << " The file " << filename
     741                          << " has more blocks than addressable with the VCI address" << std::endl;
     742                exit(1);
    713743        }
    714744
Note: See TracChangeset for help on using the changeset viewer.