Changeset 408 for trunk/modules/vci_block_device_tsar/caba/source/src
- Timestamp:
- Jun 12, 2013, 10:38:20 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.