Index: /branches/reconfiguration/modules/dspin_router/caba/source/include/dspin_router.h
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/source/include/dspin_router.h	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/source/include/dspin_router.h	(revision 1016)
@@ -29,6 +29,5 @@
     ///////////////////////////////////////////////////////////////////////////
     // Implementation Note :
-    // The xfirst_route(), broadcast_route() and is_broadcast() functions
-    // defined below are used to decode the DSPIN first flit format:
+    // DSPIN first flit format:
     // - In case of a non-broadcast packet :
     //  |   X     |   Y     |---------------------------------------|BC |
@@ -36,6 +35,6 @@
     //
     //  - In case of a broacast
-    //  |  XMIN   |  XMAX   |  YMIN   |  YMAX   |-------------------|BC |
-    //  |   5     |   5     |   5     |   5     | flit_width - 22   | 1 |
+    //  |  XMIN   |  XMAX   |  YMIN   |  YMAX   |----------------|SP|BC |
+    //  |   5     |   5     |   5     |   5     | flit_width - 21| 1| 1 |
     ///////////////////////////////////////////////////////////////////////////
 
@@ -147,29 +146,17 @@
     void    genMoore();
 
-    int     xfirst_route( size_t xdest, size_t ydest );
+    int     route( sc_uint<flit_width> data );
     int     recovery_route( size_t xdest, size_t ydest );
-    int     route( sc_uint<flit_width> data );
+    int     broadcast_route( int iter, int source, sc_uint<flit_width> data );
+    int     reallocation_route();
 
-    int     broadcast_route( int iter, int source, sc_uint<flit_width> data );
     bool    is_broadcast( sc_uint<flit_width> data );
-    sc_uint<flit_width> compute_broadcast_header( int source );
+    internal_flit_t compute_broadcast_header( int source );
 
-    bool    is_destination_blackhole( size_t xdest, size_t ydest, int bhpos );
+    bool    is_reconfigurable();
+    bool    is_recovery_routing_enabled();
+    bool    is_reallocation_enabled();
+    bool    is_destination_blackhole( size_t xdest, size_t ydest );
     int     blackhole_position();
-
-    inline bool is_network_recovery_enable()
-    {
-        return (((p_recovery_cfg->read() >> 7) & 0x1) != 0);
-    }
-
-    inline int migration_route()
-    {
-        return ((p_recovery_cfg->read() >> 4) & 0x7);
-    }
-
-    inline bool is_reconfigurable()
-    {
-        return (p_recovery_cfg != NULL);
-    }
 
     public:
Index: /branches/reconfiguration/modules/dspin_router/caba/source/src/dspin_router.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/source/src/dspin_router.cpp	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/source/src/dspin_router.cpp	(revision 1016)
@@ -26,20 +26,8 @@
   *
   */
-
-    ///////////////////////////////////////////////////////////////////////////
-    // Implementation Note :
-    // The xfirst_route(), broadcast_route() and is_broadcast() functions
-    // defined below are used to decode the DSPIN first flit format:
-    // - In case of a non-broadcast packet :
-    //  |   X     |   Y     |---------------------------------------|BC |
-    //  | x_width | y_width |  flit_width - (x_width + y_width + 2) | 0 |
-    //
-    //  - In case of a broacast
-    //  |  XMIN   |  XMAX   |  YMIN   |  YMAX   |----------------|SP|BC |
-    //  |   5     |   5     |   5     |   5     | flit_width - 21| 1| 1 |
-    ///////////////////////////////////////////////////////////////////////////
-
 #include "../include/dspin_router.h"
 #include "dspin_router_config.h"
