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 896)
+++ trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp	(revision 898)
@@ -2,21 +2,21 @@
  *
  * SOCLIB_LGPL_HEADER_BEGIN
- * 
+ *
  * This file is part of SoCLib, GNU LGPLv2.1.
- * 
+ *
  * SoCLib is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; version 2.1 of the License.
- * 
+ *
  * SoCLib is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with SoCLib; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
- * 
+ *
  * SOCLIB_LGPL_HEADER_END
  *
@@ -45,5 +45,5 @@
 tmpl(void)::transition()
 {
-    if(p_resetn.read() == false) 
+    if(p_resetn.read() == false)
     {
         r_initiator_fsm   = M_IDLE;
@@ -52,5 +52,5 @@
         r_go              = false;
         return;
-    } 
+    }
 
     //////////////////////////////////////////////////////////////////////////////
@@ -63,6 +63,6 @@
     case T_IDLE:
     {
-        if ( p_vci_target.cmdval.read() ) 
-        { 
+        if ( p_vci_target.cmdval.read() )
+        {
             r_srcid = p_vci_target.srcid.read();
             r_trdid = p_vci_target.trdid.read();
@@ -72,11 +72,12 @@
             bool found = false;
             std::list<soclib::common::Segment>::iterator seg;
-            for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; 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);
+
+            bool     read = (p_vci_target.cmd.read() == vci_param::CMD_READ);
+            uint32_t cell = (uint32_t)((address & 0x3F)>>2);
+            bool     pending = (r_initiator_fsm.read() != M_IDLE);
 
             if     ( !read && not found )                         r_target_fsm = T_WRITE_ERROR;
@@ -84,4 +85,5 @@
             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 && pending )                           r_target_fsm = T_WRITE_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;
@@ -100,5 +102,5 @@
 
             // get write data value for both 32 bits and 64 bits data width
-            if( (vci_param::B == 8) and (p_vci_target.be.read() == 0xF0) ) 
+            if( (vci_param::B == 8) and (p_vci_target.be.read() == 0xF0) )
                 r_tdata = (uint32_t)(p_vci_target.wdata.read()>>32);
             else
@@ -110,15 +112,11 @@
     case T_WRITE_BUFFER:
     {
-	    if (p_vci_target.rspack.read() ) 
-        {
-            if (r_initiator_fsm.read() == M_IDLE)
-            {
-
+        if (p_vci_target.rspack.read() )
+        {
 #if DEBUG_BDEV
 std::cout << "  <BDEV_TGT WRITE_BUFFER> value = " << r_tdata.read() << std::endl;
 #endif
-                r_buf_address = (uint64_t)r_tdata.read();
-                r_target_fsm  = T_IDLE;
-	        }
+            r_buf_address = (uint64_t)r_tdata.read();
+            r_target_fsm  = T_IDLE;
         }
         break;
@@ -127,15 +125,11 @@
     case T_WRITE_BUFFER_EXT:
     {
-        if (p_vci_target.rspack.read() ) 
-        {
-            if (r_initiator_fsm.read() == M_IDLE)
-            {
-
+        if (p_vci_target.rspack.read() )
+        {
 #if DEBUG_BDEV
 std::cout << "  <BDEV_TGT WRITE_BUFFER_EXT> value = " << r_tdata.read() << std::endl;
 #endif
-                r_buf_address = r_buf_address.read() + (((uint64_t)r_tdata.read())<<32);
-                r_target_fsm  = T_IDLE;
-            }
+            r_buf_address = r_buf_address.read() + (((uint64_t)r_tdata.read())<<32);
+            r_target_fsm  = T_IDLE;
         }
         break;
@@ -144,15 +138,11 @@
     case T_WRITE_COUNT:
     {
-        if (p_vci_target.rspack.read() ) 
-        {
-            if (r_initiator_fsm.read() == M_IDLE)
-            {
-
+        if (p_vci_target.rspack.read() )
+        {
 #if DEBUG_BDEV
 std::cout << "  <BDEV_TGT WRITE_COUNT> value = " << r_tdata.read() << std::endl;
 #endif
-                r_nblocks    = (uint32_t)r_tdata.read();
-                r_target_fsm = T_IDLE;
-            }
+            r_nblocks    = (uint32_t)r_tdata.read();
+            r_target_fsm = T_IDLE;
         }
         break;
@@ -161,15 +151,11 @@
     case T_WRITE_LBA:
     {
-        if (p_vci_target.rspack.read() ) 
-        {
-            if (r_initiator_fsm.read() == M_IDLE) 
-            {
-
+        if (p_vci_target.rspack.read() )
+        {
 #if DEBUG_BDEV
 std::cout << "  <BDEV_TGT WRITE_LBA> value = " << r_tdata.read() << std::endl;
 #endif
-                r_lba        = (uint32_t)r_tdata.read();
-                r_target_fsm = T_IDLE;
-            }
+            r_lba        = (uint32_t)r_tdata.read();
+            r_target_fsm = T_IDLE;
         }
         break;
@@ -178,5 +164,5 @@
     case T_WRITE_OP:
     {
-        if ( p_vci_target.rspack.read() )  
+        if ( p_vci_target.rspack.read() )
         {
             if ( ((uint32_t)r_tdata.read() == BLOCK_DEVICE_READ) and
@@ -215,5 +201,5 @@
     case T_WRITE_IRQEN:
     {
-        if ( p_vci_target.rspack.read() ) 
+        if ( p_vci_target.rspack.read() )
         {
 
@@ -243,5 +229,5 @@
     case T_READ_STATUS:
     {
-        if ( p_vci_target.rspack.read() ) 
+        if ( p_vci_target.rspack.read() )
         {
             r_target_fsm = T_IDLE;
@@ -254,5 +240,5 @@
     }
     } // end switch target fsm
-	
+
     //////////////////////////////////////////////////////////////////////////////
     // The initiator FSM executes a loop, transfering one block per iteration.
@@ -262,5 +248,5 @@
     //   and the number of bursts is (m_bursts_per_block).
     // - If buffer not aligned, the number of bursts is (m_bursts_per_block + 1)
-    //   and first and last burst are shorter, because all words in a burst 
+    //   and first and last burst are shorter, because all words in a burst
     //   must be contained in a single cache line.
     //   first burst => nwords = m_words_per_burst - offset
@@ -271,7 +257,7 @@
     switch( r_initiator_fsm.read() ) {
     ////////////
-    case M_IDLE: 	// check buffer alignment to compute the number of bursts
-    {
-        if ( r_go.read() ) 
+    case M_IDLE:    // check buffer alignment to compute the number of bursts
+    {
+        if ( r_go.read() )
         {
             r_index         = 0;
@@ -285,9 +271,9 @@
 
             // start tranfer
-            if ( r_read.read() ) 	r_initiator_fsm = M_READ_BLOCK;
+            if ( r_read.read() )    r_initiator_fsm = M_READ_BLOCK;
             else                    r_initiator_fsm = M_WRITE_BURST;
         }
         break;
-    } 
+    }
     //////////////////
     case M_READ_BLOCK:  // read one block from disk after waiting m_latency cycles
@@ -297,9 +283,9 @@
             r_latency_count = m_latency;
             ::lseek(m_fd, (r_lba + r_block_count)*m_words_per_block*4, SEEK_SET);
-            if( ::read(m_fd, r_local_buffer, m_words_per_block*4) < 0 )  
+            if( ::read(m_fd, r_local_buffer, m_words_per_block*4) < 0 )
             {
                 r_initiator_fsm = M_READ_ERROR;
             }
-            else   
+            else
             {
                 r_burst_count   = 0;
@@ -309,5 +295,5 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////
-//std::cout << "***** Block content after read for lba " 
+//std::cout << "***** Block content after read for lba "
 //          << std::hex << r_lba.read() << " **************" << std::endl;
 //for ( size_t line=0 ; line<16 ; line++ )
@@ -331,5 +317,5 @@
     //////////////////
     case M_READ_BURST:  // Compute the number of words and the number of flits in the burst
-                        // The number of flits can be smaller than the number of words 
+                        // The number of flits can be smaller than the number of words
                         // in case of 8 bytes flits...
     {
@@ -353,5 +339,5 @@
     }
     ////////////////
-    case M_READ_CMD:	// Send a multi-flits VCI WRITE command
+    case M_READ_CMD:    // Send a multi-flits VCI WRITE command
     {
         if ( p_vci_initiator.cmdack.read() )
@@ -359,5 +345,5 @@
             uint32_t nwords = r_burst_nwords.read() - r_words_count.read();
 
-            if ( vci_param::B == 4 )    // one word per flit 
+            if ( vci_param::B == 4 )    // one word per flit
             {
                 if ( nwords <= 1 )      // last flit
@@ -386,5 +372,5 @@
                     r_words_count = r_words_count.read() + 2;
                 }
-                    
+
                 // compute next word address and next local buffer index
                 if ( nwords == 1 )
@@ -403,5 +389,5 @@
     }
     ////////////////
-    case M_READ_RSP: 	// Wait a single flit VCI WRITE response
+    case M_READ_RSP:    // Wait a single flit VCI WRITE response
     {
         if ( p_vci_initiator.rspval.read() )
@@ -409,12 +395,12 @@
             bool aligned = (r_burst_offset.read() == 0);
 
-            if ( (p_vci_initiator.rerror.read()&0x1) != 0 ) 
+            if ( (p_vci_initiator.rerror.read()&0x1) != 0 )
             {
                 r_initiator_fsm = M_READ_ERROR;
             }
-            else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or 
+            else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or
                       (aligned and (r_burst_count.read() == (m_bursts_per_block-1))) )
             {
-                if ( r_block_count.read() == (r_nblocks.read()-1) ) // last burst of last block 
+                if ( r_block_count.read() == (r_nblocks.read()-1) ) // last burst of last block
                 {
                     r_initiator_fsm = M_READ_SUCCESS;
@@ -465,11 +451,11 @@
     }
     /////////////////
-    case M_WRITE_CMD:	// This is actually a single flit VCI READ command
-    {
-	    if ( p_vci_initiator.cmdack.read() ) r_initiator_fsm = M_WRITE_RSP;
+    case M_WRITE_CMD:   // This is actually a single flit VCI READ command
+    {
+        if ( p_vci_initiator.cmdack.read() ) r_initiator_fsm = M_WRITE_RSP;
         break;
     }
     /////////////////
-    case M_WRITE_RSP:	// This is actually a multi-words VCI READ response
+    case M_WRITE_RSP:   // This is actually a multi-words VCI READ response
     {
         if ( p_vci_initiator.rspval.read() )
@@ -491,12 +477,12 @@
             if ( p_vci_initiator.reop.read() )  // last flit of the burst
             {
-	            r_words_count  = 0;
-                r_buf_address = r_buf_address.read() + (r_burst_nwords.read()<<2); 
-
-	            if( (p_vci_initiator.rerror.read()&0x1) != 0 ) 
+                r_words_count  = 0;
+                r_buf_address = r_buf_address.read() + (r_burst_nwords.read()<<2);
+
+                if( (p_vci_initiator.rerror.read()&0x1) != 0 )
                 {
                     r_initiator_fsm = M_WRITE_ERROR;
                 }
-                else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or 
+                else if ( (not aligned and (r_burst_count.read() == m_bursts_per_block)) or
                      (aligned and (r_burst_count.read() == (m_bursts_per_block-1))) ) // last burst
                 {
@@ -511,5 +497,5 @@
             else
             {
-	            r_words_count = r_words_count.read() + 1;
+                r_words_count = r_words_count.read() + 1;
             }
         }
@@ -517,5 +503,5 @@
     }
     ///////////////////
-    case M_WRITE_BLOCK:		// write a block to disk after waiting m_latency cycles
+    case M_WRITE_BLOCK:     // write a block to disk after waiting m_latency cycles
     {
         if ( r_latency_count == 0 )
@@ -523,5 +509,5 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////
-//std::cout << "***** Block content before write for lba " 
+//std::cout << "***** Block content before write for lba "
 //          << std::hex << r_lba.read() << " ***********" << std::endl;
 //for ( size_t line=0 ; line<16 ; line++ )
@@ -540,9 +526,9 @@
             if( ::write(m_fd, r_local_buffer, m_words_per_block*4) < 0 )
             {
-                r_initiator_fsm = M_WRITE_ERROR; 
-            }
-            else if ( r_block_count.read() == r_nblocks.read() - 1 ) 
-            {
-                r_initiator_fsm = M_WRITE_SUCCESS; 
+                r_initiator_fsm = M_WRITE_ERROR;
+            }
+            else if ( r_block_count.read() == r_nblocks.read() - 1 )
+            {
+                r_initiator_fsm = M_WRITE_SUCCESS;
             }
             else
@@ -553,5 +539,5 @@
                 r_initiator_fsm  = M_WRITE_BURST;
             }
-        } 
+        }
         else
         {
@@ -573,5 +559,5 @@
 tmpl(void)::genMoore()
 {
-    // p_vci_target port   
+    // p_vci_target port
     p_vci_target.rsrcid = (sc_dt::sc_uint<vci_param::S>)r_srcid.read();
     p_vci_target.rtrdid = (sc_dt::sc_uint<vci_param::T>)r_trdid.read();
@@ -591,7 +577,7 @@
         else if(r_initiator_fsm == M_READ_SUCCESS)  p_vci_target.rdata = BLOCK_DEVICE_READ_SUCCESS;
         else if(r_initiator_fsm == M_WRITE_SUCCESS) p_vci_target.rdata = BLOCK_DEVICE_WRITE_SUCCESS;
-        else if(r_initiator_fsm == M_READ_ERROR)   	p_vci_target.rdata = BLOCK_DEVICE_READ_ERROR;
-        else if(r_initiator_fsm == M_WRITE_ERROR)  	p_vci_target.rdata = BLOCK_DEVICE_WRITE_ERROR;
-        else                                    	p_vci_target.rdata = BLOCK_DEVICE_BUSY;
+        else if(r_initiator_fsm == M_READ_ERROR)    p_vci_target.rdata = BLOCK_DEVICE_READ_ERROR;
+        else if(r_initiator_fsm == M_WRITE_ERROR)   p_vci_target.rdata = BLOCK_DEVICE_WRITE_ERROR;
+        else                                        p_vci_target.rdata = BLOCK_DEVICE_BUSY;
         p_vci_target.rerror = VCI_READ_OK;
         break;
@@ -668,10 +654,10 @@
 
     switch (r_initiator_fsm) {
-    case M_WRITE_CMD:		// It is actually a single flit VCI read command
+    case M_WRITE_CMD:       // It is actually a single flit VCI read command
         p_vci_initiator.rspack  = false;
         p_vci_initiator.cmdval  = true;
         p_vci_initiator.address = (sc_dt::sc_uint<vci_param::N>)r_buf_address.read();
         p_vci_initiator.cmd     = vci_param::CMD_READ;
-        p_vci_initiator.pktid   = TYPE_READ_DATA_UNC; 
+        p_vci_initiator.pktid   = TYPE_READ_DATA_UNC;
         p_vci_initiator.wdata   = 0;
         p_vci_initiator.be      = 0;
@@ -679,15 +665,15 @@
         p_vci_initiator.eop     = true;
         break;
-    case M_READ_CMD:		// It is actually a multi-words VCI WRITE command 
+    case M_READ_CMD:        // It is actually a multi-words VCI WRITE command
         p_vci_initiator.rspack  = false;
         p_vci_initiator.cmdval  = true;
-        p_vci_initiator.address = (sc_dt::sc_uint<vci_param::N>)r_buf_address.read(); 
+        p_vci_initiator.address = (sc_dt::sc_uint<vci_param::N>)r_buf_address.read();
         p_vci_initiator.cmd     = vci_param::CMD_WRITE;
         p_vci_initiator.pktid   = TYPE_WRITE;
         p_vci_initiator.plen    = (sc_dt::sc_uint<vci_param::K>)(r_burst_nwords.read()<<2);
-        if ( (vci_param::B == 8) and ((r_burst_nwords.read() - r_words_count.read()) > 1) )  
+        if ( (vci_param::B == 8) and ((r_burst_nwords.read() - r_words_count.read()) > 1) )
         {
             p_vci_initiator.wdata = ((uint64_t)r_local_buffer[r_index.read()  ]) +
-                                   (((uint64_t)r_local_buffer[r_index.read()+1]) << 32); 
+                                   (((uint64_t)r_local_buffer[r_index.read()+1]) << 32);
             p_vci_initiator.be    = 0xFF;
             p_vci_initiator.eop   = ( (r_burst_nwords.read() - r_words_count.read()) <= 2 );
@@ -713,8 +699,8 @@
     // IRQ signal
     if ( ((r_initiator_fsm == M_READ_SUCCESS)  ||
-	      (r_initiator_fsm == M_WRITE_SUCCESS) ||
+          (r_initiator_fsm == M_WRITE_SUCCESS) ||
           (r_initiator_fsm == M_READ_ERROR)    ||
-          (r_initiator_fsm == M_WRITE_ERROR) ) &&  
-         r_irq_enable.read() ) 
+          (r_initiator_fsm == M_WRITE_ERROR) ) &&
+         r_irq_enable.read() )
     {
 
@@ -723,7 +709,7 @@
             std::cout << "  <BDEV_INI send IRQ>" << std::endl;
 #endif
-		p_irq = true;
-    } 
-    else 
+        p_irq = true;
+    }
+    else
     {
         p_irq = false;
@@ -732,5 +718,5 @@
 
 //////////////////////////////////////////////////////////////////////////////
-tmpl(/**/)::VciBlockDeviceTsar( sc_core::sc_module_name              name, 
+tmpl(/**/)::VciBlockDeviceTsar( sc_core::sc_module_name              name,
                                 const soclib::common::MappingTable   &mt,
                                 const soclib::common::IntTab         &srcid,
@@ -742,23 +728,23 @@
 
 : caba::BaseModule(name),
-	m_seglist(mt.getSegmentList(tgtid)),
-	m_srcid(mt.indexForId(srcid)),
-	m_words_per_block(block_size/4),
-	m_words_per_burst(burst_size/4),
-	m_bursts_per_block(block_size/burst_size),
-	m_latency(latency),
-	p_clk("p_clk"),
-	p_resetn("p_resetn"),
-	p_vci_initiator("p_vci_initiator"),
-	p_vci_target("p_vci_target"),
-	p_irq("p_irq") 
+    m_seglist(mt.getSegmentList(tgtid)),
+    m_srcid(mt.indexForId(srcid)),
+    m_words_per_block(block_size/4),
+    m_words_per_burst(burst_size/4),
+    m_bursts_per_block(block_size/burst_size),
+    m_latency(latency),
+    p_clk("p_clk"),
+    p_resetn("p_resetn"),
+    p_vci_initiator("p_vci_initiator"),
+    p_vci_target("p_vci_target"),
+    p_irq("p_irq")
 {
     std::cout << "  - Building VciBlockDeviceTsar " << name << std::endl;
 
-	SC_METHOD(transition);
+    SC_METHOD(transition);
     dont_initialize();
     sensitive << p_clk.pos();
 
-	SC_METHOD(genMoore);
+    SC_METHOD(genMoore);
     dont_initialize();
     sensitive << p_clk.neg();
@@ -766,82 +752,82 @@
     size_t nbsegs = 0;
     std::list<soclib::common::Segment>::iterator seg;
-    for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ ) 
+    for ( seg = m_seglist.begin() ; seg != m_seglist.end() ; seg++ )
     {
         nbsegs++;
-        
-	    if ( (seg->baseAddress() & 0x0000003F) != 0 ) 
-	    {
-		    std::cout << "Error in component VciBlockDeviceTsar : " << name 
-		              << "The base address of segment " << seg->name()
+
+        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()
+            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);
-	    }
+            exit(1);
+        }
         std::cout << "    => segment " << seg->name()
                   << " / base = " << std::hex << seg->baseAddress()
-                  << " / size = " << seg->size() << std::endl; 
+                  << " / size = " << seg->size() << std::endl;
     }
 
     if( nbsegs == 0 )
     {
-		std::cout << "Error in component VciBlockDeviceTsar : " << name
-		          << " No segment allocated" << std::endl;
-		exit(1);
-    }
-
-    if( (block_size != 128)  && 
-        (block_size != 256)  && 
-        (block_size != 512)  && 
+        std::cout << "Error in component VciBlockDeviceTsar : " << name
+                  << " No segment allocated" << std::endl;
+        exit(1);
+    }
+
+    if( (block_size != 128)  &&
+        (block_size != 256)  &&
+        (block_size != 512)  &&
         (block_size != 1024) &&
-        (block_size != 2048) && 
+        (block_size != 2048) &&
         (block_size != 4096) )
-	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name
-		          << " The block size must be 128, 256, 512, 1024, 2048 or 4096 bytes"
+    {
+        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 != 8 ) && 
-		(burst_size != 16) && 
-		(burst_size != 32) && 
-		(burst_size != 64) )
-	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name 
-		          << " The burst size must be 8, 16, 32 or 64 bytes" << std::endl;
-		exit(1);
-	}
-
-	if ( (vci_param::B != 4) and (vci_param::B != 8) )
-	{
-		std::cout << "Error in component VciBlockDeviceTsar : " << name              
-		          << " 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 
-		          << " 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<<vci_param::N ) ) 
-	{
-		std::cout << "Error in component VciBlockDeviceTsar" << name 
-		          << " The file " << filename
-		          << " has more blocks than addressable with the VCI address" << std::endl;
-		exit(1);
-	}
-
-	r_local_buffer = new uint32_t[m_words_per_block];
+        exit(1);
+    }
+
+    if( (burst_size != 8 ) &&
+        (burst_size != 16) &&
+        (burst_size != 32) &&
+        (burst_size != 64) )
+    {
+        std::cout << "Error in component VciBlockDeviceTsar : " << name
+                  << " The burst size must be 8, 16, 32 or 64 bytes" << std::endl;
+        exit(1);
+    }
+
+    if ( (vci_param::B != 4) and (vci_param::B != 8) )
+    {
+        std::cout << "Error in component VciBlockDeviceTsar : " << name
+                  << " 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
+                  << " 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<<vci_param::N ) )
+    {
+        std::cout << "Error in component VciBlockDeviceTsar" << name
+                  << " The file " << filename
+                  << " has more blocks than addressable with the VCI address" << std::endl;
+        exit(1);
+    }
+
+    r_local_buffer = new uint32_t[m_words_per_block];
 
 } // end constructor
@@ -858,51 +844,51 @@
 tmpl(void)::print_trace()
 {
-	const char* initiator_str[] = 
-    {
-		"INI_IDLE",
-
-		"INI_READ_BLOCK",
-		"INI_READ_BURST",
-		"INI_READ_CMD",
-		"INI_READ_RSP",
-		"INI_READ_SUCCESS",
-		"INI_READ_ERROR",
-
-		"INI_WRITE_BURST",
-		"INI_WRITE_CMD",
-		"INI_WRITE_RSP",
-		"INI_WRITE_BLOCK",
-		"INI_WRITE_SUCCESS",
-		"INI_WRITE_ERROR",
-	};
-	const char* target_str[] = 
-    {
-		"TGT_IDLE",
-		"TGT_WRITE_BUFFER",
-		"TGT_READ_BUFFER",
-		"TGT_WRITE_BUFFER_EXT",
-		"TGT_READ_BUFFER_EXT",
-		"TGT_WRITE_COUNT",
-		"TGT_READ_COUNT",
-		"TGT_WRITE_LBA",
-		"TGT_READ_LBA",
-		"TGT_WRITE_OP",
-		"TGT_READ_STATUS",
-		"TGT_WRITE_IRQEN",
-		"TGT_READ_IRQEN",
-		"TGT_READ_SIZE",
-		"TGT_READ_BLOCK",
-		"TGT_READ_ERROR",
-		"TGT_WRITE_ERROR ",
-	};
-
-	std::cout << "BDEV " << name()
-              << " : " << target_str[r_target_fsm.read()] 
-		      << " / " << initiator_str[r_initiator_fsm.read()] 
+    const char* initiator_str[] =
+    {
+        "INI_IDLE",
+
+        "INI_READ_BLOCK",
+        "INI_READ_BURST",
+        "INI_READ_CMD",
+        "INI_READ_RSP",
+        "INI_READ_SUCCESS",
+        "INI_READ_ERROR",
+
+        "INI_WRITE_BURST",
+        "INI_WRITE_CMD",
+        "INI_WRITE_RSP",
+        "INI_WRITE_BLOCK",
+        "INI_WRITE_SUCCESS",
+        "INI_WRITE_ERROR",
+    };
+    const char* target_str[] =
+    {
+        "TGT_IDLE",
+        "TGT_WRITE_BUFFER",
+        "TGT_READ_BUFFER",
+        "TGT_WRITE_BUFFER_EXT",
+        "TGT_READ_BUFFER_EXT",
+        "TGT_WRITE_COUNT",
+        "TGT_READ_COUNT",
+        "TGT_WRITE_LBA",
+        "TGT_READ_LBA",
+        "TGT_WRITE_OP",
+        "TGT_READ_STATUS",
+        "TGT_WRITE_IRQEN",
+        "TGT_READ_IRQEN",
+        "TGT_READ_SIZE",
+        "TGT_READ_BLOCK",
+        "TGT_READ_ERROR",
+        "TGT_WRITE_ERROR ",
+    };
+
+    std::cout << "BDEV " << name()
+              << " : " << target_str[r_target_fsm.read()]
+              << " / " << initiator_str[r_initiator_fsm.read()]
               << " / buf = " << std::hex << r_buf_address.read()
               << " / lba = " << std::hex << r_lba.read()
-		      << " / block_count = " << std::dec << r_block_count.read() 
-		      << " / burst_count = " << r_burst_count.read() 
-		      << " / word_count = " << r_words_count.read() <<std::endl; 
+              << " / block_count = " << std::dec << r_block_count.read()
+              << " / burst_count = " << r_burst_count.read()
+              << " / word_count = " << r_words_count.read() <<std::endl;
 }
 
