Index: trunk/platforms/tsar_generic_xbar/top.cpp
===================================================================
--- trunk/platforms/tsar_generic_xbar/top.cpp	(revision 1012)
+++ trunk/platforms/tsar_generic_xbar/top.cpp	(revision 1023)
@@ -271,5 +271,4 @@
    int64_t  debug_from        = 0;                  // trace start cycle
    int64_t  frozen_cycles     = MAX_FROZEN_CYCLES;  // monitoring frozen processor
-   size_t   cluster_io_id;                         // index of cluster containing IOs
    int64_t  reset_counters    = -1;
    int64_t  dump_counters     = -1;
@@ -280,14 +279,10 @@
 
    ////////////// command line arguments //////////////////////
-   if (argc > 1)
-   {
-      for (int n = 1; n < argc; n = n + 2)
-      {
-         if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc))
-         {
+   if (argc > 1) {
+      for (int n = 1; n < argc; n = n + 2) {
+         if ((strcmp(argv[n], "-NCYCLES") == 0) && (n + 1 < argc)) {
             ncycles = (int64_t) strtol(argv[n + 1], NULL, 0);
          }
-         else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "-SOFT") == 0) && (n + 1 < argc)) {
 #ifdef USE_ALMOS
             assert( 0 && "Can't define almos soft name" );
@@ -297,15 +292,12 @@
 #endif
          }
-         else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n],"-DISK") == 0) && (n + 1 < argc)) {
             strcpy(disk_name, argv[n + 1]);
          }
-         else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n],"-DEBUG") == 0) && (n + 1 < argc)) {
             debug_ok = true;
             debug_from = (int64_t) strtol(argv[n + 1], NULL, 0);
          }
-         else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "-MEMCID") == 0) && (n + 1 < argc)) {
             debug_memc_id = (size_t) strtol(argv[n + 1], NULL, 0);
 #ifdef USE_ALMOS
@@ -320,6 +312,5 @@
 #endif
          }
-         else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "-PROCID") == 0) && (n + 1 < argc)) {
             debug_proc_id = (size_t) strtol(argv[n + 1], NULL, 0);
 #ifdef USE_ALMOS
@@ -335,29 +326,23 @@
 #endif
          }
-         else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc))
-         {
+         else if ((strcmp(argv[n], "-THREADS") == 0) && ((n + 1) < argc)) {
             threads_nr = (ssize_t) strtol(argv[n + 1], NULL, 0);
             threads_nr = (threads_nr < 1) ? 1 : threads_nr;
          }
-         else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "-FROZEN") == 0) && (n + 1 < argc)) {
             frozen_cycles = (int64_t) strtol(argv[n + 1], NULL, 0);
          }
-         else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "-PERIOD") == 0) && (n + 1 < argc)) {
             debug_period = (size_t) strtol(argv[n + 1], NULL, 0);
          }
-         else if ((strcmp(argv[n], "--reset-counters") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "--reset-counters") == 0) && (n + 1 < argc)) {
             reset_counters = (int64_t) strtol(argv[n + 1], NULL, 0);
             do_reset_counters = true;
          }
