Index: trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/include/tsar_iob_cluster.h
===================================================================
--- trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/include/tsar_iob_cluster.h	(revision 533)
+++ trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/include/tsar_iob_cluster.h	(revision 550)
@@ -25,5 +25,5 @@
 #include "vci_dspin_initiator_wrapper.h"
 #include "vci_dspin_target_wrapper.h"
-#include "dspin_router.h"
+#include "dspin_router_tsar.h"
 #include "virtual_dspin_router.h"
 #include "vci_multi_dma.h"
@@ -52,9 +52,16 @@
     sc_in<bool>                             		   p_resetn;
 
-    soclib::caba::VciInitiator<vci_param_ext>*         p_vci_iox_ini;
-    soclib::caba::VciTarget<vci_param_ext>*            p_vci_iox_tgt;
-
-    sc_in<bool>*                                       p_irq[32];  // not always used
-
+    // Thes two ports are used to connect IOB to IOX nework in top cell
+    soclib::caba::VciInitiator<vci_param_ext>*         p_vci_iob_iox_ini;
+    soclib::caba::VciTarget<vci_param_ext>*            p_vci_iob_iox_tgt; 
+
+    // These ports are used to connect IOB to RAM network in top cell
+    soclib::caba::DspinOutput<dspin_ram_cmd_width>*    p_dspin_iob_cmd_out;  
+    soclib::caba::DspinInput<dspin_ram_rsp_width>*     p_dspin_iob_rsp_in;  
+
+    // These ports are used to connect hard IRQ from external peripherals to IOB0
+    sc_in<bool>*                                       p_irq[32];
+
+    // These arrays of ports are used to connect the INT & RAM networks in top cell
 	soclib::caba::DspinOutput<dspin_int_cmd_width>**   p_dspin_int_cmd_out;
 	soclib::caba::DspinInput<dspin_int_cmd_width>**    p_dspin_int_cmd_in;
@@ -124,18 +131,10 @@
 	VciSignals<vci_param_ext>             signal_ram_vci_tgt_xram;
 
-    // RAM network DSPIN signals between VCI/DSPIN wrappers and crossbars or routers 
+    // RAM network DSPIN signals between VCI/DSPIN wrappers and routers 
 	DspinSignals<dspin_ram_cmd_width>     signal_ram_dspin_cmd_xram_t;
 	DspinSignals<dspin_ram_rsp_width>     signal_ram_dspin_rsp_xram_t;
 	DspinSignals<dspin_ram_cmd_width>     signal_ram_dspin_cmd_memc_i;
 	DspinSignals<dspin_ram_rsp_width>     signal_ram_dspin_rsp_memc_i;
-	DspinSignals<dspin_ram_cmd_width>     signal_ram_dspin_cmd_iobx_i;
-	DspinSignals<dspin_ram_rsp_width>     signal_ram_dspin_rsp_iobx_i;
   
-    // RAM network DSPIN signals between DSPIN routers and DSPIN local crossbars 
-	DspinSignals<dspin_ram_cmd_width>     signal_ram_dspin_cmd_l2g; 
-	DspinSignals<dspin_ram_cmd_width>     signal_ram_dspin_cmd_g2l; 
-	DspinSignals<dspin_ram_rsp_width>     signal_ram_dspin_rsp_l2g; 
-	DspinSignals<dspin_ram_rsp_width>     signal_ram_dspin_rsp_g2l; 
-	
     //////////////////////////////////////
     // Hardwate Components (pointers)
@@ -194,6 +193,6 @@
                           dspin_ram_rsp_width>*       xram_ram_wt;
 	
-    DspinRouter<dspin_ram_cmd_width>*	              ram_router_cmd;
-    DspinRouter<dspin_ram_rsp_width>*                 ram_router_rsp;
+    DspinRouterTsar<dspin_ram_cmd_width>*	          ram_router_cmd;
+    DspinRouterTsar<dspin_ram_rsp_width>*             ram_router_rsp;
 
 	// IO Network Components (not instanciated in all clusters)
