Index: branches/reconfiguration/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp
===================================================================
--- branches/reconfiguration/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 748)
+++ branches/reconfiguration/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 806)
@@ -1,14 +1,14 @@
 //////////////////////////////////////////////////////////////////////////////
 // File: tsar_iob_cluster.cpp
-// Author: Alain Greiner 
+// Author: Alain Greiner
 // Copyright: UPMC/LIP6
 // Date : april 2013
 // This program is released under the GNU public license
 //////////////////////////////////////////////////////////////////////////////
-// Cluster(0,0) & Cluster(xmax-1,ymax-1) contains the IOB0 & IOB1 components.
+// Cluster(0,0) & Cluster(x_size-1,y_size-1) contains the IOB0 & IOB1 components.
 // These two clusters contain 6 extra components:
 // - 1 vci_io_bridge (connected to the 3 networks.
 // - 3 vci_dspin_wrapper for the IOB.
-// - 2 dspin_local_crossbar for commands and responses. 
+// - 2 dspin_local_crossbar for commands and responses.
 //////////////////////////////////////////////////////////////////////////////
 
@@ -30,64 +30,69 @@
 //////////////////////////////////////////////////////////////////////////
 tmpl(/**/)::TsarIobCluster(
-//////////////////////////////////////////////////////////////////////////
-                    sc_module_name                     insname,
-                    size_t                             nb_procs,
-                    size_t                             nb_dmas,
-                    size_t                             x_id,
-                    size_t                             y_id,
-                    size_t                             xmax,
-                    size_t                             ymax,
-
-                    const soclib::common::MappingTable &mt_int,
-                    const soclib::common::MappingTable &mt_ram, 
-                    const soclib::common::MappingTable &mt_iox, 
-
-                    size_t                             x_width,
-                    size_t                             y_width,
-                    size_t                             l_width,
-
-                    size_t                             int_memc_tgt_id, // local index
-                    size_t                             int_xicu_tgt_id, // local index
-                    size_t                             int_mdma_tgt_id, // local index
-                    size_t                             int_brom_tgt_id, // local index
-                    size_t                             int_iobx_tgt_id, // local index
-
-                    size_t                             int_proc_ini_id, // local index
-                    size_t                             int_mdma_ini_id, // local index
-                    size_t                             int_iobx_ini_id, // local index
-
-                    size_t                             ram_xram_tgt_id, // local index
-                    size_t                             ram_memc_ini_id, // local index
-                    size_t                             ram_iobx_ini_id, // local index
-
-                    bool                               is_io,           // is IO cluster (IOB)?
-                    size_t                             iox_iobx_tgt_id, // local_index
-                    size_t                             iox_iobx_ini_id, // local index
-
-                    size_t                             memc_ways,
-                    size_t                             memc_sets,
-                    size_t                             l1_i_ways,
-                    size_t                             l1_i_sets,
-                    size_t                             l1_d_ways,
-                    size_t                             l1_d_sets,
-                    size_t                             xram_latency,
-                    size_t                             xcu_nb_inputs,
-
-                    bool                               distboot,
-
-                    const Loader                       &loader,
-
-                    uint32_t                           frozen_cycles,
-                    uint32_t                           debug_start_cycle,
-                    bool                               memc_debug_ok,
-                    bool                               proc_debug_ok,
-                    bool                               iob_debug_ok )
-    : soclib::caba::BaseModule(insname),
-      p_clk("clk"),
-      p_resetn("resetn")
+        sc_module_name                     insname,
+        size_t                             nb_procs,
+        size_t                             nb_dmas,
+        size_t                             x_id,
+        size_t                             y_id,
+        size_t                             x_size,
+        size_t                             y_size,
+
+        size_t                             p_width,
+
+        const soclib::common::MappingTable &mt_int,
+        const soclib::common::MappingTable &mt_ram,
+        const soclib::common::MappingTable &mt_iox,
+
+        size_t                             x_width,
+        size_t                             y_width,
+        size_t                             l_width,
+
+        size_t                             int_memc_tgt_id, // local index
+        size_t                             int_xicu_tgt_id, // local index
+        size_t                             int_mdma_tgt_id, // local index
+        size_t                             int_brom_tgt_id, // local index
+        size_t                             int_iobx_tgt_id, // local index
+
+        size_t                             int_proc_ini_id, // local index
+        size_t                             int_mdma_ini_id, // local index
+        size_t                             int_iobx_ini_id, // local index
+
+        size_t                             ram_xram_tgt_id, // local index
+        size_t                             ram_memc_ini_id, // local index
+        size_t                             ram_iobx_ini_id, // local index
+
+        bool                               is_io,           // is IO cluster (IOB)?
+        size_t                             iox_iobx_tgt_id, // local_index
+        size_t                             iox_iobx_ini_id, // local index
+
+        size_t                             memc_ways,
+        size_t                             memc_sets,
+        size_t                             l1_i_ways,
+        size_t                             l1_i_sets,
+        size_t                             l1_d_ways,
+        size_t                             l1_d_sets,
+        size_t                             xram_latency,
+        size_t                             xcu_nb_inputs,
+
+        bool                               distboot,
+
+        const Loader                       &loader,
+
+        uint32_t                           frozen_cycles,
+        uint32_t                           debug_start_cycle,
+        bool                               memc_debug_ok,
+        bool                               proc_debug_ok,
+        bool                               iob_debug_ok ) :
+
+            // constructor initialization list
+
+            soclib::caba::BaseModule(insname),
+            p_clk("clk"),
+            p_resetn("resetn")
 {
-    assert( (x_id < xmax) and (y_id < ymax) and "Illegal cluster coordinates");
-
-    size_t cluster_id = (x_id<<4) + y_id;
+
+    assert( (x_id < x_size) and (y_id < y_size) and "Illegal cluster coordinates");
+
+    size_t cluster_id = (x_id << x_width) | y_id;
 
     // Vectors of DSPIN ports for inter-cluster communications
@@ -103,8 +108,8 @@
 
     // VCI ports from IOB to IOX network (only in IO clusters)
-    if ( is_io )
+    if (is_io)
     {
         p_vci_iob_iox_ini = new soclib::caba::VciInitiator<vci_param_ext>;
-        p_vci_iob_iox_tgt = new soclib::caba::VciTarget<vci_param_ext>; 
+        p_vci_iob_iox_tgt = new soclib::caba::VciTarget<vci_param_ext>;
     }
 
@@ -115,5 +120,5 @@
     ////////////  PROCS
     for (size_t p = 0; p < nb_procs; p++)
-    { 
+    {
         std::ostringstream s_proc;
         s_proc << "proc_" << x_id << "_" << y_id << "_" << p;
@@ -123,8 +128,8 @@
                                          GdbServer<Mips32ElIss> >(
                       s_proc.str().c_str(),
-                      cluster_id*nb_procs + p,        // GLOBAL PROC_ID
+                      (cluster_id << p_width) | p,    // GLOBAL PROC_ID
                       mt_int,                         // Mapping Table INT network
                       IntTab(cluster_id,p),           // SRCID
-                      (cluster_id << l_width) + p,    // CC_GLOBAL_ID
+                      (cluster_id << l_width) | p,    // CC_GLOBAL_ID
                       8,                              // ITLB ways
                       8,                              // ITLB sets
@@ -135,6 +140,6 @@
                       4,                              // WBUF nlines
                       4,                              // WBUF nwords
-                      x_width,
-                      y_width,
+                      x_width,                        // number of bits for x coordinate
+                      y_width,                        // number of bits for y coordinate
                       frozen_cycles,                  // max frozen cycles
                       debug_start_cycle,
@@ -150,5 +155,5 @@
     }
 
-    ///////////  MEMC    
+    ///////////  MEMC
     std::ostringstream s_memc;
     s_memc << "memc_" << x_id << "_" << y_id;
@@ -225,5 +230,5 @@
                      cluster_id,                   // cluster id
                      nb_direct_initiators,         // number of local initiators
-                     nb_direct_targets,            // number of local targets 
+                     nb_direct_targets,            // number of local targets
                      0 );                          // default target
 
@@ -255,6 +260,6 @@
                      x_width, y_width, l_width,    // several dests
                      1,                            // number of local sources
-                     nb_procs,                     // number of local dests 
-                     2, 2,                         // fifo depths  
+                     nb_procs,                     // number of local dests
+                     2, 2,                         // fifo depths
                      true,                         // pseudo CMD
                      false,                        // no routing table
@@ -270,8 +275,8 @@
                      nb_procs,                     // number of local sources
                      1,                            // number of local dests
-                     2, 2,                         // fifo depths  
+                     2, 2,                         // fifo depths
                      false,                        // pseudo RSP
                      false,                        // no routing table
-                     false );                      // no broacast 
+                     false );                      // no broacast
 
     std::ostringstream s_int_xbar_clack_c;
