Index: /trunk/modules/vci_block_device_tsar/caba/metadata/vci_block_device_tsar.sd
===================================================================
--- /trunk/modules/vci_block_device_tsar/caba/metadata/vci_block_device_tsar.sd	(revision 407)
+++ /trunk/modules/vci_block_device_tsar/caba/metadata/vci_block_device_tsar.sd	(revision 408)
@@ -4,32 +4,48 @@
 Module('caba:vci_block_device_tsar',
 	   classname = 'soclib::caba::VciBlockDeviceTsar',
-	   tmpl_parameters = [ parameter.Module('vci_param',  default = 'caba:vci_param'), ],
-	   header_files = ['../source/include/vci_block_device_tsar.h', ],
-           interface_files = ['../../include/soclib/block_device_tsar.h', ],
-	   implementation_files = ['../source/src/vci_block_device_tsar.cpp',],
-	   ports = [
-		Port('caba:vci_target', 'p_vci_target'),
-		Port('caba:vci_initiator', 'p_vci_initiator'),
-		Port('caba:bit_out', 'p_irq'),
-		Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
-		Port('caba:clock_in', 'p_clk', auto = 'clock'), 
+
+        tmpl_parameters = [ 
+           parameter.Module('vci_param',  default = 'caba:vci_param'), 
+        ],
+
+        header_files = [
+            '../source/include/vci_block_device_tsar.h', 
+        ],
+
+        interface_files = [
+            '../../include/soclib/block_device_tsar.h', 
+        ],
+
+        implementation_files = [
+            '../source/src/vci_block_device_tsar.cpp',
+        ],
+
+        ports = [
+		    Port('caba:vci_target', 'p_vci_target'),
+		    Port('caba:vci_initiator', 'p_vci_initiator'),
+		    Port('caba:bit_out', 'p_irq'),
+		    Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
+		    Port('caba:clock_in', 'p_clk', auto = 'clock'), 
 		],
-	   uses = [
-		Uses('caba:base_module'),
-		Uses('common:mapping_table'),
+
+        uses = [
+		    Uses('caba:base_module'),
+            Uses('common:mapping_table'),
 		],
-	instance_parameters = [
+
+        instance_parameters = [
         	parameter.Module('mt', typename = 'common:mapping_table', auto = 'env:mapping_table'),
         	parameter.IntTab('srcid'),
         	parameter.IntTab('tgtid'),
         	parameter.String('filename'),
-		parameter.Int('block_size'),
-		parameter.Int('burst_size'),
-		parameter.Int('latency'),
-        	],
-	   extensions = [
-		'dsx:addressable=tgtid',
-		'dsx:max_segments=1',
-		'dsx:get_ident=tgtid:p_vci_target:mt,srcid:p_vci_initiator:mt',
+		    parameter.Int('block_size'),
+		    parameter.Int('burst_size'),
+		    parameter.Int('latency'),
+        ],
+
+	    extensions = [
+		    'dsx:addressable=tgtid',
+		    'dsx:max_segments=1',
+		    'dsx:get_ident=tgtid:p_vci_target:mt,srcid:p_vci_initiator:mt',
 		],
 )
Index: /trunk/modules/vci_block_device_tsar/caba/source/include/vci_block_device_tsar.h
===================================================================
--- /trunk/modules/vci_block_device_tsar/caba/source/include/vci_block_device_tsar.h	(revision 407)
+++ /trunk/modules/vci_block_device_tsar/caba/source/include/vci_block_device_tsar.h	(revision 408)
@@ -101,35 +101,36 @@
 
     // Registers
-    sc_signal<int>            	      r_target_fsm;   	  // target fsm state register
-    sc_signal<int>                    r_initiator_fsm;    // initiator fsm state register
-    sc_signal<bool>                   r_irq_enable;   	  // default value is true
-    sc_signal<uint32_t>               r_nblocks;      	  // number of blocks in transfer
-    sc_signal<uint64_t>               r_buf_address;  	  // memory buffer address 
-    sc_signal<uint32_t>               r_lba;          	  // first block index
-    sc_signal<bool>                   r_read;         	  // requested operation
-    sc_signal<uint32_t>               r_index;        	  // word index in local buffer
-    sc_signal<uint32_t>               r_latency_count;    // latency counter 
-    sc_signal<uint32_t>               r_words_count;   	  // word counter (in a burst)
-    sc_signal<uint32_t>               r_burst_count;   	  // burst counter (in a block)
-    sc_signal<uint32_t>               r_block_count;  	  // block counter (in a transfer)
-    sc_signal<uint32_t>               r_burst_offset;     // number of non aligned words
-    sc_signal<uint32_t>               r_burst_nwords;     // number of words in a burst
-    sc_signal<bool>                   r_go;           	  // command from T_FSM to M_FSM
-
-    sc_signal<sc_dt::sc_uint<vci_param::S> >	r_srcid;  // save srcid
-    sc_signal<sc_dt::sc_uint<vci_param::T> >	r_trdid;  // save trdid
-    sc_signal<sc_dt::sc_uint<vci_param::P> >	r_pktid;  // save pktid
-
-    uint32_t*                         r_local_buffer; 	  // capacity is one block 
+    sc_signal<int>            	       r_target_fsm;   	   // target fsm state register
+    sc_signal<int>                     r_initiator_fsm;    // initiator fsm state register
+    sc_signal<bool>                    r_irq_enable;   	   // default value is true
+    sc_signal<uint32_t>                r_nblocks;      	   // number of blocks in transfer
+    sc_signal<uint64_t>                r_buf_address;  	   // memory buffer address 
+    sc_signal<uint32_t>                r_lba;          	   // first block index
+    sc_signal<bool>                    r_read;         	   // requested operation
+    sc_signal<uint32_t>                r_index;        	   // word index in local buffer
+    sc_signal<uint32_t>                r_latency_count;    // latency counter 
+    sc_signal<uint32_t>                r_words_count;      // word counter (in a burst)
+    sc_signal<uint32_t>                r_burst_count;      // burst counter (in a block)
+    sc_signal<uint32_t>                r_block_count;  	   // block counter (in a transfer)
+    sc_signal<uint32_t>                r_burst_offset;     // number of non aligned words
+    sc_signal<uint32_t>                r_burst_nwords;     // number of words in a burst
+    sc_signal<bool>                    r_go;           	   // command from T_FSM to M_FSM
+
+    sc_signal<sc_dt::sc_uint<vci_param::S> >	r_srcid;   // save srcid
+    sc_signal<sc_dt::sc_uint<vci_param::T> >	r_trdid;   // save trdid
+    sc_signal<sc_dt::sc_uint<vci_param::P> >	r_pktid;   // save pktid
+
+    uint32_t*                          r_local_buffer; 	   // capacity is one block 
 
     // structural parameters
-    soclib::common::Segment           m_segment;      	  // segment associated to target
-    uint32_t                          m_srcid;        	  // initiator index
-    int                               m_fd;           	  // File descriptor
-    uint64_t                          m_device_size;  	  // Total number of blocks
-    const uint32_t                    m_words_per_block;  // number of words in a block
-    const uint32_t                    m_words_per_burst;  // number of words in a burst
-    const uint32_t                    m_bursts_per_block; // number of bursts in a block
-    const uint32_t                    m_latency;      	  // device latency
+    std::list<soclib::common::Segment> m_seglist;
+    size_t                             m_nbseg;
+    uint32_t                           m_srcid;        	   // initiator index
+    int                                m_fd;           	   // File descriptor
+    uint64_t                           m_device_size;  	   // Total number of blocks
+    const uint32_t                     m_words_per_block;  // number of words in a block
+    const uint32_t                     m_words_per_burst;  // number of words in a burst
+    const uint32_t                     m_bursts_per_block; // number of bursts in a block
+    const uint32_t                     m_latency;      	   // device latency
 
     // methods
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 407)
+++ /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);
 	}
 