@@ -214,7 +213,4 @@
                              dspin_ram_rsp_width>*    iob_ram_wi;
 	
-    DspinLocalCrossbar<dspin_ram_cmd_width>*          ram_xbar_cmd; 
-    DspinLocalCrossbar<dspin_ram_rsp_width>*          ram_xbar_rsp; 
-
     // cluster constructor
 	TsarIobCluster( sc_module_name                     insname,
Index: trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp
===================================================================
--- trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 533)
+++ trunk/platforms/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 550)
@@ -49,17 +49,17 @@
                     size_t                             l_width,
 
-                    size_t                             memc_int_tgtid,
-                    size_t                             xicu_int_tgtid,
-                    size_t                             mdma_int_tgtid,
-                    size_t                             iobx_int_tgtid,
-
-                    size_t                             proc_int_srcid,
-                    size_t                             mdma_int_srcid,
-                    size_t                             iobx_int_srcid,
-
-                    size_t                             xram_ram_tgtid,
-
-                    size_t                             memc_ram_srcid,
-                    size_t                             iobx_ram_srcid,
+                    size_t                             memc_int_tgtid,  // local index
+                    size_t                             xicu_int_tgtid,  // local index
+                    size_t                             mdma_int_tgtid,  // local index
+                    size_t                             iobx_int_tgtid,  // local index
+
+                    size_t                             proc_int_srcid,  // local index
+                    size_t                             mdma_int_srcid,  // local index
+                    size_t                             iobx_int_srcid,  // local index
+
+                    size_t                             xram_ram_tgtid,  // local index
+
+                    size_t                             memc_ram_srcid,  // local index
+                    size_t                             iobx_ram_srcid,  // local index
 
                     size_t                             memc_ways,
@@ -85,6 +85,7 @@
 
     size_t cluster_id = x_id * ymax + y_id;
-    size_t cluster_iob0 = 0;
-    size_t cluster_iob1 = xmax*ymax-1;
+
+    size_t cluster_iob0 = 0;                 // South-West cluster
+    size_t cluster_iob1 = xmax*ymax-1;       // North-East cluster
 
     // Vectors of DSPIN ports for inter-cluster communications
@@ -99,9 +100,14 @@
     p_dspin_ram_rsp_out = alloc_elems<DspinOutput<dspin_ram_rsp_width> >("p_ext_rsp_out", 4);
 
-    // VCI ports to IOB0 and IOB1 in cluster_iob0 and cluster_iob1
+    // ports in cluster_iob0 and cluster_iob1 only
     if ( (cluster_id == cluster_iob0) or (cluster_id == cluster_iob1) )
     {
-        p_vci_iox_ini = new soclib::caba::VciInitiator<vci_param_ext>;
-        p_vci_iox_tgt = new soclib::caba::VciTarget<vci_param_ext>; 
+        // VCI ports from IOB to IOX network
+        p_vci_iob_iox_ini = new soclib::caba::VciInitiator<vci_param_ext>;
+        p_vci_iob_iox_tgt = new soclib::caba::VciTarget<vci_param_ext>; 
+
+        // DSPIN ports from IOB to RAM network
+        p_dspin_iob_cmd_out = new soclib::caba::DspinOutput<dspin_ram_cmd_width>;
+        p_dspin_iob_rsp_in  = new soclib::caba::DspinInput<dspin_ram_rsp_width>;
     }
 
@@ -166,6 +172,6 @@
                      IntTab(cluster_id, memc_int_tgtid), // TGTID INT network
                      (cluster_id << l_width) + nb_procs, // CC_GLOBAL_ID
-                     x_width,                            // Number of x bits in platform
-                     y_width,                            // Number of y bits in platform
+                     x_width,                            // number of bits for x coordinate
+                     y_width,                            // number of bits for y coordinate
                      memc_ways, memc_sets, 16,           // CACHE SIZE
                      3,                                  // MAX NUMBER OF COPIES
