Index: trunk/platforms/tsar_generic_xbar/top.cpp
===================================================================
--- trunk/platforms/tsar_generic_xbar/top.cpp	(revision 428)
+++ trunk/platforms/tsar_generic_xbar/top.cpp	(revision 438)
@@ -45,7 +45,7 @@
 // - CLUSTER_SIZE     : size of the segment allocated to a cluster
 // - NB_PROCS_MAX     : number of processors per cluster (power of 2)
-// - NB_DMA_CHANNELS      : number of DMA channels per cluster (< 9)
-// - NB_TTY_CHANNELS          : number of TTY channels in I/O cluster (< 16)
-// - NB_NIC_CHANNELS          : number of NIC channels in I/O cluster (< 9)
+// - NB_DMA_CHANNELS  : number of DMA channels per cluster (< 9)
+// - NB_TTY_CHANNELS  : number of TTY channels in I/O cluster (< 16)
+// - NB_NIC_CHANNELS  : number of NIC channels in I/O cluster (< 9)
 // 
 // Some other hardware parameters are not used when compiling the OS,
@@ -112,5 +112,5 @@
 
 //  cluster index (computed from x,y coordinates)
-#define cluster(x,y)   (y + CLUSTER_Y*x)
+#define cluster(x,y)   (y + YMAX*x)
 
 ///////////////////////////////////////////////////////////
@@ -125,25 +125,16 @@
 ///////////////////////////////////////////////////////////
 
-#define int_vci_cell_width    4
-#define int_vci_plen_width    8
-#define int_vci_address_width 40
-#define int_vci_rerror_width  1
-#define int_vci_clen_width    1
-#define int_vci_rflag_width   1
-#define int_vci_srcid_width   14
-#define int_vci_pktid_width   4
-#define int_vci_trdid_width   4
-#define int_vci_wrplen_width  1
-
-#define ext_vci_cell_width    8
-#define ext_vci_plen_width    8
-#define ext_vci_address_width 40
-#define ext_vci_rerror_width  1
-#define ext_vci_clen_width    1
-#define ext_vci_rflag_width   1
-#define ext_vci_srcid_width   14
-#define ext_vci_pktid_width   4
-#define ext_vci_trdid_width   4
-#define ext_vci_wrplen_width  1
+#define vci_cell_width_int    4
+#define vci_cell_width_ext    8
+
+#define vci_plen_width        8
+#define vci_address_width     40
+#define vci_rerror_width      1
+#define vci_clen_width        1
+#define vci_rflag_width       1
+#define vci_srcid_width       14
+#define vci_pktid_width       4
+#define vci_trdid_width       4
+#define vci_wrplen_width      1
 
 ////////////////////////////////////////////////////////////
@@ -157,4 +148,7 @@
 //////////////////////i/////////////////////////////////////
 
+#define XMAX                  CLUSTER_X
+#define YMAX                  CLUSTER_Y
+
 #define XRAM_LATENCY          0
 
@@ -178,4 +172,9 @@
 #define NIC_TIMEOUT           10000
 
+#define NORTH                 0
+#define SOUTH                 1
+#define EAST                  2
+#define WEST                  3
+
 ////////////////////////////////////////////////////////////
 //    Software to be loaded in ROM & RAM         
@@ -189,7 +188,4 @@
 
 #define MAX_FROZEN_CYCLES     10000
-
-#define TRACE_MEMC_ID         1000000
-#define TRACE_PROC_ID         1000000
 
 /////////////////////////////////////////////////////////
@@ -241,6 +237,6 @@
 #define FBUF_TGTID      4
 #define BDEV_TGTID      5
-#define BROM_TGTID      6
-#define MNIC_TGTID      7
+#define MNIC_TGTID      6
+#define BROM_TGTID      7
 
 /////////////////////////////////
@@ -250,4 +246,5 @@
    using namespace soclib::caba;
    using namespace soclib::common;
+
 
    char     soft_name[256]   = SOFT_NAME;          // pathname to binary code
@@ -259,6 +256,6 @@
    bool     debug_ok         = false;              // trace activated
    size_t   debug_period     = 1;                  // trace period
