Index: trunk/modules/vci_synthetic_initator/caba/sources/src/vci_synthetic_initiator.cpp
===================================================================
--- trunk/modules/vci_synthetic_initator/caba/sources/src/vci_synthetic_initiator.cpp	(revision 129)
+++ trunk/modules/vci_synthetic_initator/caba/sources/src/vci_synthetic_initiator.cpp	(revision 131)
@@ -5,5 +5,5 @@
  * Copyright 	: UPMC / LIP6
  * Authors 	: Christophe Choichillon
- * Version	: 2.0
+ * Version	: 2.1
  *
  * SOCLIB_LGPL_HEADER_BEGIN
@@ -81,19 +81,24 @@
     m_ymin(ymin),
     m_ymax(ymax),
-    r_date_fifo("r_date_fifo", depth),
-    r_type_fifo("r_type_fifo", depth),
-    r_cmd_fsm;        ("r_count"),             
-    r_bc_rsp_fsm("r_bc_rsp_fsm"),
-    r_index("r_index"),
-    r_broadcast_req("r_broadcast_req"),
-    r_broadcast_rsp("r_broadcast_rsp"),
-    r_bc_nrsp("r_bc_nrsp")		    
-    //r_req_id("r_req_id")
+    r_date_fifo("r_date_fifo", m_depth),
+    r_bc_fifo("r_bc_fifo", m_depth),
+    r_cmd_fsm("r_cmd_fsm"),
+    r_cmd_address("r_cmd_address"),  		
+    r_cmd_trdid("r_cmd_trdid"),	
+    r_cmd_count("r_cmd_count"),  	
+    r_cmd_seed("r_cmd_seed"),	
+    //r_bc_fsm("r_bc_fsm"),	
+    //r_bc_date("r_bc_date"),	
+    r_bc_nrsp("r_bc_nrsp"),	
+    r_cpt_cycles("r_cpt_cycles"),  		
+    r_cpt_period("r_cpt_period"),  		
+    r_nb_single("r_nb_single"),	
+    r_latency_single("r_latency_single"),	
+    r_nb_bc("r_nb_bc"),	
+    r_latency_bc("r_latency_bc")		
 {
 
-      r_req_id = new sc_signal<uint64_t>*[tab_size];
-      for(int i = 0; i < tab_size ; i++){
-        r_req_id[i] = new sc_signal<uint64_t>[2];
-      }
+      r_pending_fsm = new sc_signal<bool>[m_tab_size];
+      r_pending_date = new sc_signal<uint64_t>[m_tab_size];
 
       SC_METHOD(transition);
@@ -112,8 +117,6 @@
     /////////////////////////////////
   {
-  	for(int i = 0; i < tab_size ; i++){
-	  delete r_req_id[i];
-	}
-	delete r_req_id;
+	delete r_pending_fsm;
+	delete r_pending_date;
   }
 
@@ -146,12 +149,12 @@
 
 	std::cout << "Vci_Synthetic_Initiator " << name()
-		  << " : " << std::dec << m_cpt_cycles << " cycles " 
+		  << " : " << std::dec << r_cpt_cycles.read() << " cycles " 
 		  << " : state_cmd_fsm = " << state_cmd_str[r_cmd_fsm] 
-		  << " : state_rsp_fsm = " << state_bc_rsp_str[r_bc_rsp_fsm] 
+		  << " : state_rsp_fsm = " << state_bc_rsp_str[r_pending_fsm[0].read()] 
 		  << " Adresse to send : " << std::hex << r_cmd_address.read()
 		  << " Number of broadcast to receive : " << std::dec << r_bc_nrsp.read() 
-		  << " Number of packets sent : " << std::dec << r_nb_single.read() << " " << r_id_to_send.read() << std::endl;
+		  << " Number of packets sent : " << std::dec << r_nb_single.read() << " " << r_cmd_trdid.read() << std::endl;
 	for(int i = 0; i < (1<<vci_param::T) ; i++){
-	  std::cout << "ID : " << i << " " << (uint64_t)(r_req_id[i][0].read()) << " " << (uint64_t)(r_req_id[i][1].read()) << std::endl;
+	  std::cout << "ID : " << i << " " << (uint64_t)(r_pending_date[i].read()) << std::endl;
 	}
   }