-         else if ((strcmp(argv[n], "--dump-counters") == 0) && (n + 1 < argc))
-         {
+         else if ((strcmp(argv[n], "--dump-counters") == 0) && (n + 1 < argc)) {
             dump_counters = (int64_t) strtol(argv[n + 1], NULL, 0);
             do_dump_counters = true;
          }
-         else
-         {
+         else {
             std::cout << "   Arguments are (key,value) couples." << std::endl;
             std::cout << "   The order is not important." << std::endl;
@@ -461,5 +446,5 @@
    else if (X_SIZE <= 4) x_width = 2;
    else if (X_SIZE <= 8) x_width = 3;
-   else                x_width = 4;
+   else                  x_width = 4;
 
    if      (Y_SIZE == 1) y_width = 0;
@@ -467,5 +452,5 @@
    else if (Y_SIZE <= 4) y_width = 2;
    else if (Y_SIZE <= 8) y_width = 3;
-   else                y_width = 4;
+   else                  y_width = 4;
 
 #else
@@ -480,8 +465,4 @@
 
 #endif
-
-   // index of cluster containing IOs
-   cluster_io_id = 0x00bfc00000ULL >> (vci_address_width - x_width - y_width);
-
 
    /////////////////////
@@ -495,8 +476,6 @@
                         0x00FF800000);
 
-   for (size_t x = 0; x < X_SIZE; x++)
-   {
-      for (size_t y = 0; y < Y_SIZE; y++)
-      {
+   for (size_t x = 0; x < X_SIZE; x++) {
+      for (size_t y = 0; y < Y_SIZE; y++) {
          sc_uint<vci_address_width> offset;
          offset = (sc_uint<vci_address_width>) cluster(x,y) 
@@ -518,6 +497,5 @@
                   IntTab(cluster(x,y), RAM_TGTID), true));
 
-         if ( cluster(x,y) == cluster_io_id )
-         {
+         if (x == X_IO && y == Y_IO) {
             maptabd.add(Segment("seg_mtty", SEG_TTY_BASE, SEG_TTY_SIZE, 
                         IntTab(cluster(x,y),TTY_TGTID), false));
@@ -545,8 +523,6 @@
                         0xFFFF000000ULL);
 
-   for (size_t x = 0; x < X_SIZE; x++)
-   {
-      for (size_t y = 0; y < Y_SIZE ; y++)
-      {
+   for (size_t x = 0; x < X_SIZE; x++) {
+      for (size_t y = 0; y < Y_SIZE ; y++) {
 
          sc_uint<vci_address_width> offset;
@@ -672,6 +648,5 @@
 #pragma omp for
 #endif
-        for (size_t i = 0; i  < (X_SIZE * Y_SIZE); i++)
-        {
+        for (size_t i = 0; i  < (X_SIZE * Y_SIZE); i++) {
             size_t x = i / Y_SIZE;
             size_t y = i % Y_SIZE;
@@ -704,4 +679,5 @@
                 y_width,
                 vci_srcid_width - x_width - y_width,   // l_id width,
+                P_WIDTH,
                 RAM_TGTID,
                 XCU_TGTID,
@@ -722,5 +698,5 @@
                 IRQ_PER_PROCESSOR,
                 XRAM_LATENCY,
-                (cluster(x,y) == cluster_io_id),
+                x == X_IO && y == Y_IO,
                 FBF_X_SIZE,
                 FBF_Y_SIZE,
@@ -752,103 +728,99 @@
 
    // Clock & RESET
-   for (size_t x = 0; x < (X_SIZE); x++){
-      for (size_t y = 0; y < Y_SIZE; y++){
-         clusters[x][y]->p_clk                         (signal_clk);
-         clusters[x][y]->p_resetn                      (signal_resetn);
+   for (int x = 0; x < X_SIZE; x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
+         clusters[x][y]->p_clk                      (signal_clk);
+         clusters[x][y]->p_resetn                   (signal_resetn);
       }
    }
 
    // Inter Clusters horizontal connections
-   if (X_SIZE > 1) {
-       for (size_t x = 0; x < (X_SIZE-1); x++) {
-           for (size_t y = 0; y < (Y_SIZE); y++) {
-               clusters[x][y]->p_cmd_out[EAST]      (signal_dspin_h_cmd_inc[x][y]);
-               clusters[x+1][y]->p_cmd_in[WEST]     (signal_dspin_h_cmd_inc[x][y]);
-               clusters[x][y]->p_cmd_in[EAST]       (signal_dspin_h_cmd_dec[x][y]);
-               clusters[x+1][y]->p_cmd_out[WEST]    (signal_dspin_h_cmd_dec[x][y]);
-
-               clusters[x][y]->p_rsp_out[EAST]      (signal_dspin_h_rsp_inc[x][y]);
-               clusters[x+1][y]->p_rsp_in[WEST]     (signal_dspin_h_rsp_inc[x][y]);
-               clusters[x][y]->p_rsp_in[EAST]       (signal_dspin_h_rsp_dec[x][y]);
-               clusters[x+1][y]->p_rsp_out[WEST]    (signal_dspin_h_rsp_dec[x][y]);
-
-               clusters[x][y]->p_m2p_out[EAST]      (signal_dspin_h_m2p_inc[x][y]);
-               clusters[x+1][y]->p_m2p_in[WEST]     (signal_dspin_h_m2p_inc[x][y]);
-               clusters[x][y]->p_m2p_in[EAST]       (signal_dspin_h_m2p_dec[x][y]);
-               clusters[x+1][y]->p_m2p_out[WEST]    (signal_dspin_h_m2p_dec[x][y]);
-
-               clusters[x][y]->p_p2m_out[EAST]      (signal_dspin_h_p2m_inc[x][y]);
-               clusters[x+1][y]->p_p2m_in[WEST]     (signal_dspin_h_p2m_inc[x][y]);
-               clusters[x][y]->p_p2m_in[EAST]       (signal_dspin_h_p2m_dec[x][y]);
-               clusters[x+1][y]->p_p2m_out[WEST]    (signal_dspin_h_p2m_dec[x][y]);
-
-               clusters[x][y]->p_cla_out[EAST]      (signal_dspin_h_cla_inc[x][y]);
-               clusters[x+1][y]->p_cla_in[WEST]     (signal_dspin_h_cla_inc[x][y]);
-               clusters[x][y]->p_cla_in[EAST]       (signal_dspin_h_cla_dec[x][y]);
-               clusters[x+1][y]->p_cla_out[WEST]    (signal_dspin_h_cla_dec[x][y]);
-           }
-       }
+   for (int x = 0; x < X_SIZE - 1; x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
+         clusters[x][y]->p_cmd_out[EAST]      (signal_dspin_h_cmd_inc[x][y]);
+         clusters[x + 1][y]->p_cmd_in[WEST]   (signal_dspin_h_cmd_inc[x][y]);
+         clusters[x][y]->p_cmd_in[EAST]       (signal_dspin_h_cmd_dec[x][y]);
+         clusters[x + 1][y]->p_cmd_out[WEST]  (signal_dspin_h_cmd_dec[x][y]);
+
+         clusters[x][y]->p_rsp_out[EAST]      (signal_dspin_h_rsp_inc[x][y]);
+         clusters[x + 1][y]->p_rsp_in[WEST]   (signal_dspin_h_rsp_inc[x][y]);
+         clusters[x][y]->p_rsp_in[EAST]       (signal_dspin_h_rsp_dec[x][y]);
+         clusters[x + 1][y]->p_rsp_out[WEST]  (signal_dspin_h_rsp_dec[x][y]);
+
+         clusters[x][y]->p_m2p_out[EAST]      (signal_dspin_h_m2p_inc[x][y]);
+         clusters[x + 1][y]->p_m2p_in[WEST]   (signal_dspin_h_m2p_inc[x][y]);
+         clusters[x][y]->p_m2p_in[EAST]       (signal_dspin_h_m2p_dec[x][y]);
+         clusters[x + 1][y]->p_m2p_out[WEST]  (signal_dspin_h_m2p_dec[x][y]);
+
+         clusters[x][y]->p_p2m_out[EAST]      (signal_dspin_h_p2m_inc[x][y]);
+         clusters[x + 1][y]->p_p2m_in[WEST]   (signal_dspin_h_p2m_inc[x][y]);
+         clusters[x][y]->p_p2m_in[EAST]       (signal_dspin_h_p2m_dec[x][y]);
+         clusters[x + 1][y]->p_p2m_out[WEST]  (signal_dspin_h_p2m_dec[x][y]);
+
+         clusters[x][y]->p_cla_out[EAST]      (signal_dspin_h_cla_inc[x][y]);
+         clusters[x + 1][y]->p_cla_in[WEST]   (signal_dspin_h_cla_inc[x][y]);
+         clusters[x][y]->p_cla_in[EAST]       (signal_dspin_h_cla_dec[x][y]);
+         clusters[x + 1][y]->p_cla_out[WEST]  (signal_dspin_h_cla_dec[x][y]);
+      }
    }
    std::cout << std::endl << "Horizontal connections done" << std::endl;
 
    // Inter Clusters vertical connections
-   if (Y_SIZE > 1) {
-       for (size_t y = 0; y < (Y_SIZE-1); y++) {
-           for (size_t x = 0; x < X_SIZE; x++) {
-               clusters[x][y]->p_cmd_out[NORTH]     (signal_dspin_v_cmd_inc[x][y]);
-               clusters[x][y+1]->p_cmd_in[SOUTH]    (signal_dspin_v_cmd_inc[x][y]);
-               clusters[x][y]->p_cmd_in[NORTH]      (signal_dspin_v_cmd_dec[x][y]);
-               clusters[x][y+1]->p_cmd_out[SOUTH]   (signal_dspin_v_cmd_dec[x][y]);
-
-               clusters[x][y]->p_rsp_out[NORTH]     (signal_dspin_v_rsp_inc[x][y]);
-               clusters[x][y+1]->p_rsp_in[SOUTH]    (signal_dspin_v_rsp_inc[x][y]);
-               clusters[x][y]->p_rsp_in[NORTH]      (signal_dspin_v_rsp_dec[x][y]);
-               clusters[x][y+1]->p_rsp_out[SOUTH]   (signal_dspin_v_rsp_dec[x][y]);
-
-               clusters[x][y]->p_m2p_out[NORTH]     (signal_dspin_v_m2p_inc[x][y]);
-               clusters[x][y+1]->p_m2p_in[SOUTH]    (signal_dspin_v_m2p_inc[x][y]);
-               clusters[x][y]->p_m2p_in[NORTH]      (signal_dspin_v_m2p_dec[x][y]);
-               clusters[x][y+1]->p_m2p_out[SOUTH]   (signal_dspin_v_m2p_dec[x][y]);
-
-               clusters[x][y]->p_p2m_out[NORTH]     (signal_dspin_v_p2m_inc[x][y]);
-               clusters[x][y+1]->p_p2m_in[SOUTH]    (signal_dspin_v_p2m_inc[x][y]);
-               clusters[x][y]->p_p2m_in[NORTH]      (signal_dspin_v_p2m_dec[x][y]);
-               clusters[x][y+1]->p_p2m_out[SOUTH]   (signal_dspin_v_p2m_dec[x][y]);
-
-               clusters[x][y]->p_cla_out[NORTH]     (signal_dspin_v_cla_inc[x][y]);
-               clusters[x][y+1]->p_cla_in[SOUTH]    (signal_dspin_v_cla_inc[x][y]);
-               clusters[x][y]->p_cla_in[NORTH]      (signal_dspin_v_cla_dec[x][y]);
-               clusters[x][y+1]->p_cla_out[SOUTH]   (signal_dspin_v_cla_dec[x][y]);
-           }
-       }
+   for (int y = 0; y < Y_SIZE - 1; y++) {
+      for (int x = 0; x < X_SIZE; x++) {
+         clusters[x][y]->p_cmd_out[NORTH]     (signal_dspin_v_cmd_inc[x][y]);
+         clusters[x][y + 1]->p_cmd_in[SOUTH]  (signal_dspin_v_cmd_inc[x][y]);
+         clusters[x][y]->p_cmd_in[NORTH]      (signal_dspin_v_cmd_dec[x][y]);
+         clusters[x][y + 1]->p_cmd_out[SOUTH] (signal_dspin_v_cmd_dec[x][y]);
+
+         clusters[x][y]->p_rsp_out[NORTH]     (signal_dspin_v_rsp_inc[x][y]);
+         clusters[x][y + 1]->p_rsp_in[SOUTH]  (signal_dspin_v_rsp_inc[x][y]);
+         clusters[x][y]->p_rsp_in[NORTH]      (signal_dspin_v_rsp_dec[x][y]);
+         clusters[x][y + 1]->p_rsp_out[SOUTH] (signal_dspin_v_rsp_dec[x][y]);
+
+         clusters[x][y]->p_m2p_out[NORTH]     (signal_dspin_v_m2p_inc[x][y]);
+         clusters[x][y + 1]->p_m2p_in[SOUTH]  (signal_dspin_v_m2p_inc[x][y]);
+         clusters[x][y]->p_m2p_in[NORTH]      (signal_dspin_v_m2p_dec[x][y]);
+         clusters[x][y + 1]->p_m2p_out[SOUTH] (signal_dspin_v_m2p_dec[x][y]);
+
+         clusters[x][y]->p_p2m_out[NORTH]     (signal_dspin_v_p2m_inc[x][y]);
+         clusters[x][y + 1]->p_p2m_in[SOUTH]  (signal_dspin_v_p2m_inc[x][y]);
+         clusters[x][y]->p_p2m_in[NORTH]      (signal_dspin_v_p2m_dec[x][y]);
+         clusters[x][y + 1]->p_p2m_out[SOUTH] (signal_dspin_v_p2m_dec[x][y]);
+
+         clusters[x][y]->p_cla_out[NORTH]     (signal_dspin_v_cla_inc[x][y]);
+         clusters[x][y + 1]->p_cla_in[SOUTH]  (signal_dspin_v_cla_inc[x][y]);
+         clusters[x][y]->p_cla_in[NORTH]      (signal_dspin_v_cla_dec[x][y]);
+         clusters[x][y + 1]->p_cla_out[SOUTH] (signal_dspin_v_cla_dec[x][y]);
+      }
    }
    std::cout << std::endl << "Vertical connections done" << std::endl;
 
    // East & West boundary cluster connections
-   for (size_t y = 0; y < (Y_SIZE); y++) {
+   for (size_t y = 0; y < Y_SIZE; y++) {
        clusters[0][y]->p_cmd_in[WEST]           (signal_dspin_bound_cmd_in[0][y][WEST]);
        clusters[0][y]->p_cmd_out[WEST]          (signal_dspin_bound_cmd_out[0][y][WEST]);
-       clusters[X_SIZE-1][y]->p_cmd_in[EAST]    (signal_dspin_bound_cmd_in[X_SIZE-1][y][EAST]);
-       clusters[X_SIZE-1][y]->p_cmd_out[EAST]   (signal_dspin_bound_cmd_out[X_SIZE-1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_cmd_in[EAST]  (signal_dspin_bound_cmd_in[X_SIZE - 1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_cmd_out[EAST] (signal_dspin_bound_cmd_out[X_SIZE - 1][y][EAST]);
 
        clusters[0][y]->p_rsp_in[WEST]           (signal_dspin_bound_rsp_in[0][y][WEST]);
        clusters[0][y]->p_rsp_out[WEST]          (signal_dspin_bound_rsp_out[0][y][WEST]);
-       clusters[X_SIZE-1][y]->p_rsp_in[EAST]    (signal_dspin_bound_rsp_in[X_SIZE-1][y][EAST]);
-       clusters[X_SIZE-1][y]->p_rsp_out[EAST]   (signal_dspin_bound_rsp_out[X_SIZE-1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_rsp_in[EAST]  (signal_dspin_bound_rsp_in[X_SIZE - 1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_rsp_out[EAST] (signal_dspin_bound_rsp_out[X_SIZE - 1][y][EAST]);
 
        clusters[0][y]->p_m2p_in[WEST]           (signal_dspin_bound_m2p_in[0][y][WEST]);
        clusters[0][y]->p_m2p_out[WEST]          (signal_dspin_bound_m2p_out[0][y][WEST]);
-       clusters[X_SIZE-1][y]->p_m2p_in[EAST]    (signal_dspin_bound_m2p_in[X_SIZE-1][y][EAST]);
-       clusters[X_SIZE-1][y]->p_m2p_out[EAST]   (signal_dspin_bound_m2p_out[X_SIZE-1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_m2p_in[EAST]  (signal_dspin_bound_m2p_in[X_SIZE - 1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_m2p_out[EAST] (signal_dspin_bound_m2p_out[X_SIZE - 1][y][EAST]);
 
        clusters[0][y]->p_p2m_in[WEST]           (signal_dspin_bound_p2m_in[0][y][WEST]);
        clusters[0][y]->p_p2m_out[WEST]          (signal_dspin_bound_p2m_out[0][y][WEST]);
-       clusters[X_SIZE-1][y]->p_p2m_in[EAST]    (signal_dspin_bound_p2m_in[X_SIZE-1][y][EAST]);
-       clusters[X_SIZE-1][y]->p_p2m_out[EAST]   (signal_dspin_bound_p2m_out[X_SIZE-1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_p2m_in[EAST]  (signal_dspin_bound_p2m_in[X_SIZE - 1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_p2m_out[EAST] (signal_dspin_bound_p2m_out[X_SIZE - 1][y][EAST]);
 
        clusters[0][y]->p_cla_in[WEST]           (signal_dspin_bound_cla_in[0][y][WEST]);
        clusters[0][y]->p_cla_out[WEST]          (signal_dspin_bound_cla_out[0][y][WEST]);
-       clusters[X_SIZE-1][y]->p_cla_in[EAST]    (signal_dspin_bound_cla_in[X_SIZE-1][y][EAST]);
-       clusters[X_SIZE-1][y]->p_cla_out[EAST]   (signal_dspin_bound_cla_out[X_SIZE-1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_cla_in[EAST]  (signal_dspin_bound_cla_in[X_SIZE - 1][y][EAST]);
+       clusters[X_SIZE - 1][y]->p_cla_out[EAST] (signal_dspin_bound_cla_out[X_SIZE - 1][y][EAST]);
    }
 
@@ -859,26 +831,26 @@
        clusters[x][0]->p_cmd_in[SOUTH]          (signal_dspin_bound_cmd_in[x][0][SOUTH]);
        clusters[x][0]->p_cmd_out[SOUTH]         (signal_dspin_bound_cmd_out[x][0][SOUTH]);
-       clusters[x][Y_SIZE-1]->p_cmd_in[NORTH]   (signal_dspin_bound_cmd_in[x][Y_SIZE-1][NORTH]);
-       clusters[x][Y_SIZE-1]->p_cmd_out[NORTH]  (signal_dspin_bound_cmd_out[x][Y_SIZE-1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_cmd_in[NORTH] (signal_dspin_bound_cmd_in[x][Y_SIZE - 1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_cmd_out[NORTH](signal_dspin_bound_cmd_out[x][Y_SIZE - 1][NORTH]);
 
        clusters[x][0]->p_rsp_in[SOUTH]          (signal_dspin_bound_rsp_in[x][0][SOUTH]);
        clusters[x][0]->p_rsp_out[SOUTH]         (signal_dspin_bound_rsp_out[x][0][SOUTH]);
-       clusters[x][Y_SIZE-1]->p_rsp_in[NORTH]   (signal_dspin_bound_rsp_in[x][Y_SIZE-1][NORTH]);
-       clusters[x][Y_SIZE-1]->p_rsp_out[NORTH]  (signal_dspin_bound_rsp_out[x][Y_SIZE-1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_rsp_in[NORTH] (signal_dspin_bound_rsp_in[x][Y_SIZE - 1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_rsp_out[NORTH](signal_dspin_bound_rsp_out[x][Y_SIZE - 1][NORTH]);
 
        clusters[x][0]->p_m2p_in[SOUTH]          (signal_dspin_bound_m2p_in[x][0][SOUTH]);
        clusters[x][0]->p_m2p_out[SOUTH]         (signal_dspin_bound_m2p_out[x][0][SOUTH]);
-       clusters[x][Y_SIZE-1]->p_m2p_in[NORTH]   (signal_dspin_bound_m2p_in[x][Y_SIZE-1][NORTH]);
-       clusters[x][Y_SIZE-1]->p_m2p_out[NORTH]  (signal_dspin_bound_m2p_out[x][Y_SIZE-1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_m2p_in[NORTH] (signal_dspin_bound_m2p_in[x][Y_SIZE - 1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_m2p_out[NORTH](signal_dspin_bound_m2p_out[x][Y_SIZE - 1][NORTH]);
 
        clusters[x][0]->p_p2m_in[SOUTH]          (signal_dspin_bound_p2m_in[x][0][SOUTH]);
        clusters[x][0]->p_p2m_out[SOUTH]         (signal_dspin_bound_p2m_out[x][0][SOUTH]);
-       clusters[x][Y_SIZE-1]->p_p2m_in[NORTH]   (signal_dspin_bound_p2m_in[x][Y_SIZE-1][NORTH]);
-       clusters[x][Y_SIZE-1]->p_p2m_out[NORTH]  (signal_dspin_bound_p2m_out[x][Y_SIZE-1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_p2m_in[NORTH] (signal_dspin_bound_p2m_in[x][Y_SIZE - 1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_p2m_out[NORTH](signal_dspin_bound_p2m_out[x][Y_SIZE - 1][NORTH]);
 
        clusters[x][0]->p_cla_in[SOUTH]          (signal_dspin_bound_cla_in[x][0][SOUTH]);
        clusters[x][0]->p_cla_out[SOUTH]         (signal_dspin_bound_cla_out[x][0][SOUTH]);
-       clusters[x][Y_SIZE-1]->p_cla_in[NORTH]   (signal_dspin_bound_cla_in[x][Y_SIZE-1][NORTH]);
-       clusters[x][Y_SIZE-1]->p_cla_out[NORTH]  (signal_dspin_bound_cla_out[x][Y_SIZE-1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_cla_in[NORTH] (signal_dspin_bound_cla_in[x][Y_SIZE - 1][NORTH]);
+       clusters[x][Y_SIZE - 1]->p_cla_out[NORTH](signal_dspin_bound_cla_out[x][Y_SIZE - 1][NORTH]);
    }
 
@@ -893,6 +865,6 @@
         GdbServer<Mips32ElIss> > * > l1_caches;
 
-   for (size_t x = 0; x < X_SIZE; x++) {
-      for (size_t y = 0; y < Y_SIZE; y++) {
+   for (int x = 0; x < X_SIZE; x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
          for (int proc = 0; proc < NB_PROCS_MAX; proc++) {
             l1_caches.push_back(clusters[x][y]->proc[proc]);
@@ -901,6 +873,6 @@
    }
 
-   for (size_t x = 0; x < X_SIZE; x++) {
-      for (size_t y = 0; y < Y_SIZE; y++) {
+   for (int x = 0; x < X_SIZE; x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
          clusters[x][y]->memc->set_vcache_list(l1_caches);
       }
@@ -913,38 +885,34 @@
    sc_trace_file * tf = sc_create_vcd_trace_file("my_trace_file");
 
-   if (X_SIZE > 1){
-      for (size_t x = 0; x < (X_SIZE-1); x++){
-         for (size_t y = 0; y < Y_SIZE; y++){
-            for (size_t k = 0; k < 3; k++){
-               signal_dspin_h_cmd_inc[x][y][k].trace(tf, "dspin_h_cmd_inc");
-               signal_dspin_h_cmd_dec[x][y][k].trace(tf, "dspin_h_cmd_dec");
-            }
-
-            for (size_t k = 0; k < 2; k++){
-               signal_dspin_h_rsp_inc[x][y][k].trace(tf, "dspin_h_rsp_inc");
-               signal_dspin_h_rsp_dec[x][y][k].trace(tf, "dspin_h_rsp_dec");
-            }
-         }
-      }
-   }
-
-   if (Y_SIZE > 1) {
-      for (size_t y = 0; y < (Y_SIZE-1); y++){
-         for (size_t x = 0; x < X_SIZE; x++){
-            for (size_t k = 0; k < 3; k++){
-               signal_dspin_v_cmd_inc[x][y][k].trace(tf, "dspin_v_cmd_inc");
-               signal_dspin_v_cmd_dec[x][y][k].trace(tf, "dspin_v_cmd_dec");
-            }
-
-            for (size_t k = 0; k < 2; k++){
-               signal_dspin_v_rsp_inc[x][y][k].trace(tf, "dspin_v_rsp_inc");
-               signal_dspin_v_rsp_dec[x][y][k].trace(tf, "dspin_v_rsp_dec");
-            }
-         }
-      }
-   }
-
-   for (size_t x = 0; x < (X_SIZE); x++){
-      for (size_t y = 0; y < Y_SIZE; y++){
+   for (int x = 0; x < X_SIZE - 1; x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
+         for (int k = 0; k < 3; k++) {
+            signal_dspin_h_cmd_inc[x][y][k].trace(tf, "dspin_h_cmd_inc");
+            signal_dspin_h_cmd_dec[x][y][k].trace(tf, "dspin_h_cmd_dec");
+         }
+
+         for (int k = 0; k < 2; k++) {
+            signal_dspin_h_rsp_inc[x][y][k].trace(tf, "dspin_h_rsp_inc");
+            signal_dspin_h_rsp_dec[x][y][k].trace(tf, "dspin_h_rsp_dec");
+         }
+      }
+   }
+
+   for (int y = 0; y < Y_SIZE - 1; y++) {
+      for (int x = 0; x < X_SIZE; x++) {
+         for (int k = 0; k < 3; k++) {
+            signal_dspin_v_cmd_inc[x][y][k].trace(tf, "dspin_v_cmd_inc");
+            signal_dspin_v_cmd_dec[x][y][k].trace(tf, "dspin_v_cmd_dec");
+         }
+
+         for (int k = 0; k < 2; k++) {
+            signal_dspin_v_rsp_inc[x][y][k].trace(tf, "dspin_v_rsp_inc");
+            signal_dspin_v_rsp_dec[x][y][k].trace(tf, "dspin_v_rsp_dec");
+         }
+      }
+   }
+
+   for (int x = 0; x < (X_SIZE); x++) {
+      for (int y = 0; y < Y_SIZE; y++) {
          std::ostringstream signame;
          signame << "cluster" << x << "_" << y;
@@ -994,4 +962,6 @@
        }
    }
+   // @M debug fu**
+   clusters[0][0]->signal_dspin_m2p_proc[2].read = true;
 
    sc_start(sc_core::sc_time(1, SC_NS));
@@ -1008,11 +978,8 @@
       }
 
-      for (int64_t n = 1; n < ncycles && !stop_called; n++)
-      {
-         if ((n % max_cycles) == 0)
-         {
-
-            if (gettimeofday(&t2, NULL) != 0)
-            {
+      for (int64_t n = 1; n < ncycles && !stop_called; n++) {
+         if ((n % max_cycles) == 0) {
+
+            if (gettimeofday(&t2, NULL) != 0) {
                perror("gettimeofday");
                return EXIT_FAILURE;
@@ -1047,12 +1014,14 @@
          }
 
-         if ((n > debug_from) and (n % debug_period == 0))
-         {
+         if ((n > debug_from) and (n % debug_period == 0)) {
             std::cout << "****************** cycle " << std::dec << n ;
             std::cout << "************************************************" << std::endl;
 
-            for (size_t x = 0; x < X_SIZE ; x++){
-               for (size_t y = 0; y < Y_SIZE ; y++){
+            for (size_t x = 0; x < X_SIZE ; x++) {
+               for (size_t y = 0; y < Y_SIZE ; y++) {
                   for (int proc = 0; proc < NB_PROCS_MAX; proc++) {
+                     if (x == 0 && y == 0 && proc == 2) {
+                        continue;
+                     }
                      clusters[x][y]->proc[proc]->print_trace();
                      std::ostringstream proc_signame;
@@ -1141,6 +1110,5 @@
 
    // Free memory
-   for (size_t i = 0; i  < (X_SIZE * Y_SIZE); i++)
-   {
+   for (size_t i = 0; i  < (X_SIZE * Y_SIZE); i++) {
       size_t x = i / Y_SIZE;
       size_t y = i % Y_SIZE;
@@ -1148,33 +1116,33 @@
    }
 
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, X_SIZE-1, Y_SIZE);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, X_SIZE-1, Y_SIZE);
-
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, X_SIZE-1, Y_SIZE);
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, X_SIZE-1, Y_SIZE);
-
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_inc, X_SIZE-1, Y_SIZE);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_dec, X_SIZE-1, Y_SIZE);
-
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_inc, X_SIZE-1, Y_SIZE);
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_dec, X_SIZE-1, Y_SIZE);
-
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_inc, X_SIZE-1, Y_SIZE);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_dec, X_SIZE-1, Y_SIZE);
-
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, X_SIZE, Y_SIZE-1);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, X_SIZE, Y_SIZE-1);
-
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, X_SIZE, Y_SIZE-1);
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, X_SIZE, Y_SIZE-1);
-
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_inc, X_SIZE, Y_SIZE-1);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_dec, X_SIZE, Y_SIZE-1);
-
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_inc, X_SIZE, Y_SIZE-1);
-   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_dec, X_SIZE, Y_SIZE-1);
-
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_inc, X_SIZE, Y_SIZE-1);
-   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_dec, X_SIZE, Y_SIZE-1);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_inc, X_SIZE - 1, Y_SIZE);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cmd_dec, X_SIZE - 1, Y_SIZE);
+
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_inc, X_SIZE - 1, Y_SIZE);
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_rsp_dec, X_SIZE - 1, Y_SIZE);
+
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_inc, X_SIZE - 1, Y_SIZE);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_m2p_dec, X_SIZE - 1, Y_SIZE);
+
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_inc, X_SIZE - 1, Y_SIZE);
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_h_p2m_dec, X_SIZE - 1, Y_SIZE);
+
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_inc, X_SIZE - 1, Y_SIZE);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_h_cla_dec, X_SIZE - 1, Y_SIZE);
+
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_inc, X_SIZE, Y_SIZE - 1);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cmd_dec, X_SIZE, Y_SIZE - 1);
+
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_inc, X_SIZE, Y_SIZE - 1);
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_rsp_dec, X_SIZE, Y_SIZE - 1);
+
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_inc, X_SIZE, Y_SIZE - 1);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_m2p_dec, X_SIZE, Y_SIZE - 1);
+
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_inc, X_SIZE, Y_SIZE - 1);
+   dealloc_elems<DspinSignals<dspin_rsp_width> >(signal_dspin_v_p2m_dec, X_SIZE, Y_SIZE - 1);
+
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_inc, X_SIZE, Y_SIZE - 1);
+   dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_v_cla_dec, X_SIZE, Y_SIZE - 1);
 
    dealloc_elems<DspinSignals<dspin_cmd_width> >(signal_dspin_bound_cmd_in, X_SIZE, Y_SIZE, 4);
@@ -1204,6 +1172,5 @@
 void voidhandler(int dummy = 0) {}
 
-int sc_main (int argc, char *argv[])
-{
+int sc_main (int argc, char *argv[]) {
    signal(SIGINT, handler);
    signal(SIGPIPE, voidhandler);
@@ -1213,5 +1180,6 @@
    } catch (std::exception &e) {
       std::cout << e.what() << std::endl;
-   } catch (...) {
+   }
+   catch (...) {
       std::cout << "Unknown exception occured" << std::endl;
       throw;
