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 381)
+++ trunk/modules/vci_block_device_tsar/caba/source/src/vci_block_device_tsar.cpp	(revision 392)
@@ -44,8 +44,8 @@
     if(p_resetn.read() == false) 
     {
-        r_initiator_fsm = M_IDLE;
-        r_target_fsm    = T_IDLE;
-        r_irq_enable    = true;
-        r_go            = false;
+        r_initiator_fsm   = M_IDLE;
+        r_target_fsm      = T_IDLE;
+        r_irq_enable      = true;
+        r_go              = false;
         return;
     } 
@@ -67,5 +67,5 @@
             sc_dt::sc_uint<vci_param::N> address = p_vci_target.address.read();
             bool                  read    = (p_vci_target.cmd.read() == vci_param::CMD_READ);
-            uint32_t              cell    = (uint32_t)((address & 0x1F)>>2);
+            uint32_t              cell    = (uint32_t)((address & 0x3F)>>2);
 
             if     ( !read && !m_segment.contains(address) )      r_target_fsm = T_WRITE_ERROR;
@@ -75,4 +75,6 @@
             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;
+            else if( !read && (cell == BLOCK_DEVICE_BUFFER_EXT) ) r_target_fsm = T_WRITE_BUFFER_EXT;
+            else if(  read && (cell == BLOCK_DEVICE_BUFFER_EXT) ) r_target_fsm = T_READ_BUFFER_EXT;
             else if( !read && (cell == BLOCK_DEVICE_COUNT) )      r_target_fsm = T_WRITE_COUNT;
             else if(  read && (cell == BLOCK_DEVICE_COUNT) )      r_target_fsm = T_READ_COUNT;
@@ -91,6 +93,20 @@
     case T_WRITE_BUFFER:
     {
-        if ( r_initiator_fsm == M_IDLE )  r_buf_address = (uint32_t)p_vci_target.wdata.read();
-        if ( p_vci_target.rspack.read() ) r_target_fsm = T_IDLE;
+        if ( (r_initiator_fsm.read() == M_IDLE) and p_vci_target.rspack.read() )  
+        {
+            r_buf_address = (uint64_t)p_vci_target.wdata.read();
+            r_target_fsm  = T_IDLE;
+        }
+        break;
+    }
+    ////////////////////////
+    case T_WRITE_BUFFER_EXT:
+    {
+        if ( (r_initiator_fsm.read() == M_IDLE) and p_vci_target.rspack.read() )  
+        {
+            r_buf_address = r_buf_address.read() + 
+                            (((uint64_t)p_vci_target.wdata.read())<<32);
+            r_target_fsm  = T_IDLE;
+        }
         break;
     }
@@ -98,6 +114,9 @@
     case T_WRITE_COUNT:
     {
-        if ( r_initiator_fsm == M_IDLE )  r_nblocks = (uint32_t)p_vci_target.wdata.read();
-        if ( p_vci_target.rspack.read() ) r_target_fsm = T_IDLE;
+        if ( (r_initiator_fsm.read() == M_IDLE) and p_vci_target.rspack.read() )  
+        {
+            r_nblocks    = (uint32_t)p_vci_target.wdata.read();
+            r_target_fsm = T_IDLE;
+        }
         break;
     }
@@ -105,6 +124,9 @@
     case T_WRITE_LBA:
     {
-        if ( r_initiator_fsm == M_IDLE )  r_lba = (uint32_t)p_vci_target.wdata.read();
-        if ( p_vci_target.rspack.read() ) r_target_fsm = T_IDLE;
+        if ( (r_initiator_fsm.read() == M_IDLE) and p_vci_target.rspack.read() )  
+        {
+            r_lba        = (uint32_t)p_vci_target.wdata.read();
+            r_target_fsm = T_IDLE;
+        }
         break;
     }
