Index: anches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/broadcast_check.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/broadcast_check.sh	(revision 997)
+++ 	(revision )
@@ -1,80 +1,0 @@
-#!/usr/bin/env sh
-# @author	Cesar Armando Fuguet Tortolero
-# @date		24 May, 2015
-# @brief	This script validates that a broadcast transaction reaches once
-#			and only once every non-faulty router in the platform.
-file=$1
-awk '
-BEGIN {
-	sent=0
-	last=0
-	failure=0
-	min=99999999
-	max=0
-}
-#   Parse coordinates of routers
-#   /DSPIN_GENERATOR/ {
-#   	regex="\\[[0-9]+\\]\\[";
-#   	if (match($2,regex)) {
-#   		x=substr($2,RSTART+1,RLENGTH-3);
-#   	}
-#   	regex="\\]\\[[0-9]+\\]";
-#   	if (match($2,regex)) {
-#   		y=substr($2,RSTART+2,RLENGTH-3);
-#   	}
-#   }
-
-#   Parse the number of sent broadcast packets
-/broadcast sent packets += +/ {
-	if ($6 != 0) {
-		sent=$6;
-	}
-}
-
-#   Parse the number of received broadcast packets
-/broadcast received packets +=/ {
-	if ($6 == 0) {
-		zero++;
-	}
-	else {
-		# store the min and max number of received packets
-		if ($6 < min) {
-			min=$6;
-		}
-		if ($6 > max) {
-			max=$6;
-		}
-	}
-}
-
-#   Validate the file
-END {
-	# it should be only two routers that do not receive the broadcast:
-	# the source and the faulty router.
-	if (zero > 2) {
-		print "error: some routers did not received broadcasts\n";
-		exit 1;
-	}
-
-	if (max > sent) {
-		print "error: at least a router received a number of broadcast greater"
-		print "than the number of broadcast sent\n";
-		exit 1;
-	}
-
-	if (zero == 1) {
-		print "error: the broadcast source received broadcasts\n";
-		exit 1;
-	}
-
-	error=sent - min
-	if (error > 20) {
-		print "error: the number of broadcast received by a router is inferior "
-		print "to the error threshold\n";
-		exit 1;
-	}
-
-	exit 0;
-}' $file
-if [[ $? == 1 ]]; then exit 1; fi
-
Index: anches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/broadcast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/broadcast_latency.sh	(revision 997)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#!/usr/bin/env sh
-# @author	Cesar Armando Fuguet Tortolero
-# @date		24 May, 2015
-# @brief	This script validates that a broadcast transaction reaches once
-#			and only once every non-faulty router in the platform.
-file=$1
-awk '
-BEGIN {
-	sent=0
-	total=0
-	targets=0
-}
-#   Parse coordinates of routers
-/DSPIN_GENERATOR/ {
-	regex="\\[[0-9]+\\]\\[";
-	if (match($2,regex)) {
-		x=substr($2,RSTART+1,RLENGTH-3);
-	}
-	regex="\\]\\[[0-9]+\\]";
-	if (match($2,regex)) {
-		y=substr($2,RSTART+2,RLENGTH-3);
-	}
-}
-
-#   Parse the number of sent broadcast packets
-/broadcast sent packets += +/ {
-	if ($6 != 0) {
-		sent=$6;
-	}
-}
-
-#   Parse the number of received broadcast packets
-/broadcast received packets +=/ {
-	packets=$6
-}
-
-#   Parse the broadcast latency
-/broadcast latency +=/ {
-	latency=$5;
-	total+=latency;
-	if (latency > 0) {
-		targets++;
-	}
-}
-
-#   Validate the file
-END {
-	print "mean latency=" total/targets
-	exit 0;
-}' $file
-if [[ $? == 1 ]]; then exit 1; fi
-
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/metadata/dspin_packet_generator.sd
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/metadata/dspin_packet_generator.sd	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/metadata/dspin_packet_generator.sd	(revision 998)
@@ -0,0 +1,18 @@
+# -*- python -*-
+
+Module('caba:reconf:dspin_router:dspin_packet_generator',
+	classname = 'soclib::caba::DspinPacketGenerator',
+	tmpl_parameters = [ parameter.Int('cmd_width'), parameter.Int('rsp_width'), ],
+	header_files = ['../source/include/dspin_packet_generator.h',],
+	implementation_files = ['../source/src/dspin_packet_generator.cpp',],
+	ports = [
+              Port('caba:bit_in', 'p_resetn', auto = 'resetn'),
+		      Port('caba:clock_in', 'p_clk', auto = 'clock'),
+		      Port('caba:dspin_output', 'p_out', dspin_data_size = parameter.Reference('cmd_width')), 
+		      Port('caba:dspin_input', 'p_in', dspin_data_size = parameter.Reference('rsp_width')),
+	],
+	uses = [ 
+              Uses('caba:base_module'),
+              Uses('caba:generic_fifo'),
+           ],
+)
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/include/dspin_packet_generator.h
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/include/dspin_packet_generator.h	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/include/dspin_packet_generator.h	(revision 998)
@@ -0,0 +1,178 @@
+/* -*- 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
+ * Date     : august 2013
+ * Copyright: UPMC - LIP6
+ *
+ * Modified by: Cesar Fuguet Tortolero
+ */
+
+#ifndef DSPIN_PACKET_GENERATOR_H
+#define DSPIN_PACKET_GENERATOR_H
+
+#include <systemc>
+#include "caba_base_module.h"
+#include "dspin_interface.h"
+#include "generic_fifo.h"
+#include "alloc_elems.h"
+
+////////////////////////////////////////////////////////////////////////////
+// This component is a synthetic sender/receiver of DSPIN paquets.
+// It has two DSPIN ports, and behaves as both a packet generator
+// (controled by the SEND_FSM), and a packet analyser (controled by
+// the RECEIVE_FSM). The flit width can be different for send packets
+// and received packets. These flit widths are template parameters.
+// - As a packet generator, it cand send unicast or broadcast packets.
+//   A first GENERATOR FSM post dated requests in a FIFO. The CMD FSM
+//   consume these dated requests as soon as the FIFO is not empty,
+//   and try to send unicast or broadcast DSPIN packets.
+//   For an unicast packet, the number of flits is fixed and defined
+//   as a constructor parameter (plen), It cannot be less than 2 flits.
+//   The number of flits is exactly two flits for a broadcast packet.
+//   The flit width cannot be less than 33 bits (including EOP).
+//   For both packet types, the first flit is the header, and the second
+//   flit contains the sender absolute date.
+//   The constructor parameter (load) define the requested (offered) load.
+//   The accepted load is computed as : (NB_PACKETS * LENGTH / NB_CYCLES).
+// - As a packet analyser, it computes the total number of received packets
+//   (for each type of packet), and the total cumulated latency.
+////////////////////////////////////////////////////////////////////////////
+// - first flit format in case of a unicast packet :
+//  |EOP|   X     |   Y     |---------------------------------------|BC |
+//  | 0 | x_width | y_width |  flit_width - (x_width + y_width + 2) | 1 |
+//
+// - first flit format in case of a broadcast packet :
+//  |EOP|  XMIN   |  XMAX   |  YMIN   |  YMAX   |-------------------|BC |
+//  | 0 |   5     |   5     |   5     |   5     | flit_width - 22   | 1 |
+//
+// - second flit format :
+//  |EOP|-----------------|         date                                |
+//  | * | flit_width - 33 |          32                                 |
+////////////////////////////////////////////////////////////////////////////
+// It has three constructors parameters :
+// - size_t length == number of flits
+// - size_t load == LOAD*1000
+// - size_t bcp == NB_PACKETS / NB_BROACAST  (optionnal)
+////////////////////////////////////////////////////////////////////////////
+
+namespace soclib { namespace caba {
+
+// FSM states
+enum
+{
+    SEND_IDLE,
+    SEND_UNICAST,
+    SEND_BROADCAST,
+};
+
+enum
+{
+    RECEIVE_IDLE,
+    RECEIVE_UNICAST,
+    RECEIVE_BROADCAST,
+    RECEIVE_WAIT_EOP,
+};
+
+template<int cmd_width, int rsp_width>
+class DspinPacketGenerator
+: public soclib::caba::BaseModule
+{
+
+protected:
+
+    SC_HAS_PROCESS(DspinPacketGenerator);
+
+public:
+
+    // ports
+    sc_core::sc_in<bool>                  p_clk;
+    sc_core::sc_in<bool>                  p_resetn;
+    soclib::caba::DspinInput<rsp_width>   p_in;
+    soclib::caba::DspinOutput<cmd_width>  p_out;
+
+    // constructor
+    DspinPacketGenerator( sc_module_name  name,
+                          const size_t    srcid,       // source identifier
+                          const size_t    length,      // unicast packet length
+                          const size_t    load,        // requested load * 1000
+                          const size_t    fifo_depth,  // fifo depth
+                          const size_t    bcp,         // broadcast period
+                          const size_t    x_width,
+                          const size_t    y_width,
+                          const size_t    x_size,
+                          const size_t    y_size,
+                          const size_t    max_packets = 0);
+private:
+
+    //  registers
+    sc_core::sc_signal<uint32_t>  r_cycles;              // cycles counter (date)
+
+    sc_core::sc_signal<uint32_t>  r_posted_date;         // packet posted date
+    sc_core::sc_signal<uint32_t>  r_posted_bc_packets;   // # of posted broadcasts
+    sc_core::sc_signal<uint32_t>  r_posted_packets;      // # of posted unicasts
+
+    sc_core::sc_signal<int>       r_send_fsm;            // SEND state
+    sc_core::sc_signal<size_t>    r_send_length;         // flit counter
+    sc_core::sc_signal<size_t>    r_send_dest;           // packet destination (x,y)
+    sc_core::sc_signal<uint32_t>  r_send_packets;        // number of unicast packets
+    sc_core::sc_signal<uint32_t>  r_send_bc_packets;     // number of broadcast packets
+
+    sc_core::sc_signal<int>       r_receive_fsm;         // RECEIVE FSM state
+    sc_core::sc_signal<size_t>    r_receive_packets;     // number of unicast packets
+    sc_core::sc_signal<size_t>    r_receive_latency;     // cululated unicast latency
+    sc_core::sc_signal<size_t>    r_receive_bc_packets;  // number of broadcast packets
+    sc_core::sc_signal<size_t>    r_receive_bc_latency;  // cumulated broadcast latency
+
+    // Fifo from GENERATOR FSM to SEND FSM
+    GenericFifo<uint32_t>         r_transaction_fifo;
+
+    // structural variables
+    const size_t                  m_length;              // unicast packet length
+    const size_t                  m_load;                // requested load
+    const size_t                  m_bcp;                 // broadcast period
+    const size_t                  m_srcid;               // seed for random
+    const size_t                  m_x_width;             // X coordinate width
+    const size_t                  m_y_width;             // Y coordinate width
+    const size_t                  m_x_size;              // X coordinate max
+    const size_t                  m_y_size;              // Y coordinate max
+    const size_t                  m_max_packets;         // max number of sent packets
+
+    // methods
+    void transition();
+    void genMoore();
+
+public:
+
+    inline uint32_t get_sent_packets()
+    {
+        return r_send_packets.read() + r_send_bc_packets.read();
+    }
+
+    void print_trace();
+    void print_stats();
+
+}; // end class DspinPacketGenerator
+
+}} // end namespace
+
+#endif // end DSPIN_PACKET_GENERATOR_H
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/src/dspin_packet_generator.cpp
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/src/dspin_packet_generator.cpp	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/src/dspin_packet_generator.cpp	(revision 998)
@@ -0,0 +1,338 @@
+/* -*- 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
+ * Date     : july 2010
+ * Copyright: UPMC - LIP6
+ *
+ * Modified by: Cesar Fuguet Tortolero
+ */
+
+#include "../include/dspin_packet_generator.h"
+#include <cassert>
+
+namespace soclib { namespace caba {
+
+using namespace soclib::caba;
+using namespace soclib::common;
+
+#define tmpl(x) template<int cmd_width, int rsp_width> x DspinPacketGenerator<cmd_width, rsp_width>
+
+
+//////////////////////////////////////////////////////
+tmpl(/**/)::DspinPacketGenerator( sc_module_name name,
+                                  const size_t   srcid,      // srcid for random
+                                  const size_t   length,     // packet length (flits)
+                                  const size_t   load,       // requested load * 1000
+                                  const size_t   fifo_depth, // Fifo depth
+                                  const size_t   bcp,        // broadcast period
+                                  const size_t   x_width,
+                                  const size_t   y_width,
+                                  const size_t   x_size,
+                                  const size_t   y_size,
+                                  const size_t   max_packets)
+    : BaseModule(name),
+
+    p_clk( "clk" ),
+    p_resetn( "resetn" ),
+    p_in( "p_in" ),
+    p_out( "p_out" ),
+
+    r_cycles( "r_cycles" ),
+
+	r_posted_bc_packets( "r_posted_bc_packets" ),
+	r_posted_packets( "r_posted_packets" ),
+
+    r_send_fsm( "r_send_fsm" ),
+    r_send_length( "r_send_length" ),
+    r_send_dest( "r_send_dest" ),
+    r_send_packets( "r_send_packets" ),
+    r_send_bc_packets( "r_send_bc_packets" ),
+
+    r_receive_fsm( "r_receive_fsm" ),
+    r_receive_packets( "r_receive_packets" ),
+    r_receive_latency( "r_receive_latency" ),
+    r_receive_bc_packets( "r_receive_bc_packets" ),
+    r_receive_bc_latency( "r_receive_bc_latency" ),
+
+    r_transaction_fifo( "r_transaction_fifo", fifo_depth ),
+
+    m_length( length ),
+    m_load( load ),
+    m_bcp( bcp ),
+    m_srcid( srcid ),
+    m_x_width( x_width ),
+    m_y_width( y_width ),
+    m_x_size( x_size ),
+    m_y_size( y_size ),
+    m_max_packets( max_packets )
+{
+    assert( (load <= 1000 ) and
+    "DSPIN PACKET GENERATOR ERROR: The load should be between 0 and 1000" );
+
+    assert( (cmd_width >= 33) and
+    "DSPIN PACKET GENERATOR ERROR: CMD flit width smaller than 33 bits");
+
+    assert( (length > 1 ) and
+    "DSPIN PACKET GENERATOR ERROR: Packet length smaller than 2 flits");
+
+    SC_METHOD (transition);
+    dont_initialize();
+    sensitive << p_clk.pos();
+
+    SC_METHOD (genMoore);
+    dont_initialize();
+    sensitive  << p_clk.neg();
+} //  end constructor
+
+////////////////////////
+tmpl(void)::transition()
+{
+    if ( not p_resetn.read() )
+    {
+        r_send_fsm            = SEND_IDLE;
+        r_receive_fsm         = RECEIVE_IDLE;
+        r_cycles              = 0;
+		r_posted_date         = 0;
+        r_posted_packets      = 0;
+        r_posted_bc_packets   = 0;
+        r_send_packets        = 0;
+        r_send_bc_packets     = 0;
+        r_receive_packets     = 0;
+        r_receive_latency     = 0;
+        r_receive_bc_packets  = 0;
+        r_receive_bc_latency  = 0;
+        return;
+    }
+
+    // default values
+    bool fifo_put = false;
+    bool fifo_get = false;
+
+    uint32_t alea = random();
+
+    /////////////////////////   GENERATOR FSM
+	size_t bcast_flits = r_posted_bc_packets.read() * 2;
+	size_t ucast_flits = r_posted_packets.read() * m_length;
+	size_t posted_flits = bcast_flits + ucast_flits;
+    size_t accepted_load = posted_flits * 1000 / (r_cycles.read() + 1);
+	size_t total_packets = r_posted_bc_packets.read() + r_posted_packets.read();
+	bool is_broadcast = ((m_bcp != 0) && (((total_packets + 1) % m_bcp) == 0));
+
+    if( ((accepted_load + ((alea >> 16) & 0xF)) < m_load) )
+    {
+		size_t total_packets = r_posted_packets.read() + r_posted_bc_packets.read();
+        bool max_not_reached = (total_packets < m_max_packets);
+        if ( (m_max_packets == 0) || max_not_reached )
+        {
+            fifo_put = true ;
+            if( r_transaction_fifo.wok() )
+			{
+                if (is_broadcast)
+				{
+					r_posted_bc_packets = r_posted_bc_packets.read() + 1;
+				}
+				else
+				{
+					r_posted_packets = r_posted_packets.read() + 1;
+				}
+			}
+        }
+    }
+
+    /////////////////////////// CMD FSM
+    switch( r_send_fsm.read() )
+    {
+        case SEND_IDLE:
+            if ( r_transaction_fifo.rok() )
+            {
+                fifo_get = true;
+				r_posted_date = (r_transaction_fifo.read() >> 1);
+
+				// broadcast transaction
+                if ( (r_transaction_fifo.read() & 1) == 1 )
+                {
+                    r_send_length     = 2;
+                    r_send_fsm        = SEND_BROADCAST;
+                    r_send_bc_packets = r_send_bc_packets.read() + 1;
+					break;
+                }
+
+				// unicast transaction
+				int x_dest = ((alea >> 8) & 0xFF) % m_x_size;
+				int y_dest = ((alea     ) & 0xFF) % m_y_size;
+
+				r_send_length  = m_length;
+				r_send_fsm     = SEND_UNICAST;
+				r_send_packets = r_send_packets.read() + 1;
+				r_send_dest    = (x_dest << m_y_width) | y_dest;
+            }
+			break;
+        case SEND_UNICAST:
+        case SEND_BROADCAST:
+            if( p_out.read.read() )
+            {
+                r_send_length = r_send_length.read() - 1;
+                if( r_send_length.read() == 1 )
+				{
+					r_send_fsm = SEND_IDLE;
+				}
+            }
+			break;
+    }  // end SEND FSM
+
+    //////////////////////////////	RECEIVE FSM
+    switch( r_receive_fsm.read() )
+    {
+        case RECEIVE_IDLE:
+            if ( p_in.write.read() )
+            {
+                if ( ((p_in.data.read() & 1) == 1) )
+				{
+                    r_receive_fsm = RECEIVE_BROADCAST;
+				}
+                else
+				{
+                    r_receive_fsm = RECEIVE_UNICAST;
+				}
+            }
+			break;
+        case RECEIVE_BROADCAST:
+            if ( p_in.write.read() )
+            {
+				uint32_t latency = r_cycles.read() - (uint32_t)p_in.data.read();
+                r_receive_bc_packets  = r_receive_bc_packets.read() + 1;
+                r_receive_bc_latency  = r_receive_bc_latency.read() + latency ;
+                r_receive_fsm = RECEIVE_IDLE;
+            }
+			break;
+		case RECEIVE_UNICAST:
+			if ( p_in.write.read() )
+			{
+				uint32_t latency = r_cycles.read() - (uint32_t)p_in.data.read();
+				r_receive_packets = r_receive_packets.read() + 1;
+				r_receive_latency = r_receive_latency.read() + latency;
+				if ( p_in.eop.read() )
+				{
+					r_receive_fsm = RECEIVE_IDLE;
+				}
+				else
+				{
+					r_receive_fsm = RECEIVE_WAIT_EOP;
+				}
+			}
+			break;
+        case RECEIVE_WAIT_EOP:
+            if ( p_in.write.read() and p_in.eop.read() )
+            {
+                r_receive_fsm = RECEIVE_IDLE;
+            }
+			break;
+    } // end RECEIVE FSM
+
+    // increment date
+    r_cycles = r_cycles.read() + 1;
+
+    //  update fifos
+	uint32_t fifo_data = (r_cycles.read() << 1) | (is_broadcast ? 1 : 0);
+    r_transaction_fifo.update( fifo_get, fifo_put, fifo_data );
+
+} // end transition
+
+//////////////////////
+tmpl(void)::genMoore()
+{
+    // p_out
+    sc_uint<cmd_width>	data = 0;
+    bool                write = false;
+    bool                eop = false;
+
+    if ( r_send_fsm.read() == SEND_UNICAST )
+    {
+        write = true;
+        if ( r_send_length.read() == m_length )  // first flit
+        {
+			sc_uint<cmd_width> dest = r_send_dest.read();
+            data = dest << (cmd_width - m_x_width - m_y_width);
+        }
+        else if ( r_send_length.read() == (m_length-1) )  // second flit
+        {
+            data = (sc_uint<cmd_width>)r_posted_date.read();
+        }
+		eop = (r_send_length.read() == 1);
+    }
+    else if ( r_send_fsm.read() == SEND_BROADCAST )
+    {
+        write = true;
+        if ( r_send_length.read() == 2 )  // first flit
+        {
+			sc_uint<cmd_width> boundaries = 0x07C1F;
+            data = (boundaries << (cmd_width - 20)) | 1;
+        }
+        else                              // second flit
+        {
+            data = (sc_uint<cmd_width>)r_posted_date.read();
+        }
+		eop = (r_send_length.read() == 1);
+    }
+    p_out.data  = data;
+    p_out.eop   = eop;
+    p_out.write = write;
+
+    p_in.read = true;
+} // end genMoore
+
+/////////////////////////
+tmpl(void)::print_trace()
+{
+    const char* cmd_str[] = { "IDLE", "SEND_UNICAST", "SEND_BROADCAST" };
+    const char* rsp_str[] = { "IDLE", "RECEIVE_UNICAST", "RECEIVE_BROADCAST", "RECEIVE_WAIT" };
+
+    std::cout << "DSPIN_GENERATOR " << name()
+              << " : send_fsm = " << cmd_str[r_send_fsm.read()]
+              << " / recv_fsm = " << rsp_str[r_receive_fsm.read()]
+              << " / fifo_content = " << r_transaction_fifo.filled_status() << std::endl;
+} // end print_trace
+
+/////////////////////////
+tmpl(void)::print_stats()
+{
+	size_t   bcast_flits = r_send_bc_packets.read() * 2;
+	size_t   ucast_flits = r_send_packets.read() * m_length;
+    size_t   load        = (bcast_flits + ucast_flits * 1000) / r_cycles.read();
+    uint32_t latency     = r_receive_latency.read() / (r_receive_packets.read() + 1);
+    uint32_t bc_latency  = r_receive_bc_latency.read() / (r_receive_bc_packets.read() + 1);
+
+	std::cout << "DSPIN_GENERATOR " << name() << std::dec
+		<< "\n - offered load               = " << m_load
+		<< "\n - accepted load              = " << load
+		<< "\n - unicast sent packets       = " << r_send_packets.read()
+		<< "\n - unicast received packets   = " << r_receive_packets.read()
+		<< "\n - unicast latency            = " << latency
+		<< "\n - broadcast sent packets     = " << r_send_bc_packets.read()
+		<< "\n - broadcast received packets = " << r_receive_bc_packets.read()
+		<< "\n - broadcast latency          = " << bc_latency
+		<< std::endl;
+} // end print_stats
+
+
+}} // end namespaces :w
+
Index: anches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/run_broadcast_check.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/run_broadcast_check.sh	(revision 997)
+++ 	(revision )
@@ -1,23 +1,0 @@
-#!/usr/bin/env sh
-LOGDIR=logs
-COMMON="-X 5 -Y 5 -N 10000"
-
-mkdir -p $LOGDIR
-for (( x = 0; x < 5; x++ )); do
-	for (( y = 0; y < 5; y++ )); do
-		for (( fx = 0; fx < 5; fx++ )); do
-			for (( fy = 0; fy < 5; fy++ )); do
-				if [[ ( $x == $fx ) && ( $y == $fy ) ]]; then continue; fi
-				LOGFILE=$LOGDIR/$(echo log'_'$x'_'$y'_'$fx'_'$fy);
-				ARGS="$COMMON -SX $x -SY $y -FX $fx -FY $fy";
-				echo "./simul.x $ARGS ($LOGFILE)"
-				./simul.x $ARGS > $LOGFILE 2>/dev/null;
-				./broadcast_check.sh $LOGFILE
-				if [[ $? == 1 ]]; then
-					echo "FAILURE";
-					exit 1;
-				fi
-			done
-		done
-	done
-done
Index: anches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/run_broadcast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/run_broadcast_latency.sh	(revision 997)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#!/usr/bin/env sh
-LOGDIR=logs
-FX=2
-FY=2
-COMMON="-X 5 -Y 5 -FX $FX -FY $FY -N 10000"
-
-mkdir -p $LOGDIR
-for (( x = 0; x < 5; x++ )); do
-	for (( y = 0; y < 5; y++ )); do
-		for (( load = 100; load <= 1000; load += 100 )); do
-			if [[ ( $x == $FX ) && ( $y == $FY ) ]]; then continue; fi
-			LOGFILE=$LOGDIR/$(echo latency'_'$x'_'$y'_'$load);
-			ARGS="$COMMON -SX $x -SY $y -FX $FX -FY $FY -L $load";
-			echo "./simul.x $ARGS ($LOGFILE)"
-			./simul.x $ARGS > $LOGFILE 2>/dev/null;
-			./broadcast_latency.sh $LOGFILE
-			if [[ $? == 1 ]]; then
-				echo "FAILURE";
-				exit 1;
-			fi
-		done
-	done
-done
-for (( load = 100; load <= 1000; load += 100 )); do
-	LOGFILE=$LOGDIR/$(echo latency_all'_'$load);
-	ARGS="$COMMON -FX $FX -FY $FY -L $load";
-	echo "./simul.x $ARGS ($LOGFILE)"
-	./simul.x $ARGS > $LOGFILE 2>/dev/null;
-	./broadcast_latency.sh $LOGFILE
-	if [[ $? == 1 ]]; then
-		echo "FAILURE";
-		exit 1;
-	fi
-done
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_check.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_check.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_check.sh	(revision 998)
@@ -0,0 +1,80 @@
+#!/usr/bin/env sh
+# @author	Cesar Armando Fuguet Tortolero
+# @date		24 May, 2015
+# @brief	This script validates that a broadcast transaction reaches once
+#			and only once every non-faulty router in the platform.
+file=$1
+awk '
+BEGIN {
+	sent=0
+	last=0
+	failure=0
+	min=99999999
+	max=0
+}
+#   Parse coordinates of routers
+#   /DSPIN_GENERATOR/ {
+#   	regex="\\[[0-9]+\\]\\[";
+#   	if (match($2,regex)) {
+#   		x=substr($2,RSTART+1,RLENGTH-3);
+#   	}
+#   	regex="\\]\\[[0-9]+\\]";
+#   	if (match($2,regex)) {
+#   		y=substr($2,RSTART+2,RLENGTH-3);
+#   	}
+#   }
+
+#   Parse the number of sent broadcast packets
+/broadcast sent packets += +/ {
+	if ($6 != 0) {
+		sent=$6;
+	}
+}
+
+#   Parse the number of received broadcast packets
+/broadcast received packets +=/ {
+	if ($6 == 0) {
+		zero++;
+	}
+	else {
+		# store the min and max number of received packets
+		if ($6 < min) {
+			min=$6;
+		}
+		if ($6 > max) {
+			max=$6;
+		}
+	}
+}
+
+#   Validate the file
+END {
+	# it should be only two routers that do not receive the broadcast:
+	# the source and the faulty router.
+	if (zero > 2) {
+		print "error: some routers did not received broadcasts\n";
+		exit 1;
+	}
+
+	if (max > sent) {
+		print "error: at least a router received a number of broadcast greater"
+		print "than the number of broadcast sent\n";
+		exit 1;
+	}
+
+	if (zero == 1) {
+		print "error: the broadcast source received broadcasts\n";
+		exit 1;
+	}
+
+	error=sent - min
+	if (error > 0) {
+		print "error: the number of broadcast received by a router is inferior "
+		print "to the error threshold: error = " error "\n";
+		exit 1;
+	}
+
+	exit 0;
+}' $file
+if [[ $? == 1 ]]; then exit 1; fi
+
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_latency.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/broadcast_latency.sh	(revision 998)
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+# @author	Cesar Armando Fuguet Tortolero
+# @date		24 May, 2015
+# @brief
+file=$1
+awk '
+BEGIN {
+	total=0
+	targets=0
+}
+
+#   Parse the broadcast latency
+/broadcast latency +=/ {
+	latency=$5;
+	total+=latency;
+	if (latency > 0) {
+		targets++;
+	}
+}
+
+#   Validate the file
+END {
+	print "mean latency=" total/targets
+	exit 0;
+}' $file
+if [[ $? == 1 ]]; then exit 1; fi
+
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_check.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_check.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_check.sh	(revision 998)
@@ -0,0 +1,28 @@
+#!/usr/bin/env sh
+LOGDIR=logs
+COMMON="-X 5 -Y 5 -P 1500"
+SCRIPTPATH=$(dirname $0)
+
+# compile the platform
+make
+if [[ ! -f ./simul.x ]]; then exit 1; fi;
+
+mkdir -p $LOGDIR
+for (( x = 0; x < 5; x++ )); do
+	for (( y = 0; y < 5; y++ )); do
+		for (( fx = 0; fx < 5; fx++ )); do
+			for (( fy = 0; fy < 5; fy++ )); do
+				if [[ ( $x == $fx ) && ( $y == $fy ) ]]; then continue; fi
+				LOGFILE=$LOGDIR/$(echo log'_'$x'_'$y'_'$fx'_'$fy);
+				ARGS="$COMMON -SX $x -SY $y -FX $fx -FY $fy";
+				echo "./simul.x $ARGS ($LOGFILE)"
+				./simul.x $ARGS > $LOGFILE 2>/dev/null;
+				$SCRIPTPATH/broadcast_check.sh $LOGFILE
+				if [[ $? == 1 ]]; then
+					echo "FAILURE";
+					exit 1;
+				fi
+			done
+		done
+	done
+done
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_latency.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_broadcast_latency.sh	(revision 998)
@@ -0,0 +1,45 @@
+#!/usr/bin/env sh
+LOGDIR=logs
+COMMON="-X 5 -Y 5 -N 10000"
+SCRIPTPATH=$(dirname $0)
+
+# compile the platform
+make
+if [[ ! -f simul.x ]]; then exit 1; fi;
+
+mkdir -p $LOGDIR
+#for (( x = 0; x < 5; x++ )); do
+#	for (( y = 0; y < 5; y++ )); do
+#		for (( load = 100; load <= 1000; load += 100 )); do
+#			if [[ ( $x == $FX ) && ( $y == $FY ) ]]; then continue; fi
+#			LOGFILE=$LOGDIR/$(echo latency'_'$x'_'$y'_'$load);
+#			ARGS="$COMMON -SX $x -SY $y -FX $FX -FY $FY -L $load";
+#			echo "./simul.x $ARGS ($LOGFILE)"
+#			./simul.x $ARGS > $LOGFILE 2>/dev/null;
+#			./broadcast_latency.sh $LOGFILE
+#			if [[ $? == 1 ]]; then
+#				echo "FAILURE";
+#				exit 1;
+#			fi
+#		done
+#	done
+#done
+for (( load = 25; load <= 550; load += 25 )); do
+	LOGFILE=$LOGDIR/$(echo latency_all'_'$load);
+	ARGS="$COMMON -L $load";
+	echo "./simul.x $ARGS ($LOGFILE)"
+	./simul.x $ARGS > $LOGFILE 2>/dev/null;
+	$SCRIPTPATH/broadcast_latency.sh $LOGFILE
+done;
+
+for (( x = 0; x < 5; x++ )); do
+	for (( y = 0; y < 5; y++ )); do
+		for (( load = 25; load <= 550; load += 25 )); do
+			LOGFILE=$LOGDIR/$(echo latency_all'_'$x'_'$y'_'$load);
+			ARGS="$COMMON -FX $x -FY $y -L $load";
+			echo "./simul.x $ARGS ($LOGFILE)"
+			./simul.x $ARGS > $LOGFILE 2>/dev/null;
+			$SCRIPTPATH/broadcast_latency.sh $LOGFILE
+		done;
+	done;
+done;
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_unicast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_unicast_latency.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/run_unicast_latency.sh	(revision 998)
@@ -0,0 +1,33 @@
+#!/usr/bin/env sh
+LOGDIR=logs
+COMMON="-X 5 -Y 5 -B 0 -N 10000 -P 0"
+MEANFILE=unicast_mean_latency.txt
+MAXLOAD=550
+SCRIPTPATH=$(dirname $0)
+
+# compile the platform
+make
+if [[ ! -f simul.x ]]; then exit 1; fi;
+
+rm -f $MEANFILE
+
+mkdir -p $LOGDIR
+for (( load = 25; load <= $MAXLOAD; load += 25 )); do
+	LOGFILE=$LOGDIR/$(echo latency_unicast_all'_'$load);
+	ARGS="$COMMON -L $load";
+	echo "./simul.x $ARGS ($LOGFILE)" | tee -a $MEANFILE
+	./simul.x $ARGS > $LOGFILE 2>/dev/null;
+	$SCRIPTPATH/unicast_latency.sh $LOGFILE >> $MEANFILE
+done
+
+for (( x = 0; x < 5; x++ )); do
+	for (( y = 0; y < 5; y++ )); do
+		for (( load = 25; load <= $MAXLOAD; load += 25 )); do
+			LOGFILE=$LOGDIR/$(echo latency_unicast_all'_'$x'_'$y'_'$load);
+			ARGS="$COMMON -L $load -FX $x -FY $y";
+			echo "./simul.x $ARGS ($LOGFILE)" | tee -a $MEANFILE
+			./simul.x $ARGS > $LOGFILE 2>/dev/null;
+			$SCRIPTPATH/unicast_latency.sh $LOGFILE >> $MEANFILE
+		done;
+	done;
+done;
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/unicast_latency.sh
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/unicast_latency.sh	(revision 998)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/scripts/unicast_latency.sh	(revision 998)
@@ -0,0 +1,38 @@
+#!/usr/bin/env sh
+# @author	Cesar Armando Fuguet Tortolero
+# @date		24 May, 2015
+# @brief
+file=$1
+awk '
+BEGIN {
+	total=0
+	total_load=0
+	targets=0
+}
+
+#   Parse the number of received packets
+/unicast received packets +=/ {
+	packets=$6
+}
+
+#   Parse the unicast latency
+/unicast latency +=/ {
+	latency=$5;
+	total+=latency;
+	if (latency > 0) {
+		targets++;
+	}
+}
+
+/accepted load +=/ {
+	total_load+=$5;
+}
+
+#   Validate the file
+END {
+	print "mean latency=" total/targets
+	print "mean load=" total_load/targets
+	exit 0;
+}' $file
+if [[ $? == 1 ]]; then exit 1; 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 997)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.cpp	(revision 998)
@@ -9,4 +9,5 @@
 #include <systemc>
 #include <cassert>