@@ -161,6 +164,5 @@
   //////////////////////////////////
   {
-  	std::cout << name() << " : "<< std::dec << m_cpt_cycles << " cycles, " << r_nb_single.read() << " packets sent" << std::endl;
-	std::cout << ((double)r_latency1.read()/(double)r_nb_single.read()) << " | " << ((double)r_latency2.read()/(double)r_nb_single.read()) << std::endl;
+  	std::cout << name() << " : "<< std::dec << r_cpt_cycles.read() << " cycles, " << r_nb_single.read() << " packets sent" << std::endl;
 	if(m_bc_period)
 	  std::cout << ((double)r_latency_bc.read()/(double)r_nb_bc.read()) << std::endl;
@@ -182,5 +184,5 @@
       // Initializing FSMs
       r_cmd_fsm = VCI_IDLE;
-      r_bc_fsm = BC_RSP_IDLE;
+      //r_bc_fsm = false;
       for(size_t i=0 ; i<m_tab_size ; i++) r_pending_fsm[i] = false;
 
@@ -216,10 +218,10 @@
 	  if (r_date_fifo.rok())
           {
-	    if ( r_bc_fifo() = true )	// its a broadcast request
+	    if ( r_bc_fifo.read() == true )	// its a broadcast request
             {
-	      if ( r_bc_fsm.read() = false )	// no current broadcast
+	      if ( r_pending_fsm[0].read() == false )	// no current broadcast
               {
-	      r_cmd_fsm = VCI_BC_SEND ;
-	      r_cmd_address = 0x3 | (0x7c1f << vci_param::N-20) ;
+	        r_cmd_fsm = VCI_BC_SEND ;
+		r_cmd_address = 0x3 | (0x7c1f << vci_param::N-20) ;
               }
             }
@@ -227,5 +229,5 @@
             {
 	      int id = -1;
-	      for(int i = 0; i < tab_size; i++){
+	      for(int i = 1; i < m_tab_size; i++){  	// ID 0 reserved for broadcast transactions
 	        if(r_pending_fsm[i].read() == false)
                 {
@@ -254,5 +256,5 @@
 	  if ( p_vci.cmdack.read())
           {
-	    r_count = r_count.read() + 1;
+	    r_cmd_count = r_cmd_count.read() + 1;
 	    if (r_cmd_count.read() == m_length-1) 
             {
@@ -265,5 +267,5 @@
       case VCI_SINGLE_REGISTER:
         {
-	  r_pending_date[r_cmd_trdid.read()] = (uint64_t)(m_date_fifo.read());
+	  r_pending_date[r_cmd_trdid.read()] = (uint64_t)(r_date_fifo.read());
           r_pending_fsm[r_cmd_trdid.read()] = true;
           fifo_get = true;
@@ -274,7 +276,9 @@
 	  if (p_vci.cmdack.read()) 
           {
-	    r_bc_fsm = true;
+	    //r_bc_fsm = true;
 	    r_bc_nrsp = (m_xmax - m_xmin) * (m_ymax - m_ymin) ;
-	    r_bc_date = (uint64_t)(m_date_fifo.read());
+	    //r_bc_date = (uint64_t)(r_date_fifo.read());
+	    r_pending_fsm[0] = true;
+	    r_pending_date[0] = (uint64_t)(r_date_fifo.read());
 	    fifo_get = true;
 	    r_cmd_fsm = VCI_IDLE;
@@ -287,23 +291,35 @@
     // BC_FSM
     /////////////////////
-    if ( r_bc_fsm.read() && p_vci.rspval.read() ) 
-    {
-      if ( p_vci.rpktid.read() == 1 ) r_bc_nrsp = r_bc_nrsp.read() - 1; 
-      if (r_bc_nrsp == 1)
-      {
-	r_bc_fsm = false;
-        r_latency_bc = r_latency_bc.read() + (r_cpt_cycle.read() - r_bc_date.read());
-      }
-    }
+    //if ( r_pending_fsm[0].read() && p_vci.rspval.read() ) 
+    //{
+    //  if ( p_vci.rtrdid.read() == 0 ) r_bc_nrsp = r_bc_nrsp.read() - 1; 
+    //  if (r_bc_nrsp.read() == 1)
+    //  {
+    //    //r_bc_fsm = false;
+    //    r_pending_fsm[0] = false ;
+    //    r_latency_bc = r_latency_bc.read() + (r_cpt_cycles.read() - r_pending_date[0].read());
+    //  }
+    //}
 
     ///////////////////
     // PENDING FSMs
     //////////////////
-    if(p_vci.rspval.read())i
+    if(p_vci.rspval.read())
     {
-      if((int)(p_vci.pktid.read()) == 0)	// not a broadcast
+      if(p_vci.rtrdid.read() == 0)	// not a broadcast
+      {
+        assert( ( r_pending_fsm[0].read() == true ) && 
+                "illegal broadcast response received");
+	r_bc_nrsp = r_bc_nrsp.read() - 1 ;
+	if(r_bc_nrsp.read() == 1) 
+	{
+	  r_pending_fsm[0] = false;
+          r_latency_bc = r_latency_bc.read() + (r_cpt_cycles.read() - r_pending_date[0].read());
+	}
+      }
+      else
       {
         assert( ( r_pending_fsm[(int)p_vci.rtrdid.read()] == true ) && 
-                "illegal single response received")
+                "illegal single response received");
         r_pending_fsm[p_vci.rtrdid.read()] = false;
 	r_latency_single = r_latency_single.read() + 
@@ -332,22 +348,22 @@
     }
 
-    if ( m_bc_period && (r_cpt_period.read() > m_bc_period) && r_data_fifo.wok() ) 
-      m_cpt_period = 0;
+    if ( m_bc_period && (r_cpt_period.read() > m_bc_period) && r_date_fifo.wok() ) 
+      r_cpt_period = 0;
     else
-      m_cpt_period = m_cpt_period.read() + 1;
+      r_cpt_period = r_cpt_period.read() + 1;
 
     ////////////////////////
     //  update fifos
     ////////////////////////
-    if (date_fifo_put){
-      if (date_fifo_get){
+    if (fifo_put){
+      if (fifo_get){
         r_date_fifo.put_and_get(r_cpt_cycles.read());
         r_bc_fifo.put_and_get(fifo_bc);
       } else {
-        r_date_fifo.simple_put(m_cpt_cycles);
+        r_date_fifo.simple_put(r_cpt_cycles.read());
         r_bc_fifo.simple_put(fifo_bc);
       }
     } else {
-      if (date_fifo_get){
+      if (fifo_get){
         r_date_fifo.simple_get();
         r_bc_fifo.simple_get();
@@ -374,5 +390,4 @@
      p_vci.be         = 0xF;                             
      p_vci.srcid      = m_srcid;   
-     p_vci.pktid      = 0;      
      p_vci.cons       = false;        
      p_vci.wrap       = false;       
@@ -393,4 +408,5 @@
 	  p_vci.wdata   = 0;                                       
 	  p_vci.trdid   = 0;                  
+	  p_vci.pktid      = 0;      
 	  p_vci.eop     = false;                                   
           break;
@@ -400,9 +416,10 @@
         {
 	  p_vci.cmdval  = true;                 
-	  p_vci.address = (addr_t)(r_cmd_address.read() + (r_count.read()*4)); 
+	  p_vci.address = (addr_t)(r_cmd_address.read() + (r_cmd_count.read()*4)); 
 	  p_vci.plen    = m_length*4;                                         
 	  p_vci.wdata   = 0;                                       
-	  p_vci.trdid   = r_id_to_send.read();                  
-	  if (r_count.read() == m_length - 1 ) {
+	  p_vci.trdid   = r_cmd_trdid.read();                  
+	  p_vci.pktid   = 0;      
+	  if (r_cmd_count.read() == m_length - 1 ) {
 	    p_vci.eop     = true;                                   
 	  } else {
@@ -418,9 +435,21 @@
 	  p_vci.plen    = 4;                                         
 	  p_vci.wdata   = 0;                                       
-          p_vci.pktid   = 1;      
 	  p_vci.trdid   = 0;                  
+          p_vci.pktid   = 0;      
 	  p_vci.eop     = true;                                   
           break;
         }
+      //////////////////
+      case VCI_SINGLE_REGISTER:
+        {
+	  p_vci.cmdval  = false;                 
+	  p_vci.address = 0; 
+	  p_vci.plen    = 0;                                         
+	  p_vci.wdata   = 0;                                       
+	  p_vci.trdid   = 0;                  
+	  p_vci.pktid   = 0;      
+	  p_vci.eop     = false;                                   
+          break;
+        }
     } // end switch vci_cmd_fsm
 