-   size_t   debug_memc_id    = TRACE_MEMC_ID;      // index of memc to be traced 
-   size_t   debug_proc_id    = TRACE_PROC_ID;      // index of proc to be traced
+   size_t   debug_memc_id    = 0;                  // index of memc to be traced 
+   size_t   debug_proc_id    = 0;                  // index of proc to be traced
    uint32_t debug_from       = 0;                  // trace start cycle
    uint32_t frozen_cycles    = MAX_FROZEN_CYCLES;  // monitoring frozen processor
@@ -290,5 +287,5 @@
          {
             debug_memc_id = atoi(argv[n+1]);
-            assert( (debug_memc_id < (CLUSTER_X*CLUSTER_Y) ) && 
+            assert( (debug_memc_id < (XMAX*YMAX) ) && 
                    "debug_memc_id larger than XMAX * YMAX" );
          }
@@ -296,5 +293,5 @@
          {
             debug_proc_id = atoi(argv[n+1]);
-            assert( (debug_proc_id < (CLUSTER_X * CLUSTER_Y * NB_PROCS_MAX) ) && 
+            assert( (debug_proc_id < (XMAX * YMAX * NB_PROCS_MAX) ) && 
                    "debug_proc_id larger than XMAX * YMAX * NB_PROCS" );
          }
@@ -332,11 +329,11 @@
 
     // checking hardware parameters
-    assert( ( (CLUSTER_X == 1) or (CLUSTER_X == 2) or (CLUSTER_X == 4) or
-              (CLUSTER_X == 8) or (CLUSTER_X == 16) ) and
-              "The CLUSTER_X parameter must be 1, 2, 4, 8 or 16" );
-
-    assert( ( (CLUSTER_Y == 1) or (CLUSTER_Y == 2) or (CLUSTER_Y == 4) or
-              (CLUSTER_Y == 8) or (CLUSTER_Y == 16) ) and
-              "The CLUSTER_Y parameter must be 1, 2, 4, 8 or 16" );
+    assert( ( (XMAX == 1) or (XMAX == 2) or (XMAX == 4) or
+              (XMAX == 8) or (XMAX == 16) ) and
+              "The XMAX parameter must be 1, 2, 4, 8 or 16" );
+
+    assert( ( (YMAX == 1) or (YMAX == 2) or (YMAX == 4) or
+              (YMAX == 8) or (YMAX == 16) ) and
+              "The YMAX parameter must be 1, 2, 4, 8 or 16" );
 
     assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or
@@ -353,46 +350,46 @@
             "The NB_NIC_CHANNELS parameter must be smaller than 9" );
 
-    assert( (int_vci_address_width == ext_vci_address_width) and
+    assert( (vci_address_width == vci_address_width) and
             "address widths must be equal on internal & external networks" );
 
-    assert( (int_vci_address_width == 40) and
+    assert( (vci_address_width == 40) and
             "VCI address width must be 40 bits" );
 
     std::cout << std::endl;
-    std::cout << " - CLUSTER_X    = " << CLUSTER_X << std::endl;
-    std::cout << " - CLUSTER_Y    = " << CLUSTER_Y << std::endl;
-    std::cout << " - NB_PROCS_MAX = " << NB_PROCS_MAX <<  std::endl;
+    std::cout << " - XMAX             = " << XMAX << std::endl;
+    std::cout << " - YMAX             = " << YMAX << std::endl;
+    std::cout << " - NB_PROCS_MAX     = " << NB_PROCS_MAX <<  std::endl;
     std::cout << " - NB_DMA_CHANNELS  = " << NB_DMA_CHANNELS <<  std::endl;
-    std::cout << " - NB_TTY_CHANNELS      = " << NB_TTY_CHANNELS <<  std::endl;
-    std::cout << " - NB_NIC_CHANNELS      = " << NB_NIC_CHANNELS <<  std::endl;
-    std::cout << " - MEMC_WAYS    = " << MEMC_WAYS << std::endl;
-    std::cout << " - MEMC_SETS    = " << MEMC_SETS << std::endl;
-    std::cout << " - RAM_LATENCY  = " << XRAM_LATENCY << std::endl;
-    std::cout << " - MAX_FROZEN   = " << frozen_cycles << std::endl;
+    std::cout << " - NB_TTY_CHANNELS  = " << NB_TTY_CHANNELS <<  std::endl;
+    std::cout << " - NB_NIC_CHANNELS  = " << NB_NIC_CHANNELS <<  std::endl;
+    std::cout << " - MEMC_WAYS        = " << MEMC_WAYS << std::endl;
+    std::cout << " - MEMC_SETS        = " << MEMC_SETS << std::endl;
+    std::cout << " - RAM_LATENCY      = " << XRAM_LATENCY << std::endl;
+    std::cout << " - MAX_FROZEN       = " << frozen_cycles << std::endl;
 
     std::cout << std::endl;
 
     // Internal and External VCI parameters definition
-    typedef soclib::caba::VciParams<int_vci_cell_width,
-                                    int_vci_plen_width,
-                                    int_vci_address_width,
-                                    int_vci_rerror_width,
-                                    int_vci_clen_width,
-                                    int_vci_rflag_width,
-                                    int_vci_srcid_width,
-                                    int_vci_pktid_width,
-                                    int_vci_trdid_width,
-                                    int_vci_wrplen_width> vci_param_int;
-
-    typedef soclib::caba::VciParams<ext_vci_cell_width,
-                                    ext_vci_plen_width,
-                                    ext_vci_address_width,
-                                    ext_vci_rerror_width,
-                                    ext_vci_clen_width,
-                                    ext_vci_rflag_width,
-                                    ext_vci_srcid_width,
-                                    ext_vci_pktid_width,
-                                    ext_vci_trdid_width,
-                                    ext_vci_wrplen_width> vci_param_ext;
+    typedef soclib::caba::VciParams<vci_cell_width_int,
+                                    vci_plen_width,
+                                    vci_address_width,
+                                    vci_rerror_width,
+                                    vci_clen_width,
+                                    vci_rflag_width,
+                                    vci_srcid_width,
+                                    vci_pktid_width,
+                                    vci_trdid_width,
+                                    vci_wrplen_width> vci_param_int;
+
+    typedef soclib::caba::VciParams<vci_cell_width_ext,
+                                    vci_plen_width,
+                                    vci_address_width,
+                                    vci_rerror_width,
+                                    vci_clen_width,
+                                    vci_rflag_width,
+                                    vci_srcid_width,
+                                    vci_pktid_width,
+                                    vci_trdid_width,
+                                    vci_wrplen_width> vci_param_ext;
 
 #if USE_OPENMP
@@ -406,14 +403,14 @@
    size_t   y_width;
 
-   if      (CLUSTER_X == 1) x_width = 0;
-   else if (CLUSTER_X == 2) x_width = 1;
-   else if (CLUSTER_X <= 4) x_width = 2;
-   else if (CLUSTER_X <= 8) x_width = 3;
+   if      (XMAX == 1) x_width = 0;
+   else if (XMAX == 2) x_width = 1;
+   else if (XMAX <= 4) x_width = 2;
+   else if (XMAX <= 8) x_width = 3;
    else                     x_width = 4;
 
-   if      (CLUSTER_Y == 1) y_width = 0;
-   else if (CLUSTER_Y == 2) y_width = 1;
-   else if (CLUSTER_Y <= 4) y_width = 2;
-   else if (CLUSTER_Y <= 8) y_width = 3;
+   if      (YMAX == 1) y_width = 0;
+   else if (YMAX == 2) y_width = 1;
+   else if (YMAX <= 4) y_width = 2;
+   else if (YMAX <= 8) y_width = 3;
    else                     y_width = 4;
 
@@ -423,16 +420,16 @@
 
    // internal network
-   MappingTable maptabd(int_vci_address_width, 
+   MappingTable maptabd(vci_address_width, 
                         IntTab(x_width + y_width, 16 - x_width - y_width), 
-                        IntTab(x_width + y_width, int_vci_srcid_width - x_width - y_width), 
+                        IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), 
                         0x00FF000000);
 
-   for (size_t x = 0; x < CLUSTER_X; x++)
+   for (size_t x = 0; x < XMAX; x++)
    {
-      for (size_t y = 0; y < CLUSTER_Y; y++)
+      for (size_t y = 0; y < YMAX; y++)
       {
-         sc_uint<int_vci_address_width> offset;
-         offset = (sc_uint<int_vci_address_width>)cluster(x,y) 
-                   << (int_vci_address_width-x_width-y_width);
+         sc_uint<vci_address_width> offset;
+         offset = (sc_uint<vci_address_width>)cluster(x,y) 
+                   << (vci_address_width-x_width-y_width);
 
          std::ostringstream    sh;
@@ -469,17 +466,17 @@
 
    // external network
-   MappingTable maptabx(ext_vci_address_width, 
+   MappingTable maptabx(vci_address_width, 
                         IntTab(x_width+y_width), 
                         IntTab(x_width+y_width), 
                         0xFFFF000000ULL);
 
-   for (size_t x = 0; x < CLUSTER_X; x++)
+   for (size_t x = 0; x < XMAX; x++)
    {
-      for (size_t y = 0; y < CLUSTER_Y ; y++)
+      for (size_t y = 0; y < YMAX ; y++)
       { 
 
-         sc_uint<ext_vci_address_width> offset;
-         offset = (sc_uint<ext_vci_address_width>)cluster(x,y) 
-                   << (ext_vci_address_width-x_width-y_width);
+         sc_uint<vci_address_width> offset;
+         offset = (sc_uint<vci_address_width>)cluster(x,y) 
+                   << (vci_address_width-x_width-y_width);
 
          std::ostringstream sh;
@@ -499,41 +496,33 @@
    sc_signal<bool>    signal_resetn("resetn");
 
-   enum {
-      NORTH = VirtualDspinRouter<dspin_cmd_width>::NORTH,
-      SOUTH = VirtualDspinRouter<dspin_cmd_width>::SOUTH,
-      EAST  = VirtualDspinRouter<dspin_cmd_width>::EAST,
-      WEST  = VirtualDspinRouter<dspin_cmd_width>::WEST,
-      LOCAL = VirtualDspinRouter<dspin_cmd_width>::LOCAL
-   };
-
    // Horizontal inter-clusters DSPIN signals
    DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_inc =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", CLUSTER_X-1, CLUSTER_Y, 2);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", XMAX-1, YMAX, 2);
    DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", CLUSTER_X-1, CLUSTER_Y, 2);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", XMAX-1, YMAX, 2);
    DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", CLUSTER_X-1, CLUSTER_Y, 2);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", XMAX-1, YMAX, 2);
    DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", CLUSTER_X-1, CLUSTER_Y, 2);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", XMAX-1, YMAX, 2);
 
    // Vertical inter-clusters DSPIN signals
    DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", CLUSTER_X, CLUSTER_Y-1, 2);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", XMAX, YMAX-1, 2);
    DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", CLUSTER_X, CLUSTER_Y-1, 2);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", XMAX, YMAX-1, 2);
    DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", CLUSTER_X, CLUSTER_Y-1, 2);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", XMAX, YMAX-1, 2);
    DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", CLUSTER_X, CLUSTER_Y-1, 2);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", XMAX, YMAX-1, 2);
 
    // Mesh boundaries DSPIN signals
    DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in", CLUSTER_X, CLUSTER_Y, 2, 4);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in", XMAX, YMAX, 2, 4);
    DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out =
