Index: trunk/platforms/caba-vdspin-vci_synthetic_initiator/top.cpp
===================================================================
--- trunk/platforms/caba-vdspin-vci_synthetic_initiator/top.cpp	(revision 105)
+++ trunk/platforms/caba-vdspin-vci_synthetic_initiator/top.cpp	(revision 112)
@@ -67,14 +67,16 @@
 	//soclib::common::Loader loader();
 	// Mapping table primary network
-	soclib::common::MappingTable maptab0(address_width, IntTab(srcid_width-1 ,1), IntTab(srcid_width-1 ,1), 0xFFC0000);
-	soclib::common::MappingTable maptab1(address_width, IntTab(srcid_width-1 ,1), IntTab(srcid_width-1 ,1), 0xFFC0000);
+	soclib::common::MappingTable maptab0(address_width, IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)),
+							    IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), 0xFFC0000);
+	soclib::common::MappingTable maptab1(address_width, IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)),
+							    IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), 0xFFC0000);
 	for(int i = 0 ; i < Y_MAX ; i++){
 		for(int j = 0 ; j < X_MAX ; j++){
 			std::ostringstream	str0;
 			std::ostringstream	str1;
-			str0 << "Target_c0_" << (i*X_MAX+j) ;
-			str1 << "Target_c1_" << (i*X_MAX+j) ;
-			maptab0.add(Segment(str0.str(), TARGET_ADDR + ((i*X_MAX+j) << (address_width-srcid_width+1)), TARGET_SIZE, IntTab((i*X_MAX+j),0), false));
-			maptab1.add(Segment(str1.str(), TARGET_ADDR + ((i*X_MAX+j) << (address_width-srcid_width+1)), TARGET_SIZE, IntTab((i*X_MAX+j),0), false));
+			str0 << "Target_c0_" << (i*Y_MAX+j) ;
+			str1 << "Target_c1_" << (i*Y_MAX+j) ;
+			maptab0.add(Segment(str0.str(), TARGET_ADDR + ((i*Y_MAX+j) << (address_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX))), TARGET_SIZE, IntTab((i*X_MAX+j),0), false));
+			maptab1.add(Segment(str1.str(), TARGET_ADDR + ((i*Y_MAX+j) << (address_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX))), TARGET_SIZE, IntTab((i*X_MAX+j),0), false));
 		}
 	}
@@ -109,19 +111,35 @@
 		str0 << "cluster_c0_" << i ;
 		str1 << "cluster_c1_" << i ;
