Index: trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp
===================================================================
--- trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp	(revision 401)
+++ trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp	(revision 408)
@@ -66,11 +66,19 @@
             r_pktid = p_vci_target.pktid.read();
             sc_dt::sc_uint<vci_param::N> address = p_vci_target.address.read();
+
+            bool found = false;
+            std::list<soclib::common::Segment>::iterator seg;
+            for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ ) 
+            {
+                if ( seg->contains(address) ) found = true;
+            }
+ 
             bool                  read    = (p_vci_target.cmd.read() == vci_param::CMD_READ);
             uint32_t              cell    = (uint32_t)((address & 0x3F)>>2);
 
-            if     ( !read && !m_segment.contains(address) )      r_target_fsm = T_WRITE_ERROR;
-            else if(  read && !m_segment.contains(address) )      r_target_fsm = T_READ_ERROR;
-            else if( !read && !p_vci_target.eop.read() )          r_target_fsm = T_WRITE_ERROR;
-            else if(  read && !p_vci_target.eop.read() )          r_target_fsm = T_READ_ERROR;
+            if     ( !read && not found )                         r_target_fsm = T_WRITE_ERROR;
+            else if(  read && not found )                         r_target_fsm = T_READ_ERROR;
+            else if( !read && not p_vci_target.eop.read() )       r_target_fsm = T_WRITE_ERROR;
+            else if(  read && not p_vci_target.eop.read() )       r_target_fsm = T_READ_ERROR;
             else if( !read && (cell == BLOCK_DEVICE_BUFFER) )     r_target_fsm = T_WRITE_BUFFER;
             else if(  read && (cell == BLOCK_DEVICE_BUFFER) )     r_target_fsm = T_READ_BUFFER;
@@ -638,5 +646,6 @@
 
 : caba::BaseModule(name),
-	m_segment(mt.getSegment(tgtid)),
+	m_seglist(mt.getSegmentList(tgtid)),
+    m_nbseg(0),
 	m_srcid(mt.indexForId(srcid)),
 	m_words_per_block(block_size/4),
@@ -658,4 +667,32 @@
     sensitive << p_clk.neg();
 
+    std::list<soclib::common::Segment>::iterator seg;
+    for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ ) 
+    {
+        m_nbseg++;
+        
+	    if ( (seg->baseAddress() & 0x0000003F) != 0 ) 
+	    {
+		    std::cout << "Error in component VciBlockDeviceTsar : " << name 
+		              << "The base address of segment " << seg->name()
+                      << " must be multiple of 64 bytes" << std::endl;
+		    exit(1);
+	    }
+	    if ( seg->size() < 64 ) 
+	    {
+		    std::cout << "Error in component VciBlockDeviceTsar : " << name 
+	                  << "The size of segment " << seg->name()
+                      << " cannot be smaller than 64 bytes" << std::endl;
+		    exit(1);
+	    }
+    }
+
+    if( m_nbseg == 0 )
+    {
+		std::cout << "Error in component VciBlockDeviceTsar : " << name
+		          << " No segment allocated" << std::endl;
+		exit(1);
+    }
+
     if( (block_size != 128)  && 
         (block_size != 256)  && 
@@ -665,8 +702,10 @@
         (block_size != 4096) )
 	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "The block size must be 128, 256, 512, 1024, 2048 or 4096 bytes" << std::endl;
+		std::cout << "Error in component VciBlockDeviceTsar : " << name
+		          << " The block size must be 128, 256, 512, 1024, 2048 or 4096 bytes"
+                  << std::endl;
 		exit(1);
 	}
+
     if( (burst_size != 4 ) && 
 		(burst_size != 8 ) && 
@@ -675,40 +714,31 @@
 		(burst_size != 64) )
 	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "The burst size must be 4, 8, 16, 32 or 64 bytes" << std::endl;
+		std::cout << "Error in component VciBlockDeviceTsar : " << name 
+		          << " The burst size must be 4, 8, 16, 32 or 64 bytes" << std::endl;
 		exit(1);
 	}
-	if ( m_segment.size() < 64 ) 
+
+	if ( (vci_param::B != 4) and (vci_param::B != 8) )
 	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "The size of the segment cannot be smaller than 64 bytes" << std::endl;
+		std::cout << "Error in component VciBlockDeviceTsar : " << name              
+		          << " The VCI data fields must have 32 bits or 64 bits" << std::endl;
 		exit(1);
 	}
-	if ( (m_segment.baseAddress() & 0x0000003F) != 0 ) 
-	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "The base address of the segment must be multiple of 64 bytes" << std::endl;
-		exit(1);
-	}
-	if ( (vci_param::B != 4) and (vci_param::B != 8) )
-	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "The VCI data fields must have 32 bits or 64 bits" << std::endl;
-		exit(1);
-	}
+
 	m_fd = ::open(filename.c_str(), O_RDWR);
 	if ( m_fd < 0 ) 
 	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name << std::endl;
-		std::cout << "Unable to open file " << filename << std::endl;
+		std::cout << "Error in component VciBlockDeviceTsar : " << name 
+		          << " Unable to open file " << filename << std::endl;
 		exit(1);
 	}
 	m_device_size = lseek(m_fd, 0, SEEK_END) / block_size;
-	if ( m_device_size > ((uint64_t)1<<32) ) 
+
+	if ( m_device_size > ((uint64_t)1<<vci_param::N ) ) 
 	{
-		std::cout << "Warning: block device " << name << std::endl;
-		std::cout << "The file " << filename << std::endl;
-		std::cout << "has more blocks than addressable with the 32 bits PIBUS address" << std::endl;
-		m_device_size = ((uint64_t)1<<32);
+		std::cout << "Error in component VciBlockDeviceTsar" << name 
+		          << " The file " << filename
+		          << " has more blocks than addressable with the VCI address" << std::endl;
+		exit(1);
 	}
 
