Index: trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/include/tsar_leti_cluster.h
===================================================================
--- trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/include/tsar_leti_cluster.h	(revision 664)
+++ trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/include/tsar_leti_cluster.h	(revision 692)
@@ -22,4 +22,5 @@
 #include "vci_simple_ram.h"
 #include "vci_xicu.h"
+#include "vci_local_crossbar.h"
 #include "dspin_local_crossbar.h"
 #include "vci_dspin_initiator_wrapper.h"
@@ -44,5 +45,5 @@
 
     // Used in destructor
-    size_t n_procs;
+    size_t m_nprocs;
 
     // Ports
@@ -75,14 +76,14 @@
     DspinSignals<dspin_cmd_width>   signal_dspin_cmd_l2g_d;
     DspinSignals<dspin_cmd_width>   signal_dspin_cmd_g2l_d;
+    DspinSignals<dspin_rsp_width>   signal_dspin_rsp_l2g_d;
+    DspinSignals<dspin_rsp_width>   signal_dspin_rsp_g2l_d;
     DspinSignals<dspin_cmd_width>   signal_dspin_m2p_l2g_c;
     DspinSignals<dspin_cmd_width>   signal_dspin_m2p_g2l_c;
     DspinSignals<dspin_cmd_width>   signal_dspin_clack_l2g_c;
     DspinSignals<dspin_cmd_width>   signal_dspin_clack_g2l_c;
-    DspinSignals<dspin_rsp_width>   signal_dspin_rsp_l2g_d;
-    DspinSignals<dspin_rsp_width>   signal_dspin_rsp_g2l_d;
     DspinSignals<dspin_rsp_width>   signal_dspin_p2m_l2g_c;
     DspinSignals<dspin_rsp_width>   signal_dspin_p2m_g2l_c;
 
-    // Direct VCI signals to VCI/DSPIN wrappers
+    // Direct VCI signals
     VciSignals<vci_param_int>       signal_vci_ini_proc[4];
     VciSignals<vci_param_int>       signal_vci_ini_mdma;
@@ -100,32 +101,6 @@
     VciSignals<vci_param_int>       signal_vci_tgt_simh;
 
-    // Direct DSPIN signals to local crossbars
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_proc_i[4];
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_proc_i[4];
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mdma_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mdma_i;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_bdev_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_bdev_i;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_chbuf_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_chbuf_i;
-
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_memc_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_memc_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_xicu_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_xicu_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mdma_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mdma_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mtty_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mtty_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_bdev_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_bdev_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_fbuf_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_fbuf_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mnic_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mnic_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_chbuf_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_chbuf_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_simh_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_simh_t;
+    VciSignals<vci_param_int>       signal_vci_g2l;
+    VciSignals<vci_param_int>       signal_vci_l2g;
 
     // Coherence DSPIN signals to local crossbar
@@ -147,8 +122,4 @@
                        GdbServer<Mips32ElIss> >*  proc[4];
 
-    VciDspinInitiatorWrapper<vci_param_int,
-                             dspin_cmd_width,
-                             dspin_rsp_width>*    wi_proc[4];
-
     VciMemCache<vci_param_int,
                 vci_param_ext,
@@ -156,13 +127,5 @@
                 dspin_cmd_width>*                 memc;
 
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_memc;
-
     VciXicu<vci_param_int>*                       xicu;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_xicu;
 
     VciSimpleRam<vci_param_ext>*                  xram;
@@ -170,20 +133,16 @@
     VciMultiTty<vci_param_int>*                   mtty;
 
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_mtty;
+    VciBlockDeviceTsar<vci_param_int>*            bdev;
 
-    VciBlockDeviceTsar<vci_param_int>*            bdev;
+    VciLocalCrossbar<vci_param_int>*              xbar_cmd;
 
     VciDspinInitiatorWrapper<vci_param_int,
                              dspin_cmd_width,
-                             dspin_rsp_width>*    wi_bdev;
+                             dspin_rsp_width>*    wi_gate;
 
     VciDspinTargetWrapper<vci_param_int,
                           dspin_cmd_width,
-                          dspin_rsp_width>*       wt_bdev;
+                          dspin_rsp_width>*       wt_gate;
 
-    DspinLocalCrossbar<dspin_cmd_width>*          xbar_cmd;
-    DspinLocalCrossbar<dspin_rsp_width>*          xbar_rsp;
     DspinLocalCrossbar<dspin_cmd_width>*          xbar_m2p;
     DspinLocalCrossbar<dspin_rsp_width>*          xbar_p2m;