-      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", CLUSTER_X, CLUSTER_Y, 2, 4);
+      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", XMAX, YMAX, 2, 4);
    DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in", CLUSTER_X, CLUSTER_Y, 2, 4);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in", XMAX, YMAX, 2, 4);
    DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out =
-      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", CLUSTER_X, CLUSTER_Y, 2, 4);
+      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", XMAX, YMAX, 2, 4);
 
 
@@ -560,5 +549,5 @@
                    dspin_rsp_width,
                    vci_param_int,
-                   vci_param_ext>*          clusters[CLUSTER_X][CLUSTER_Y];
+                   vci_param_ext>*          clusters[XMAX][YMAX];
 
 #if USE_OPENMP
@@ -567,8 +556,8 @@
 #pragma omp for
 #endif
-        for(size_t i = 0; i  < (CLUSTER_X * CLUSTER_Y); i++)
+        for(size_t i = 0; i  < (XMAX * YMAX); i++)
         {
-            size_t x = i / CLUSTER_Y;
-            size_t y = i % CLUSTER_Y;
+            size_t x = i / YMAX;
+            size_t y = i % YMAX;
 
 #if USE_OPENMP
@@ -576,4 +565,7 @@
             {
 #endif
+            std::cout << std::endl;
+            std::cout << "Cluster_" << x << "_" << y << std::endl;
+            std::cout << std::endl;
 
             std::ostringstream sc;
@@ -595,5 +587,5 @@
                 x_width,
                 y_width,
-                int_vci_srcid_width - x_width - y_width,   // l_id width,
+                vci_srcid_width - x_width - y_width,   // l_id width,
                 MEMC_TGTID,
                 XICU_TGTID,
@@ -627,8 +619,4 @@
             );
 
-            std::cout << std::endl;
-            std::cout << "cluster_" << x << "_" << y << " constructed" << std::endl;
-            std::cout << std::endl;
-
 #if USE_OPENMP
             } // end critical