+#include <cstdlib>
 
 #include "dspin_router.h"
@@ -25,15 +26,16 @@
 #define Y_WIDTH 4
 
-#define FIFO_DEPTH 8
-#define NFLITS 2
+#define FIFO_DEPTH 2
+#define NFLITS 8
 #define LOAD 1000
-#define BROADCAST_PERIOD 3
+#define BROADCAST_PERIOD 1
 #define DSPIN_WIDTH 39
+#define MAX_PACKETS 100
 
 /*
  * Platform default values
  */
-#define X_SIZE 4
-#define Y_SIZE 4
+#define X_SIZE 5
+#define Y_SIZE 5
 
 static inline int cluster(int x, int y)
@@ -78,12 +80,18 @@
     int yFaulty = -1;
 
-    /* enable the DSPIN router's debug */
-    int debug = false;
-
-    /* number of simulation cycles */
-    int simCycles = 100000;
+    /* simulation cycles */
+    size_t simCycles = 0;
+
+    /* debug */
+    bool debug = false;
 
     /* synthetic generator load */
     int load = LOAD;
+
+    /* broadcast period */
+    int bcp = BROADCAST_PERIOD;
+
+    /* maximum number of packets per generator */
+    size_t max = MAX_PACKETS;
 
     for (int n = 1; n < argc; n += 2) {
@@ -122,5 +130,14 @@
             continue;
         }
