[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 : |
---|
[1016] | 31 | // DSPIN first flit format: |
---|
[854] | 32 | // - In case of a non-broadcast packet : |
---|
| 33 | // | X | Y |---------------------------------------|BC | |
---|
| 34 | // | x_width | y_width | flit_width - (x_width + y_width + 2) | 0 | |
---|
| 35 | // |
---|
| 36 | // - In case of a broacast |
---|
[1016] | 37 | // | XMIN | XMAX | YMIN | YMAX |----------------|SP|BC | |
---|
| 38 | // | 5 | 5 | 5 | 5 | flit_width - 21| 1| 1 | |
---|
[854] | 39 | /////////////////////////////////////////////////////////////////////////// |
---|
| 40 | |
---|
| 41 | #ifndef DSPIN_ROUTER_H_ |
---|
| 42 | #define DSPIN_ROUTER_H_ |
---|
| 43 | |
---|
| 44 | #include <systemc> |
---|
| 45 | #include "caba_base_module.h" |
---|
| 46 | #include "generic_fifo.h" |
---|
| 47 | #include "dspin_interface.h" |
---|
| 48 | #include "alloc_elems.h" |
---|
| 49 | |
---|
| 50 | namespace soclib { namespace caba { |
---|
| 51 | |
---|
| 52 | using namespace sc_core; |
---|
| 53 | |
---|
| 54 | template<int flit_width> |
---|
| 55 | class DspinRouter |
---|
| 56 | : public soclib::caba::BaseModule |
---|
| 57 | { |
---|
| 58 | // Input Port FSM |
---|
| 59 | enum |
---|
| 60 | { |
---|
| 61 | INFSM_IDLE, |
---|
| 62 | INFSM_REQ, |
---|
| 63 | INFSM_ALLOC, |
---|
| 64 | INFSM_REQ_FIRST, |
---|
| 65 | INFSM_ALLOC_FIRST, |
---|
| 66 | INFSM_REQ_SECOND, |
---|
| 67 | INFSM_ALLOC_SECOND, |
---|
| 68 | INFSM_REQ_THIRD, |
---|
| 69 | INFSM_ALLOC_THIRD, |
---|
| 70 | INFSM_REQ_FOURTH, |
---|
| 71 | INFSM_ALLOC_FOURTH, |
---|
| 72 | }; |
---|
| 73 | |
---|
| 74 | protected: |
---|
| 75 | SC_HAS_PROCESS(DspinRouter); |
---|
| 76 | |
---|
| 77 | public: |
---|
| 78 | |
---|
[1010] | 79 | // port index |
---|
| 80 | enum { |
---|
| 81 | N = 0, |
---|
| 82 | S = 1, |
---|
| 83 | E = 2, |
---|
| 84 | W = 3, |
---|
| 85 | L = 4 |
---|
| 86 | }; |
---|
| 87 | |
---|
[854] | 88 | // ports |
---|
| 89 | sc_in<bool> p_clk; |
---|
| 90 | sc_in<bool> p_resetn; |
---|
| 91 | DspinInput<flit_width> *p_in; |
---|
| 92 | DspinOutput<flit_width> *p_out; |
---|
| 93 | |
---|
| 94 | // constructor / destructor |
---|
| 95 | DspinRouter( sc_module_name name, |
---|
| 96 | const size_t x, |
---|
| 97 | const size_t y, |
---|
| 98 | const size_t x_width, |
---|
| 99 | const size_t y_width, |
---|
| 100 | const size_t in_fifo_depth, |
---|
| 101 | const size_t out_fifo_depth, |
---|
[994] | 102 | const bool broadcast_supported = false, |
---|
| 103 | const bool configuration_supported = false ); |
---|
[854] | 104 | |
---|
[877] | 105 | ~DspinRouter(); |
---|
| 106 | |
---|
[854] | 107 | private: |
---|
| 108 | |
---|
| 109 | // define the FIFO flit |
---|
| 110 | typedef struct internal_flit_s |
---|
| 111 | { |
---|
| 112 | sc_uint<flit_width> data; |
---|
| 113 | bool eop; |
---|
| 114 | } internal_flit_t; |
---|
| 115 | |
---|
[994] | 116 | // reconfiguration port |
---|
| 117 | // port binding is performed with the bind_recovery_port() function |
---|
| 118 | sc_in<uint32_t> *p_recovery_cfg; |
---|
| 119 | |
---|
[854] | 120 | // registers |
---|
| 121 | sc_signal<bool> *r_alloc_out; // output port is allocated |
---|
| 122 | sc_signal<size_t> *r_index_out; // index of owner input port |
---|
| 123 | |
---|
| 124 | sc_signal<int> *r_fsm_in; // input port state |
---|
| 125 | sc_signal<size_t> *r_index_in; // index of requested output port |
---|
| 126 | internal_flit_t *r_buf_in; // save first flit for a broadcast |
---|
| 127 | |
---|
| 128 | // fifos |
---|
| 129 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_in; |
---|
| 130 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_out; |
---|
| 131 | |
---|
| 132 | // structural parameters |
---|
| 133 | size_t m_local_x; |
---|
| 134 | size_t m_local_y; |
---|
| 135 | size_t m_x_width; |
---|
| 136 | size_t m_x_shift; |
---|
| 137 | size_t m_x_mask; |
---|
| 138 | size_t m_y_width; |
---|
| 139 | size_t m_y_shift; |
---|
| 140 | size_t m_y_mask; |
---|
| 141 | bool m_broadcast_supported; |
---|
| 142 | int m_disable_mask; |
---|
| 143 | |
---|
| 144 | // methods |
---|
| 145 | void transition(); |
---|
| 146 | void genMoore(); |
---|
[994] | 147 | |
---|
[1016] | 148 | int route( sc_uint<flit_width> data ); |
---|
[994] | 149 | int recovery_route( size_t xdest, size_t ydest ); |
---|
[1016] | 150 | int broadcast_route( int iter, int source, sc_uint<flit_width> data ); |
---|
| 151 | int reallocation_route(); |
---|
[994] | 152 | |
---|
[854] | 153 | bool is_broadcast( sc_uint<flit_width> data ); |
---|
[1016] | 154 | internal_flit_t compute_broadcast_header( int source ); |
---|
[854] | 155 | |
---|
[1016] | 156 | bool is_reconfigurable(); |
---|
| 157 | bool is_recovery_routing_enabled(); |
---|
| 158 | bool is_reallocation_enabled(); |
---|
| 159 | bool is_destination_blackhole( size_t xdest, size_t ydest ); |
---|
[994] | 160 | int blackhole_position(); |
---|
[931] | 161 | |
---|
[994] | 162 | public: |
---|
[931] | 163 | |
---|
[994] | 164 | inline void set_disable_mask( int mask ) |
---|
| 165 | { |
---|
| 166 | m_disable_mask = mask; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | void bind_recovery_port(sc_signal<uint32_t> &s); |
---|
| 170 | |
---|
[873] | 171 | void print_trace(); |
---|
[854] | 172 | }; |
---|
| 173 | |
---|
| 174 | }} // end namespace |
---|
| 175 | |
---|
| 176 | #endif // DSPIN_ROUTER_BC_H_ |
---|
| 177 | |
---|
| 178 | // Local Variables: |
---|
| 179 | // tab-width: 4 |
---|
| 180 | // c-basic-offset: 4 |
---|
| 181 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 182 | // indent-tabs-mode: nil |
---|
| 183 | // End: |
---|
| 184 | |
---|
| 185 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|