@@ -644,6 +632,6 @@
 
    // Clock & RESET
-   for (size_t x = 0; x < (CLUSTER_X); x++){
-      for (size_t y = 0; y < CLUSTER_Y; y++){
+   for (size_t x = 0; x < (XMAX); x++){
+      for (size_t y = 0; y < YMAX; y++){
          clusters[x][y]->p_clk                         (signal_clk);
          clusters[x][y]->p_resetn                      (signal_resetn);
@@ -652,16 +640,16 @@
 
    // Inter Clusters horizontal connections
-   if (CLUSTER_X > 1){
-      for (size_t x = 0; x < (CLUSTER_X-1); x++){
-         for (size_t y = 0; y < CLUSTER_Y; y++){
+   if (XMAX > 1){
+      for (size_t x = 0; x < (XMAX-1); x++){
+         for (size_t y = 0; y < YMAX; y++){
             for (size_t k = 0; k < 2; k++){
-               clusters[x][y]->p_cmd_out[k][EAST]   (signal_dspin_h_cmd_inc[x][y][k]);
-               clusters[x+1][y]->p_cmd_in[k][WEST]  (signal_dspin_h_cmd_inc[x][y][k]);
-               clusters[x][y]->p_cmd_in[k][EAST]    (signal_dspin_h_cmd_dec[x][y][k]);
-               clusters[x+1][y]->p_cmd_out[k][WEST] (signal_dspin_h_cmd_dec[x][y][k]);
-               clusters[x][y]->p_rsp_out[k][EAST]   (signal_dspin_h_rsp_inc[x][y][k]);
-               clusters[x+1][y]->p_rsp_in[k][WEST]  (signal_dspin_h_rsp_inc[x][y][k]);
-               clusters[x][y]->p_rsp_in[k][EAST]    (signal_dspin_h_rsp_dec[x][y][k]);
-               clusters[x+1][y]->p_rsp_out[k][WEST] (signal_dspin_h_rsp_dec[x][y][k]);
+               clusters[x][y]->p_cmd_out[k][EAST]      (signal_dspin_h_cmd_inc[x][y][k]);
+               clusters[x+1][y]->p_cmd_in[k][WEST]     (signal_dspin_h_cmd_inc[x][y][k]);
+               clusters[x][y]->p_cmd_in[k][EAST]       (signal_dspin_h_cmd_dec[x][y][k]);
+               clusters[x+1][y]->p_cmd_out[k][WEST]    (signal_dspin_h_cmd_dec[x][y][k]);
+               clusters[x][y]->p_rsp_out[k][EAST]      (signal_dspin_h_rsp_inc[x][y][k]);
+               clusters[x+1][y]->p_rsp_in[k][WEST]     (signal_dspin_h_rsp_inc[x][y][k]);
+               clusters[x][y]->p_rsp_in[k][EAST]       (signal_dspin_h_rsp_dec[x][y][k]);
+               clusters[x+1][y]->p_rsp_out[k][WEST]    (signal_dspin_h_rsp_dec[x][y][k]);
             }
          }
@@ -671,16 +659,16 @@
 
    // Inter Clusters vertical connections
-   if (CLUSTER_Y > 1) {
-      for (size_t y = 0; y < (CLUSTER_Y-1); y++){
-         for (size_t x = 0; x < CLUSTER_X; x++){
+   if (YMAX > 1) {
+      for (size_t y = 0; y < (YMAX-1); y++){
+         for (size_t x = 0; x < XMAX; x++){
             for (size_t k = 0; k < 2; k++){
-               clusters[x][y]->p_cmd_out[k][NORTH]   (signal_dspin_v_cmd_inc[x][y][k]);
-               clusters[x][y+1]->p_cmd_in[k][SOUTH]  (signal_dspin_v_cmd_inc[x][y][k]);
-               clusters[x][y]->p_cmd_in[k][NORTH]    (signal_dspin_v_cmd_dec[x][y][k]);
-               clusters[x][y+1]->p_cmd_out[k][SOUTH] (signal_dspin_v_cmd_dec[x][y][k]);
-               clusters[x][y]->p_rsp_out[k][NORTH]   (signal_dspin_v_rsp_inc[x][y][k]);
-               clusters[x][y+1]->p_rsp_in[k][SOUTH]  (signal_dspin_v_rsp_inc[x][y][k]);
-               clusters[x][y]->p_rsp_in[k][NORTH]    (signal_dspin_v_rsp_dec[x][y][k]);
-               clusters[x][y+1]->p_rsp_out[k][SOUTH] (signal_dspin_v_rsp_dec[x][y][k]);
+               clusters[x][y]->p_cmd_out[k][NORTH]     (signal_dspin_v_cmd_inc[x][y][k]);
+               clusters[x][y+1]->p_cmd_in[k][SOUTH]    (signal_dspin_v_cmd_inc[x][y][k]);
+               clusters[x][y]->p_cmd_in[k][NORTH]      (signal_dspin_v_cmd_dec[x][y][k]);
+               clusters[x][y+1]->p_cmd_out[k][SOUTH]   (signal_dspin_v_cmd_dec[x][y][k]);
+               clusters[x][y]->p_rsp_out[k][NORTH]     (signal_dspin_v_rsp_inc[x][y][k]);
+               clusters[x][y+1]->p_rsp_in[k][SOUTH]    (signal_dspin_v_rsp_inc[x][y][k]);
+               clusters[x][y]->p_rsp_in[k][NORTH]      (signal_dspin_v_rsp_dec[x][y][k]);
+               clusters[x][y+1]->p_rsp_out[k][SOUTH]   (signal_dspin_v_rsp_dec[x][y][k]);
             }
          }
@@ -690,22 +678,22 @@
 
    // East & West boundary cluster connections
-   for (size_t y = 0; y < CLUSTER_Y; y++)
+   for (size_t y = 0; y < YMAX; y++)
    {
       for (size_t k = 0; k < 2; k++)
       {
-         clusters[0][y]->p_cmd_in[k][WEST]            (signal_dspin_false_cmd_in[0][y][k][WEST]);
-         clusters[0][y]->p_cmd_out[k][WEST]           (signal_dspin_false_cmd_out[0][y][k][WEST]);
-         clusters[0][y]->p_rsp_in[k][WEST]            (signal_dspin_false_rsp_in[0][y][k][WEST]);
-         clusters[0][y]->p_rsp_out[k][WEST]           (signal_dspin_false_rsp_out[0][y][k][WEST]);
-
-         clusters[CLUSTER_X-1][y]->p_cmd_in[k][EAST]  (signal_dspin_false_cmd_in[CLUSTER_X-1][y][k][EAST]);
-         clusters[CLUSTER_X-1][y]->p_cmd_out[k][EAST] (signal_dspin_false_cmd_out[CLUSTER_X-1][y][k][EAST]);
-         clusters[CLUSTER_X-1][y]->p_rsp_in[k][EAST]  (signal_dspin_false_rsp_in[CLUSTER_X-1][y][k][EAST]);
-         clusters[CLUSTER_X-1][y]->p_rsp_out[k][EAST] (signal_dspin_false_rsp_out[CLUSTER_X-1][y][k][EAST]);
+         clusters[0][y]->p_cmd_in[k][WEST]             (signal_dspin_false_cmd_in[0][y][k][WEST]);
+         clusters[0][y]->p_cmd_out[k][WEST]            (signal_dspin_false_cmd_out[0][y][k][WEST]);
+         clusters[0][y]->p_rsp_in[k][WEST]             (signal_dspin_false_rsp_in[0][y][k][WEST]);
+         clusters[0][y]->p_rsp_out[k][WEST]            (signal_dspin_false_rsp_out[0][y][k][WEST]);
+
+         clusters[XMAX-1][y]->p_cmd_in[k][EAST]   (signal_dspin_false_cmd_in[XMAX-1][y][k][EAST]);
+         clusters[XMAX-1][y]->p_cmd_out[k][EAST]  (signal_dspin_false_cmd_out[XMAX-1][y][k][EAST]);
+         clusters[XMAX-1][y]->p_rsp_in[k][EAST]   (signal_dspin_false_rsp_in[XMAX-1][y][k][EAST]);
+         clusters[XMAX-1][y]->p_rsp_out[k][EAST]  (signal_dspin_false_rsp_out[XMAX-1][y][k][EAST]);
       }
    }
 
    // North & South boundary clusters connections
-   for (size_t x = 0; x < CLUSTER_X; x++)
+   for (size_t x = 0; x < XMAX; x++)
    {
       for (size_t k = 0; k < 2; k++)
@@ -716,8 +704,8 @@
          clusters[x][0]->p_rsp_out[k][SOUTH]           (signal_dspin_false_rsp_out[x][0][k][SOUTH]);
 
-         clusters[x][CLUSTER_Y-1]->p_cmd_in[k][NORTH]  (signal_dspin_false_cmd_in[x][CLUSTER_Y-1][k][NORTH]);
-         clusters[x][CLUSTER_Y-1]->p_cmd_out[k][NORTH] (signal_dspin_false_cmd_out[x][CLUSTER_Y-1][k][NORTH]);
-         clusters[x][CLUSTER_Y-1]->p_rsp_in[k][NORTH]  (signal_dspin_false_rsp_in[x][CLUSTER_Y-1][k][NORTH]);
-         clusters[x][CLUSTER_Y-1]->p_rsp_out[k][NORTH] (signal_dspin_false_rsp_out[x][CLUSTER_Y-1][k][NORTH]);
+         clusters[x][YMAX-1]->p_cmd_in[k][NORTH]  (signal_dspin_false_cmd_in[x][YMAX-1][k][NORTH]);
+         clusters[x][YMAX-1]->p_cmd_out[k][NORTH] (signal_dspin_false_cmd_out[x][YMAX-1][k][NORTH]);
+         clusters[x][YMAX-1]->p_rsp_in[k][NORTH]  (signal_dspin_false_rsp_in[x][YMAX-1][k][NORTH]);
+         clusters[x][YMAX-1]->p_rsp_out[k][NORTH] (signal_dspin_false_rsp_out[x][YMAX-1][k][NORTH]);
       }
    }
@@ -734,6 +722,6 @@
 
    // network boundaries signals
-   for (size_t x = 0; x < CLUSTER_X ; x++){
-      for (size_t y = 0; y < CLUSTER_Y ; y++){
+   for (size_t x = 0; x < XMAX ; x++){
+      for (size_t y = 0; y < YMAX ; y++){
          for (size_t k = 0; k < 2; k++){
             for (size_t a = 0; a < 4; a++){
@@ -767,65 +755,59 @@
 
         // trace proc[debug_proc_id] 
-        if ( debug_proc_id < (CLUSTER_X * CLUSTER_Y * NB_PROCS_MAX) )
-        {
-            size_t l = debug_proc_id % NB_PROCS_MAX ;
-            size_t y = (debug_proc_id / NB_PROCS_MAX) % CLUSTER_Y ;
-            size_t x = debug_proc_id / (CLUSTER_Y * NB_PROCS_MAX) ;
-
-            std::ostringstream vci_signame;
-            vci_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
-            std::ostringstream p2m_signame;
-            p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " P2M" ;
-            std::ostringstream m2p_signame;
-            m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ;
-            std::ostringstream cmd_signame;
-            cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ;
-            std::ostringstream rsp_signame;
-            rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ;
-
-            clusters[x][y]->proc[l]->print_trace();
-            clusters[x][y]->wi_proc[l]->print_trace();
-            clusters[x][y]->signal_vci_ini_proc[l].print_trace(vci_signame.str());
-            clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str());
-            clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str());
-            clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(cmd_signame.str());
-            clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(rsp_signame.str());
-
-            clusters[x][y]->xbar_rsp_d->print_trace();
-            clusters[x][y]->xbar_cmd_d->print_trace();
-            clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD");
-            clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD");
-            clusters[x][y]->signal_dspin_rsp_l2g_d.print_trace("[SIG]L2G RSP");
-            clusters[x][y]->signal_dspin_rsp_g2l_d.print_trace("[SIG]G2L RSP");
-        }
+        size_t l = debug_proc_id % NB_PROCS_MAX ;
+        size_t y = (debug_proc_id / NB_PROCS_MAX) % YMAX ;
+        size_t x = debug_proc_id / (YMAX * NB_PROCS_MAX) ;
+
+        std::ostringstream proc_signame;
+        proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
+        std::ostringstream p2m_signame;
+        p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " P2M" ;
+        std::ostringstream m2p_signame;
+        m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ;
+        std::ostringstream p_cmd_signame;
+        p_cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ;
+        std::ostringstream p_rsp_signame;
+        p_rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ;
+
+        clusters[x][y]->proc[l]->print_trace();
+        clusters[x][y]->wi_proc[l]->print_trace();
+        clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str());
+        clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str());
+        clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str());
+        clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(p_cmd_signame.str());
+        clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(p_rsp_signame.str());
+
+        clusters[x][y]->xbar_rsp_d->print_trace();
+        clusters[x][y]->xbar_cmd_d->print_trace();
+        clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD");
+        clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD");
+        clusters[x][y]->signal_dspin_rsp_l2g_d.print_trace("[SIG]L2G RSP");
+        clusters[x][y]->signal_dspin_rsp_g2l_d.print_trace("[SIG]G2L RSP");
 
         // trace memc[debug_memc_id] 
-        if ( debug_memc_id < (CLUSTER_X * CLUSTER_Y) )
-        {
-            size_t x = debug_memc_id / CLUSTER_Y;
-            size_t y = debug_memc_id % CLUSTER_Y;
-
-            std::ostringstream smemc;
-            smemc << "[SIG]MEMC_" << x << "_" << y;
-            std::ostringstream sxram;
-            sxram << "[SIG]XRAM_" << x << "_" << y;
-            std::ostringstream sm2p;
-            sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P" ;
-            std::ostringstream sp2m;
-            sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ;
-            std::ostringstream cmd_signame;
-            cmd_signame << "[SIG]MEMC_" << x << "_" << y <<  " CMD" ;
-            std::ostringstream rsp_signame;
-            rsp_signame << "[SIG]MEMC_" << x << "_" << y <<  " RSP" ;
-
-            clusters[x][y]->memc->print_trace();
-            clusters[x][y]->wt_memc->print_trace();
-            clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str());
-            clusters[x][y]->signal_vci_xram.print_trace(sxram.str());
-            clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str());
-            clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str());
-            clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(cmd_signame.str());
-            clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(rsp_signame.str());
-        }
+        x = debug_memc_id / YMAX;
+        y = debug_memc_id % YMAX;
+
+        std::ostringstream smemc;
+        smemc << "[SIG]MEMC_" << x << "_" << y;
+        std::ostringstream sxram;
+        sxram << "[SIG]XRAM_" << x << "_" << y;
+        std::ostringstream sm2p;
+        sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P" ;
+        std::ostringstream sp2m;
+        sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ;
+        std::ostringstream m_cmd_signame;
+        m_cmd_signame << "[SIG]MEMC_" << x << "_" << y <<  " CMD" ;
+        std::ostringstream m_rsp_signame;
+        m_rsp_signame << "[SIG]MEMC_" << x << "_" << y <<  " RSP" ;
+
+        clusters[x][y]->memc->print_trace();
+        clusters[x][y]->wt_memc->print_trace();
+        clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str());
+        clusters[x][y]->signal_vci_xram.print_trace(sxram.str());
+        clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str());
+        clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str());
+        clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(m_cmd_signame.str());
+        clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(m_rsp_signame.str());
         
         // trace replicated peripherals
@@ -836,6 +818,6 @@
 
         // trace external peripherals
-        size_t io_x   = cluster_io_id / CLUSTER_Y;
-        size_t io_y   = cluster_io_id % CLUSTER_Y;
+        size_t io_x   = cluster_io_id / YMAX;
+        size_t io_y   = cluster_io_id % YMAX;
         
         clusters[io_x][io_y]->brom->print_trace();