-		new(&local_ring_c0[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str0.str().c_str() ,maptab0, IntTab(i), 2, 18, 1, 1);
-		new(&local_ring_c1[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str1.str().c_str() ,maptab1, IntTab(i), 2, 18, 1, 1);
+		new(&local_ring_c0[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str0.str().c_str(),
+													maptab0, 
+													IntTab(i), 
+													2, 
+													18, 
+													1, 
+													1);
+		new(&local_ring_c1[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str1.str().c_str(), 
+													maptab1, 
+													IntTab(i), 
+													2, 
+													18,
+													1,
+													1);
 	}
 
 	// Virtual dspin routers
-	soclib::caba::VirtualDspinRouter<WIDTH_CMD> ** routers_cmd = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD> *) * Y_MAX);
-	soclib::caba::VirtualDspinRouter<WIDTH_RSP> ** routers_rsp = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP> *) * Y_MAX);
-
-	for(int i = 0; i < Y_MAX; i++ ){
-	  routers_cmd[i] = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD>) * X_MAX);
-	  routers_rsp[i] = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP>) * X_MAX);
-	  for(int j = 0; j < X_MAX; j++){
+	soclib::caba::VirtualDspinRouter<WIDTH_CMD> ** routers_cmd = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD> *) * X_MAX);
+	soclib::caba::VirtualDspinRouter<WIDTH_RSP> ** routers_rsp = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP> *) * X_MAX);
+
+	for(int i = 0; i < X_MAX; i++ ){
+	  routers_cmd[i] = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD>) * Y_MAX);
+	  routers_rsp[i] = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP>) * Y_MAX);
+	  for(int j = 0; j < Y_MAX; j++){
 		  std::cout << "Passe " << i << j << " pour instanciation vdspin" << std::endl;
-		  new(&routers_cmd[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_CMD> ("VDspinRouterCMD" + i + j, j, i, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4);
-		  new(&routers_rsp[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_RSP> ("VDspinRouterRSP" + i + j, j, i, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4);
+		  std::ostringstream	str0;
+		  std::ostringstream	str1;
+		  str0 << "VDspinRouterCMD" << i << j;
+		  str1 << "VDspinRouterRSP" << i << j;
+		  new(&routers_cmd[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_CMD> (str0.str().c_str(), i, j, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4);
+		  new(&routers_rsp[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_RSP> (str1.str().c_str(), i, j, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4);
 	  }
 	}
@@ -135,26 +153,31 @@
 	soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c0 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS);
 	soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c1 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS);
-	for(int i = 0 ; i < Y_MAX; i++)
-		for(int j = 0 ; j < X_MAX ; j++){
+	for(int i = 0 ; i < X_MAX; i++)
+		for(int j = 0 ; j < Y_MAX ; j++){
 			std::cout << "Passe " << i << j << " pour instanciation synthetic_init" << std::endl;
 			std::ostringstream	str0;
 			std::ostringstream	str1;
-			str0 << "Initiator_c0_" << (i*X_MAX+j) ;
-			str1 << "Initiator_c1_" << (i*X_MAX+j) ;
-			new(&initiator_c0[X_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab(i*X_MAX+j,0), 16, 0.5, 2, X_MAX, Y_MAX ); //, 0, 0, 0, 0, 0);
-			new(&initiator_c1[X_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab0, IntTab(i*X_MAX+j,0), 16, 0.5, 2, X_MAX, Y_MAX ); //, 0, 0, 0, 0, 0);
+			str0 << "Initiator_c0_" << (i*Y_MAX+j) ;
+			str1 << "Initiator_c1_" << (i*Y_MAX+j) ;
+			if( (i == X_MAX-1) && (j == Y_MAX-1)){
+				new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j) ,0), 16, 900, 2, X_MAX, Y_MAX, 25, 0, X_MAX, 0, Y_MAX); //, 0, 0, 0, 0, 0);
+				new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j) ,0), 16, 900, 2, X_MAX, Y_MAX, 25, 0, X_MAX, 0, Y_MAX); //, 0, 0, 0, 0, 0);
+			} else {
+				new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j),0), 16, 500, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0);
+				new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j),0), 16, 500, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0);
+			}
 		}
 
 	soclib::caba::VciSimpleRam<vci_param> * ram_c0 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS);
 	soclib::caba::VciSimpleRam<vci_param> * ram_c1 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS);
