source: branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/dspin_broadcast_generator/caba/source/include/dspin_broadcast_generator.h @ 1009

Last change on this file since 1009 was 1009, checked in by cfuguet, 9 years ago

add a new platform for the evaluation of the broadcast recovery
replication policy.

File size: 6.2 KB
Line 
1/* -*- c++ -*-
2 *
3 * SOCLIB_LGPL_HEADER_BEGIN
4 *
5 * This file is part of SoCLib, GNU LGPLv2.1.
6 *
7 * SoCLib is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; version 2.1 of the License.
10 *
11 * SoCLib is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with SoCLib; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * SOCLIB_LGPL_HEADER_END
22 *
23 * Authors  : alain.greiner@lip6.fr
24 * Date     : august 2013
25 * Copyright: UPMC - LIP6
26 *
27 *
28 * Modified by: Cesar Armando Fuguet Tortolero
29 * Date       : jul 2015
30 */
31
32#ifndef DSPIN_BROADCAST_GENERATOR_H
33#define DSPIN_BROADCAST_GENERATOR_H
34
35#include <systemc>
36#include "caba_base_module.h"
37#include "dspin_interface.h"
38#include "generic_fifo.h"
39#include "alloc_elems.h"
40
41////////////////////////////////////////////////////////////////////////////
42// This component is a synthetic sender/receiver of DSPIN paquets. It
43// has two DSPIN ports, and behaves as both a packet generator
44// (controled by the SEND_FSM), and a packet analyser (controled by
45// the RECEIVE_FSM). The flit width can be different for send packets
46// and received packets. These flit widths are template parameters.
47//
48// - As a packet generator, it cand send broadcast packets. A first
49//   GENERATOR FSM post dated requests in a FIFO. The CMD FSM consume
50//   these dated requests as soon as the FIFO is not empty, and try to
51//   send broadcast DSPIN packets.
52//
53// - The number of flits is exactly two flits for a broadcast
54//   packet. The flit width cannot be less than 33 bits (including
55//   EOP).
56//
57// - The first flit is the header, and the second flit contains the
58//   sender absolute date. The constructor parameter (load) define the
59//   requested (offered) load.  The accepted load is computed as :
60//   (NB_PACKETS * LENGTH * MESH_SIZE / NB_CYCLES). NB_PACKETS *
61//   LENGTH equals the number of sent flits, and this is multiplied by
62//   MESH_SIZE because the broadcast flits are replicated once for
63//   each cluster in the mesh.
64//
65// - As a packet analyser, it computes the total number of received
66//   packets, and the total cumulated latency.
67//
68////////////////////////////////////////////////////////////////////////////
69// - first flit format in case of a broadcast packet :
70//  |EOP|  XMIN   |  XMAX   |  YMIN   |  YMAX   |-------------------|BC |
71//  | 0 |   5     |   5     |   5     |   5     | flit_width - 22   | 1 |
72//
73// - second flit format :
74//  |EOP|-----------------|         date                                |
75//  | * | flit_width - 33 |          32                                 |
76////////////////////////////////////////////////////////////////////////////
77// It has three constructors parameters :
78// - size_t length == number of flits
79// - size_t load == LOAD*1000
80////////////////////////////////////////////////////////////////////////////
81
82namespace soclib { namespace caba {
83
84// FSM states
85enum { 
86    SEND_IDLE,
87    SEND_BROADCAST,
88};
89
90enum {
91    RECEIVE_IDLE,
92    RECEIVE_BROADCAST,
93};
94
95template<int cmd_width, int rsp_width>
96class DspinBroadcastGenerator
97    : public soclib::caba::BaseModule
98{           
99
100protected:
101
102    SC_HAS_PROCESS(DspinBroadcastGenerator);
103
104public:
105
106    // ports
107    sc_core::sc_in<bool>                  p_clk;
108    sc_core::sc_in<bool>                  p_resetn;
109    soclib::caba::DspinInput<rsp_width>   p_in;
110    soclib::caba::DspinOutput<cmd_width>  p_out;
111
112    // constructor
113    DspinBroadcastGenerator( sc_module_name  name,
114                             const size_t    x_size,        // # of columns in the mesh
115                             const size_t    y_size,        // # of rows in the mesh
116                             const size_t    srcid,         // source identifier
117                             const size_t    load,          // requested load * 1000
118                             const size_t    fifo_depth );  // fifo depth
119private:
120
121    //  registers
122    sc_core::sc_signal<uint32_t>  r_cycles;                 // cycles counter (date)
123                                                           
124    sc_core::sc_signal<uint32_t>  r_fifo_posted;            // number of posted requests
125                                                           
126    sc_core::sc_signal<int>       r_send_fsm;               // SEND state
127    sc_core::sc_signal<size_t>    r_send_length;            // flit counter
128    sc_core::sc_signal<size_t>    r_send_dest;              // packet destination (x,y)
129    sc_core::sc_signal<uint32_t>  r_send_date;              // request date
130    sc_core::sc_signal<uint32_t>  r_send_bc_packets;        // number of broadcast packets
131
132    sc_core::sc_signal<int>       r_receive_fsm;            // RECEIVE FSM state
133    sc_core::sc_signal<size_t>    r_receive_bc_packets;     // number of broadcast packets
134    sc_core::sc_signal<size_t>    r_receive_bc_latency;     // cumulated broadcast latency
135    sc_core::sc_signal<size_t>    r_receive_bc_max_latency; // max broadcast latency
136
137    sc_core::sc_signal<size_t>    r_max_fill_status;        // max fifo fill status
138   
139    // Fifo from GENERATOR FSM to SEND FSM
140    GenericFifo<uint64_t>         r_date_fifo;
141
142    // structural variables
143    const size_t                  m_x_size;                 // # of columns of the mesh
144    const size_t                  m_y_size;                 // # of rows of the mesh
145    const size_t                  m_load;                   // requested load
146    const size_t                  m_srcid;                  // seed for random
147
148    // methods
149    void transition();
150    void genMoore();
151
152public:
153
154    void print_trace();
155    void print_stats();
156
157}; // end class DspinBroadcastGenerator
158   
159}} // end namespace
160
161#endif // end DSPIN_BROADCAST_GENERATOR_H
162
163// Local Variables:
164// tab-width: 4
165// c-basic-offset: 4
166// c-file-offsets:((innamespace . 0)(inline-open . 0))
167// indent-tabs-mode: nil
168// End:
Note: See TracBrowser for help on using the repository browser.