1 | /* -*- c++ -*- |
---|
2 | * File : dspin_local_crossbar.h |
---|
3 | * Copyright (c) UPMC, Lip6 |
---|
4 | * Author : Alain Greiner |
---|
5 | * |
---|
6 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
7 | * |
---|
8 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
9 | * |
---|
10 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
11 | * under the terms of the GNU Lesser General Public License as published |
---|
12 | * by the Free Software Foundation; version 2.1 of the License. |
---|
13 | * |
---|
14 | * SoCLib is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * Lesser General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU Lesser General Public |
---|
20 | * License along with SoCLib; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
22 | * 02110-1301 USA |
---|
23 | * |
---|
24 | * SOCLIB_LGPL_HEADER_END |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef DSPIN_LOCAL_CROSSBAR_H_ |
---|
29 | #define DSPIN_LOCAL_CROSSBAR_H_ |
---|
30 | |
---|
31 | #include <systemc> |
---|
32 | #include <cassert> |
---|
33 | #include "alloc_elems.h" |
---|
34 | #include "caba_base_module.h" |
---|
35 | #include "generic_fifo.h" |
---|
36 | #include "dspin_interface.h" |
---|
37 | #include "mapping_table.h" |
---|
38 | #include "address_decoding_table.h" |
---|
39 | |
---|
40 | namespace soclib { namespace caba { |
---|
41 | |
---|
42 | using namespace sc_core; |
---|
43 | using namespace soclib::common; |
---|
44 | |
---|
45 | template<size_t flit_width> |
---|
46 | class DspinLocalCrossbar |
---|
47 | : public soclib::caba::BaseModule |
---|
48 | { |
---|
49 | // Input Port FSM |
---|
50 | enum |
---|
51 | { |
---|
52 | INFSM_IDLE, |
---|
53 | INFSM_REQ, |
---|
54 | INFSM_ALLOC, |
---|
55 | INFSM_REQ_BC, |
---|
56 | INFSM_ALLOC_BC, |
---|
57 | }; |
---|
58 | |
---|
59 | protected: |
---|
60 | SC_HAS_PROCESS(DspinLocalCrossbar); |
---|
61 | |
---|
62 | public: |
---|
63 | |
---|
64 | // ports |
---|
65 | sc_in<bool> p_clk; |
---|
66 | sc_in<bool> p_resetn; |
---|
67 | DspinInput<flit_width> p_global_in; |
---|
68 | DspinOutput<flit_width> p_global_out; |
---|
69 | DspinInput<flit_width>* p_local_in; |
---|
70 | DspinOutput<flit_width>* p_local_out; |
---|
71 | |
---|
72 | sc_in<uint32_t> *p_barrier_enable; |
---|
73 | |
---|
74 | void print_trace(); |
---|
75 | |
---|
76 | // constructor / destructor |
---|
77 | DspinLocalCrossbar( sc_module_name name, |
---|
78 | const MappingTable &mt, |
---|
79 | const size_t x, // cluster x coordinate |
---|
80 | const size_t y, // cluster y coordinate |
---|
81 | const size_t x_width, // x field width |
---|
82 | const size_t y_width, // y field width |
---|
83 | const size_t l_width, // local field width |
---|
84 | const size_t nb_local_inputs, |
---|
85 | const size_t nb_local_outputs, |
---|
86 | const size_t in_fifo_depth, |
---|
87 | const size_t out_fifo_depth, |
---|
88 | const bool is_cmd, |
---|
89 | const bool use_routing_table, |
---|
90 | const bool broadcast_supported, |
---|
91 | const bool hardware_barrier = false ); |
---|
92 | |
---|
93 | ~DspinLocalCrossbar(); |
---|
94 | |
---|
95 | private: |
---|
96 | |
---|
97 | // define the FIFO flit |
---|
98 | typedef struct internal_flit_s |
---|
99 | { |
---|
100 | sc_uint<flit_width> data; |
---|
101 | bool eop; |
---|
102 | } internal_flit_t; |
---|
103 | |
---|
104 | // internal registers |
---|
105 | sc_signal<bool> *r_alloc_out; // output port allocated |
---|
106 | sc_signal<size_t> *r_index_out; // owner input port index |
---|
107 | internal_flit_t *r_buf_in; // input port fifo extension |
---|
108 | sc_signal<int> *r_fsm_in; // input port state |
---|
109 | sc_signal<size_t> *r_index_in; // requested output port index |
---|
110 | |
---|
111 | // fifos |
---|
112 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_in; |
---|
113 | soclib::caba::GenericFifo<internal_flit_t>* r_fifo_out; |
---|
114 | |
---|
115 | // structural parameters |
---|
116 | const size_t m_local_x; |
---|
117 | const size_t m_local_y; |
---|
118 | const size_t m_x_width; |
---|
119 | const size_t m_x_shift; |
---|
120 | const size_t m_x_mask; |
---|
121 | const size_t m_y_width; |
---|
122 | const size_t m_y_shift; |
---|
123 | const size_t m_y_mask; |
---|
124 | const size_t m_l_width; |
---|
125 | const size_t m_l_shift; |
---|
126 | const size_t m_l_mask; |
---|
127 | const size_t m_local_inputs; |
---|
128 | const size_t m_local_outputs; |
---|
129 | const size_t m_addr_width; |
---|
130 | const bool m_is_cmd; |
---|
131 | const bool m_use_routing_table; |
---|
132 | const bool m_broadcast_supported; |
---|
133 | |
---|
134 | // we define two routing tables, but only one is used |
---|
135 | AddressDecodingTable<uint64_t, size_t> m_cmd_rt; |
---|
136 | AddressDecodingTable<uint32_t, size_t> m_rsp_rt; |
---|
137 | |
---|
138 | // methods |
---|
139 | void transition(); |
---|
140 | void genMoore(); |
---|
141 | size_t route( sc_uint<flit_width> data, size_t index ); |
---|
142 | bool is_broadcast( sc_uint<flit_width> data ); |
---|
143 | }; |
---|
144 | |
---|
145 | }} // end namespace |
---|
146 | |
---|
147 | #endif // DSPIN_LOCAL_CROSSBAR_H_ |
---|
148 | |
---|
149 | // Local Variables: |
---|
150 | // tab-width: 4 |
---|
151 | // c-basic-offset: 4 |
---|
152 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
153 | // indent-tabs-mode: nil |
---|
154 | // End: |
---|
155 | |
---|
156 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|