-	for(int i = 0 ; i < Y_MAX ; i++)
-		for(int j = 0 ; j < X_MAX ; j++){
+	for(int i = 0 ; i < X_MAX ; i++)
+		for(int j = 0 ; j < Y_MAX ; j++){
 			std::cout << "Passe " << i << j << " pour instanciation Ram" << std::endl;
 			std::ostringstream	str0;
 			std::ostringstream	str1;
-			str0 << "Ram_c0_" << (i*X_MAX+j) ;
-			str1 << "Ram_c1_" << (i*X_MAX+j) ;
-			new(&ram_c0[X_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str0.str().c_str() , IntTab(i*X_MAX+j,0), maptab0, soclib::common::Loader(), 0);
-			new(&ram_c1[X_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str1.str().c_str() , IntTab(i*X_MAX+j,0), maptab1, soclib::common::Loader(), 0);
+			str0 << "Ram_c0_" << (i*Y_MAX+j) ;
+			str1 << "Ram_c1_" << (i*Y_MAX+j) ;
+			new(&ram_c0[Y_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str0.str().c_str() , IntTab(i*Y_MAX+j,0), maptab0, soclib::common::Loader(), 0);
+			new(&ram_c1[Y_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str1.str().c_str() , IntTab(i*Y_MAX+j,0), maptab1, soclib::common::Loader(), 0);
 		}
 
@@ -189,91 +212,92 @@
 	// neighbors VDspin Router
 	///////////////////////////////////////////////////////////////
-	for(int i = 0; i < Y_MAX ; i++){
-	  for(int j = 0; j < X_MAX ; j++){
+	for(int i = 0; i < X_MAX ; i++){
+	  for(int j = 0; j < Y_MAX ; j++){
 	    routers_cmd[i][j].p_clk(signal_clk);
 	    routers_cmd[i][j].p_resetn(signal_resetn);
 	    routers_rsp[i][j].p_clk(signal_clk);
 	    routers_rsp[i][j].p_resetn(signal_resetn);
-	    local_ring_c0[i*X_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c0[0][i][j][LOCAL]);
-	    local_ring_c0[i*X_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c0[1][i][j][LOCAL] );
-	    local_ring_c0[i*X_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c0[0][i][j][LOCAL]);
-	    local_ring_c0[i*X_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c0[1][i][j][LOCAL] );
-	    local_ring_c1[i*X_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c1[0][i][j][LOCAL]);
-	    local_ring_c1[i*X_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c1[1][i][j][LOCAL] );
-	    local_ring_c1[i*X_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c1[0][i][j][LOCAL]);
-	    local_ring_c1[i*X_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c1[1][i][j][LOCAL] );
+	    local_ring_c0[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c0[0][i][j][LOCAL]);
+	    local_ring_c1[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c1[0][i][j][LOCAL]);
+	    local_ring_c0[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c0[1][i][j][LOCAL]);
+	    local_ring_c1[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c1[1][i][j][LOCAL]);
+	    local_ring_c0[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c0[0][i][j][LOCAL]);
+	    local_ring_c1[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c1[0][i][j][LOCAL]);
+	    local_ring_c0[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c0[1][i][j][LOCAL]);
+	    local_ring_c1[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c1[1][i][j][LOCAL]);
+	    std::cout << "Ring to DSPIN Connection done" << std::endl;
 	    for(int k = 0; k < 5; k++){
-	      if(i == 0){
-	        if(j == 0){
-		  routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
-		  routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
-		  routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
-		  routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
-		  routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
-		  routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
-		  routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
-		  routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
-		} else {
-		  if(k == WEST){
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i][j-1][EAST]);
-		  } else {
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
-		  }
-		}
-	      } else {
-		if(k == SOUTH){
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i-1][j][NORTH]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i-1][j][NORTH]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i-1][j][NORTH]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i-1][j][NORTH]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i-1][j][NORTH]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i-1][j][NORTH]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i-1][j][NORTH]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i-1][j][NORTH]);
-		} else if(k == WEST){
-		   if(j == 0){
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
-		   } else {
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i][j-1][EAST]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i][j-1][EAST]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i][j-1][EAST]);
-		   }
-		} else {
-		 	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
-		 	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
-		 	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
-		 	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
-		 	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
-		 	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
-		 	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
-		 	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
-		}
-	      }
+	     	if(j == 0){
+	     	  if(i == 0){
+	     	    routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
+	     	    routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
+	     	    routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
+	     	    routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
+	     	    routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
+	     	    routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
+	     	    routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
+	     	    routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
+	     	  } else {
+	     	    if(k == WEST){
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i-1][j][EAST]);
+	     	    } else {
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
+	     	    }
+	     	  }
+	     	} else {
+	     	  if(k == SOUTH){
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i][j-1][NORTH]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i][j-1][NORTH]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i][j-1][NORTH]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i][j-1][NORTH]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i][j-1][NORTH]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i][j-1][NORTH]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i][j-1][NORTH]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i][j-1][NORTH]);
+	     	  } else if(k == WEST){
+	     	     if(i == 0){
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
+	     	     } else {
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i-1][j][EAST]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i-1][j][EAST]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i-1][j][EAST]);
+	     	     }
+	     	  } else {
+	     	   	routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]);
+	     	   	routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]);
+	     	   	routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]);
+	     	  }
+	     	}
 	    }
 	  }
@@ -281,4 +305,48 @@
 
 	////////////////////////////////////////////////////////
