Changeset 408 for trunk/modules/vci_block_device_tsar
- Timestamp:
- Jun 12, 2013, 10:38:20 AM (12 years ago)
- 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 4 4 Module('caba:vci_block_device_tsar', 5 5 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'), 16 29 ], 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'), 20 34 ], 21 instance_parameters = [ 35 36 instance_parameters = [ 22 37 parameter.Module('mt', typename = 'common:mapping_table', auto = 'env:mapping_table'), 23 38 parameter.IntTab('srcid'), 24 39 parameter.IntTab('tgtid'), 25 40 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', 34 50 ], 35 51 ) -
trunk/modules/vci_block_device_tsar/caba/source/include/vci_block_device_tsar.h
r400 r408 101 101 102 102 // Registers 103 sc_signal<int> r_target_fsm;// target fsm state register104 sc_signal<int> r_initiator_fsm; // initiator fsm state register105 sc_signal<bool> r_irq_enable;// default value is true106 sc_signal<uint32_t> r_nblocks;// number of blocks in transfer107 sc_signal<uint64_t> r_buf_address;// memory buffer address108 sc_signal<uint32_t> r_lba;// first block index109 sc_signal<bool> r_read;// requested operation110 sc_signal<uint32_t> r_index;// word index in local buffer111 sc_signal<uint32_t> r_latency_count; // latency counter112 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 words116 sc_signal<uint32_t> r_burst_nwords; // number of words in a burst117 sc_signal<bool> r_go;// command from T_FSM to M_FSM118 119 sc_signal<sc_dt::sc_uint<vci_param::S> > r_srcid; // save srcid120 sc_signal<sc_dt::sc_uint<vci_param::T> > r_trdid; // save trdid121 sc_signal<sc_dt::sc_uint<vci_param::P> > r_pktid; // save pktid122 123 uint32_t* r_local_buffer;// capacity is one block103 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 124 124 125 125 // 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 134 135 135 136 // methods -
trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp
r401 r408 66 66 r_pktid = p_vci_target.pktid.read(); 67 67 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 68 76 bool read = (p_vci_target.cmd.read() == vci_param::CMD_READ); 69 77 uint32_t cell = (uint32_t)((address & 0x3F)>>2); 70 78 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; 75 83 else if( !read && (cell == BLOCK_DEVICE_BUFFER) ) r_target_fsm = T_WRITE_BUFFER; 76 84 else if( read && (cell == BLOCK_DEVICE_BUFFER) ) r_target_fsm = T_READ_BUFFER; … … 638 646 639 647 : caba::BaseModule(name), 640 m_segment(mt.getSegment(tgtid)), 648 m_seglist(mt.getSegmentList(tgtid)), 649 m_nbseg(0), 641 650 m_srcid(mt.indexForId(srcid)), 642 651 m_words_per_block(block_size/4), … … 658 667 sensitive << p_clk.neg(); 659 668 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 660 697 if( (block_size != 128) && 661 698 (block_size != 256) && … … 665 702 (block_size != 4096) ) 666 703 { 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; 669 707 exit(1); 670 708 } 709 671 710 if( (burst_size != 4 ) && 672 711 (burst_size != 8 ) && … … 675 714 (burst_size != 64) ) 676 715 { 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; 679 718 exit(1); 680 719 } 681 if ( m_segment.size() < 64 ) 720 721 if ( (vci_param::B != 4) and (vci_param::B != 8) ) 682 722 { 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; 685 725 exit(1); 686 726 } 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 699 728 m_fd = ::open(filename.c_str(), O_RDWR); 700 729 if ( m_fd < 0 ) 701 730 { 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; 704 733 exit(1); 705 734 } 706 735 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 ) ) 708 738 { 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 PIBUSaddress" << 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); 713 743 } 714 744
Note: See TracChangeset
for help on using the changeset viewer.