@@ -334,5 +340,5 @@
     int_router_rsp = new VirtualDspinRouter<dspin_int_rsp_width>(
                      s_int_router_rsp.str().c_str(),
-                     x_id,y_id,                    // coordinates in mesh
+                     x_id,y_id,                    // router coordinates in mesh
                      x_width, y_width,             // x & y fields width
                      2,                            // nb virtual channels
@@ -360,17 +366,28 @@
     std::ostringstream s_ram_router_cmd;
     s_ram_router_cmd << "ram_router_cmd_" << x_id << "_" << y_id;
-    ram_router_cmd = new DspinRouter<dspin_ram_cmd_width>(
+    ram_router_cmd = new DspinRouterTsar<dspin_ram_cmd_width>(
                      s_ram_router_cmd.str().c_str(),
-                     x_id,y_id,                    // coordinate in the mesh
-                     x_width, y_width,             // x & y fields width
-                     4,4);                         // input & output fifo depths
+                     x_id, y_id,                  // router coordinates in mesh
+                     x_width,                     // x field width in first flit
+                     x_width,                     // y field width in first flit
+                     4, 4,                        // input & output fifo depths
+                     cluster_iob0,                // cluster containing IOB0
+                     cluster_iob1,                // cluster containing IOB1
+                     l_width,                     // local field width in first flit
+                     iobx_ram_srcid );            // IOB local index
 
     std::ostringstream s_ram_router_rsp;
     s_ram_router_rsp << "ram_router_rsp_" << x_id << "_" << y_id;
-    ram_router_rsp = new DspinRouter<dspin_ram_rsp_width>(
+    ram_router_rsp = new DspinRouterTsar<dspin_ram_rsp_width>(
                      s_ram_router_rsp.str().c_str(),
-                     x_id,y_id,                    // coordinates in mesh
-                     x_width, y_width,             // x & y fields width
-                     4,4);                         // input & output fifo depths
+                     x_id, y_id,                  // coordinates in mesh
+                     x_width,                     // x field width in first flit
+                     y_width,                     // y field width in first flit
+                     4, 4,                        // input & output fifo depths
+                     cluster_iob0,                // cluster containing IOB0
+                     cluster_iob1,                // cluster containing IOB1
+                     l_width,                     // local field width in first flit
+                     iobx_ram_srcid );            // IOB local index
+
 
     ////////////////////// I/O  CLUSTER ONLY    ///////////////////////
@@ -435,34 +452,5 @@
                      s_iob_ram_wi.str().c_str(),
                      x_width + y_width + l_width);
-
-        ///////////// RAM LOCAL_XBAR(S)
-        std::ostringstream s_ram_xbar_cmd;
-        s_ram_xbar_cmd << "ram_xbar_cmd_" << x_id << "_" << y_id;   
-        ram_xbar_cmd = new DspinLocalCrossbar<dspin_ram_cmd_width>(
-                     s_ram_xbar_cmd.str().c_str(),
-                     mt_ram,                       // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, 0,          // one dest on ram_cmd network 
-                     2,                            // number of local sources
-                     1,                            // number of local dests
-                     2, 2,                         // fifo depths  
-                     true,                         // CMD crossbar
-                     false,                        // no routing table (one dest)
-                     false );                      // no broadcast 
-
-        std::ostringstream s_ram_xbar_rsp;
-        s_ram_xbar_rsp << "ram_xbar_rsp_" << x_id << "_" << y_id;   
-        ram_xbar_rsp = new DspinLocalCrossbar<dspin_ram_rsp_width>(
-                     s_ram_xbar_rsp.str().c_str(),
-                     mt_ram,                       // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, l_width,    // two sources on ram_rsp network
-                     1,                            // number of local sources
-                     2,                            // number of local dests
-                     2, 2,                         // fifo depths  
-                     false,                        // RSP crossbar
-                     true,                         // use routing table
-                     false );                      // no broadcast 
-    }
+    } // end if IO
 
     ////////////////////////////////////