+	for(int i = 0; i < Y_MAX ; i++){
+		for(int j = 0; j < Y_MAX ; j++){
+			if(i == 0){
+			  	dspin_signals_cmd_c0[0][i][j][SOUTH].read = true   ;
+			  	dspin_signals_cmd_c0[1][i][j][SOUTH].write = false ;
+			  	dspin_signals_cmd_c1[0][i][j][SOUTH].read = true   ;
+			  	dspin_signals_cmd_c1[1][i][j][SOUTH].write = false ;
+			  	dspin_signals_rsp_c0[0][i][j][SOUTH].read = true   ;
+			  	dspin_signals_rsp_c0[1][i][j][SOUTH].write = false ;
+			  	dspin_signals_rsp_c1[0][i][j][SOUTH].read = true   ;
+			  	dspin_signals_rsp_c1[1][i][j][SOUTH].write = false ;
+			} 
+			if(i == Y_MAX-1){
+			  	dspin_signals_cmd_c0[0][i][j][NORTH].read = true   ;
+			  	dspin_signals_cmd_c0[1][i][j][NORTH].write = false ;
+			  	dspin_signals_cmd_c1[0][i][j][NORTH].read = true   ;
+			  	dspin_signals_cmd_c1[1][i][j][NORTH].write = false ;
+			  	dspin_signals_rsp_c0[0][i][j][NORTH].read = true   ;
+			  	dspin_signals_rsp_c0[1][i][j][NORTH].write = false ;
+			  	dspin_signals_rsp_c1[0][i][j][NORTH].read = true   ;
+			  	dspin_signals_rsp_c1[1][i][j][NORTH].write = false ;
+			} 
+			if(j == 0){
+				dspin_signals_cmd_c0[0][i][j][WEST].read = true   ;
+				dspin_signals_cmd_c0[1][i][j][WEST].write = false ;
+				dspin_signals_cmd_c1[0][i][j][WEST].read = true   ;
+				dspin_signals_cmd_c1[1][i][j][WEST].write = false ;
+				dspin_signals_rsp_c0[0][i][j][WEST].read = true   ;
+				dspin_signals_rsp_c0[1][i][j][WEST].write = false ;
+				dspin_signals_rsp_c1[0][i][j][WEST].read = true   ;
+				dspin_signals_rsp_c1[1][i][j][WEST].write = false ;
+			} 
+			if(j == X_MAX-1){
+				dspin_signals_cmd_c0[0][i][j][EAST].read = true   ;
+				dspin_signals_cmd_c0[1][i][j][EAST].write = false ;
+				dspin_signals_cmd_c1[0][i][j][EAST].read = true   ;
+				dspin_signals_cmd_c1[1][i][j][EAST].write = false ;
+				dspin_signals_rsp_c0[0][i][j][EAST].read = true   ;
+				dspin_signals_rsp_c0[1][i][j][EAST].write = false ;
+				dspin_signals_rsp_c1[0][i][j][EAST].read = true   ;
+				dspin_signals_rsp_c1[1][i][j][EAST].write = false ;
+			}
+		}
+	}
 
 
@@ -287,5 +355,5 @@
 	//             Simulation Loop                //
 	////////////////////////////////////////////////
-	int ncycles;
+	//int ncycles;
 
 	sc_start(sc_core::sc_time(0, SC_NS));