Index: trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/src/tsar_leti_cluster.cpp
===================================================================
--- trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/src/tsar_leti_cluster.cpp	(revision 664)
+++ trunk/platforms/tsar_generic_leti/tsar_leti_cluster/caba/source/src/tsar_leti_cluster.cpp	(revision 692)
@@ -52,4 +52,5 @@
          uint32_t                           trace_memc_id )
             : soclib::caba::BaseModule(insname),
+            m_nprocs(nb_procs),
             p_clk("clk"),
             p_resetn("resetn")
@@ -114,12 +115,4 @@
                       trace_start_cycle,
                       trace_ok );
-
-        std::ostringstream swip;
-        swip << "wi_proc_" << x_id << "_" << y_id << "_" << p;
-        wi_proc[p] = new VciDspinInitiatorWrapper<vci_param_int,
-                                                  dspin_cmd_width,
-                                                  dspin_rsp_width>(
-                     swip.str().c_str(),
-                     x_width + y_width + l_width);
     }
 
@@ -148,10 +141,4 @@
                      trace_ok );
 
-    wt_memc = new VciDspinTargetWrapper<vci_param_int,
-                                        dspin_cmd_width,
-                                        dspin_rsp_width>(
-                     "wt_memc",
-                     x_width + y_width + l_width);
-
     /////////////////////////////////////////////////////////////////////////////
     std::ostringstream sxram;
@@ -176,48 +163,34 @@
                      16 );                              // number of output IRQs
 
-    wt_xicu = new VciDspinTargetWrapper<vci_param_int,
+    /////////////////////////////////////////////////////////////////////////////
+    size_t nb_initiators = nb_procs;
+    size_t nb_targets    = 2;
+
+    if ((x_id == 0) and (y_id == 0))  // cluster(0,0)
+    {
+        nb_initiators = nb_procs + 1;
+        nb_targets    = 4;
+    }
+
+    std::ostringstream s_xbar_cmd;
+    xbar_cmd = new VciLocalCrossbar<vci_param_int>(
+                     s_xbar_cmd.str().c_str(),
+                     mtd,                          // mapping table
+                     cluster_xy,                   // cluster id
+                     nb_initiators,                // number of local initiators
+                     nb_targets,                   // number of local targets 
+                     0 );                          // default target
+
+    wi_gate = new VciDspinInitiatorWrapper<vci_param_int,
+                                           dspin_cmd_width,
+                                           dspin_rsp_width>(
+                     "wi_gate",
+                     x_width + y_width + l_width);
+
+    wt_gate = new VciDspinTargetWrapper<vci_param_int,
                                         dspin_cmd_width,
                                         dspin_rsp_width>(
-                     "wt_xicu",
+                     "wt_gate",
                      x_width + y_width + l_width);
-
-    /////////////////////////////////////////////////////////////////////////////
-    size_t nb_initiators = nb_procs;
-    size_t nb_targets    = 2;
-
-    if ((x_id == 0) and (y_id == 0))  // cluster(0,0)
-    {
-        nb_initiators = nb_procs + 1;
-        nb_targets    = 4;
-    }
-
-    std::ostringstream s_xbar_cmd;
-    s_xbar_cmd << "xbar_cmd_" << x_id << "_" << y_id;
-    xbar_cmd = new DspinLocalCrossbar<dspin_cmd_width>(
-                     s_xbar_cmd.str().c_str(),
-                     mtd,                          // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, l_width,
-                     nb_initiators,                // number of local of sources
-                     nb_targets,                   // number of local dests 
-                     2, 2,                         // fifo depths  
-                     true,                         // CMD
-                     true,                         // use local routing table 
-                     false );                      // no broadcast
-
-    /////////////////////////////////////////////////////////////////////////////
-    std::ostringstream s_xbar_rsp;
-    s_xbar_rsp << "xbar_rsp_" << x_id << "_" << y_id;
-    xbar_rsp = new DspinLocalCrossbar<dspin_rsp_width>(
-                     s_xbar_rsp.str().c_str(),
-                     mtd,                          // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, l_width,
-                     nb_targets,                   // number of local sources
-                     nb_initiators,                // number of local dests
-                     2, 2,                         // fifo depths  
-                     false,                        // RSP
-                     false,                        // don't use local routing table 
-                     false );                      // no broadcast
 
     /////////////////////////////////////////////////////////////////////////////
@@ -313,4 +286,6 @@
 
     // backup BDV and TTY peripherals in cluster(0,0)
+    bdev = NULL;
+    mtty = NULL;
     if ((x_id == 0) and (y_id == 0))
     {
@@ -325,16 +300,4 @@
                      64 );            // burst size
 