-        if ((strcmp(argv[n--], "-DEBUG") == 0)) {
+        if ((strcmp(argv[n], "-B") == 0) && ((n + 1) < argc) ) {
+            bcp = strtol(argv[n + 1], NULL, 0);
+            assert(bcp >= 0);
+            continue;
+        }
+        if ((strcmp(argv[n], "-P") == 0) && ((n + 1) < argc) ) {
+            max = strtol(argv[n + 1], NULL, 0);
+            continue;
+        }
+        if ((strcmp(argv[n--], "-G") == 0)) {
             debug = true;
             continue;
@@ -154,11 +171,15 @@
             }
 
-            int broadcast_period = 0;
             int ld = 0;
             const int SRCID = cluster(x,y);
             bool all = (xSrc == -1) || (ySrc == -1);
             if (all || (cluster(x,y) == cluster(xSrc,ySrc))) {
-               broadcast_period = BROADCAST_PERIOD;
-               ld = load;
+                ld = load;
+            }
+            if ((x == xFaulty) && (y == yFaulty)) {
+                ld = 0;
+            }
+            if (simCycles > 0) {
+                max = 0;
             }
             std::ostringstream generatorStr;
@@ -167,6 +188,9 @@
                 new DspinGeneratorType(generatorStr.str().c_str(),
                                        SRCID, NFLITS,
-                                       ld, FIFO_DEPTH,
-                                       broadcast_period);
+                                       ld, 8,
+                                       bcp,
+                                       X_WIDTH, Y_WIDTH,
+                                       X_SIZE, Y_SIZE,
+                                       max);
         }
     }