@@ -283,5 +288,5 @@
                      x_width, y_width, l_width,
                      1,                            // number of local sources
-                     nb_procs,                     // number of local targets 
+                     nb_procs,                     // number of local targets
                      1, 1,                         // fifo depths
                      true,                         // CMD
@@ -297,5 +302,5 @@
                      x_width, y_width,             // x & y fields width
                      3,                            // nb virtual channels
-                     4,4);                         // input & output fifo depths
+                     4, 4);                        // input & output fifo depths
 
     std::ostringstream s_int_router_rsp;
@@ -306,5 +311,5 @@
                      x_width, y_width,             // x & y fields width
                      2,                            // nb virtual channels
-                     4,4);                         // input & output fifo depths
+                     4, 4);                        // input & output fifo depths
 
     //////////////  XRAM
@@ -351,7 +356,7 @@
         ///////////  IO_BRIDGE
         std::ostringstream s_iob;
-        s_iob << "iob_" << x_id << "_" << y_id;   
+        s_iob << "iob_" << x_id << "_" << y_id;
         iob = new VciIoBridge<vci_param_int,
-                              vci_param_ext>(  
+                              vci_param_ext>(
                      s_iob.str().c_str(),
                      mt_ram,                                // EXT network maptab
@@ -367,7 +372,7 @@
                      debug_start_cycle,
                      iob_debug_ok );
-        
+
         std::ostringstream s_iob_ram_wi;
-        s_iob_ram_wi << "iob_ram_wi_" << x_id << "_" << y_id;   
+        s_iob_ram_wi << "iob_ram_wi_" << x_id << "_" << y_id;
         iob_ram_wi = new VciDspinInitiatorWrapper<vci_param_ext,
                                                   dspin_ram_cmd_width,
@@ -409,5 +414,5 @@
     // on coherence network : local srcid[proc] in [0...nb_procs-1]
     //                      : local srcid[memc] = nb_procs
- 
+
     //////////////////////// internal CMD & RSP routers
     int_router_cmd->p_clk                        (this->p_clk);
@@ -438,5 +443,5 @@
     int_router_cmd->p_in[4][1]                   (signal_int_dspin_m2p_l2g_c);
     int_router_cmd->p_in[4][2]                   (signal_int_dspin_clack_l2g_c);
-    
+
     int_router_rsp->p_out[4][0]                  (signal_int_dspin_rsp_g2l_d);
     int_router_rsp->p_out[4][1]                  (signal_int_dspin_p2m_g2l_c);
@@ -475,5 +480,5 @@
     int_wt_gate_d->p_dspin_cmd                   (signal_int_dspin_cmd_g2l_d);
     int_wt_gate_d->p_dspin_rsp                   (signal_int_dspin_rsp_l2g_d);
-    
+
     ////////////////////// M2P DSPIN local crossbar coherence
     int_xbar_m2p_c->p_clk                        (this->p_clk);
@@ -482,5 +487,5 @@
     int_xbar_m2p_c->p_global_in                  (signal_int_dspin_m2p_g2l_c);
     int_xbar_m2p_c->p_local_in[0]                (signal_int_dspin_m2p_memc);
-    for (size_t p = 0; p < nb_procs; p++) 
+    for (size_t p = 0; p < nb_procs; p++)
         int_xbar_m2p_c->p_local_out[p]           (signal_int_dspin_m2p_proc[p]);
 
@@ -491,5 +496,5 @@
     int_xbar_p2m_c->p_global_in                  (signal_int_dspin_p2m_g2l_c);
     int_xbar_p2m_c->p_local_out[0]               (signal_int_dspin_p2m_memc);
-    for (size_t p = 0; p < nb_procs; p++) 
+    for (size_t p = 0; p < nb_procs; p++)
         int_xbar_p2m_c->p_local_in[p]            (signal_int_dspin_p2m_proc[p]);
 
@@ -533,5 +538,5 @@
         else if ( i <= nb_dmas ) xicu->p_hwi[i]  (signal_irq_mdma[i-1]);
         else                     xicu->p_hwi[i]  (signal_false);
-    }                     
+    }
 
     ///////////////////////////////////// MEMC
@@ -603,6 +608,6 @@
        ram_router_rsp->p_out[4]                  (signal_ram_dspin_rsp_memc_i);
     }
-   
-    ///////////////////////// IOB exists only in cluster_iob0 & cluster_iob1. 
+
+    ///////////////////////// IOB exists only in cluster_iob0 & cluster_iob1.
     if ( is_io )
     {
