[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 | // Port indexing |
---|
| 60 | enum |
---|
| 61 | { |
---|
| 62 | REQ_NORTH = 0, |
---|
| 63 | REQ_SOUTH = 1, |
---|
| 64 | REQ_EAST = 2, |
---|
| 65 | REQ_WEST = 3, |
---|
| 66 | REQ_LOCAL = 4, |
---|
| 67 | REQ_NOP = 5, |
---|
| 68 | }; |
---|
| 69 | |
---|
| 70 | // Input Port FSM |
---|
| 71 | enum |
---|
| 72 | { |
---|
| 73 | INFSM_IDLE, |
---|
| 74 | INFSM_REQ, |
---|
| 75 | INFSM_ALLOC, |
---|
| 76 | INFSM_REQ_FIRST, |
---|
| 77 | INFSM_ALLOC_FIRST, |
---|
| 78 | INFSM_REQ_SECOND, |
---|
| 79 | INFSM_ALLOC_SECOND, |
---|
| 80 | INFSM_REQ_THIRD, |
---|
| 81 | INFSM_ALLOC_THIRD, |
---|
| 82 | INFSM_REQ_FOURTH, |
---|
| 83 | INFSM_ALLOC_FOURTH, |
---|
| 84 | }; |
---|
| 85 | |
---|
| 86 | protected: |
---|
| 87 | SC_HAS_PROCESS(DspinRouter); |
---|
| 88 | |
---|
| 89 | public: |
---|
| 90 | |
---|
| 91 | // ports |
---|
| 92 | sc_in<bool> p_clk; |
---|
| 93 | sc_in<bool> p_resetn; |
---|
| 94 | DspinInput<flit_width> *p_in; |
---|
| 95 | DspinOutput<flit_width> *p_out; |
---|
[883] | 96 | sc_in<uint32_t> *p_blackhole_pos; |
---|
[854] | 97 | |
---|
| 98 | // constructor / destructor |
---|
| 99 | DspinRouter( sc_module_name name, |
---|
| 100 | const size_t x, |
---|
| 101 | const size_t y, |
---|
| 102 | const size_t x_width, |
---|
| 103 | const size_t y_width, |
---|
| 104 | const size_t in_fifo_depth, |
---|
| 105 | const size_t out_fifo_depth, |
---|
[877] | 106 | const bool broadcast_supported = false, |
---|
| 107 | const bool reconfigurable = false ); |
---|
[854] | 108 | |
---|
[877] | 109 | ~DspinRouter(); |
---|
| 110 | |
---|
[854] | 111 | private: |
---|
| 112 | |
---|
| 113 | // define the FIFO flit |
---|
| 114 | typedef struct internal_flit_s |
---|
| 115 | { |
---|
| 116 | sc_uint<flit_width> data; |
---|
| 117 | bool eop; |
---|
| 118 | } internal_flit_t; |
---|
| 119 | |
---|
| 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(); |
---|
[873] | 147 | int xfirst_route( size_t xdest, size_t ydest ); |
---|
| 148 | int recovery_route( size_t xdest, size_t ydest ); |
---|
| 149 | int route( sc_uint<flit_width> data ); |
---|
[854] | 150 | int broadcast_route( int iter, int source, sc_uint<flit_width> data ); |
---|
| 151 | bool is_broadcast( sc_uint<flit_width> data ); |
---|
| 152 | |
---|
| 153 | public: |
---|
| 154 | |
---|
[873] | 155 | void set_disable_mask( int mask ) |
---|
| 156 | { |
---|
| 157 | m_disable_mask = mask; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | void print_trace(); |
---|
[854] | 161 | }; |
---|
| 162 | |
---|
| 163 | }} // end namespace |
---|
| 164 | |
---|
| 165 | #endif // DSPIN_ROUTER_BC_H_ |
---|
| 166 | |
---|
| 167 | // Local Variables: |
---|
| 168 | // tab-width: 4 |
---|
| 169 | // c-basic-offset: 4 |
---|
| 170 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 171 | // indent-tabs-mode: nil |
---|
| 172 | // End: |
---|
| 173 | |
---|
| 174 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|