source: branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/dspin_packet_generator/caba/source/include/dspin_packet_generator.h @ 998

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

reconf: several improvements in the dspin_router synthetic test platform

File size: 7.0 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 * Modified by: Cesar Fuguet Tortolero
28 */
29
30#ifndef DSPIN_PACKET_GENERATOR_H
31#define DSPIN_PACKET_GENERATOR_H
32
33#include <systemc>
34#include "caba_base_module.h"
35#include "dspin_interface.h"
36#include "generic_fifo.h"
37#include "alloc_elems.h"
38
39////////////////////////////////////////////////////////////////////////////
40// This component is a synthetic sender/receiver of DSPIN paquets.
41// It has two DSPIN ports, and behaves as both a packet generator
42// (controled by the SEND_FSM), and a packet analyser (controled by
43// the RECEIVE_FSM). The flit width can be different for send packets
44// and received packets. These flit widths are template parameters.
45// - As a packet generator, it cand send unicast or broadcast packets.
46//   A first GENERATOR FSM post dated requests in a FIFO. The CMD FSM
47//   consume these dated requests as soon as the FIFO is not empty,
48//   and try to send unicast or broadcast DSPIN packets.
49//   For an unicast packet, the number of flits is fixed and defined
50//   as a constructor parameter (plen), It cannot be less than 2 flits.
51//   The number of flits is exactly two flits for a broadcast packet.
52//   The flit width cannot be less than 33 bits (including EOP).
53//   For both packet types, the first flit is the header, and the second
54//   flit contains the sender absolute date.
55//   The constructor parameter (load) define the requested (offered) load.
56//   The accepted load is computed as : (NB_PACKETS * LENGTH / NB_CYCLES).
57// - As a packet analyser, it computes the total number of received packets
58//   (for each type of packet), and the total cumulated latency.
59////////////////////////////////////////////////////////////////////////////
60// - first flit format in case of a unicast packet :
61//  |EOP|   X     |   Y     |---------------------------------------|BC |
62//  | 0 | x_width | y_width |  flit_width - (x_width + y_width + 2) | 1 |
63//
64// - first flit format in case of a broadcast packet :
65//  |EOP|  XMIN   |  XMAX   |  YMIN   |  YMAX   |-------------------|BC |
66//  | 0 |   5     |   5     |   5     |   5     | flit_width - 22   | 1 |
67//
68// - second flit format :
69//  |EOP|-----------------|         date                                |
70//  | * | flit_width - 33 |          32                                 |
71////////////////////////////////////////////////////////////////////////////
72// It has three constructors parameters :
73// - size_t length == number of flits
74// - size_t load == LOAD*1000
75// - size_t bcp == NB_PACKETS / NB_BROACAST  (optionnal)
76////////////////////////////////////////////////////////////////////////////
77
78namespace soclib { namespace caba {
79
80// FSM states
81enum
82{
83    SEND_IDLE,
84    SEND_UNICAST,
85    SEND_BROADCAST,
86};
87
88enum
89{
90    RECEIVE_IDLE,
91    RECEIVE_UNICAST,
92    RECEIVE_BROADCAST,
93    RECEIVE_WAIT_EOP,
94};
95
96template<int cmd_width, int rsp_width>
97class DspinPacketGenerator
98: public soclib::caba::BaseModule
99{
100
101protected:
102
103    SC_HAS_PROCESS(DspinPacketGenerator);
104
105public:
106
107    // ports
108    sc_core::sc_in<bool>                  p_clk;
109    sc_core::sc_in<bool>                  p_resetn;
110    soclib::caba::DspinInput<rsp_width>   p_in;
111    soclib::caba::DspinOutput<cmd_width>  p_out;
112
113    // constructor
114    DspinPacketGenerator( sc_module_name  name,
115                          const size_t    srcid,       // source identifier
116                          const size_t    length,      // unicast packet length
117                          const size_t    load,        // requested load * 1000
118                          const size_t    fifo_depth,  // fifo depth
119                          const size_t    bcp,         // broadcast period
120                          const size_t    x_width,
121                          const size_t    y_width,
122                          const size_t    x_size,
123                          const size_t    y_size,
124                          const size_t    max_packets = 0);
125private:
126
127    //  registers
128    sc_core::sc_signal<uint32_t>  r_cycles;              // cycles counter (date)
129
130    sc_core::sc_signal<uint32_t>  r_posted_date;         // packet posted date
131    sc_core::sc_signal<uint32_t>  r_posted_bc_packets;   // # of posted broadcasts
132    sc_core::sc_signal<uint32_t>  r_posted_packets;      // # of posted unicasts
133
134    sc_core::sc_signal<int>       r_send_fsm;            // SEND state
135    sc_core::sc_signal<size_t>    r_send_length;         // flit counter
136    sc_core::sc_signal<size_t>    r_send_dest;           // packet destination (x,y)
137    sc_core::sc_signal<uint32_t>  r_send_packets;        // number of unicast packets
138    sc_core::sc_signal<uint32_t>  r_send_bc_packets;     // number of broadcast packets
139
140    sc_core::sc_signal<int>       r_receive_fsm;         // RECEIVE FSM state
141    sc_core::sc_signal<size_t>    r_receive_packets;     // number of unicast packets
142    sc_core::sc_signal<size_t>    r_receive_latency;     // cululated unicast latency
143    sc_core::sc_signal<size_t>    r_receive_bc_packets;  // number of broadcast packets
144    sc_core::sc_signal<size_t>    r_receive_bc_latency;  // cumulated broadcast latency
145
146    // Fifo from GENERATOR FSM to SEND FSM
147    GenericFifo<uint32_t>         r_transaction_fifo;
148
149    // structural variables
150    const size_t                  m_length;              // unicast packet length
151    const size_t                  m_load;                // requested load
152    const size_t                  m_bcp;                 // broadcast period
153    const size_t                  m_srcid;               // seed for random
154    const size_t                  m_x_width;             // X coordinate width
155    const size_t                  m_y_width;             // Y coordinate width
156    const size_t                  m_x_size;              // X coordinate max
157    const size_t                  m_y_size;              // Y coordinate max
158    const size_t                  m_max_packets;         // max number of sent packets
159
160    // methods
161    void transition();
162    void genMoore();
163
164public:
165
166    inline uint32_t get_sent_packets()
167    {
168        return r_send_packets.read() + r_send_bc_packets.read();
169    }
170
171    void print_trace();
172    void print_stats();
173
174}; // end class DspinPacketGenerator
175
176}} // end namespace
177
178#endif // end DSPIN_PACKET_GENERATOR_H
Note: See TracBrowser for help on using the repository browser.