@@ -682,46 +670,42 @@
     mdma_int_wi->p_vci                           (signal_int_vci_ini_mdma);
 
-    // For the IO bridge and the RAM network components, the connexions
-    // depend on cluster type: The vci_io_bridge and dspin_local_crossbar
-    // components are only in cluster_iob0 & cluster_iob1
-
-    if ( (cluster_id != cluster_iob0) and (cluster_id != cluster_iob1) )
-    {
-        // RAM network CMD & RSP routers
-        ram_router_cmd->p_clk                    (this->p_clk);
-        ram_router_cmd->p_resetn                 (this->p_resetn);
-        ram_router_rsp->p_clk                    (this->p_clk);
-        ram_router_rsp->p_resetn                 (this->p_resetn);
-        for( size_t n=0 ; n<4 ; n++)
-        {
-            ram_router_cmd->p_out[n]             (this->p_dspin_ram_cmd_out[n]);
-            ram_router_cmd->p_in[n]              (this->p_dspin_ram_cmd_in[n]);
-            ram_router_rsp->p_out[n]             (this->p_dspin_ram_rsp_out[n]);
-            ram_router_rsp->p_in[n]              (this->p_dspin_ram_rsp_in[n]);
-        }
-        ram_router_cmd->p_out[4]                 (signal_ram_dspin_cmd_xram_t);
-        ram_router_cmd->p_in[4]                  (signal_ram_dspin_cmd_memc_i);
-        ram_router_rsp->p_out[4]                 (signal_ram_dspin_rsp_memc_i);
-        ram_router_rsp->p_in[4]                  (signal_ram_dspin_rsp_xram_t);
-    }
-    else  // IO cluster
+    //////////////////////////// RAM network CMD & RSP routers
+    ram_router_cmd->p_clk                    (this->p_clk);
+    ram_router_cmd->p_resetn                 (this->p_resetn);
+    ram_router_rsp->p_clk                    (this->p_clk);
+    ram_router_rsp->p_resetn                 (this->p_resetn);
+    for( size_t n=0 ; n<4 ; n++)
+    {
+        ram_router_cmd->p_out[n]             (this->p_dspin_ram_cmd_out[n]);
+        ram_router_cmd->p_in[n]              (this->p_dspin_ram_cmd_in[n]);
+        ram_router_rsp->p_out[n]             (this->p_dspin_ram_rsp_out[n]);
+        ram_router_rsp->p_in[n]              (this->p_dspin_ram_rsp_in[n]);
+    }
+    ram_router_cmd->p_out[4]                 (signal_ram_dspin_cmd_xram_t);
+    ram_router_cmd->p_in[4]                  (signal_ram_dspin_cmd_memc_i);
+    ram_router_rsp->p_out[4]                 (signal_ram_dspin_rsp_memc_i);
+    ram_router_rsp->p_in[4]                  (signal_ram_dspin_rsp_xram_t);
+   
+    ///////////////////////// IOB exists only in cluster_iob0 & cluster_iob1. 
+    if ( (cluster_id == cluster_iob0) or (cluster_id == cluster_iob1) )
     {
         // IO bridge
         iob->p_clk                               (this->p_clk);
         iob->p_resetn                            (this->p_resetn);
-        iob->p_vci_ini_iox                       (*(this->p_vci_iox_ini));
-        iob->p_vci_tgt_iox                       (*(this->p_vci_iox_tgt));
+        iob->p_vci_ini_iox                       (*(this->p_vci_iob_iox_ini));
+        iob->p_vci_tgt_iox                       (*(this->p_vci_iob_iox_tgt));
         iob->p_vci_tgt_int                       (signal_int_vci_tgt_iobx);
         iob->p_vci_ini_int                       (signal_int_vci_ini_iobx);
         iob->p_vci_ini_ram                       (signal_ram_vci_ini_iobx);
+
         if ( cluster_id == cluster_iob0 )
-            for ( size_t n=0 ; n<32 ; n++ )
-                (*iob->p_irq[n])                 (*(this->p_irq[n]));
+               for ( size_t n=0 ; n<32 ; n++ )
+                   (*iob->p_irq[n])                 (*(this->p_irq[n]));
 
         // initiator wrapper to RAM network
         iob_ram_wi->p_clk                        (this->p_clk);
         iob_ram_wi->p_resetn                     (this->p_resetn);
-        iob_ram_wi->p_dspin_cmd                  (signal_ram_dspin_cmd_iobx_i);
-        iob_ram_wi->p_dspin_rsp                  (signal_ram_dspin_rsp_iobx_i);
+        iob_ram_wi->p_dspin_cmd                  (*(this->p_dspin_iob_cmd_out));
+        iob_ram_wi->p_dspin_rsp                  (*(this->p_dspin_iob_rsp_in));
         iob_ram_wi->p_vci                        (signal_ram_vci_ini_iobx);
 
@@ -739,41 +723,6 @@
         iob_int_wt->p_dspin_rsp                  (signal_int_dspin_rsp_iobx_t);
         iob_int_wt->p_vci                        (signal_int_vci_tgt_iobx);
-
-        // RAM network CMD local crossbar
-        ram_xbar_cmd->p_clk                      (this->p_clk);
-        ram_xbar_cmd->p_resetn                   (this->p_resetn);
-        ram_xbar_cmd->p_global_out               (signal_ram_dspin_cmd_l2g);
-        ram_xbar_cmd->p_global_in                (signal_ram_dspin_cmd_g2l);
-        ram_xbar_cmd->p_local_in[0]              (signal_ram_dspin_cmd_memc_i);
-        ram_xbar_cmd->p_local_in[1]              (signal_ram_dspin_cmd_iobx_i);
-        ram_xbar_cmd->p_local_out[0]             (signal_ram_dspin_cmd_xram_t);
-
-        // RAM network RSP local crossbar
-        ram_xbar_rsp->p_clk                      (this->p_clk);
-        ram_xbar_rsp->p_resetn                   (this->p_resetn);
-        ram_xbar_rsp->p_global_out               (signal_ram_dspin_rsp_l2g);
-        ram_xbar_rsp->p_global_in                (signal_ram_dspin_rsp_g2l);
-        ram_xbar_rsp->p_local_in[0]              (signal_ram_dspin_rsp_xram_t);
-        ram_xbar_rsp->p_local_out[0]             (signal_ram_dspin_rsp_memc_i);
-        ram_xbar_rsp->p_local_out[1]             (signal_ram_dspin_rsp_iobx_i);
-
-        // RAM network CMD & RSP routers
-        ram_router_cmd->p_clk                    (this->p_clk);
-        ram_router_cmd->p_resetn                 (this->p_resetn);
-        ram_router_rsp->p_clk                    (this->p_clk);
-        ram_router_rsp->p_resetn                 (this->p_resetn);
-        for( size_t n=0 ; n<4 ; n++)
-        {
-            ram_router_cmd->p_out[n]             (this->p_dspin_ram_cmd_out[n]);
-            ram_router_cmd->p_in[n]              (this->p_dspin_ram_cmd_in[n]);
-            ram_router_rsp->p_out[n]             (this->p_dspin_ram_rsp_out[n]);
-            ram_router_rsp->p_in[n]              (this->p_dspin_ram_rsp_in[n]);
-        }
-        ram_router_cmd->p_out[4]                 (signal_ram_dspin_cmd_g2l);
-        ram_router_cmd->p_in[4]                  (signal_ram_dspin_cmd_l2g);
-        ram_router_rsp->p_out[4]                 (signal_ram_dspin_rsp_g2l);
-        ram_router_rsp->p_in[4]                  (signal_ram_dspin_rsp_l2g);
-    }
-   
+    }
+
 } // end constructor
 
