Changeset 408 for trunk


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.

Location:
trunk/modules/vci_block_device_tsar/caba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/vci_block_device_tsar/caba/metadata/vci_block_device_tsar.sd

    r374 r408  
    44Module('caba:vci_block_device_tsar',
    55           classname = 'soclib::caba::VciBlockDeviceTsar',
    6            tmpl_parameters = [ parameter.Module('vci_param',  default = 'caba:vci_param'), ],
    7            header_files = ['../source/include/vci_block_device_tsar.h', ],
    8            interface_files = ['../../include/soclib/block_device_tsar.h', ],
    9            implementation_files = ['../source/src/vci_block_device_tsar.cpp',],
    10            ports = [
    11                 Port('caba:vci_target', 'p_vci_target'),
    12                 Port('caba:vci_initiator', 'p_vci_initiator'),
    13                 Port('caba:bit_out', 'p_irq'),
    14                 Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
    15                 Port('caba:clock_in', 'p_clk', auto = 'clock'),
     6
     7        tmpl_parameters = [
     8           parameter.Module('vci_param',  default = 'caba:vci_param'),
     9        ],
     10
     11        header_files = [
     12            '../source/include/vci_block_device_tsar.h',
     13        ],
     14
     15        interface_files = [
     16            '../../include/soclib/block_device_tsar.h',
     17        ],
     18
     19        implementation_files = [
     20            '../source/src/vci_block_device_tsar.cpp',
     21        ],
     22
     23        ports = [
     24                    Port('caba:vci_target', 'p_vci_target'),
     25                    Port('caba:vci_initiator', 'p_vci_initiator'),
     26                    Port('caba:bit_out', 'p_irq'),
     27                    Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
     28                    Port('caba:clock_in', 'p_clk', auto = 'clock'),
    1629                ],
    17            uses = [
    18                 Uses('caba:base_module'),
    19                 Uses('common:mapping_table'),
     30
     31        uses = [
     32                    Uses('caba:base_module'),
     33            Uses('common:mapping_table'),
    2034                ],
    21         instance_parameters = [
     35
     36        instance_parameters = [
    2237                parameter.Module('mt', typename = 'common:mapping_table', auto = 'env:mapping_table'),
    2338                parameter.IntTab('srcid'),
    2439                parameter.IntTab('tgtid'),
    2540                parameter.String('filename'),
    26                 parameter.Int('block_size'),
    27                 parameter.Int('burst_size'),
    28                 parameter.Int('latency'),
    29                 ],
    30            extensions = [
    31                 'dsx:addressable=tgtid',
    32                 'dsx:max_segments=1',
    33                 'dsx:get_ident=tgtid:p_vci_target:mt,srcid:p_vci_initiator:mt',
     41                    parameter.Int('block_size'),
     42                    parameter.Int('burst_size'),
     43                    parameter.Int('latency'),
     44        ],
     45
     46            extensions = [
     47                    'dsx:addressable=tgtid',
     48                    'dsx:max_segments=1',
     49                    'dsx:get_ident=tgtid:p_vci_target:mt,srcid:p_vci_initiator:mt',
    3450                ],
    3551)
  • trunk/modules/vci_block_device_tsar/caba/source/include/vci_block_device_tsar.h

    r400 r408  
    101101
    102102    // Registers
    103     sc_signal<int>                    r_target_fsm;       // target fsm state register
    104     sc_signal<int>                    r_initiator_fsm;    // initiator fsm state register
    105     sc_signal<bool>                   r_irq_enable;       // default value is true
    106     sc_signal<uint32_t>               r_nblocks;          // number of blocks in transfer
    107     sc_signal<uint64_t>               r_buf_address;      // memory buffer address
    108     sc_signal<uint32_t>               r_lba;              // first block index
    109     sc_signal<bool>                   r_read;             // requested operation
    110     sc_signal<uint32_t>               r_index;            // word index in local buffer
    111     sc_signal<uint32_t>               r_latency_count;    // latency counter
    112     sc_signal<uint32_t>               r_words_count;      // word counter (in a burst)
    113     sc_signal<uint32_t>               r_burst_count;      // burst counter (in a block)
    114     sc_signal<uint32_t>               r_block_count;      // block counter (in a transfer)
    115     sc_signal<uint32_t>               r_burst_offset;     // number of non aligned words
    116     sc_signal<uint32_t>               r_burst_nwords;     // number of words in a burst
    117     sc_signal<bool>                   r_go;               // command from T_FSM to M_FSM
    118 
    119     sc_signal<sc_dt::sc_uint<vci_param::S> >    r_srcid;  // save srcid
    120     sc_signal<sc_dt::sc_uint<vci_param::T> >    r_trdid;  // save trdid
    121     sc_signal<sc_dt::sc_uint<vci_param::P> >    r_pktid;  // save pktid
    122 
    123     uint32_t*                         r_local_buffer;     // capacity is one block
     103    sc_signal<int>                     r_target_fsm;       // target fsm state register
     104    sc_signal<int>                     r_initiator_fsm;    // initiator fsm state register
     105    sc_signal<bool>                    r_irq_enable;       // default value is true
     106    sc_signal<uint32_t>                r_nblocks;          // number of blocks in transfer
     107    sc_signal<uint64_t>                r_buf_address;      // memory buffer address
     108    sc_signal<uint32_t>                r_lba;              // first block index
     109    sc_signal<bool>                    r_read;             // requested operation
     110    sc_signal<uint32_t>                r_index;            // word index in local buffer
     111    sc_signal<uint32_t>                r_latency_count;    // latency counter
     112    sc_signal<uint32_t>                r_words_count;      // word counter (in a burst)
     113    sc_signal<uint32_t>                r_burst_count;      // burst counter (in a block)
     114    sc_signal<uint32_t>                r_block_count;      // block counter (in a transfer)
     115    sc_signal<uint32_t>                r_burst_offset;     // number of non aligned words
     116    sc_signal<uint32_t>                r_burst_nwords;     // number of words in a burst
     117    sc_signal<bool>                    r_go;               // command from T_FSM to M_FSM
     118
     119    sc_signal<sc_dt::sc_uint<vci_param::S> >    r_srcid;   // save srcid
     120    sc_signal<sc_dt::sc_uint<vci_param::T> >    r_trdid;   // save trdid
     121    sc_signal<sc_dt::sc_uint<vci_param::P> >    r_pktid;   // save pktid
     122
     123    uint32_t*                          r_local_buffer;     // capacity is one block
    124124
    125125    // structural parameters
    126     soclib::common::Segment           m_segment;          // segment associated to target
    127     uint32_t                          m_srcid;            // initiator index
    128     int                               m_fd;               // File descriptor
    129     uint64_t                          m_device_size;      // Total number of blocks
    130     const uint32_t                    m_words_per_block;  // number of words in a block
    131     const uint32_t                    m_words_per_burst;  // number of words in a burst
    132     const uint32_t                    m_bursts_per_block; // number of bursts in a block
    133     const uint32_t                    m_latency;          // device latency
     126    std::list<soclib::common::Segment> m_seglist;
     127    size_t                             m_nbseg;
     128    uint32_t                           m_srcid;            // initiator index
     129    int                                m_fd;               // File descriptor
     130    uint64_t                           m_device_size;      // Total number of blocks
     131    const uint32_t                     m_words_per_block;  // number of words in a block
     132    const uint32_t                     m_words_per_burst;  // number of words in a burst
     133    const uint32_t                     m_bursts_per_block; // number of bursts in a block
     134    const uint32_t                     m_latency;          // device latency
    134135
    135136    // methods
  • 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.