[854] | 1 | /* -*- c++ -*- |
---|
| 2 | * |
---|
| 3 | * File : dspin_router.h |
---|
| 4 | * Copyright (c) UPMC, Lip6 |
---|
| 5 | * Authors : Alain Greiner, Abbas Sheibanyrad, Ivan Miro, Zhen Zhang |
---|
| 6 | * |
---|
| 7 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
| 8 | * |
---|
| 9 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
| 10 | * |
---|
| 11 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
| 12 | * under the terms of the GNU Lesser General Public License as published |
---|
| 13 | * by the Free Software Foundation; version 2.1 of the License. |
---|
| 14 | * |
---|
| 15 | * SoCLib is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * Lesser General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU Lesser General Public |
---|
| 21 | * License along with SoCLib; if not, write to the Free Software |
---|
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 23 | * 02110-1301 USA |
---|
| 24 | * |
---|
| 25 | * SOCLIB_LGPL_HEADER_END |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /////////////////////////////////////////////////////////////////////////// |
---|
| 30 | // Implementation Note : |
---|
| 31 | // The xfirst_route(), broadcast_route() and is_broadcast() functions |
---|
| 32 | // defined below are used to decode the DSPIN first flit format: |
---|
| 33 | // - In case of a non-broadcast packet : |
---|
| 34 | // | X | Y |---------------------------------------|BC | |
---|
| 35 | // | x_width | y_width | flit_width - (x_width + y_width + 2) | 0 | |
---|
| 36 | // |
---|
| 37 | // - In case of a broacast |
---|
| 38 | // | XMIN | XMAX | YMIN | YMAX |-------------------|BC | |
---|
| 39 | // | 5 | 5 | 5 | 5 | flit_width - 22 | 1 | |
---|
| 40 | /////////////////////////////////////////////////////////////////////////// |
---|
| 41 | |
---|
| 42 | #ifndef DSPIN_ROUTER_H_ |
---|
| 43 | #define DSPIN_ROUTER_H_ |
---|
| 44 | |
---|
| 45 | #include <systemc> |
---|
| 46 | #include "caba_base_module.h" |
---|
| 47 | #include "generic_fifo.h" |
---|
| 48 | #include "dspin_interface.h" |
---|
| 49 | #include "alloc_elems.h" |
---|
| 50 | |
---|
| 51 | namespace soclib { namespace caba { |
---|
| 52 | |
---|
| 53 | using namespace sc_core; |
---|
| 54 | |
---|
| 55 | template<int flit_width> |
---|
| 56 | class DspinRouter |
---|
| 57 | : public soclib::caba::BaseModule |
---|
| 58 | { |
---|
| 59 | // Input Port FSM |
---|
| 60 | enum |
---|
| 61 | { |
---|
| 62 | INFSM_IDLE, |
---|
| 63 | INFSM_REQ, |
---|
| 64 | INFSM_ALLOC, |
---|
| 65 | INFSM_REQ_FIRST, |
---|
| 66 | INFSM_ALLOC_FIRST, |
---|
| 67 | INFSM_REQ_SECOND, |
---|
| 68 | INFSM_ALLOC_SECOND, |
---|
| 69 | INFSM_REQ_THIRD, |
---|
| 70 | INFSM_ALLOC_THIRD, |
---|
| 71 | INFSM_REQ_FOURTH, |
---|
| 72 | INFSM_ALLOC_FOURTH, |
---|
| 73 | }; |
---|
| 74 | |
---|
| 75 | protected: |
---|
| 76 | SC_HAS_PROCESS(DspinRouter); |
---|
| 77 | |
---|
| 78 | public: |
---|
| 79 | |
---|
| 80 | // ports |
---|
| 81 | sc_in<bool> p_clk; |
---|
| 82 | sc_in<bool> p_resetn; |
---|
| 83 | DspinInput<flit_width> *p_in; |
---|
| 84 | DspinOutput<flit_width> *p_out; |
---|
| 85 | |
---|
| 86 | // constructor / destructor |
---|
| 87 | DspinRouter( sc_module_name name, |
---|
| 88 | const size_t x, |
---|
| 89 | const size_t y, |
---|
| 90 | const size_t x_width, |
---|
| 91 | const size_t y_width, |
---|
| 92 | const size_t in_fifo_depth, |
---|
| 93 | const size_t out_fifo_depth, |
---|
[994] | 94 | const bool broadcast_supported = false, |
---|
| 95 | const bool configuration_supported = false ); |
---|
[854] | 96 | |
---|
[877] | 97 | ~DspinRouter(); |
---|
| 98 | |
---|
[854] | 99 | private: |
---|
| 100 | |
---|
| 101 | // define the FIFO flit |
---|
| 102 | typedef struct internal_flit_s |
---|
| 103 | { |
---|
| 104 | sc_uint<flit_width> data; |
---|
| 105 | bool eop; |
---|
| 106 | } internal_flit_t; |
---|
| 107 | |
---|
[994] | 108 | // reconfiguration port |
---|
| 109 | // port binding is performed with the bind_recovery_port() function |
---|
| 110 | sc_in<uint32_t> *p_recovery_cfg; |
---|
| 111 | |
---|
[854] | 112 | // registers |
---|
| 113 | sc_signal<bool> *r_alloc_out; // output port is allocated |
---|
| 114 | sc_signal<size_t> *r_index_out; // index of owner input port |
---|
| 115 | |
---|
| 116 | sc_signal<int> *r_fsm_in; // input port state |
---|
| 117 | sc_signal<size_t> *r_index_in; // index of requested output port |
---|
| 118 | internal_flit_t *r_buf_in; // save first flit for a broadcast |
---|
| 119 | |
---|
| 120 | // fifos |
---|
| 121 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_in; |
---|
| 122 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_out; |
---|
| 123 | |
---|
| 124 | // structural parameters |
---|
| 125 | size_t m_local_x; |
---|
| 126 | size_t m_local_y; |
---|
| 127 | size_t m_x_width; |
---|
| 128 | size_t m_x_shift; |
---|
| 129 | size_t m_x_mask; |
---|
| 130 | size_t m_y_width; |
---|
| 131 | size_t m_y_shift; |
---|
| 132 | size_t m_y_mask; |
---|
| 133 | bool m_broadcast_supported; |
---|
| 134 | int m_disable_mask; |
---|
| 135 | |
---|
| 136 | // methods |
---|
| 137 | void transition(); |
---|
| 138 | void genMoore(); |
---|
[994] | 139 | |
---|
[873] | 140 | int xfirst_route( size_t xdest, size_t ydest ); |
---|
[994] | 141 | int recovery_route( size_t xdest, size_t ydest ); |
---|
[873] | 142 | int route( sc_uint<flit_width> data ); |
---|
[994] | 143 | |
---|
[854] | 144 | int broadcast_route( int iter, int source, sc_uint<flit_width> data ); |
---|
| 145 | bool is_broadcast( sc_uint<flit_width> data ); |
---|
[994] | 146 | sc_uint<flit_width> compute_broadcast_header( int source ); |
---|
[854] | 147 | |
---|
[947] | 148 | bool is_destination_blackhole( size_t xdest, size_t ydest, int bhpos ); |
---|
[994] | 149 | int blackhole_position(); |
---|
[931] | 150 | |
---|
[947] | 151 | inline bool is_network_recovery_enable() |
---|
| 152 | { |
---|
| 153 | return (((p_recovery_cfg->read() >> 7) & 0x1) != 0); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | inline int migration_route() |
---|
| 157 | { |
---|
| 158 | return ((p_recovery_cfg->read() >> 4) & 0x7); |
---|
| 159 | } |
---|
| 160 | |
---|
[994] | 161 | inline bool is_reconfigurable() |
---|
[947] | 162 | { |
---|
[994] | 163 | return (p_recovery_cfg != NULL); |
---|
[947] | 164 | } |
---|
| 165 | |
---|
[994] | 166 | public: |
---|
[931] | 167 | |
---|
[994] | 168 | inline void set_disable_mask( int mask ) |
---|
| 169 | { |
---|
| 170 | m_disable_mask = mask; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | void bind_recovery_port(sc_signal<uint32_t> &s); |
---|
| 174 | |
---|
[873] | 175 | void print_trace(); |
---|
[854] | 176 | }; |
---|
| 177 | |
---|
| 178 | }} // end namespace |
---|
| 179 | |
---|
| 180 | #endif // DSPIN_ROUTER_BC_H_ |
---|
| 181 | |
---|
| 182 | // Local Variables: |
---|
| 183 | // tab-width: 4 |
---|
| 184 | // c-basic-offset: 4 |
---|
| 185 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 186 | // indent-tabs-mode: nil |
---|
| 187 | // End: |
---|
| 188 | |
---|
| 189 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|