-        wt_bdev = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_bdev",
-                     x_width + y_width + l_width);
-
-        wi_bdev = new VciDspinInitiatorWrapper<vci_param_int,
-                                               dspin_cmd_width,
-                                               dspin_rsp_width>(
-                     "wi_bdev",
-                     x_width + y_width + l_width);
-
         /////////////////////////////////////////////
         mtty = new VciMultiTty<vci_param_int>(
@@ -342,11 +305,5 @@
                      IntTab(cluster_xy, tgtid_mtty),
                      mtd,
-                     "backup", NULL );
-
-        wt_mtty = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_mtty",
-                     x_width + y_width + l_width);
+                     "tty_backup", NULL );
     }
 
@@ -408,44 +365,33 @@
     xbar_cmd->p_clk                            (this->p_clk);
     xbar_cmd->p_resetn                         (this->p_resetn);
-    xbar_cmd->p_global_out                     (signal_dspin_cmd_l2g_d);
-    xbar_cmd->p_global_in                      (signal_dspin_cmd_g2l_d);
-
-    xbar_cmd->p_local_out[tgtid_memc]          (signal_dspin_cmd_memc_t);
-    xbar_cmd->p_local_out[tgtid_xicu]          (signal_dspin_cmd_xicu_t);
+    xbar_cmd->p_initiator_to_up                (signal_vci_l2g);
+    xbar_cmd->p_target_to_up                   (signal_vci_g2l);
+
+    xbar_cmd->p_to_target[tgtid_memc]          (signal_vci_tgt_memc);
+    xbar_cmd->p_to_target[tgtid_xicu]          (signal_vci_tgt_xicu);
 
     for (size_t p = 0; p < nb_procs; p++)
-        xbar_cmd->p_local_in[p]                (signal_dspin_cmd_proc_i[p]);
+        xbar_cmd->p_to_initiator[p]            (signal_vci_ini_proc[p]);
 
     if ((x_id == 0) and (y_id == 0))  // cluster(0,0)
     {
-        xbar_cmd->p_local_out[tgtid_mtty]      (signal_dspin_cmd_mtty_t);
-        xbar_cmd->p_local_out[tgtid_bdev]      (signal_dspin_cmd_bdev_t);
-
-        xbar_cmd->p_local_in[nb_procs]         (signal_dspin_cmd_bdev_i);
-    }
-
-    std::cout << "  - CMD Direct crossbar connected" << std::endl;
-
-    //////////////////////// RSP DSPIN  local crossbar direct
-    xbar_rsp->p_clk                            (this->p_clk);
-    xbar_rsp->p_resetn                         (this->p_resetn);
-    xbar_rsp->p_global_out                     (signal_dspin_rsp_l2g_d);
-    xbar_rsp->p_global_in                      (signal_dspin_rsp_g2l_d);
-
-    xbar_rsp->p_local_in[tgtid_memc]           (signal_dspin_rsp_memc_t);
-    xbar_rsp->p_local_in[tgtid_xicu]           (signal_dspin_rsp_xicu_t);
-
-    for (size_t p = 0; p < nb_procs; p++)
-        xbar_rsp->p_local_out[p]               (signal_dspin_rsp_proc_i[p]);
-
-    if ((x_id == 0) and (y_id == 0))  // cluster(0,0)
-    {
-        xbar_rsp->p_local_in[tgtid_mtty]       (signal_dspin_rsp_mtty_t);
-        xbar_rsp->p_local_in[tgtid_bdev]       (signal_dspin_rsp_bdev_t);
-
-        xbar_rsp->p_local_out[nb_procs]        (signal_dspin_rsp_bdev_i);
-    }
-
-    std::cout << "  - RSP Direct crossbar connected" << std::endl;
+        xbar_cmd->p_to_target[tgtid_mtty]      (signal_vci_tgt_mtty);
+        xbar_cmd->p_to_target[tgtid_bdev]      (signal_vci_tgt_bdev);
+        xbar_cmd->p_to_initiator[nb_procs]     (signal_vci_ini_bdev);
+    }
+
+    wi_gate->p_clk                             (this->p_clk);
+    wi_gate->p_resetn                          (this->p_resetn);
+    wi_gate->p_vci                             (signal_vci_l2g);
+    wi_gate->p_dspin_cmd                       (signal_dspin_cmd_l2g_d);
+    wi_gate->p_dspin_rsp                       (signal_dspin_rsp_g2l_d);
+
+    wt_gate->p_clk                             (this->p_clk);
+    wt_gate->p_resetn                          (this->p_resetn);
+    wt_gate->p_vci                             (signal_vci_g2l);
+    wt_gate->p_dspin_cmd                       (signal_dspin_cmd_g2l_d);
+    wt_gate->p_dspin_rsp                       (signal_dspin_rsp_l2g_d);
+
+    std::cout << "  - CMD & RSP Direct crossbar connected" << std::endl;
 
     ////////////////////// M2P DSPIN local crossbar coherence