@@ -266,4 +290,5 @@
     }
 
+    srandom(3);
     sc_start(sc_core::SC_ZERO_TIME);
     signal_resetn = 0;
@@ -297,21 +322,43 @@
     signal_resetn = 1;
 
-    for(int i = 0; i < simCycles; ++i) {
-        if (!debug) {
+    size_t n;
+    if (debug) {
+        for(n = 0; n < simCycles; ++n) {
+            std::cout << std::endl;
+            std::cout << "##########################################" << std::endl;
+            std::cout << "Simulation cycle " << n << std::endl;
+            std::cout << "##########################################" << std::endl;
+            std::cout << std::endl;
+            sc_start(sc_core::sc_time(1, SC_NS));
+            for (int x = 0; x < xSize; ++x) {
+                for (int y = 0; y < ySize; ++y) {
+                    dspinRouter[x][y]->print_trace();
+                    dspinGenerator[x][y]->print_trace();
+                }
+            }
+        }
+    } else {
+        if (simCycles > 0) {
             sc_start(sc_core::sc_time(simCycles, SC_NS));
-            break;
-        }
-        std::cout << std::endl;
-        std::cout << "##########################################" << std::endl;
-        std::cout << "Simulation cycle " << i << std::endl;
-        std::cout << "##########################################" << std::endl;
-        std::cout << std::endl;
-        sc_start(sc_core::sc_time(1, SC_NS));
-        for (int x = 0; x < xSize; ++x) {
-            for (int y = 0; y < ySize; ++y) {
-                dspinRouter[x][y]->print_trace();
-            }
-        }
-    }
+        }
+        else {
+            const int period = 3000;
+            for (n = 0; n < (max * 200); n += period) {
+                if ((xSrc == -1) || (ySrc == -1)) {
+                    std::cout << "When using a packet limit, there must be one ";
+                    std::cout << "source only" << std::endl;
+                    std::exit(1);
+                }
+
+                sc_start(sc_core::sc_time(period, SC_NS));
+
+                uint32_t pkts = dspinGenerator[xSrc][ySrc]->get_sent_packets();
+                if (pkts >= max) break;
+            }
+            sc_start(sc_core::sc_time(period, SC_NS));
+            std::cout << "Simulated cycles: " << n + period << std::endl;
+        }
+    }
+
     for (int x = 0; x < xSize; ++x) {
         for (int y = 0; y < ySize; ++y) {
Index: /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.desc
===================================================================
--- /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.desc	(revision 997)
+++ /branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/top.desc	(revision 998)
@@ -10,5 +10,5 @@
 			 flit_width=dspin_size),
 
-        Uses('caba:dspin_packet_generator',
+        Uses('caba:reconf:dspin_router:dspin_packet_generator',
              cmd_width=dspin_size,
              rsp_width=dspin_size)