@@ -296,5 +364,78 @@
 
 	while(1) {
-		sc_start(sc_core::sc_time(100000, SC_NS));
+		sc_start(sc_time(1, SC_NS));
+		std::cout << "Synthetic initiators signals ------------------------------" << std::endl;
+		for(int i = 0 ; i < N_CLUSTERS ; i++){
+			initiator_c0[i].print_trace();
+			std::cout << std::hex;
+			std::cout << "synt_cmdval  = " << signal_vci_ini_synth_c0[0][i].cmdval.read() << std::endl;
+			std::cout << "synt_address = " << signal_vci_ini_synth_c0[0][i].address.read() << std::endl;
+			std::cout << "synt_cmd     = " << signal_vci_ini_synth_c0[0][i].cmd.read() << std::endl;
+			std::cout << "synt_srcid   = " << signal_vci_ini_synth_c0[0][i].srcid.read() << std::endl;
+			std::cout << "synt_plen    = " << signal_vci_ini_synth_c0[0][i].plen.read() << std::endl;
+			std::cout << "synt_eop     = " << signal_vci_ini_synth_c0[0][i].eop.read() << std::endl;
+			std::cout << "synt_rspval  = " << signal_vci_ini_synth_c0[0][i].rspval.read() << std::endl;
+			std::cout << "synt_rerror  = " << signal_vci_ini_synth_c0[0][i].rerror.read() << std::endl;
+			std::cout << "synt_reop    = " << signal_vci_ini_synth_c0[0][i].reop.read() << std::endl;
+		}
+		std::cout << "RAM signals -----------------------------------------------" << std::endl;
+		for(int i = 0 ; i < N_CLUSTERS ; i++){
+			ram_c0[i].print_trace();
+			std::cout << std::hex;
+			std::cout << "ram_cmdval  = " << signal_vci_ini_synth_c0[1][i].cmdval.read() << std::endl;
+			std::cout << "ram_address = " << signal_vci_ini_synth_c0[1][i].address.read() << std::endl;
+			std::cout << "ram_cmd     = " << signal_vci_ini_synth_c0[1][i].cmd.read() << std::endl;
+			std::cout << "ram_srcid   = " << signal_vci_ini_synth_c0[1][i].srcid.read() << std::endl;
+			std::cout << "ram_plen    = " << signal_vci_ini_synth_c0[1][i].plen.read() << std::endl;
+			std::cout << "ram_eop     = " << signal_vci_ini_synth_c0[1][i].eop.read() << std::endl;
+			std::cout << "ram_rspval  = " << signal_vci_ini_synth_c0[1][i].rspval.read() << std::endl;
+			std::cout << "ram_rsrcid  = " << signal_vci_ini_synth_c0[1][i].rsrcid.read() << std::endl;
+			std::cout << "ram_rerror  = " << signal_vci_ini_synth_c0[1][i].rerror.read() << std::endl;
+			std::cout << "ram_reop    = " << signal_vci_ini_synth_c0[1][i].reop.read() << std::endl;
+		}
+		std::cout << "Local_ring ------------------------------------------------" << std::endl;
+		for(int i = 0 ; i < N_CLUSTERS ; i++){
+			local_ring_c0[i].print_trace();
+		}
+		std::cout << "Routers CMD -----------------------------------------------" << std::endl;
+		for(int i = 0 ; i < Y_MAX ; i++){
+			for(int j = 0 ; j < X_MAX ; j++){
+				routers_cmd[i][j].printTrace(0);
+			}
+		}
+		std::cout << "Routers RSP -----------------------------------------------" << std::endl;
+		for(int i = 0 ; i < Y_MAX ; i++){
+			for(int j = 0 ; j < X_MAX ; j++){
+				routers_rsp[i][j].printTrace(0);
+			}
+		}
+
+		//for(int i = 0; i< N_CLUSTERS; i++){
+		//	initiator_c1[i].print_trace();
+		//	std::cout << std::hex;
+		//	std::cout << "synt_cmdval  = " << signal_vci_ini_synth_c1[0][i].cmdval.read() << std::endl;
+		//	std::cout << "synt_address = " << signal_vci_ini_synth_c1[0][i].address.read() << std::endl;
+		//	std::cout << "synt_cmd     = " << signal_vci_ini_synth_c1[0][i].cmd.read() << std::endl;
+		//	std::cout << "synt_srcid   = " << signal_vci_ini_synth_c1[0][i].srcid.read() << std::endl;
+		//	std::cout << "synt_plen    = " << signal_vci_ini_synth_c1[0][i].plen.read() << std::endl;
+		//	std::cout << "synt_eop     = " << signal_vci_ini_synth_c1[0][i].eop.read() << std::endl;
+		//	std::cout << "synt_rspval  = " << signal_vci_ini_synth_c1[0][i].rspval.read() << std::endl;
+		//	std::cout << "synt_rerror  = " << signal_vci_ini_synth_c1[0][i].rerror.read() << std::endl;
+		//	std::cout << "synt_reop    = " << signal_vci_ini_synth_c1[0][i].reop.read() << std::endl;
+		//}
+		//for(int i = 0 ; i < N_CLUSTERS ; i++){
+		//	ram_c1[i].print_trace();
+		//	std::cout << std::hex;
+		//	std::cout << "ram_cmdval  = " << signal_vci_ini_synth_c0[1][i].cmdval.read() << std::endl;
+		//	std::cout << "ram_address = " << signal_vci_ini_synth_c0[1][i].address.read() << std::endl;
+		//	std::cout << "ram_cmd     = " << signal_vci_ini_synth_c0[1][i].cmd.read() << std::endl;
+		//	std::cout << "ram_srcid   = " << signal_vci_ini_synth_c0[1][i].srcid.read() << std::endl;
+		//	std::cout << "ram_plen    = " << signal_vci_ini_synth_c0[1][i].plen.read() << std::endl;
+		//	std::cout << "ram_eop     = " << signal_vci_ini_synth_c0[1][i].eop.read() << std::endl;
+		//	std::cout << "ram_rspval  = " << signal_vci_ini_synth_c0[1][i].rspval.read() << std::endl;
+		//	std::cout << "ram_rerror  = " << signal_vci_ini_synth_c0[1][i].rerror.read() << std::endl;
+		//	std::cout << "ram_reop    = " << signal_vci_ini_synth_c0[1][i].reop.read() << std::endl;
+		//}
+		
 	}
 