@@ -497,10 +443,4 @@
             else         proc[p]->p_irq[j]  (signal_false);
         }
-
-        wi_proc[p]->p_clk                   (this->p_clk);
-        wi_proc[p]->p_resetn                (this->p_resetn);
-        wi_proc[p]->p_dspin_cmd             (signal_dspin_cmd_proc_i[p]);
-        wi_proc[p]->p_dspin_rsp             (signal_dspin_rsp_proc_i[p]);
-        wi_proc[p]->p_vci                   (signal_vci_ini_proc[p]);
     }
 
@@ -533,11 +473,4 @@
     }
 
-    // wrapper XICU
-    wt_xicu->p_clk                     (this->p_clk);
-    wt_xicu->p_resetn                  (this->p_resetn);
-    wt_xicu->p_dspin_cmd               (signal_dspin_cmd_xicu_t);
-    wt_xicu->p_dspin_rsp               (signal_dspin_rsp_xicu_t);
-    wt_xicu->p_vci                     (signal_vci_tgt_xicu);
-
     std::cout << "  - XICU connected" << std::endl;
 
@@ -552,11 +485,4 @@
     memc->p_dspin_clack                (signal_dspin_clack_memc);
 
-    // wrapper MEMC
-    wt_memc->p_clk                     (this->p_clk);
-    wt_memc->p_resetn                  (this->p_resetn);
-    wt_memc->p_dspin_cmd               (signal_dspin_cmd_memc_t);
-    wt_memc->p_dspin_rsp               (signal_dspin_rsp_memc_t);
-    wt_memc->p_vci                     (signal_vci_tgt_memc);
-
     std::cout << "  - MEMC connected" << std::endl;
 
@@ -579,18 +505,4 @@
         bdev->p_vci_initiator          (signal_vci_ini_bdev);
 
-        // wrapper tgt BDEV
-        wt_bdev->p_clk                 (this->p_clk);
-        wt_bdev->p_resetn              (this->p_resetn);
-        wt_bdev->p_dspin_cmd           (signal_dspin_cmd_bdev_t);
-        wt_bdev->p_dspin_rsp           (signal_dspin_rsp_bdev_t);
-        wt_bdev->p_vci                 (signal_vci_tgt_bdev);
-
-        // wrapper ini BDEV
-        wi_bdev->p_clk                 (this->p_clk);
-        wi_bdev->p_resetn              (this->p_resetn);
-        wi_bdev->p_dspin_cmd           (signal_dspin_cmd_bdev_i);
-        wi_bdev->p_dspin_rsp           (signal_dspin_rsp_bdev_i);
-        wi_bdev->p_vci                 (signal_vci_ini_bdev);
-
         std::cout << "  - BDEV connected" << std::endl;
 
@@ -600,11 +512,4 @@
         mtty->p_vci                    (signal_vci_tgt_mtty);
         mtty->p_irq[0]                 (signal_irq_mtty);
-
-        // wrapper tgt MTTY
-        wt_mtty->p_clk                 (this->p_clk);
-        wt_mtty->p_resetn              (this->p_resetn);
-        wt_mtty->p_dspin_cmd           (signal_dspin_cmd_mtty_t);
-        wt_mtty->p_dspin_rsp           (signal_dspin_rsp_mtty_t);
-        wt_mtty->p_vci                 (signal_vci_tgt_mtty);
 
         std::cout << "  - MTTY connected" << std::endl;
@@ -637,17 +542,13 @@
     dealloc_elems<DspinOutput<dspin_cmd_width> >(p_cla_out, 4);
 
-    for (size_t p = 0; p < 4 ; p++)
-    {
-        if ( proc[p] )     delete proc[p];
-        if ( wi_proc[p] )  delete wi_proc[p];
+    for (size_t p = 0; p < m_nprocs ; p++)
+    {
+        if ( proc[p] ) delete proc[p];
     }
 
     delete memc;
-    delete wt_memc;
     delete xram;
     delete xicu;
-    delete wt_xicu;
     delete xbar_cmd;
-    delete xbar_rsp;
     delete xbar_m2p;
     delete xbar_p2m;
@@ -658,10 +559,10 @@
     delete router_p2m;
     delete router_cla;
+    delete wi_gate;
+    delete wt_gate;
 
     if ( bdev )
     {
         delete bdev;
-        delete wt_bdev;
-        delete wi_bdev;
     }
 
@@ -669,5 +570,4 @@
     {
         delete mtty;
-        delete wt_mtty;
     }
 }