@@ -112,18 +134,24 @@
     case T_WRITE_OP:
     {
-        if ( r_initiator_fsm == M_IDLE ) 
-        {
-            if ( (uint32_t)p_vci_target.wdata.read() == BLOCK_DEVICE_READ )
+        if ( p_vci_target.rspack.read() )  
+        {
+            if ( ((uint32_t)p_vci_target.wdata.read() == BLOCK_DEVICE_READ) and
+                 (r_initiator_fsm.read() == M_IDLE) )
             {
                 r_read = true;
-                r_go = true;
-            }
-            else if ( (uint32_t)p_vci_target.wdata.read() == BLOCK_DEVICE_WRITE)
+                r_go   = true;
+            }
+            else if ( ((uint32_t)p_vci_target.wdata.read() == BLOCK_DEVICE_WRITE) and
+                      (r_initiator_fsm.read() == M_IDLE) )
             {
                 r_read = false;
-                r_go = true;
-            }
-        }
-        if ( p_vci_target.rspack.read() ) r_target_fsm = T_IDLE;
+                r_go   = true;
+            }
+            else
+            {
+                r_go   = false;
+            }
+            r_target_fsm = T_IDLE;
+        }
         break;
     }
@@ -131,10 +159,14 @@
     case T_WRITE_IRQEN:
     {
-        r_irq_enable = (p_vci_target.wdata.read() != 0);
-        if ( p_vci_target.rspack.read() ) r_target_fsm = T_IDLE;
+        if ( p_vci_target.rspack.read() ) 
+        {
+            r_target_fsm = T_IDLE;
+            r_irq_enable = (p_vci_target.wdata.read() != 0);
+        }
         break;
     }
     ///////////////////
     case T_READ_BUFFER:
+    case T_READ_BUFFER_EXT:
     case T_READ_COUNT:
     case T_READ_LBA:
@@ -190,5 +222,5 @@
 
             // compute r_burst_offset (zero when buffer aligned)
-            r_burst_offset = (r_buf_address.read()>>2) % m_flits_per_burst;
+            r_burst_offset = (uint32_t)((r_buf_address.read()>>2) % m_flits_per_burst);
 
             // start tranfer
@@ -338,8 +370,8 @@
             if ( p_vci_initiator.reop.read() )  // last flit of the burst
             {
-	        r_flit_count  = 0;
+	            r_flit_count  = 0;
                 r_buf_address = r_buf_address.read() + (r_burst_nflits.read()<<2); 
 
-	        if( (p_vci_initiator.rerror.read()&0x1) != 0 ) 
+	            if( (p_vci_initiator.rerror.read()&0x1) != 0 ) 
                 {
                     r_initiator_fsm = M_WRITE_ERROR;
@@ -431,4 +463,10 @@
         p_vci_target.rspval = true;
         p_vci_target.rdata  = (uint32_t)r_buf_address.read();
+        p_vci_target.rerror = VCI_READ_OK;
+        break;
+    case T_READ_BUFFER_EXT:
+        p_vci_target.cmdack = false;
+        p_vci_target.rspval = true;
+        p_vci_target.rdata  = (uint32_t)(r_buf_address.read()>>32);
         p_vci_target.rerror = VCI_READ_OK;
         break;
@@ -649,18 +687,20 @@
 	};
 	const char* target_str[] = {
-		"IDLE        ",
+		"IDLE",
 		"WRITE_BUFFER",
-		"READ_BUFFER ",
-		"WRITE_COUNT ",
-		"READ_COUNT  ",
-		"WRITE_LBA   ",
-		"READ_LBA    ",
-		"WRITE_OP    ",
-		"READ_STATUS ",
-		"WRITE_IRQEN ",
-		"READ_IRQEN  ",
-		"READ_SIZE   ",
-		"READ_BLOCK  ",
-		"READ_ERROR  ",
+		"READ_BUFFER",
+		"WRITE_BUFFER_EXT",
+		"READ_BUFFER_EXT",
+		"WRITE_COUNT",
+		"READ_COUNT",
+		"WRITE_LBA",
+		"READ_LBA",
+		"WRITE_OP",
+		"READ_STATUS",
+		"WRITE_IRQEN",
+		"READ_IRQEN",
+		"READ_SIZE",
+		"READ_BLOCK",
+		"READ_ERROR",
 		"WRITE_ERROR ",
 	};
@@ -668,5 +708,6 @@
 	std::cout << "BDEV_TGT : " << target_str[r_target_fsm.read()] 
 		  << "  BDEV_INI : " << initiator_str[r_initiator_fsm.read()] 
-		  << "  block = " << r_block_count.read() 
+          << "  buf = " << std::hex << r_buf_address.read()
+		  << "  block = " << std::dec << r_block_count.read() 
 		  << "  burst = " << r_burst_count.read() 
 		  << "  flit  = " << r_flit_count.read() <<std::endl; 
