Index: branches/fault_tolerance/platform/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp
===================================================================
--- branches/fault_tolerance/platform/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 658)
+++ branches/fault_tolerance/platform/tsar_generic_iob/tsar_iob_cluster/caba/source/src/tsar_iob_cluster.cpp	(revision 695)
@@ -33,13 +33,18 @@
 //////////////////////////////////////////////////////////////////////////
 tmpl(/**/)::TsarIobCluster(struct ClusterParams& params) :
-   soclib::caba::BaseModule(params.insname), p_clk("clk"), p_resetn("resetn")
-{
-   assert((params.x_id < params.x_size) and (params.y_id < params.y_size));
-
-   this->m_procs = params.nb_procs;
-   size_t cluster_id = (params.x_id << 4) + params.y_id;
-
-   size_t cluster_iob0 = 0;
-   size_t cluster_iob1 = ((params.x_size - 1) << 4) + params.y_size - 1;
+   soclib::caba::BaseModule(params.insname),
+   p_clk("clk"),
+   p_resetn("resetn") {
+
+   assert((params.x_id < X_MAX) && (params.y_id < Y_MAX));
+
+   size_t cid           = this->clusterId(params.x_id, params.y_id);
+   size_t cluster_iob0  = this->clusterId(0, 0);
+   size_t cluster_iob1  = this->clusterId(X_SIZE - 1, Y_SIZE - 1);
+   size_t is_iob0       = (cid == cluster_iob0);
+   size_t is_iob1       = (cid == cluster_iob1);
+   bool   is_io_cluster = is_iob0 || is_iob1;
+
+   size_t l_width = vci_param_int::S - X_WIDTH - Y_WIDTH;
 
    // Vectors of DSPIN ports for inter-cluster communications
@@ -63,6 +68,9 @@
 
    // ports in cluster_iob0 and cluster_iob1 only
-   if ( (cluster_id == cluster_iob0) or (cluster_id == cluster_iob1) )
-   {
+   p_vci_iob_iox_ini   = NULL;
+   p_vci_iob_iox_tgt   = NULL;
+   p_dspin_iob_cmd_out = NULL;
+   p_dspin_iob_rsp_in  = NULL;
+   if ( is_io_cluster ) {
       // VCI ports from IOB to IOX network
       p_vci_iob_iox_ini = new soclib::caba::VciInitiator<vci_param_ext>;
@@ -70,28 +78,11 @@
 
       // 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>;
-   }
-   else
-   {
-      p_vci_iob_iox_ini   = NULL;
-      p_vci_iob_iox_tgt   = NULL;
-      p_dspin_iob_cmd_out = NULL;
-      p_dspin_iob_rsp_in  = NULL;
+      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>;
    }
 
    // IRQ ports in cluster_iob0 only
-   for ( size_t n = 0 ; n < 32 ; n++ )
-   {
-      if ( cluster_id == cluster_iob0 )
-      {
-         p_irq[n] = new sc_in<bool>;
-      }
-      else
-      {
-         p_irq[n] = NULL;
-      }
+   for ( size_t n = 0 ; n < 32 ; n++ ) {
+      p_irq[n] = ( is_iob0 ) ? new sc_in<bool> : NULL;
    }
 
@@ -101,14 +92,13 @@
 
    ////////////  PROCS
-   for (size_t p = 0; p < params.nb_procs; p++)
-   { 
+   for (size_t p = 0; p < NB_PROCS; p++) { 
       std::ostringstream s_proc;
       s_proc << "proc_" << params.x_id << "_" << params.y_id << "_" << p;
       proc[p] = new VciCcVCacheWrapperType (
             s_proc.str().c_str(),
-            cluster_id * params.nb_procs + p,
+            cid * NB_PROCS + p,
             params.mt_int,
-            IntTab(cluster_id,p),
-            (cluster_id << params.l_width) + p,
+            IntTab(cid,p),
+            (cid << l_width) + p,
             8, 8,
             8, 8,
@@ -116,14 +106,16 @@
             params.l1_d_ways, params.l1_d_sets, 16,
             4, 4,
-            params.x_width, params.y_width,
+            X_WIDTH, Y_WIDTH,
             params.frozen_cycles,
             params.debug_start_cycle, params.proc_debug_ok);
 
+      proc[p]->set_dcache_paddr_ext_reset(cid);
+      proc[p]->set_icache_paddr_ext_reset(cid);
+
       std::ostringstream s_wi_proc;
-      s_wi_proc << "proc_wi_" << params.x_id << "_" << params.y_id << "_"
-         << p;
+      s_wi_proc << "proc_wi_" << params.x_id << "_" << params.y_id << "_" << p;
       proc_wi[p] = new VciIntDspinInitiatorWrapperType(
             s_wi_proc.str().c_str(),
-            params.x_width + params.y_width + params.l_width);
+            vci_param_int::S);
    }
 
@@ -135,14 +127,12 @@
          params.mt_int,
          params.mt_ext,
-         IntTab(cluster_id, params.ext_memc_srcid),
-         IntTab(cluster_id, params.int_memc_tgtid),
-         params.x_width,
-         params.y_width,
+         IntTab(cid, RAM_MEMC_INI_ID),
+         IntTab(cid, INT_MEMC_TGT_ID),
+         X_WIDTH,
+         Y_WIDTH,
          params.memc_ways, params.memc_sets, 16,
          3,
          4096,
-         8,
-         8,
-         8,
+         8, 8, 8,
          params.debug_start_cycle,
          params.memc_debug_ok);
@@ -152,5 +142,5 @@
    memc_int_wt = new VciIntDspinTargetWrapperType (
          s_wt_memc.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    std::ostringstream s_wi_memc;
@@ -158,13 +148,15 @@
    memc_ram_wi = new VciExtDspinInitiatorWrapperType (
          s_wi_memc.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    ///////////   LOCAL ROM
+   std::ostringstream s_brom;
+   s_brom << "brom_" << params.x_id << "_" << params.y_id;
    brom = new VciSimpleRom<vci_param_int>(
-         "brom",
-         IntTab(cluster_id, params.int_brom_tgtid),
+         s_brom.str().c_str(),
+         IntTab(cid, INT_BROM_TGT_ID),
          params.mt_int,
          params.loader,
-         params.x_width + params.y_width);
+         X_WIDTH + Y_WIDTH);
 
    std::ostringstream s_wt_brom;
@@ -172,5 +164,32 @@
    brom_int_wt = new VciIntDspinTargetWrapperType (
          s_wt_brom.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
+
+   // Multi-TTY controller
+   mtty        = NULL;
+   mtty_int_wt = NULL;
+   if (NB_DEBUG_TTY_CHANNELS) {
+      assert(NB_DEBUG_TTY_CHANNELS < 8);
+
+      std::ostringstream s_mtty;
+      s_mtty << "mtty_" << params.x_id << "_" << params.y_id;
+      std::vector<std::string> vect_names;
+      for( size_t tid = 0 ; tid < NB_DEBUG_TTY_CHANNELS ; tid++ ) {
+         std::ostringstream term_name;
+         term_name << s_mtty.str() << "_" << tid;
+         vect_names.push_back(term_name.str().c_str());
+      }
+      mtty = new VciMultiTty<vci_param_int>(
+            s_mtty.str().c_str(),
+            IntTab(cid, INT_MTTY_TGT_ID),
+            params.mt_int,
+            vect_names);
+
+      std::ostringstream s_wt_mtty;
+      s_wt_mtty << "mtty_wt_" << params.x_id << "_" << params.y_id;
+      mtty_int_wt = new VciIntDspinTargetWrapperType (
+            s_wt_mtty.str().c_str(),
+            vci_param_int::S);
+   }
 
    ///////////   XICU
@@ -180,7 +199,7 @@
          s_xicu.str().c_str(),
          params.mt_int,
-         IntTab(cluster_id,params.int_xicu_tgtid),
+         IntTab(cid, INT_XICU_TGT_ID),
          32, 32, 32,
-         params.nb_procs);
+         NB_PROCS);
 
    std::ostringstream s_wt_xicu;
@@ -188,5 +207,5 @@
    xicu_int_wt = new VciIntDspinTargetWrapperType (
          s_wt_xicu.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    ////////////  MDMA
@@ -196,8 +215,8 @@
          s_mdma.str().c_str(),
          params.mt_int,
-         IntTab(cluster_id, params.nb_procs),
-         IntTab(cluster_id, params.int_mdma_tgtid),
+         IntTab(cid, NB_PROCS),
+         IntTab(cid, INT_MDMA_TGT_ID),
          64,
-         params.nb_dmas);
+         NB_DMA_CHANNELS);
 
    std::ostringstream s_wt_mdma;
@@ -205,5 +224,5 @@
    mdma_int_wt = new VciIntDspinTargetWrapperType(
          s_wt_mdma.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    std::ostringstream s_wi_mdma;
@@ -211,13 +230,15 @@
    mdma_int_wi = new VciIntDspinInitiatorWrapperType(
          s_wi_mdma.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    ///////////  Direct LOCAL_XBAR(S)
-   size_t nb_direct_initiators = params.nb_procs + 1;
+   size_t nb_direct_initiators = NB_PROCS + 1;
    size_t nb_direct_targets    = 4;
-   if ((cluster_id == cluster_iob0) or (cluster_id == cluster_iob1))
-   {
-      nb_direct_initiators = params.nb_procs + 2;
-      nb_direct_targets    = 5;
+   if (NB_DEBUG_TTY_CHANNELS) {
+      nb_direct_targets++;
+   }
+   if ( is_io_cluster ) {
+      nb_direct_initiators++;
+      nb_direct_targets++;
    }
 
@@ -228,5 +249,5 @@
          params.mt_int,
          params.x_id, params.y_id,
-         params.x_width, params.y_width, params.l_width,
+         X_WIDTH, Y_WIDTH, l_width,
          nb_direct_initiators,
          nb_direct_targets,
@@ -242,5 +263,5 @@
          params.mt_int,
          params.x_id, params.y_id,
-         params.x_width, params.y_width, params.l_width,
+         X_WIDTH, Y_WIDTH, l_width,
          nb_direct_targets,
          nb_direct_initiators,
@@ -257,7 +278,7 @@
          params.mt_int,
          params.x_id, params.y_id,
-         params.x_width, params.y_width, params.l_width,
+         X_WIDTH, Y_WIDTH, l_width,
          1,
-         params.nb_procs,
+         NB_PROCS,
          2, 2,
          true,
@@ -271,6 +292,6 @@
          params.mt_int,
          params.x_id, params.y_id,
-         params.x_width, params.y_width, 0,
-         params.nb_procs,
+         X_WIDTH, Y_WIDTH, 0,
+         NB_PROCS,
          1,
          2, 2,
@@ -281,12 +302,12 @@
    std::ostringstream s_int_xbar_clack_c;
    s_int_xbar_clack_c << "int_xbar_clack_c_" << params.x_id << "_"
-      << params.y_id;
+                                             << params.y_id;
    int_xbar_clack_c = new DspinLocalCrossbar<dspin_int_cmd_width>(
          s_int_xbar_clack_c.str().c_str(),
          params.mt_int,
          params.x_id, params.y_id,
-         params.x_width, params.y_width, params.l_width,
+         X_WIDTH, Y_WIDTH, l_width,
          1,
-         params.nb_procs,
+         NB_PROCS,
          1, 1,
          true,
@@ -299,6 +320,6 @@
    int_router_cmd = new VirtualDspinRouter<dspin_int_cmd_width>(
          s_int_router_cmd.str().c_str(),
-         params.x_id,params.y_id,
-         params.x_width, params.y_width,
+         params.x_id, params.y_id,
+         X_WIDTH, Y_WIDTH,
          3,
          4,4);
@@ -308,6 +329,6 @@
    int_router_rsp = new VirtualDspinRouter<dspin_int_rsp_width>(
          s_int_router_rsp.str().c_str(),
-         params.x_id,params.y_id,
-         params.x_width, params.y_width,
+         params.x_id, params.y_id,
+         X_WIDTH, Y_WIDTH,
          2,
          4,4);
@@ -318,5 +339,5 @@
    xram = new VciSimpleRam<vci_param_ext>(
          s_xram.str().c_str(),
-         IntTab(cluster_id, params.ext_xram_tgtid),
+         IntTab(cid, RAM_XRAM_TGT_ID),
          params.mt_ext,
          params.loader,
@@ -327,22 +348,17 @@
    xram_ram_wt = new VciExtDspinTargetWrapperType(
          s_wt_xram.str().c_str(),
-         params.x_width + params.y_width + params.l_width);
+         vci_param_int::S);
 
    /////////////  RAM ROUTER(S)
    std::ostringstream s_ram_router_cmd;
    s_ram_router_cmd << "ram_router_cmd_" << params.x_id << "_" << params.y_id;
-   size_t is_iob0 = (params.x_id == 0) and (params.y_id == 0);
-   size_t is_iob1 = (params.x_id == (params.x_size-1)) and
-      (params.y_id == (params.y_size-1));
    ram_router_cmd = new DspinRouterTsar<dspin_ram_cmd_width>(
          s_ram_router_cmd.str().c_str(),
          params.x_id, params.y_id,
-         params.x_width,
-         params.y_width,
+         X_WIDTH, Y_WIDTH,
          4, 4,
-         is_iob0,
-         is_iob1,
+         is_iob0, is_iob1,
          false,
-         params.l_width);
+         l_width);
 
    std::ostringstream s_ram_router_rsp;
@@ -351,29 +367,25 @@
          s_ram_router_rsp.str().c_str(),
          params.x_id, params.y_id,
-         params.x_width,
-         params.y_width,
+         X_WIDTH, Y_WIDTH,
          4, 4,
-         is_iob0,
-         is_iob1,
+         is_iob0, is_iob1,
          true,
-         params.l_width);
+         l_width);
 
    ////////////////////// I/O  CLUSTER ONLY ///////////////////////
-   if ((cluster_id == cluster_iob0) or (cluster_id == cluster_iob1))
-   {
+   iob        = NULL;
+   iob_int_wi = NULL;
+   iob_int_wt = NULL;
+   iob_ram_wi = NULL;
+   if ( is_io_cluster ) {
       ///////////  IO_BRIDGE
       size_t iox_local_id;
-      size_t global_id;
       bool   has_irqs;
-      if (cluster_id == cluster_iob0 ) 
-      {
+      if ( is_iob0 ) {
          iox_local_id = 0;
-         global_id    = cluster_iob0;
          has_irqs     = true;
       }
-      else
-      {
+      else {
          iox_local_id = 1;
-         global_id    = cluster_iob1;
          has_irqs     = false;
       }
@@ -386,7 +398,7 @@
             params.mt_int,
             params.mt_iox,
-            IntTab( global_id, params.int_iobx_tgtid),
-            IntTab( global_id, params.int_iobx_srcid),
-            IntTab( global_id, iox_local_id ),
+            IntTab(cid, INT_IOBX_TGT_ID),
+            IntTab(cid, INT_IOBX_INI_ID),
+            IntTab(cid, iox_local_id ),
             has_irqs,
             16,
@@ -400,5 +412,5 @@
       iob_int_wi = new VciIntDspinInitiatorWrapperType(
             s_iob_int_wi.str().c_str(),
-            params.x_width + params.y_width + params.l_width);
+            vci_param_int::S);
 
       std::ostringstream s_iob_int_wt;
@@ -406,5 +418,5 @@
       iob_int_wt = new VciIntDspinTargetWrapperType(
             s_iob_int_wt.str().c_str(),
-            params.x_width + params.y_width + params.l_width);
+            vci_param_int::S);
 
       std::ostringstream s_iob_ram_wi;
@@ -412,12 +424,5 @@
       iob_ram_wi = new VciExtDspinInitiatorWrapperType(
             s_iob_ram_wi.str().c_str(),
-            params.x_width + params.y_width + params.l_width);
-   }
-   else
-   {
-      iob        = NULL;
-      iob_int_wi = NULL;
-      iob_int_wt = NULL;
-      iob_ram_wi = NULL;
+            vci_param_int::S);
    }
 
@@ -426,6 +431,6 @@
    ////////////////////////////////////
 
-   // on coherence network : local srcid[proc] in [0...nb_procs-1]
-   //                      : local srcid[memc] = nb_procs
+   // on coherence network : local srcid[proc] in [0...NB_PROCS-1]
+   //                      : local srcid[memc] = NB_PROCS
    // In cluster_iob0, 32 HWI interrupts from external peripherals
    // are connected to the XICU ports p_hwi[0:31] 
@@ -438,14 +443,10 @@
    int_router_rsp->p_resetn (this->p_resetn);
 
-   for (int i = 0; i < 4; i++)
-   {
-      for(int k = 0; k < 3; k++)
-      {
+   for (int i = 0; i < 4; i++) {
+      for(int k = 0; k < 3; k++) {
          int_router_cmd->p_out[i][k] (this->p_dspin_int_cmd_out[i][k]);
          int_router_cmd->p_in[i][k]  (this->p_dspin_int_cmd_in[i][k]);
       }
-
-      for(int k = 0; k < 2; k++)
-      {
+      for(int k = 0; k < 2; k++) {
          int_router_rsp->p_out[i][k] (this->p_dspin_int_rsp_out[i][k]);
          int_router_rsp->p_in[i][k]  (this->p_dspin_int_rsp_in[i][k]);
@@ -472,25 +473,22 @@
    int_xbar_cmd_d->p_global_in  (signal_int_dspin_cmd_g2l_d);
 
-   int_xbar_cmd_d->p_local_out[params.int_memc_tgtid](
-         signal_int_dspin_cmd_memc_t);
-   int_xbar_cmd_d->p_local_out[params.int_xicu_tgtid](
-         signal_int_dspin_cmd_xicu_t);
-   int_xbar_cmd_d->p_local_out[params.int_brom_tgtid](
-         signal_int_dspin_cmd_brom_t);
-   int_xbar_cmd_d->p_local_out[params.int_mdma_tgtid](
-         signal_int_dspin_cmd_mdma_t);
-   int_xbar_cmd_d->p_local_in[params.int_mdma_srcid](
-         signal_int_dspin_cmd_mdma_i);
-
-   for (size_t p = 0; p < params.nb_procs; p++) {
-      int_xbar_cmd_d->p_local_in[params.int_proc_srcid + p](
+   int_xbar_cmd_d->p_local_out[INT_MEMC_TGT_ID] (signal_int_dspin_cmd_memc_t);
+   int_xbar_cmd_d->p_local_out[INT_XICU_TGT_ID] (signal_int_dspin_cmd_xicu_t);
+   int_xbar_cmd_d->p_local_out[INT_BROM_TGT_ID] (signal_int_dspin_cmd_brom_t);
+   int_xbar_cmd_d->p_local_out[INT_MDMA_TGT_ID] (signal_int_dspin_cmd_mdma_t);
+   if (NB_DEBUG_TTY_CHANNELS) {
+      int_xbar_cmd_d->p_local_out[INT_MTTY_TGT_ID] (signal_int_dspin_cmd_mtty_t);
+   }
+   int_xbar_cmd_d->p_local_in[INT_MDMA_INI_ID]  (signal_int_dspin_cmd_mdma_i);
+
+   for (size_t p = 0; p < NB_PROCS; p++) {
+      int_xbar_cmd_d->p_local_in[INT_PROC_INI_ID + p](
             signal_int_dspin_cmd_proc_i[p]);
    }
 
-   if ((cluster_id == cluster_iob0) or (cluster_id == cluster_iob1))
-   {
-      int_xbar_cmd_d->p_local_out[params.int_iobx_tgtid](
+   if ( is_io_cluster ) {
+      int_xbar_cmd_d->p_local_out[INT_IOBX_TGT_ID](
             signal_int_dspin_cmd_iobx_t);
-      int_xbar_cmd_d->p_local_in[params.int_iobx_srcid](
+      int_xbar_cmd_d->p_local_in[INT_IOBX_INI_ID](
             signal_int_dspin_cmd_iobx_i);
    }
@@ -502,24 +500,21 @@
    int_xbar_rsp_d->p_global_in  (signal_int_dspin_rsp_g2l_d);
 
-   int_xbar_rsp_d->p_local_in[params.int_memc_tgtid](
-         signal_int_dspin_rsp_memc_t);
-   int_xbar_rsp_d->p_local_in[params.int_xicu_tgtid](
-         signal_int_dspin_rsp_xicu_t);
-   int_xbar_rsp_d->p_local_in[params.int_brom_tgtid](
-         signal_int_dspin_rsp_brom_t);
-   int_xbar_rsp_d->p_local_in[params.int_mdma_tgtid](
-         signal_int_dspin_rsp_mdma_t);
-
-   int_xbar_rsp_d->p_local_out[params.int_mdma_srcid](
-         signal_int_dspin_rsp_mdma_i);
-   for (size_t p = 0; p < params.nb_procs; p++)
-      int_xbar_rsp_d->p_local_out[params.int_proc_srcid + p](
+   int_xbar_rsp_d->p_local_in[INT_MEMC_TGT_ID] (signal_int_dspin_rsp_memc_t);
+   int_xbar_rsp_d->p_local_in[INT_XICU_TGT_ID] (signal_int_dspin_rsp_xicu_t);
+   int_xbar_rsp_d->p_local_in[INT_BROM_TGT_ID] (signal_int_dspin_rsp_brom_t);
+   if (NB_DEBUG_TTY_CHANNELS) {
+      int_xbar_rsp_d->p_local_in[INT_MTTY_TGT_ID] (signal_int_dspin_rsp_mtty_t);
+   }
+   int_xbar_rsp_d->p_local_in[INT_MDMA_TGT_ID] (signal_int_dspin_rsp_mdma_t);
+
+   int_xbar_rsp_d->p_local_out[INT_MDMA_INI_ID](signal_int_dspin_rsp_mdma_i);
+   for (size_t p = 0; p < NB_PROCS; p++)
+      int_xbar_rsp_d->p_local_out[INT_PROC_INI_ID + p](
             signal_int_dspin_rsp_proc_i[p]);
 
-   if ((cluster_id == cluster_iob0) or (cluster_id == cluster_iob1))
-   {
-      int_xbar_rsp_d->p_local_in[params.int_iobx_tgtid](
+   if ( is_io_cluster ) {
+      int_xbar_rsp_d->p_local_in[INT_IOBX_TGT_ID](
             signal_int_dspin_rsp_iobx_t);
-      int_xbar_rsp_d->p_local_out[params.int_iobx_srcid](
+      int_xbar_rsp_d->p_local_out[INT_IOBX_INI_ID](
             signal_int_dspin_rsp_iobx_i);
    }
@@ -531,6 +526,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 < params.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]);
    }
@@ -542,6 +536,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 < params.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]);
    }
@@ -553,12 +546,10 @@
    int_xbar_clack_c->p_global_in       (signal_int_dspin_clack_g2l_c);
    int_xbar_clack_c->p_local_in[0]     (signal_int_dspin_clack_memc);
-   for (size_t p = 0; p < params.nb_procs; p++)
-   {
+   for (size_t p = 0; p < NB_PROCS; p++) {
       int_xbar_clack_c->p_local_out[p] (signal_int_dspin_clack_proc[p]);
    }
 
    //////////////////////////////////// Processors
-   for (size_t p = 0; p < params.nb_procs; p++)
-   {
+   for (size_t p = 0; p < NB_PROCS; p++) {
       proc[p]->p_clk          (this->p_clk);
       proc[p]->p_resetn       (this->p_resetn);
@@ -568,6 +559,5 @@
       proc[p]->p_dspin_clack  (signal_int_dspin_clack_proc[p]);
       proc[p]->p_irq[0]       (signal_proc_it[p]);
-      for ( size_t j = 1 ; j < 6 ; j++)
-      {
+      for ( size_t j = 1 ; j < 6 ; j++) {
          proc[p]->p_irq[j]    (signal_false);
       }
@@ -584,11 +574,9 @@
    xicu->p_resetn (this->p_resetn);
    xicu->p_vci    (signal_int_vci_tgt_xicu);
-   for ( size_t p = 0 ; p < params.nb_procs ; p++)
-   {
+   for ( size_t p = 0 ; p < NB_PROCS ; p++) {
       xicu->p_irq[p] (signal_proc_it[p]);
    }
-   for ( size_t i=0 ; i<32 ; i++)
-   {
-      if (cluster_id == cluster_iob0) 
+   for ( size_t i=0 ; i<32 ; i++) {
+      if ( is_iob0 ) 
          xicu->p_hwi[i] (*(this->p_irq[i]));
       else  
@@ -639,4 +627,22 @@
    brom_int_wt->p_vci       (signal_int_vci_tgt_brom);
 
+   if (NB_DEBUG_TTY_CHANNELS) {
+      //////////////////////////////////// MTTY
+      mtty->p_clk              (this->p_clk);
+      mtty->p_resetn           (this->p_resetn);
+      mtty->p_vci              (signal_int_vci_tgt_mtty);
+
+      for ( size_t i=0 ; i < NB_DEBUG_TTY_CHANNELS ; i++ ) {
+         mtty->p_irq[i] (signal_irq_mtty[i]);
+      }
+
+      //wrapper to INT network
+      mtty_int_wt->p_clk       (this->p_clk);
+      mtty_int_wt->p_resetn    (this->p_resetn);
+      mtty_int_wt->p_dspin_cmd (signal_int_dspin_cmd_mtty_t);
+      mtty_int_wt->p_dspin_rsp (signal_int_dspin_rsp_mtty_t);
+      mtty_int_wt->p_vci       (signal_int_vci_tgt_mtty);
+   }
+
    //////////////////////////////////// XRAM
    xram->p_clk              (this->p_clk);
@@ -656,5 +662,5 @@
    mdma->p_vci_target       (signal_int_vci_tgt_mdma);
    mdma->p_vci_initiator    (signal_int_vci_ini_mdma);
-   for (size_t i = 0 ; i < params.nb_dmas ; i++)
+   for (size_t i = 0 ; i < NB_DMA_CHANNELS ; i++)
       mdma->p_irq[i]        (signal_irq_mdma[i]);
 
@@ -678,6 +684,5 @@
    ram_router_rsp->p_clk       (this->p_clk);
    ram_router_rsp->p_resetn    (this->p_resetn);
-   for( size_t n=0 ; n<4 ; n++)
-   {
+   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]);
@@ -691,6 +696,5 @@
 
    ///////////////////////// IOB exists only in cluster_iob0 & cluster_iob1. 
-   if ( (cluster_id == cluster_iob0) or (cluster_id == cluster_iob1) )
-   {
+   if ( is_io_cluster ) {
       // IO bridge
       iob->p_clk         (this->p_clk);
@@ -702,5 +706,5 @@
       iob->p_vci_ini_ram (signal_ram_vci_ini_iobx);
 
-      if ( cluster_id == cluster_iob0 )
+      if ( is_iob0 )
          for ( size_t n = 0 ; n < 32 ; n++ )
             (*iob->p_irq[n]) (*(this->p_irq[n]));
@@ -729,6 +733,5 @@
 } // end constructor
 
-tmpl(/**/)::~TsarIobCluster()
-{
+tmpl(/**/)::~TsarIobCluster() {
    if (p_vci_iob_iox_ini)   delete p_vci_iob_iox_ini;
    if (p_vci_iob_iox_tgt)   delete p_vci_iob_iox_tgt;
@@ -740,11 +743,9 @@
    if (iob_ram_wi)          delete iob_ram_wi;
 
-   for (size_t n = 0 ; n < 32 ; n++)
-   {
+   for (size_t n = 0 ; n < 32 ; n++) {
       if (p_irq[n]) delete p_irq[n];
    }
 
-   for (size_t p = 0; p < m_procs; p++)
-   { 
+   for (size_t p = 0; p < NB_PROCS; p++) { 
       delete proc[p];
       delete proc_wi[p];
@@ -758,4 +759,6 @@
    delete brom;
    delete brom_int_wt;
+   delete mtty;
+   delete mtty_int_wt;
    delete mdma;
    delete mdma_int_wt;