+
+#include <cassert>
 
 namespace soclib { namespace caba {
@@ -132,8 +120,6 @@
     tmpl(int)::blackhole_position()
     {
-        if ( is_reconfigurable() ) {
-            return p_recovery_cfg->read() & 0xF;
-        }
-        return BH_NONE;
+        assert( is_reconfigurable() );
+        return p_recovery_cfg->read() & 0xF;
     }
 
@@ -141,5 +127,5 @@
     tmpl(void)::bind_recovery_port(sc_signal<uint32_t> &s)
     {
-        if (!is_reconfigurable()) {
+        if ( not is_reconfigurable() ) {
             std::cerr << "Error in " << name()
                       << ": router configuration not supported." << std::endl
@@ -150,100 +136,114 @@
     }
 
+    tmpl(bool)::is_recovery_routing_enabled()
+    {
+        assert( is_reconfigurable() );
+        return (((p_recovery_cfg->read() >> 4) & 0x1) != 0);
+    }
+
+    tmpl(bool)::is_reallocation_enabled()
+    {
+        assert( is_reconfigurable() );
+        return (blackhole_position() != NORMAL);
+    }
+
+    tmpl(int)::reallocation_route()
+    {
+        assert( is_reconfigurable() );
+        return ((p_recovery_cfg->read() >> 5) & 0x7);
+    }
+
+    tmpl(bool)::is_reconfigurable()
+    {
+        return (p_recovery_cfg != NULL);
+    }
+
     ///////////////////////////////////////////////////
-    tmpl(int)::xfirst_route( size_t xdest, size_t ydest )
-    {
-        return (xdest < m_local_x ? REQ_WEST :
-               (xdest > m_local_x ? REQ_EAST :
-               (ydest < m_local_y ? REQ_SOUTH :
-               (ydest > m_local_y ? REQ_NORTH : REQ_LOCAL))));
+    tmpl(bool)::is_destination_blackhole( size_t xdest, size_t ydest )
+    {
+        assert ( is_reconfigurable() );
+
+        const int bhpos = blackhole_position();
+
+        const bool is_n = (bhpos == N_OF_X);
+        const bool is_s = (bhpos == S_OF_X);
+        const bool is_w = (bhpos == W_OF_X);
+        const bool is_e = (bhpos == E_OF_X);
+        const bool is_nw = (bhpos == NW_OF_X);
+        const bool is_ne = (bhpos == NE_OF_X);
+        const bool is_sw = (bhpos == SW_OF_X);
+        const bool is_se = (bhpos == SE_OF_X);
+
+        if ( bhpos == NORMAL ) return false;
+
+        size_t xhole;
+        if      (is_nw || is_w  || is_sw) xhole = m_local_x + 1;
+        else if (is_ne || is_se || is_e ) xhole = m_local_x - 1;
+        else                              xhole = m_local_x;
+
+        size_t yhole;
+        if      (is_sw || is_s  || is_se) yhole = m_local_y + 1;
+        else if (is_nw || is_n  || is_ne) yhole = m_local_y - 1;
+        else                              yhole = m_local_y;
+
+        return ((xdest == xhole) && (ydest == yhole));
     }
 
     ///////////////////////////////////////////////////
-    tmpl(bool)::is_destination_blackhole( size_t xdest, size_t ydest, int bhpos )
-    {
-        size_t xhole, yhole;
-        switch (bhpos) {
-            case BH_N:
-                xhole = m_local_x;
-                yhole = m_local_y - 1;
-                break;
-            case BH_NW:
-                xhole = m_local_x + 1;
-                yhole = m_local_y - 1;
-                break;
-            case BH_W:
-                xhole = m_local_x + 1;
-                yhole = m_local_y;
-                break;
-            case BH_SW:
-                xhole = m_local_x + 1;
-                yhole = m_local_y + 1;
-                break;
-            case BH_S:
-                xhole = m_local_x;
-                yhole = m_local_y + 1;
-                break;
-            case BH_SE:
-                xhole = m_local_x - 1;
-                yhole = m_local_y + 1;
-                break;
-            case BH_E:
-                xhole = m_local_x - 1;
-                yhole = m_local_y;
-                break;
-            case BH_NE:
-                xhole = m_local_x - 1;
-                yhole = m_local_y - 1;
-                break;
-            default:
-                return false;
-        }
-
-        return ((xdest == xhole) && (ydest == yhole));
-    }
-
-    ///////////////////////////////////////////////////
-    tmpl(int)::recovery_route( size_t xdest, size_t ydest )
-    {
-        int bhpos = blackhole_position();
-
-        if ( xdest > m_local_x ) {
-            if ( (bhpos == BH_NE) || (bhpos == BH_E) || (bhpos == BH_SE) ||
-                 (bhpos == BH_S) ) {
+    tmpl(int)::recovery_route( size_t dx, size_t dy )
+    {
+        // use normal routing (X-first) when the recovery routing is disabled
+        int bhpos = NORMAL;
+        bool normal = true;
+        if (is_reconfigurable()) {
+            assert(not is_reallocation_enabled() or
+                   not is_destination_blackhole(dx, dy));
+
+            bhpos  = blackhole_position();
+
+            normal = (bhpos == NORMAL) or
+                     (not is_recovery_routing_enabled() and
+                      not is_destination_blackhole(dx, dy));
+        }
+
+        const bool is_n  = not normal and (bhpos == N_OF_X);
+        const bool is_s  = not normal and (bhpos == S_OF_X);
+        const bool is_w  = not normal and (bhpos == W_OF_X);
+        const bool is_e  = not normal and (bhpos == E_OF_X);
+        const bool is_nw = not normal and (bhpos == NW_OF_X);
+        const bool is_ne = not normal and (bhpos == NE_OF_X);
+        const bool is_sw = not normal and (bhpos == SW_OF_X);
+        const bool is_se = not normal and (bhpos == SE_OF_X);
+
+        const size_t lx = m_local_x;
+        const size_t ly = m_local_y;
+
+        if ( dx > lx ) {
+            if ( is_ne || is_e || is_se || is_s || normal )
                 return REQ_EAST;
-            }
-            else if ( bhpos == BH_N ) {
-                if ( (m_local_y == 1) || (m_local_x == 0) || (ydest >= m_local_y) ||
-                     (xdest > (m_local_x + 1)) ) {
+
+            else if ( is_n ) {
+                if ( (ly == 1) || (lx == 0) || (dy >= ly) || (dx > (lx + 1)) )
                     return REQ_EAST;
-                }
-                else {
+                else
                     return REQ_WEST;
-                }
-            }
-            else if ( bhpos == BH_NW ) {
-                if ( (m_local_y == 1) || (ydest >= m_local_y) ||
-                     (xdest > (m_local_x + 2)) ) {
+            }
+            else if ( is_nw ) {
+                if ( (ly == 1) || (dy >= ly) || (dx > (lx + 2)) )
                     return REQ_EAST;
-                }
-                else {
+                else
                     return REQ_SOUTH;
-                }
-            }
-            else if ( bhpos == BH_W ) {
-                if ( (m_local_y == 0) || (ydest > m_local_y)) {
+            }
+            else if ( is_w ) {
+                if ( (ly == 0) || (dy > ly))
                     return REQ_NORTH;
-                }
-                else {
+                else
                     return REQ_SOUTH;
-                }
-            }
-            else if ( bhpos == BH_SW ) {
-                if ( (ydest <= m_local_y) || (xdest > (m_local_x + 1)) ) {
+            }
+            else if ( is_sw ) {
+                if ( (dy <= ly) || (dx > (lx + 1)) )
                     return REQ_EAST;
-                }
-                else {
+                else
                     return REQ_NORTH;
-                }
             }
             std::cout << "error: unexpected condition in function "
@@ -251,34 +251,26 @@
                       << std::endl;
             exit(1);
-        }                    // end if (xdest > m_local_x)
-        else if ( xdest < m_local_x ) {
-            if ( (bhpos == BH_N) || (bhpos == BH_NW) || (bhpos == BH_W) ||
-                 (bhpos == BH_SW) || (bhpos == BH_S) ) {
+        }                    // end if (dx > lx)
+        else if ( dx < lx ) {
+            if ( is_n || is_nw || is_w || is_sw || is_s || normal )
                 return REQ_WEST;
-            }
-            else if ( bhpos == BH_NE ) {
-                if ( (xdest < (m_local_x - 1)) || (ydest >= m_local_y) ) {
+
+            else if ( is_ne ) {
+                if ( (dx < (lx - 1)) || (dy >= ly) )
                     return REQ_WEST;
-                }
-                else {
+                else
                     return REQ_SOUTH;
-                }
-            }
-            else if ( bhpos == BH_SE ) {
-                if ( (m_local_x == 1) && (ydest > (m_local_y + 1)) ) {
+            }
+            else if ( is_se ) {
+                if ( (lx == 1) && (dy > (ly + 1)) )
                     return REQ_NORTH;
-                }
-                else {
+                else
                     return REQ_WEST;
-                }
-            }
-            else if ( bhpos == BH_E ) {
-                if ( (m_local_y == 0) ||
-                    ((m_local_x == 1) && (ydest > m_local_y)) ) {
+            }
+            else if ( is_e ) {
+                if ( (ly == 0) || ((lx == 1) && (dy > ly)) )
                     return REQ_NORTH;
-                }
-                else {
+                else
                     return REQ_SOUTH;
-                }
             }
             std::cout << "error: unexpected condition in function "
@@ -286,27 +278,15 @@
                       << std::endl;
             exit(1);
-        }                    // end if (xdest < m_local_x)
-        else if ( ydest > m_local_y ) {
-            if ( bhpos != BH_S ) {
-                return REQ_NORTH;
-            }
-            else if ( m_local_x != 0 ) {
-                return REQ_WEST;
-            }
-            else {
-                return REQ_EAST;
-            }
-        }                    // end if (ydest > m_local_y)
-        else if ( ydest < m_local_y ) {
-            if ( bhpos != BH_N ) {
-                return REQ_SOUTH;
-            }
-            else if ( m_local_x != 0) {
-                return REQ_WEST;
-            }
-            else {
-                return REQ_EAST;
-            }
-        }                    // end if (ydest < m_local_y)
+        }                    // end if (dx < lx)
+        else if ( dy > ly ) {
+            if      ( ! is_s  ) return REQ_NORTH;
+            else if ( lx != 0 ) return REQ_WEST;
+            else                return REQ_EAST;
+        }
+        else if ( dy < ly ) {
+            if      ( ! is_n )  return REQ_SOUTH;
+            else if ( lx != 0)  return REQ_WEST;
+            else                return REQ_EAST;
+        }
         return REQ_LOCAL;
     }
@@ -315,33 +295,18 @@
     tmpl(int)::route( sc_uint<flit_width> data )
     {
-        size_t xdest = (size_t)(data >> m_x_shift) & m_x_mask;
-        size_t ydest = (size_t)(data >> m_y_shift) & m_y_mask;
-        if ( blackhole_position() != BH_NONE )
-        {
-            // reroute the request if its destination is the blackhole (this
-            // is to implement the segment recovery mechanism)
-            if ( is_destination_blackhole(xdest, ydest, blackhole_position()) )
+        const size_t dx = (size_t)(data >> m_x_shift) & m_x_mask;
+        const size_t dy = (size_t)(data >> m_y_shift) & m_y_mask;
+
+        if ( is_reconfigurable() ) {
+            // reroute requests whose destination is the blackhole (this is to
+            // implement the segment reallocation mechanism)
+            if ( is_reallocation_enabled() and is_destination_blackhole(dx, dy))
             {
-                int dir = migration_route();
-
-#if SOCLIB_MODULE_DEBUG
-                std::cout << "<" << name() << "> migration: "
-                          << "route request to DIR = " << dir << std::endl;
-#endif
-                return dir;
-            }
-
-            if (is_network_recovery_enable())
-            {
-                int dir = recovery_route(xdest, ydest);
-
-#if SOCLIB_MODULE_DEBUG
-                std::cout << "<" << name() << "> network recovery: "
-                          << "route request to DIR = " << dir << std::endl;
-#endif
-                return dir;
-            }
-        }
-        return xfirst_route(xdest, ydest);
+                return reallocation_route();
+            }
+        }
+
+        // use the recovery routing
+        return recovery_route(dx, dy);
     }
 
@@ -349,15 +314,30 @@
     tmpl(int)::broadcast_route(int step, int source, sc_uint<flit_width> data)
     {
-        const size_t lx   = m_local_x;
-        const size_t ly   = m_local_y;
+        const size_t lx = m_local_x;
+        const size_t ly = m_local_y;
         const size_t xmin = (data >> (flit_width - 5 )) & 0x1F;
         const size_t xmax = (data >> (flit_width - 10)) & 0x1F;
         const size_t ymin = (data >> (flit_width - 15)) & 0x1F;
         const size_t ymax = (data >> (flit_width - 20)) & 0x1F;
-        const int    bh   = blackhole_position();
-
-        int  sel = REQ_NOP;
-        bool special = ((data & 0x2) != 0);
-
+
+        int bhpos = NORMAL;
+        bool recovery = false;
+        if (is_reconfigurable()) {
+            bhpos    = blackhole_position();
+            recovery = is_recovery_routing_enabled();
+        }
+
+        const bool is_n  = recovery and (bhpos == N_OF_X);
+        const bool is_s  = recovery and (bhpos == S_OF_X);
+        const bool is_w  = recovery and (bhpos == W_OF_X);
+        const bool is_e  = recovery and (bhpos == E_OF_X);
+        const bool is_nw = recovery and (bhpos == NW_OF_X);
+        const bool is_ne = recovery and (bhpos == NE_OF_X);
+        const bool is_sw = recovery and (bhpos == SW_OF_X);
+        const bool is_se = recovery and (bhpos == SE_OF_X);
+
+        const bool special = ((data & 0x2) != 0) and recovery;
+
+        int sel = REQ_NOP;
         switch(source) {
         case REQ_LOCAL :
@@ -365,16 +345,14 @@
             else if ( step == 2 ) sel = REQ_SOUTH;
             else if ( step == 3 ) {
-                if ( (bh == BH_N) && (lx != 0) && (ly != 1) ) {
+                if ( is_n && (lx != 0) && (ly != 1) )
                     sel = REQ_NOP;
-                    break;
-                }
-                sel = REQ_EAST;
+                else
+                    sel = REQ_EAST;
             }
             else if ( step == 4 ) {
-                if ( (bh == BH_NE) && (lx != 1) && (ly != 1) ) {
+                if ( is_ne && (lx != 1) && (ly != 1) )
                     sel = REQ_NOP;
-                    break;
-                }
-                sel = REQ_WEST;
+                else
+                    sel = REQ_WEST;
             }
         break;
@@ -383,16 +361,14 @@
             else if ( step == 2 ) sel = REQ_LOCAL;
             else if ( step == 3 ) {
-                if ( bh == BH_SW ) {
+                if ( is_sw )
                     sel = REQ_EAST;
-                    break;
-                }
-                sel = REQ_NOP;
+                else
+                    sel = REQ_NOP;
             }
             else if ( step == 4 ) {
-                if ( (bh == BH_SE) && (!special || (lx == 1))) {
+                if ( is_se && (!special || (lx == 1)))
                     sel = REQ_WEST;
-                    break;
-                }
-                sel = REQ_NOP;
+                else
+                    sel = REQ_NOP;
             }
         break;
@@ -401,13 +377,10 @@
             else if ( step == 2 ) sel = REQ_LOCAL;
             else if ( step == 3 ) {
-                if ( bh == BH_NW ) {
+                if ( is_nw )
                     sel = REQ_EAST;
-                    break;
-                }
-                if ( (bh == BH_NE) && ((lx == 1) || (ly == 1)) ) {
+                else if ( is_ne && ((lx == 1) || (ly == 1)) )
                     sel = REQ_WEST;
-                    break;
-                }
-                sel = REQ_NOP;
+                else
+                    sel = REQ_NOP;
             }
             else if ( step == 4 ) sel = REQ_NOP;
@@ -415,9 +388,8 @@
         case REQ_EAST :
             if ( step == 1 ) {
-                if ( (bh == BH_NE) && (lx != 1) && (ly != 1) ) {
+                if ( is_ne && (lx != 1) && (ly != 1) )
                     sel = REQ_NOP;
-                    break;
-                }
-                sel = REQ_WEST;
+                else
+                    sel = REQ_WEST;
             }
             else if ( step == 2 ) sel = REQ_NORTH;
@@ -427,13 +399,10 @@
         case REQ_WEST :
             if ( step == 1 ) {
-                if ( (bh == BH_N) && (ly != 1) ) {
+                if ( is_n && (ly != 1) )
                     sel = REQ_NOP;
-                    break;
-                }
-                if ( (bh == BH_S) && special ) {
+                else if ( is_s && special )
                     sel = REQ_NOP;
-                    break;
-                }
-                sel = REQ_EAST;
+                else
+                    sel = REQ_EAST;
             }
             else if ( step == 2 ) sel = REQ_NORTH;
@@ -443,19 +412,9 @@
         }
 
-        if      ( (sel == REQ_NORTH) && !(ly < ymax) ) sel = REQ_NOP;
-        else if ( (sel == REQ_SOUTH) && !(ly > ymin) ) sel = REQ_NOP;
-        else if ( (sel == REQ_EAST ) && !(lx < xmax) ) sel = REQ_NOP;
-        else if ( (sel == REQ_WEST ) && !(lx > xmin) ) sel = REQ_NOP;
-
-#if 0
-        /* This code can be used if we want to inhibit requests to the
-         * blackhole. However, it is not strictly necessary because the
-         * blackhole will consume the request and will do nothing with it */
-
-        if      ( (sel == REQ_NORTH) && (bh == BH_S) ) sel = REQ_NOP;
-        else if ( (sel == REQ_SOUTH) && (bh == BH_N) ) sel = REQ_NOP;
-        else if ( (sel == REQ_EAST ) && (bh == BH_W) ) sel = REQ_NOP;
-        else if ( (sel == REQ_WEST ) && (bh == BH_E) ) sel = REQ_NOP;
-#endif
+        // inhibit requests to the blackhole or beyond the mesh boundaries.
+        if      ( (sel == REQ_NORTH) && (!(ly < ymax) || is_s)) sel = REQ_NOP;
+        else if ( (sel == REQ_SOUTH) && (!(ly > ymin) || is_n)) sel = REQ_NOP;
+        else if ( (sel == REQ_EAST ) && (!(lx < xmax) || is_w)) sel = REQ_NOP;
+        else if ( (sel == REQ_WEST ) && (!(lx > xmin) || is_e)) sel = REQ_NOP;
 
         return sel;
@@ -469,14 +428,20 @@
 
     /////////////////////////////////////////////////////////
-    tmpl(sc_uint<flit_width>)::compute_broadcast_header(int source)
-    {
-        const int bh = blackhole_position();
-        sc_uint<flit_width> header = r_fifo_in[source].read().data;
-        sc_uint<flit_width> special = 0x2;
+    tmpl(typename DspinRouter<flit_width>::internal_flit_t)::
+    compute_broadcast_header(int source)
+    {
+        const int bhpos = blackhole_position();
+
+        const int is_nw = (bhpos == NW_OF_X);
+        const int is_ne = (bhpos == NE_OF_X);
+
+        internal_flit_t header;
+        header.eop = false;
+        header.data = r_fifo_in[source].read().data;
+
+        const int SPECIAL = 0x2;
         switch (source) {
             case REQ_NORTH:
-                if ( (bh == BH_NW) || (bh == BH_NE) ) {
-                    header |= special;
-                }
+                if ( is_nw || is_ne ) header.data |= SPECIAL;
                 break;
 
@@ -484,7 +449,7 @@
              * network with the special bit set. This can arrive if an initiator
              * or a local interconnect uses the broadcast header reserved bits
-             * internally and don't reset them */
+             * internally */
             case REQ_LOCAL:
-                header &= ~special;
+                header.data &= ~SPECIAL;
                 break;
         }
@@ -521,17 +486,25 @@
         const char* bh_str[] =
         {
-            "BH_NONE",
-            "BH_N",
-            "BH_NE",
-            "BH_E",
-            "BH_SE",
-            "BH_S",
-            "BH_SW",
-            "BH_W",
-            "BH_NW"
+            "N_OF_X",
+            "NE_OF_X",
+            "E_OF_X",
+            "SE_OF_X",
+            "S_OF_X",
+            "SW_OF_X",
+            "W_OF_X",
+            "NW_OF_X"
         };
 
         std::cout << "DSPIN_ROUTER " << name();
-        std::cout << " / bh = " << bh_str[blackhole_position()];
+
+        if ( is_reconfigurable() ) {
+            std::cout << " / bh = " << bh_str[blackhole_position()];
+            if (is_recovery_routing_enabled())
+                std::cout << " / recovery_routing ";
+            if (is_reallocation_enabled())
+                std::cout << " / reallocation dir = "
+                          << port_name[reallocation_route()];
+        }
+
 
         for( size_t i = 0 ; i < 5 ; i++)  // loop on input ports
@@ -640,11 +613,10 @@
                             {
                                 std::cout << "ERROR in DSPIN_ROUTER " << name()
-                                          << " : broadcast packet must be 2 flits" << std::endl;
+                                          << " : broadcast packet must be 2 flits"
+                                          << std::endl;
                                 exit(1);
                             }
 
-                            internal_flit_t header;
-                            header.eop  = false;
-                            header.data = compute_broadcast_header(i);
+                            const internal_flit_t& header = compute_broadcast_header(i);
 
                             fifo_in_read[i] = true;
@@ -652,6 +624,6 @@
                             r_buf_in[i]     = header;
                             r_index_in[i]   = req_in[i];
-                            if( req_in[i] == REQ_NOP ) r_fsm_in[i] = INFSM_REQ_SECOND;
-                            else                       r_fsm_in[i] = INFSM_REQ_FIRST;
+                            if ( req_in[i] == REQ_NOP ) r_fsm_in[i] = INFSM_REQ_SECOND;
+                            else                        r_fsm_in[i] = INFSM_REQ_FIRST;
                         }
                         else                                  // unicast
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/dspin_broadcast_generator/caba/source/src/dspin_broadcast_generator.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/dspin_broadcast_generator/caba/source/src/dspin_broadcast_generator.cpp	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/dspin_broadcast_generator/caba/source/src/dspin_broadcast_generator.cpp	(revision 1016)
@@ -1,24 +1,24 @@
 /* -*- c++ -*-
  * SOCLIB_LGPL_HEADER_BEGIN
- * 
+ *
  * This file is part of SoCLib, GNU LGPLv2.1.
- * 
+ *
  * SoCLib is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; version 2.1 of the License.
- * 
+ *
  * SoCLib is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with SoCLib; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
- * 
+ *
  * SOCLIB_LGPL_HEADER_END
  *
- * Authors  : alain.greiner@lip6.fr 
+ * Authors  : alain.greiner@lip6.fr
  * Date     : july 2010
  * Copyright: UPMC - LIP6
@@ -44,9 +44,9 @@
                                      const size_t   x_size,
                                      const size_t   y_size,
-                                     const size_t   srcid,      // srcid for random 
+                                     const size_t   srcid,      // srcid for random
                                      const size_t   load,       // requested load * 1000
                                      const size_t   fifo_depth) // Fifo depth
            : BaseModule(name),
-           
+
            p_clk( "clk" ),
            p_resetn( "resetn" ),
@@ -58,5 +58,5 @@
 
            r_send_fsm( "r_send_fsm" ),
-           r_send_length( "r_send_length" ), 
+           r_send_length( "r_send_length" ),
            r_send_dest( "r_send_dest" ),
            r_send_date( "r_send_date" ),
@@ -69,5 +69,5 @@
 
            r_max_fill_status( "r_max_fill_status" ),
-           
+
            r_date_fifo( "r_date_fifo", fifo_depth ),
 
@@ -127,5 +127,5 @@
 
     /////////////////////////// CMD FSM
-    switch( r_send_fsm.read() ) 
+    switch( r_send_fsm.read() )
     {
         case SEND_IDLE:
@@ -141,5 +141,5 @@
         break;
         case SEND_BROADCAST:
-            if( p_out.read.read() ) 
+            if( p_out.read.read() )
             {
                 r_send_length = r_send_length.read() - 1;
@@ -164,5 +164,5 @@
             if (latency > r_receive_bc_max_latency.read())
                 r_receive_bc_max_latency = latency;
-            
+
             r_receive_fsm = RECEIVE_IDLE;
         }
@@ -178,5 +178,5 @@
     if (r_date_fifo.filled_status() > r_max_fill_status.read())
         r_max_fill_status.write(r_date_fifo.filled_status());
-    
+
 } // end transition
 
@@ -210,5 +210,5 @@
     p_out.eop   = eop;
     p_out.write = write;
-    
+
     p_in.read = true;
 
@@ -221,7 +221,7 @@
     const char* rsp_str[] = { "IDLE", "RECEIVE_BROADCAST" };
 
-    std::cout << "DSPIN_GENERATOR " << name() 
-              << " : send_fsm = " << cmd_str[r_send_fsm.read()] 
-              << " / recv_fsm = " << rsp_str[r_receive_fsm.read()] 
+    std::cout << "DSPIN_GENERATOR " << name()
+              << " : send_fsm = " << cmd_str[r_send_fsm.read()]
+              << " / recv_fsm = " << rsp_str[r_receive_fsm.read()]
               << " / fifo_content = " << r_date_fifo.filled_status() << std::endl;
 } // end print_trace
@@ -253,2 +253,4 @@
 // indent-tabs-mode: nil
 // End:
+
+// vim: ts=4 : sts=4 : sw=4 : et
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/soclib.conf
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/soclib.conf	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/soclib.conf	(revision 1016)
@@ -1,7 +1,7 @@
 # append compilation flags
 cflags = config.default.toolchain.cflags
-#cflags.extend(['-ggdb'])
+# cflags.extend(['-ggdb'])
+# cflags.extend(['-DUNICAST'])
 config.default.toolchain.set("cflags", cflags)
-
 
 # append modules' description file paths
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/metadata/synthetic_dspin_network.sd
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/metadata/synthetic_dspin_network.sd	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/metadata/synthetic_dspin_network.sd	(revision 1016)
@@ -18,4 +18,7 @@
            Uses('caba:dspin_broadcast_generator',
                 cmd_width=DSPIN_FLIT_WIDTH,
+                rsp_width=DSPIN_FLIT_WIDTH),
+           Uses('caba:dspin_packet_generator',
+                cmd_width=DSPIN_FLIT_WIDTH,
                 rsp_width=DSPIN_FLIT_WIDTH)
        ],
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/include/synthetic_dspin_network.h
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/include/synthetic_dspin_network.h	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/include/synthetic_dspin_network.h	(revision 1016)
@@ -2,24 +2,24 @@
  *
  * SOCLIB_LGPL_HEADER_BEGIN
- * 
+ *
  * This file is part of SoCLib, GNU LGPLv2.1.
- * 
+ *
  * SoCLib is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; version 2.1 of the License.
- * 
+ *
  * SoCLib is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with SoCLib; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
- * 
+ *
  * SOCLIB_LGPL_HEADER_END
  *
- * Authors  : Cesar Armando Fuguet Tortolero 
+ * Authors  : Cesar Armando Fuguet Tortolero
  * Date     : jul 2015
  * Copyright: UPMC - LIP6
@@ -32,5 +32,10 @@
 #include "caba_base_module.h"
 #include "dspin_router.h"
+
+#if UNICAST
+#include "dspin_packet_generator.h"
+#else
 #include "dspin_broadcast_generator.h"
+#endif
 
 namespace soclib {
@@ -47,6 +52,12 @@
     static const int DSPIN_GENERATOR_FIFO_DEPTH = 50;
 
+#if UNICAST
+    typedef DspinPacketGenerator<DSPIN_WIDTH, DSPIN_WIDTH>
+    DspinNetworkGenerator;
+#else
     typedef DspinBroadcastGenerator<DSPIN_WIDTH, DSPIN_WIDTH>
     DspinNetworkGenerator;
+#endif
+
     typedef DspinRouter<DSPIN_WIDTH>
     DspinNetworkRouter;
@@ -54,5 +65,5 @@
     DspinNetworkSignal;
 
-      
+
 public:
 
@@ -71,10 +82,10 @@
     void print_stats(const size_t x, const size_t y);
 
-      
+
 private:
 
     const size_t m_x_size;
     const size_t m_y_size;
-      
+
     DspinNetworkGenerator **dspinGenerator;
     DspinNetworkRouter **dspinRouter;
@@ -83,5 +94,5 @@
     DspinNetworkSignal ***sH;
     DspinNetworkSignal ***sV;
-      
+
     sc_core::sc_signal<uint32_t>** sConfigRouter;
 };                  // end class SyntheticDspinNetwork
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/src/synthetic_dspin_network.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/src/synthetic_dspin_network.cpp	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/synthetic_dspin_network/caba/source/src/synthetic_dspin_network.cpp	(revision 1016)
@@ -2,24 +2,24 @@
  *
  * SOCLIB_LGPL_HEADER_BEGIN
- * 
+ *
  * This file is part of SoCLib, GNU LGPLv2.1.
- * 
+ *
  * SoCLib is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation; version 2.1 of the License.
- * 
+ *
  * SoCLib is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with SoCLib; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
- * 
+ *
  * SOCLIB_LGPL_HEADER_END
  *
- * Authors  : Cesar Armando Fuguet Tortolero 
+ * Authors  : Cesar Armando Fuguet Tortolero
  * Date     : jul 2015
  * Copyright: UPMC - LIP6
@@ -34,5 +34,5 @@
 namespace caba {
 using namespace soclib::common;
-    
+
 
 SyntheticDspinNetwork::SyntheticDspinNetwork(sc_module_name name,
@@ -58,4 +58,14 @@
             const int SRCID = (x << Y_WIDTH) | y;
             generator_name << "generator[" << x << "][" << y << "]";
+#if UNICAST
+            const size_t PACKET_LENGTH = 8;
+            new(&dspinGenerator[x][y])
+                DspinNetworkGenerator(generator_name.str().c_str(),
+                                      (size_t)SRCID,
+                                      PACKET_LENGTH,
+                                      load,
+                                      (size_t)DSPIN_GENERATOR_FIFO_DEPTH,
+                                      0 );
+#else
             new(&dspinGenerator[x][y])
                 DspinNetworkGenerator(generator_name.str().c_str(),
@@ -65,8 +75,9 @@
                                       load,
                                       DSPIN_GENERATOR_FIFO_DEPTH);
-	  
-        }
-    }
-      
+#endif
+
+        }
+    }
+
     // DSPIN router instantiation
     dspinRouter = (DspinNetworkRouter**)
@@ -74,5 +85,5 @@
 
     for (size_t x = 0; x < m_x_size; ++x) {
-      	dspinRouter[x] = (DspinNetworkRouter*)
+        dspinRouter[x] = (DspinNetworkRouter*)
             malloc(sizeof(DspinNetworkRouter) * m_y_size);
 
@@ -102,5 +113,5 @@
                                                    m_x_size, m_y_size);
 
-      
+
     // netlist
     for (size_t x = 0; x < m_x_size; ++x) {
@@ -133,5 +144,9 @@
     for (size_t x = 0; x < m_x_size; ++x) {
         for (size_t y = 0; y < m_y_size; ++y) {
+#if UNICAST
+            dspinGenerator[x][y].~DspinPacketGenerator();
+#else
             dspinGenerator[x][y].~DspinBroadcastGenerator();
+#endif
             dspinRouter[x][y].~DspinRouter();
         }
@@ -151,9 +166,11 @@
 
 
-static inline uint32_t configRouter(int bypass_mode,
-                                    int reallocation_dir,
+static inline uint32_t configRouter(int reallocation_dir,
+                                    int recovery_mode,
                                     int blackhole_pos)
 {
-    return (bypass_mode << 7) | (reallocation_dir << 4) | blackhole_pos;
+    return ((reallocation_dir & 0x7) << 5) |
+           ((recovery_mode & 0x1)    << 4) |
+           (blackhole_pos & 0xF);
 }
 
@@ -164,9 +181,9 @@
     for (size_t x = 0; x < m_x_size; ++x) {
         for (size_t y = 0; y < m_y_size; ++y) {
-            const uint32_t CONFIG_NONE = configRouter(0, REQ_NOP, BH_NONE);
+            const uint32_t CONFIG_NONE = configRouter(0, 0, NORMAL);
             sConfigRouter[x][y].write(CONFIG_NONE);
         }
     }
-      
+
 
     // initialize mesh's boundary signals
@@ -184,5 +201,5 @@
     }
 }                   // end reset()
-    
+
 
 void SyntheticDspinNetwork::set_faulty_router(const size_t faulty_x,
@@ -199,13 +216,13 @@
     // reconfigure the faulty router's contour
     if (faulty_y < (m_y_size - 1)) {
-        const uint32_t CONFIG_N = configRouter(1, REQ_SOUTH, BH_N);
+        const uint32_t CONFIG_N = configRouter(REQ_SOUTH, 1, N_OF_X);
         sConfigRouter[faulty_x][faulty_y + 1].write(CONFIG_N);
 
         if (faulty_x > 0) {
-            const uint32_t CONFIG_NW = configRouter(1, REQ_EAST, BH_NW);
+            const uint32_t CONFIG_NW = configRouter(REQ_EAST, 1, NW_OF_X);
             sConfigRouter[faulty_x - 1][faulty_y + 1].write(CONFIG_NW);
         }
         if (faulty_x < (m_x_size - 1)) {
-            const uint32_t CONFIG_NE = configRouter(1, REQ_WEST, BH_NE);
+            const uint32_t CONFIG_NE = configRouter(REQ_WEST, 1, NE_OF_X);
             sConfigRouter[faulty_x + 1][faulty_y + 1].write(CONFIG_NE);
         }
@@ -213,13 +230,13 @@
 
     if (faulty_y > 0) {
-        const uint32_t CONFIG_S = configRouter(1, REQ_NORTH, BH_S);
+        const uint32_t CONFIG_S = configRouter(REQ_NORTH, 1, S_OF_X);
         sConfigRouter[faulty_x][faulty_y - 1].write(CONFIG_S);
 
         if (faulty_x > 0) {
-            const uint32_t CONFIG_SW = configRouter(1, REQ_EAST, BH_SW);
+            const uint32_t CONFIG_SW = configRouter(REQ_EAST, 1, SW_OF_X);
             sConfigRouter[faulty_x - 1][faulty_y - 1].write(CONFIG_SW);
         }
         if (faulty_x < (m_x_size - 1)) {
-            const uint32_t CONFIG_SE = configRouter(1, REQ_WEST, BH_SE);
+            const uint32_t CONFIG_SE = configRouter(REQ_WEST, 1, SE_OF_X);
             sConfigRouter[faulty_x + 1][faulty_y - 1].write(CONFIG_SE);
         }
@@ -227,10 +244,10 @@
 
     if (faulty_x > 0) {
-        const uint32_t CONFIG_W = configRouter(1, REQ_EAST, BH_W);
+        const uint32_t CONFIG_W = configRouter(REQ_EAST, 1, W_OF_X);
         sConfigRouter[faulty_x - 1][faulty_y].write(CONFIG_W);
     }
 
     if (faulty_x < (m_x_size - 1)) {
-        const uint32_t CONFIG_E = configRouter(1, REQ_WEST, BH_E);
+        const uint32_t CONFIG_E = configRouter(REQ_WEST, 1, E_OF_X);
         sConfigRouter[faulty_x + 1][faulty_y].write(CONFIG_E);
     }
@@ -245,5 +262,5 @@
     dspinGenerator[x][y].print_stats();
 }
-    
+
 
 }                   // end namespace caba
@@ -256,2 +273,4 @@
 // indent-tabs-mode: nil
 // End:
+
+// vim: ts=4 : sts=4 : sw=4 : et
Index: /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/top.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/top.cpp	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/top.cpp	(revision 1016)
@@ -73,13 +73,15 @@
             continue;
         }
-    
+
         std::cout << "   Arguments are (key, value) couples." << std::endl;
         std::cout << "   The order is not important." << std::endl;
         std::cout << "   Accepted arguments are :" << std::endl << std::endl;
-        std::cout << "     -L dspin generators' accepted load * 1000" << std::endl;
+        std::cout << "     -L generators' accepted load * 1000" << std::endl;
         std::cout << "     -X number of clusters per row" << std::endl;
         std::cout << "     -Y number of clusters per column" << std::endl;
         std::cout << "     -N simulation's cycles" << std::endl;
         std::cout << "     -F deactivate a router" << std::endl;
+
+        exit(1);
     }
 }                        // end parse_args()
@@ -137,5 +139,6 @@
         // deactivate a router in the center of the mesh and create its
         // recovery cycle-free contour
-        syntheticDspinNetwork.set_faulty_router(args.x_size / 2, args.y_size / 2);
+        syntheticDspinNetwork.set_faulty_router(args.x_size / 2,
+                                                args.y_size / 2);
     }
 
@@ -154,5 +157,5 @@
     }
 
-  
+
     return 0;
 }                   // end sc_main()
@@ -164,2 +167,4 @@
 // indent-tabs-mode: nil
 // End:
+
+// vim: ts=4 : sts=4 : sw=4 : et
Index: /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/Makefile
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/Makefile	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/Makefile	(revision 1016)
@@ -70,5 +70,5 @@
 
 mkconfig $(SIMULATOR) $(CONF): $(PLATFORM)/scripts/onerun.py
-	./$< -o $(CONFDIR) -p $(PLATFORM) -x3 -y3 -n1 -c
+	./$< -o $(CONFDIR) -p $(PLATFORM) -x3 -y3 -n1 -f -c
 
 $(BUILD_DIR):
Index: /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/main.c
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/main.c	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/main.c	(revision 1016)
@@ -25,55 +25,47 @@
     /* configure the routers around the blackhole (1, 1) to define a cycle-free
      * contour */
-    const int PATH_RECOVERY = 1;
+    const int RECOVERY = 1;
     uint32_t val;
 
     printf("router(0, 2): configuring as NW\n");
-    assert(xcu_get_register(0, 2, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_SOUTH << 4) | BH_NW;
+    val = (REQ_SOUTH << 5) | (RECOVERY << 4) | NW_OF_X;
     xcu_set_register(0, 2, XICU_CFG_REG, 0, val);     /* configure NW */
 
     printf("router(0, 1): configuring as W\n");
-    assert(xcu_get_register(0, 1, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_LOCAL << 4) | BH_W;
+    val = (REQ_LOCAL << 5) | (RECOVERY << 4) | W_OF_X;
     xcu_set_register(0, 1, XICU_CFG_REG, 0, val);     /* configure W */
 
     printf("router(0, 0): configuring as SW\n");
-    assert(xcu_get_register(0, 0, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_NORTH << 4) | BH_SW;
+    val = (REQ_NORTH << 5) | (RECOVERY << 4) | SW_OF_X;
     xcu_set_register(0, 0, XICU_CFG_REG, 0, val);     /* configure SW */
 
     printf("router(1, 2): configuring as N\n");
-    assert(xcu_get_register(1, 2, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_WEST << 4) | BH_N;
+    val = (REQ_WEST << 5) | (RECOVERY << 4) | N_OF_X;
     xcu_set_register(1, 2, XICU_CFG_REG, 0, val);     /* configure N */
 
     printf("router(2, 2): configuring as NE\n");
-    assert(xcu_get_register(2, 2, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_WEST << 4) | BH_NE;
+    val = (REQ_WEST << 5) | (RECOVERY << 4) | NE_OF_X;
     xcu_set_register(2, 2, XICU_CFG_REG, 0, val);     /* configure NE */
 
     printf("router(2, 1): configuring as E\n");
-    assert(xcu_get_register(2, 1, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_SOUTH << 4) | BH_E;
+    val = (REQ_SOUTH << 5) | (RECOVERY << 4) | E_OF_X;
     xcu_set_register(2, 1, XICU_CFG_REG, 0, val);     /* configure E */
 
     printf("router(2, 0): configuring as SE\n");
-    assert(xcu_get_register(2, 0, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_WEST << 4) | BH_SE;
+    val = (REQ_WEST << 5) | (RECOVERY << 4) | SE_OF_X;
     xcu_set_register(2, 0, XICU_CFG_REG, 0, val);     /* configure SE */
 
     printf("router(1, 0): configuring as S\n");
-    assert(xcu_get_register(1, 0, XICU_CFG_REG, 0) == BH_NONE);
-    val = (PATH_RECOVERY << 7) | (REQ_WEST << 4) | BH_S;
+    val = (REQ_WEST << 5) | (RECOVERY << 4) | S_OF_X;
     xcu_set_register(1, 0, XICU_CFG_REG, 0, val);     /* configure S */
 
-    assert((xcu_get_register(0, 2, XICU_CFG_REG, 0) & 0xF) == BH_NW);
-    assert((xcu_get_register(0, 1, XICU_CFG_REG, 0) & 0xF) == BH_W);
-    assert((xcu_get_register(0, 0, XICU_CFG_REG, 0) & 0xF) == BH_SW);
-    assert((xcu_get_register(1, 2, XICU_CFG_REG, 0) & 0xF) == BH_N);
-    assert((xcu_get_register(2, 2, XICU_CFG_REG, 0) & 0xF) == BH_NE);
-    assert((xcu_get_register(2, 1, XICU_CFG_REG, 0) & 0xF) == BH_E);
-    assert((xcu_get_register(2, 0, XICU_CFG_REG, 0) & 0xF) == BH_SE);
-    assert((xcu_get_register(1, 0, XICU_CFG_REG, 0) & 0xF) == BH_S);
+    assert((xcu_get_register(0, 2, XICU_CFG_REG, 0) & 0xF) == NW_OF_X);
+    assert((xcu_get_register(0, 1, XICU_CFG_REG, 0) & 0xF) == W_OF_X);
+    assert((xcu_get_register(0, 0, XICU_CFG_REG, 0) & 0xF) == SW_OF_X);
+    assert((xcu_get_register(1, 2, XICU_CFG_REG, 0) & 0xF) == N_OF_X);
+    assert((xcu_get_register(2, 2, XICU_CFG_REG, 0) & 0xF) == NE_OF_X);
+    assert((xcu_get_register(2, 1, XICU_CFG_REG, 0) & 0xF) == E_OF_X);
+    assert((xcu_get_register(2, 0, XICU_CFG_REG, 0) & 0xF) == SE_OF_X);
+    assert((xcu_get_register(1, 0, XICU_CFG_REG, 0) & 0xF) == S_OF_X);
 
     /* Test the recovered segment that has been migrated to the EAST cluster */
Index: /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/reset.S
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/reset.S	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/reset.S	(revision 1016)
@@ -21,4 +21,12 @@
 #define Y_MASK ((1<<Y_WIDTH)-1)
 
+#define XCU_REG(func, idx) ((((func)<<5)|(idx)) << 2)
+#define XCU_CFG_REG 17
+#define XCU_BARRIER 5
+
+#define MEMC_REG(func,idx) (((func<<7)|idx) << 2)
+#define MEMC_CONFIG 0
+#define MEMC_SCRATCHPAD 4
+
 reset:
     .set noreorder
@@ -33,12 +41,27 @@
 
     /*
-     * All processors compute:
-     *   cid = (x * Y_SIZE) + y
-     *   pid = (cid * NB_PROCS_MAX) + lpid
+     * Get processor ID
      */
     mfc0   k0,  CP0_PROCID
-    andi   k0,  k0,  0xFFF             /* k0 <= proc_xyl                 */
+    andi   k0,  k0,  0xFFF             /* k0 <= proc_xyl                     */
 
-    /* Only the processor 0 continues the execution                      */
+    /*
+     * Release local gateway hardware barrier
+     */
+    la     k1,     SEG_XCU_BASE        /* k1 <= ICU base address             */
+    li     t0,     XCU_REG(XCU_CFG_REG, XCU_BARRIER)
+    or     k1,     k1,     t0          /* k1 <= &XICU[CFG_REG][BARRIER]      */
+    li     t0,     0xFFFFFFFF
+    sw     t0,     0(k1)
+
+    /*
+     * Disable the scratchpad mode on the local memory cache
+     */
+    la     k1,     SEG_MMC_BASE        /* k1 <= MMC base address             */
+    li     t0,     MEMC_REG(MEMC_CONFIG, MEMC_SCRATCHPAD)
+    or     k1,     k1,     t0          /* k1 <= &MEMC[CONFIG][SCRATCHPAD]    */
+    sw     zero,   0(k1)
+
+    /* Only the processor 0 continues the execution                          */
     beqz   k0,  1f
     nop
@@ -47,5 +70,5 @@
 1:  /* processor 0 initializes stack pointer (16K) */
     la     sp,  _stack
-    addiu  sp,  sp,  (1<<14)           /* sp <= _stack + 16K             */
+    addiu  sp,  sp,  (1<<14)           /* sp <= _stack + 16K                 */
 
     /* jumps to main in kernel mode */
Index: /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/test.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/test.sh	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/simple_segment_recovery_test/test.sh	(revision 1016)
@@ -13,10 +13,17 @@
 PLATFORM=../../../../../platforms/tsar_generic_iob
 SIMULATOR=$PLATFORM/simul.x
-$SIMULATOR -DSOFT $SOFT -DISK /dev/null -FAULTY_ROUTER 0 1 1 > output/log 2>&1
+$SIMULATOR -DSOFT $SOFT \
+           -DISK /dev/null \
+           -FAULTY_ROUTER 0 1 1 \
+           -NCYCLES 20000 > output/log 2>&1
+#          -PROCID 0 \
+#          -MEMCID 0x1 \
+#          -DEBUG 3000 \
+
 soclib-cleanup-terms &> /dev/null
 mv term0 output/term
 grep -q "success" output/term
 if [ $? == 0 ];
-	then echo $(basename $PWD) ": Success";
-	else echo $(basename $PWD) ": Failure";
+    then echo $(basename $PWD) ": Success";
+    else echo $(basename $PWD) ": Failure";
 fi;
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.cpp	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.cpp	(revision 1016)
@@ -44,9 +44,11 @@
 }
 
-static inline uint32_t configRouter(int bypass_mode,
-                                    int reallocation_dir,
+static inline uint32_t configRouter(int reallocation_dir,
+                                    int recovery_mode,
                                     int blackhole_pos)
 {
-    return (bypass_mode << 7) | (reallocation_dir << 4) | blackhole_pos;
+    return ((reallocation_dir & 0x7) << 5) |
+           ((recovery_mode    & 0x1) << 4) |
+           (blackhole_pos     & 0xF);
 }
 
@@ -295,13 +297,15 @@
 
     /* initialize the configuration signals */
-    sConfigNONE.write(configRouter(0, REQ_NOP, BH_NONE));
-    sConfigN.write(configRouter(1, REQ_SOUTH, BH_N));
-    sConfigNE.write(configRouter(1, REQ_WEST, BH_NE));
-    sConfigE.write(configRouter(1, REQ_WEST, BH_E));
-    sConfigSE.write(configRouter(1, REQ_WEST, BH_SE));
-    sConfigS.write(configRouter(1, REQ_NORTH, BH_S));
-    sConfigSW.write(configRouter(1, REQ_EAST, BH_SW));
-    sConfigW.write(configRouter(1, REQ_EAST, BH_W));
-    sConfigNW.write(configRouter(1, REQ_EAST, BH_NW));
+    sConfigNONE.write(configRouter(0, 0, NORMAL));
+
+    // requests to the deactivated segment are dropped
+    sConfigN.write(configRouter(REQ_SOUTH, 1, N_OF_X));
+    sConfigNE.write(configRouter(REQ_WEST, 1, NE_OF_X));
+    sConfigE.write(configRouter(REQ_WEST, 1, E_OF_X));
+    sConfigSE.write(configRouter(REQ_WEST, 1, SE_OF_X));
+    sConfigS.write(configRouter(REQ_NORTH, 1, S_OF_X));
+    sConfigSW.write(configRouter(REQ_EAST, 1, SW_OF_X));
+    sConfigW.write(configRouter(REQ_EAST, 1, W_OF_X));
+    sConfigNW.write(configRouter(REQ_EAST, 1, NW_OF_X));
 
     /* initialize mesh boundary signals */
Index: /branches/reconfiguration/modules/dspin_router/include/soclib/dspin_router_config.h
===================================================================
--- /branches/reconfiguration/modules/dspin_router/include/soclib/dspin_router_config.h	(revision 1015)
+++ /branches/reconfiguration/modules/dspin_router/include/soclib/dspin_router_config.h	(revision 1016)
@@ -30,10 +30,10 @@
 enum
 {
-    REQ_NORTH   = 0,
-    REQ_SOUTH   = 1,
-    REQ_EAST    = 2,
-    REQ_WEST    = 3,
-    REQ_LOCAL   = 4,
-    REQ_NOP     = 5,
+    REQ_NORTH = 0,
+    REQ_SOUTH = 1,
+    REQ_EAST = 2,
+    REQ_WEST = 3,
+    REQ_LOCAL = 4,
+    REQ_NOP = 5,
 };
 
@@ -41,13 +41,13 @@
 enum
 {
-    BH_NONE = 0,
-    BH_N = 1,
-    BH_NE = 2,
-    BH_E = 3,
-    BH_SE = 4,
-    BH_S = 5,
-    BH_SW = 6,
-    BH_W = 7,
-    BH_NW = 8
+    NORMAL = 0,
+    N_OF_X = 1,
+    NE_OF_X = 2,
+    E_OF_X = 3,
+    SE_OF_X = 4,
+    S_OF_X = 5,
+    SW_OF_X = 6,
+    W_OF_X = 7,
+    NW_OF_X = 8
 };
 
