1 | |
---|
2 | #include <stdint.h> |
---|
3 | #include <systemc> |
---|
4 | #include <sys/time.h> |
---|
5 | #include <iostream> |
---|
6 | #include <cstdlib> |
---|
7 | #include <cstdarg> |
---|
8 | |
---|
9 | #include "arithmetics.h" |
---|
10 | #include "mapping_table.h" |
---|
11 | #include "alloc_elems.h" |
---|
12 | #include "vci_simple_ram.h" |
---|
13 | #include "vci_local_ring_fast.h" |
---|
14 | #include "virtual_dspin_router.h" |
---|
15 | #include "vci_synthetic_initiator.h" |
---|
16 | |
---|
17 | // MESH SIZE |
---|
18 | #define X_MAX 2 |
---|
19 | #define Y_MAX 2 |
---|
20 | #define N_CLUSTERS X_MAX*Y_MAX |
---|
21 | // FLIT_WIDTH |
---|
22 | #define WIDTH_CMD 40 |
---|
23 | #define WIDTH_RSP 33 |
---|
24 | // Face of each DSPIN Router |
---|
25 | #define NORTH 0 |
---|
26 | #define SOUTH 1 |
---|
27 | #define EAST 2 |
---|
28 | #define WEST 3 |
---|
29 | #define LOCAL 4 |
---|
30 | // VCI parameters |
---|
31 | #define cell_width 4 |
---|
32 | #define plen_width 8 |
---|
33 | #define address_width 32 |
---|
34 | #define error_width 1 |
---|
35 | #define clen_width 1 |
---|
36 | #define rflag_width 1 |
---|
37 | #define srcid_width 11 |
---|
38 | #define pktid_width 4 |
---|
39 | #define trdid_width 4 |
---|
40 | #define wrplen_width 1 |
---|
41 | // Adress of targets |
---|
42 | #define TARGET_ADDR 0x00000000 |
---|
43 | #define TARGET_SIZE 0x400 |
---|
44 | |
---|
45 | |
---|
46 | int _main(int argc, char *argv[]) |
---|
47 | { |
---|
48 | using namespace sc_core; |
---|
49 | // Avoid repeating these everywhere |
---|
50 | using soclib::common::IntTab; |
---|
51 | using soclib::common::Segment; |
---|
52 | |
---|
53 | using soclib::common::uint32_log2; |
---|
54 | |
---|
55 | // Define VCI parameters |
---|
56 | typedef soclib::caba::VciParams<cell_width, |
---|
57 | plen_width, |
---|
58 | address_width, |
---|
59 | error_width, |
---|
60 | clen_width, |
---|
61 | rflag_width, |
---|
62 | srcid_width, |
---|
63 | pktid_width, |
---|
64 | trdid_width, |
---|
65 | wrplen_width> vci_param; |
---|
66 | |
---|
67 | //soclib::common::Loader loader(); |
---|
68 | // Mapping table primary network |
---|
69 | soclib::common::MappingTable maptab0(address_width, IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), |
---|
70 | IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), 0xFFC0000); |
---|
71 | soclib::common::MappingTable maptab1(address_width, IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), |
---|
72 | IntTab(soclib::common::uint32_log2(X_MAX)+soclib::common::uint32_log2(Y_MAX) ,srcid_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX)), 0xFFC0000); |
---|
73 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
74 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
75 | std::ostringstream str0; |
---|
76 | std::ostringstream str1; |
---|
77 | str0 << "Target_c0_" << (i*Y_MAX+j) ; |
---|
78 | str1 << "Target_c1_" << (i*Y_MAX+j) ; |
---|
79 | maptab0.add(Segment(str0.str(), TARGET_ADDR + ((i*Y_MAX+j) << (address_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX))), TARGET_SIZE, IntTab((i*X_MAX+j),0), false)); |
---|
80 | maptab1.add(Segment(str1.str(), TARGET_ADDR + ((i*Y_MAX+j) << (address_width-soclib::common::uint32_log2(X_MAX)-soclib::common::uint32_log2(Y_MAX))), TARGET_SIZE, IntTab((i*X_MAX+j),0), false)); |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | std::cout << maptab0 << std::endl; |
---|
86 | // Signals |
---|
87 | |
---|
88 | sc_clock signal_clk("clk"); |
---|
89 | sc_signal<bool> signal_resetn("resetn"); |
---|
90 | |
---|
91 | soclib::caba::VciSignals<vci_param> ** signal_vci_ini_synth_c0 = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("signal_vci_ini_synth_c0", 2, N_CLUSTERS); |
---|
92 | soclib::caba::VciSignals<vci_param> ** signal_vci_ini_synth_c1 = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("signal_vci_ini_synth_c1", 2, N_CLUSTERS); |
---|
93 | /////////////////////////////////////////////////////////////// |
---|
94 | // VDSPIN Signals : one level for in and out, one level for X length in the mesh, |
---|
95 | // one level for Y length in the mesh, last level for each port of the router |
---|
96 | /////////////////////////////////////////////////////////////// |
---|
97 | soclib::caba::DspinSignals<WIDTH_CMD> **** dspin_signals_cmd_c0 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_CMD> >("Dspin_cmd_signals_channel_0", 2, Y_MAX, X_MAX, 5 ); |
---|
98 | soclib::caba::DspinSignals<WIDTH_CMD> **** dspin_signals_cmd_c1 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_CMD> >("Dspin_cmd_signals_channel_1", 2, Y_MAX, X_MAX, 5 ); |
---|
99 | soclib::caba::DspinSignals<WIDTH_RSP> **** dspin_signals_rsp_c0 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_RSP> >("Dspin_rsp_signals_channel_0", 2, Y_MAX, X_MAX, 5 ); |
---|
100 | soclib::caba::DspinSignals<WIDTH_RSP> **** dspin_signals_rsp_c1 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_RSP> >("Dspin_rsp_signals_channel_2", 2, Y_MAX, X_MAX, 5 ); |
---|
101 | |
---|
102 | //soclib::caba::VciSignals<vci_param> * signal_vci_tgt_proc = soclib::common::alloc_elems<soclib::caba::VciSignals<vci_param> >("signal_vci_tgt_proc", N_CLUSTERS); |
---|
103 | |
---|
104 | // N_CLUSTERS ring. |
---|
105 | soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> * local_ring_c0 = (soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> *) malloc(sizeof(soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> ) * N_CLUSTERS) ; |
---|
106 | soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> * local_ring_c1 = (soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> *) malloc(sizeof(soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> ) * N_CLUSTERS) ; |
---|
107 | for(int i = 0 ; i < N_CLUSTERS ; i++){ // ringid, fifo, fifo, nb_init, nb_tgt |
---|
108 | std::cout << "Passe " << i << " pour instanciation ring" << std::endl; |
---|
109 | std::ostringstream str0; |
---|
110 | std::ostringstream str1; |
---|
111 | str0 << "cluster_c0_" << i ; |
---|
112 | str1 << "cluster_c1_" << i ; |
---|
113 | new(&local_ring_c0[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str0.str().c_str(), |
---|
114 | maptab0, |
---|
115 | IntTab(i), |
---|
116 | 2, |
---|
117 | 18, |
---|
118 | 1, |
---|
119 | 1); |
---|
120 | new(&local_ring_c1[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str1.str().c_str(), |
---|
121 | maptab1, |
---|
122 | IntTab(i), |
---|
123 | 2, |
---|
124 | 18, |
---|
125 | 1, |
---|
126 | 1); |
---|
127 | } |
---|
128 | |
---|
129 | // Virtual dspin routers |
---|
130 | soclib::caba::VirtualDspinRouter<WIDTH_CMD> ** routers_cmd = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD> *) * X_MAX); |
---|
131 | soclib::caba::VirtualDspinRouter<WIDTH_RSP> ** routers_rsp = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP> *) * X_MAX); |
---|
132 | |
---|
133 | for(int i = 0; i < X_MAX; i++ ){ |
---|
134 | routers_cmd[i] = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD>) * Y_MAX); |
---|
135 | routers_rsp[i] = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP>) * Y_MAX); |
---|
136 | for(int j = 0; j < Y_MAX; j++){ |
---|
137 | std::cout << "Passe " << i << j << " pour instanciation vdspin" << std::endl; |
---|
138 | std::ostringstream str0; |
---|
139 | std::ostringstream str1; |
---|
140 | str0 << "VDspinRouterCMD" << i << j; |
---|
141 | str1 << "VDspinRouterRSP" << i << j; |
---|
142 | new(&routers_cmd[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_CMD> (str0.str().c_str(), i, j, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4); |
---|
143 | new(&routers_rsp[i][j]) soclib::caba::VirtualDspinRouter<WIDTH_RSP> (str1.str().c_str(), i, j, soclib::common::uint32_log2(X_MAX), soclib::common::uint32_log2(Y_MAX), 4, 4); |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | /////////////////////////////////////////////////////////////// |
---|
149 | // Components |
---|
150 | /////////////////////////////////////////////////////////////// |
---|
151 | |
---|
152 | // N_CLUSTERS VCI Synthetic Initiator (1 initiator per cluster/network) |
---|
153 | soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c0 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS); |
---|
154 | soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c1 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS); |
---|
155 | for(int i = 0 ; i < X_MAX; i++) |
---|
156 | for(int j = 0 ; j < Y_MAX ; j++){ |
---|
157 | std::cout << "Passe " << i << j << " pour instanciation synthetic_init" << std::endl; |
---|
158 | std::ostringstream str0; |
---|
159 | std::ostringstream str1; |
---|
160 | str0 << "Initiator_c0_" << (i*Y_MAX+j) ; |
---|
161 | str1 << "Initiator_c1_" << (i*Y_MAX+j) ; |
---|
162 | if( (i == X_MAX-1) && (j == Y_MAX-1)){ |
---|
163 | new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j) ,0), 16, 900, 2, X_MAX, Y_MAX, 25, 0, X_MAX, 0, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
164 | new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j) ,0), 16, 900, 2, X_MAX, Y_MAX, 25, 0, X_MAX, 0, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
165 | } else { |
---|
166 | new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j),0), 16, 500, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
167 | new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j),0), 16, 500, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | soclib::caba::VciSimpleRam<vci_param> * ram_c0 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS); |
---|
172 | soclib::caba::VciSimpleRam<vci_param> * ram_c1 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS); |
---|
173 | for(int i = 0 ; i < X_MAX ; i++) |
---|
174 | for(int j = 0 ; j < Y_MAX ; j++){ |
---|
175 | std::cout << "Passe " << i << j << " pour instanciation Ram" << std::endl; |
---|
176 | std::ostringstream str0; |
---|
177 | std::ostringstream str1; |
---|
178 | str0 << "Ram_c0_" << (i*Y_MAX+j) ; |
---|
179 | str1 << "Ram_c1_" << (i*Y_MAX+j) ; |
---|
180 | new(&ram_c0[Y_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str0.str().c_str() , IntTab(i*Y_MAX+j,0), maptab0, soclib::common::Loader(), 0); |
---|
181 | new(&ram_c1[Y_MAX*i+j]) soclib::caba::VciSimpleRam<vci_param> (str1.str().c_str() , IntTab(i*Y_MAX+j,0), maptab1, soclib::common::Loader(), 0); |
---|
182 | } |
---|
183 | |
---|
184 | /////////////////////////////////////////////////////////////// |
---|
185 | // Connection of Synthetic Initiator to each local ring per cluster |
---|
186 | /////////////////////////////////////////////////////////////// |
---|
187 | for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
188 | local_ring_c0[i].p_clk(signal_clk); |
---|
189 | local_ring_c0[i].p_resetn(signal_resetn); |
---|
190 | local_ring_c0[i].p_to_initiator[0](signal_vci_ini_synth_c0[0][i]); |
---|
191 | local_ring_c0[i].p_to_target[0](signal_vci_ini_synth_c0[1][i]); |
---|
192 | initiator_c0[i].p_clk(signal_clk); |
---|
193 | initiator_c0[i].p_resetn(signal_resetn); |
---|
194 | initiator_c0[i].p_vci(signal_vci_ini_synth_c0[0][i]); |
---|
195 | ram_c0[i].p_clk(signal_clk); |
---|
196 | ram_c0[i].p_resetn(signal_resetn); |
---|
197 | ram_c0[i].p_vci(signal_vci_ini_synth_c0[1][i]); |
---|
198 | local_ring_c1[i].p_clk(signal_clk); |
---|
199 | local_ring_c1[i].p_resetn(signal_resetn); |
---|
200 | local_ring_c1[i].p_to_initiator[0](signal_vci_ini_synth_c1[0][i]); |
---|
201 | local_ring_c1[i].p_to_target[0](signal_vci_ini_synth_c1[1][i]); |
---|
202 | initiator_c1[i].p_clk(signal_clk); |
---|
203 | initiator_c1[i].p_resetn(signal_resetn); |
---|
204 | initiator_c1[i].p_vci(signal_vci_ini_synth_c1[0][i]); |
---|
205 | ram_c1[i].p_clk(signal_clk); |
---|
206 | ram_c1[i].p_resetn(signal_resetn); |
---|
207 | ram_c1[i].p_vci(signal_vci_ini_synth_c1[1][i]); |
---|
208 | } |
---|
209 | |
---|
210 | /////////////////////////////////////////////////////////////// |
---|
211 | // Connection of each VDspin Router to each local ring and |
---|
212 | // neighbors VDspin Router |
---|
213 | /////////////////////////////////////////////////////////////// |
---|
214 | for(int i = 0; i < X_MAX ; i++){ |
---|
215 | for(int j = 0; j < Y_MAX ; j++){ |
---|
216 | routers_cmd[i][j].p_clk(signal_clk); |
---|
217 | routers_cmd[i][j].p_resetn(signal_resetn); |
---|
218 | routers_rsp[i][j].p_clk(signal_clk); |
---|
219 | routers_rsp[i][j].p_resetn(signal_resetn); |
---|
220 | local_ring_c0[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c0[0][i][j][LOCAL]); |
---|
221 | local_ring_c1[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c1[0][i][j][LOCAL]); |
---|
222 | local_ring_c0[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c0[1][i][j][LOCAL]); |
---|
223 | local_ring_c1[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c1[1][i][j][LOCAL]); |
---|
224 | local_ring_c0[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c0[0][i][j][LOCAL]); |
---|
225 | local_ring_c1[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c1[0][i][j][LOCAL]); |
---|
226 | local_ring_c0[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c0[1][i][j][LOCAL]); |
---|
227 | local_ring_c1[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c1[1][i][j][LOCAL]); |
---|
228 | std::cout << "Ring to DSPIN Connection done" << std::endl; |
---|
229 | for(int k = 0; k < 5; k++){ |
---|
230 | if(j == 0){ |
---|
231 | if(i == 0){ |
---|
232 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]); |
---|
233 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]); |
---|
234 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]); |
---|
235 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]); |
---|
236 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]); |
---|
237 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]); |
---|
238 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]); |
---|
239 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]); |
---|
240 | } else { |
---|
241 | if(k == WEST){ |
---|
242 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i-1][j][EAST]); |
---|
243 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i-1][j][EAST]); |
---|
244 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i-1][j][EAST]); |
---|
245 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i-1][j][EAST]); |
---|
246 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i-1][j][EAST]); |
---|
247 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i-1][j][EAST]); |
---|
248 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i-1][j][EAST]); |
---|
249 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i-1][j][EAST]); |
---|
250 | } else { |
---|
251 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]); |
---|
252 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]); |
---|
253 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]); |
---|
254 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]); |
---|
255 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]); |
---|
256 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]); |
---|
257 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]); |
---|
258 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]); |
---|
259 | } |
---|
260 | } |
---|
261 | } else { |
---|
262 | if(k == SOUTH){ |
---|
263 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i][j-1][NORTH]); |
---|
264 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i][j-1][NORTH]); |
---|
265 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i][j-1][NORTH]); |
---|
266 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i][j-1][NORTH]); |
---|
267 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i][j-1][NORTH]); |
---|
268 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i][j-1][NORTH]); |
---|
269 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i][j-1][NORTH]); |
---|
270 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i][j-1][NORTH]); |
---|
271 | } else if(k == WEST){ |
---|
272 | if(i == 0){ |
---|
273 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]); |
---|
274 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]); |
---|
275 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]); |
---|
276 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]); |
---|
277 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]); |
---|
278 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]); |
---|
279 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]); |
---|
280 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]); |
---|
281 | } else { |
---|
282 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[1][i-1][j][EAST]); |
---|
283 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[1][i-1][j][EAST]); |
---|
284 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[0][i-1][j][EAST]); |
---|
285 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[0][i-1][j][EAST]); |
---|
286 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[1][i-1][j][EAST]); |
---|
287 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[1][i-1][j][EAST]); |
---|
288 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[0][i-1][j][EAST]); |
---|
289 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[0][i-1][j][EAST]); |
---|
290 | } |
---|
291 | } else { |
---|
292 | routers_cmd[i][j].p_out[0][k](dspin_signals_cmd_c0[0][i][j][k]); |
---|
293 | routers_cmd[i][j].p_out[1][k](dspin_signals_cmd_c1[0][i][j][k]); |
---|
294 | routers_cmd[i][j].p_in[0][k](dspin_signals_cmd_c0[1][i][j][k]); |
---|
295 | routers_cmd[i][j].p_in[1][k](dspin_signals_cmd_c1[1][i][j][k]); |
---|
296 | routers_rsp[i][j].p_out[0][k](dspin_signals_rsp_c0[0][i][j][k]); |
---|
297 | routers_rsp[i][j].p_out[1][k](dspin_signals_rsp_c1[0][i][j][k]); |
---|
298 | routers_rsp[i][j].p_in[0][k](dspin_signals_rsp_c0[1][i][j][k]); |
---|
299 | routers_rsp[i][j].p_in[1][k](dspin_signals_rsp_c1[1][i][j][k]); |
---|
300 | } |
---|
301 | } |
---|
302 | } |
---|
303 | } |
---|
304 | } |
---|
305 | |
---|
306 | //////////////////////////////////////////////////////// |
---|
307 | for(int i = 0; i < Y_MAX ; i++){ |
---|
308 | for(int j = 0; j < Y_MAX ; j++){ |
---|
309 | if(i == 0){ |
---|
310 | dspin_signals_cmd_c0[0][i][j][SOUTH].read = true ; |
---|
311 | dspin_signals_cmd_c0[1][i][j][SOUTH].write = false ; |
---|
312 | dspin_signals_cmd_c1[0][i][j][SOUTH].read = true ; |
---|
313 | dspin_signals_cmd_c1[1][i][j][SOUTH].write = false ; |
---|
314 | dspin_signals_rsp_c0[0][i][j][SOUTH].read = true ; |
---|
315 | dspin_signals_rsp_c0[1][i][j][SOUTH].write = false ; |
---|
316 | dspin_signals_rsp_c1[0][i][j][SOUTH].read = true ; |
---|
317 | dspin_signals_rsp_c1[1][i][j][SOUTH].write = false ; |
---|
318 | } |
---|
319 | if(i == Y_MAX-1){ |
---|
320 | dspin_signals_cmd_c0[0][i][j][NORTH].read = true ; |
---|
321 | dspin_signals_cmd_c0[1][i][j][NORTH].write = false ; |
---|
322 | dspin_signals_cmd_c1[0][i][j][NORTH].read = true ; |
---|
323 | dspin_signals_cmd_c1[1][i][j][NORTH].write = false ; |
---|
324 | dspin_signals_rsp_c0[0][i][j][NORTH].read = true ; |
---|
325 | dspin_signals_rsp_c0[1][i][j][NORTH].write = false ; |
---|
326 | dspin_signals_rsp_c1[0][i][j][NORTH].read = true ; |
---|
327 | dspin_signals_rsp_c1[1][i][j][NORTH].write = false ; |
---|
328 | } |
---|
329 | if(j == 0){ |
---|
330 | dspin_signals_cmd_c0[0][i][j][WEST].read = true ; |
---|
331 | dspin_signals_cmd_c0[1][i][j][WEST].write = false ; |
---|
332 | dspin_signals_cmd_c1[0][i][j][WEST].read = true ; |
---|
333 | dspin_signals_cmd_c1[1][i][j][WEST].write = false ; |
---|
334 | dspin_signals_rsp_c0[0][i][j][WEST].read = true ; |
---|
335 | dspin_signals_rsp_c0[1][i][j][WEST].write = false ; |
---|
336 | dspin_signals_rsp_c1[0][i][j][WEST].read = true ; |
---|
337 | dspin_signals_rsp_c1[1][i][j][WEST].write = false ; |
---|
338 | } |
---|
339 | if(j == X_MAX-1){ |
---|
340 | dspin_signals_cmd_c0[0][i][j][EAST].read = true ; |
---|
341 | dspin_signals_cmd_c0[1][i][j][EAST].write = false ; |
---|
342 | dspin_signals_cmd_c1[0][i][j][EAST].read = true ; |
---|
343 | dspin_signals_cmd_c1[1][i][j][EAST].write = false ; |
---|
344 | dspin_signals_rsp_c0[0][i][j][EAST].read = true ; |
---|
345 | dspin_signals_rsp_c0[1][i][j][EAST].write = false ; |
---|
346 | dspin_signals_rsp_c1[0][i][j][EAST].read = true ; |
---|
347 | dspin_signals_rsp_c1[1][i][j][EAST].write = false ; |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | |
---|
353 | |
---|
354 | //////////////////////////////////////////////// |
---|
355 | // Simulation Loop // |
---|
356 | //////////////////////////////////////////////// |
---|
357 | //int ncycles; |
---|
358 | |
---|
359 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
360 | signal_resetn = false; |
---|
361 | |
---|
362 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
363 | signal_resetn = true; |
---|
364 | |
---|
365 | while(1) { |
---|
366 | sc_start(sc_time(1, SC_NS)); |
---|
367 | std::cout << "Synthetic initiators signals ------------------------------" << std::endl; |
---|
368 | for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
369 | initiator_c0[i].print_trace(); |
---|
370 | std::cout << std::hex; |
---|
371 | std::cout << "synt_cmdval = " << signal_vci_ini_synth_c0[0][i].cmdval.read() << std::endl; |
---|
372 | std::cout << "synt_address = " << signal_vci_ini_synth_c0[0][i].address.read() << std::endl; |
---|
373 | std::cout << "synt_cmd = " << signal_vci_ini_synth_c0[0][i].cmd.read() << std::endl; |
---|
374 | std::cout << "synt_srcid = " << signal_vci_ini_synth_c0[0][i].srcid.read() << std::endl; |
---|
375 | std::cout << "synt_plen = " << signal_vci_ini_synth_c0[0][i].plen.read() << std::endl; |
---|
376 | std::cout << "synt_eop = " << signal_vci_ini_synth_c0[0][i].eop.read() << std::endl; |
---|
377 | std::cout << "synt_rspval = " << signal_vci_ini_synth_c0[0][i].rspval.read() << std::endl; |
---|
378 | std::cout << "synt_rerror = " << signal_vci_ini_synth_c0[0][i].rerror.read() << std::endl; |
---|
379 | std::cout << "synt_reop = " << signal_vci_ini_synth_c0[0][i].reop.read() << std::endl; |
---|
380 | } |
---|
381 | std::cout << "RAM signals -----------------------------------------------" << std::endl; |
---|
382 | for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
383 | ram_c0[i].print_trace(); |
---|
384 | std::cout << std::hex; |
---|
385 | std::cout << "ram_cmdval = " << signal_vci_ini_synth_c0[1][i].cmdval.read() << std::endl; |
---|
386 | std::cout << "ram_address = " << signal_vci_ini_synth_c0[1][i].address.read() << std::endl; |
---|
387 | std::cout << "ram_cmd = " << signal_vci_ini_synth_c0[1][i].cmd.read() << std::endl; |
---|
388 | std::cout << "ram_srcid = " << signal_vci_ini_synth_c0[1][i].srcid.read() << std::endl; |
---|
389 | std::cout << "ram_plen = " << signal_vci_ini_synth_c0[1][i].plen.read() << std::endl; |
---|
390 | std::cout << "ram_eop = " << signal_vci_ini_synth_c0[1][i].eop.read() << std::endl; |
---|
391 | std::cout << "ram_rspval = " << signal_vci_ini_synth_c0[1][i].rspval.read() << std::endl; |
---|
392 | std::cout << "ram_rsrcid = " << signal_vci_ini_synth_c0[1][i].rsrcid.read() << std::endl; |
---|
393 | std::cout << "ram_rerror = " << signal_vci_ini_synth_c0[1][i].rerror.read() << std::endl; |
---|
394 | std::cout << "ram_reop = " << signal_vci_ini_synth_c0[1][i].reop.read() << std::endl; |
---|
395 | } |
---|
396 | std::cout << "Local_ring ------------------------------------------------" << std::endl; |
---|
397 | for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
398 | local_ring_c0[i].print_trace(); |
---|
399 | } |
---|
400 | std::cout << "Routers CMD -----------------------------------------------" << std::endl; |
---|
401 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
402 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
403 | routers_cmd[i][j].printTrace(0); |
---|
404 | } |
---|
405 | } |
---|
406 | std::cout << "Routers RSP -----------------------------------------------" << std::endl; |
---|
407 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
408 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
409 | routers_rsp[i][j].printTrace(0); |
---|
410 | } |
---|
411 | } |
---|
412 | |
---|
413 | //for(int i = 0; i< N_CLUSTERS; i++){ |
---|
414 | // initiator_c1[i].print_trace(); |
---|
415 | // std::cout << std::hex; |
---|
416 | // std::cout << "synt_cmdval = " << signal_vci_ini_synth_c1[0][i].cmdval.read() << std::endl; |
---|
417 | // std::cout << "synt_address = " << signal_vci_ini_synth_c1[0][i].address.read() << std::endl; |
---|
418 | // std::cout << "synt_cmd = " << signal_vci_ini_synth_c1[0][i].cmd.read() << std::endl; |
---|
419 | // std::cout << "synt_srcid = " << signal_vci_ini_synth_c1[0][i].srcid.read() << std::endl; |
---|
420 | // std::cout << "synt_plen = " << signal_vci_ini_synth_c1[0][i].plen.read() << std::endl; |
---|
421 | // std::cout << "synt_eop = " << signal_vci_ini_synth_c1[0][i].eop.read() << std::endl; |
---|
422 | // std::cout << "synt_rspval = " << signal_vci_ini_synth_c1[0][i].rspval.read() << std::endl; |
---|
423 | // std::cout << "synt_rerror = " << signal_vci_ini_synth_c1[0][i].rerror.read() << std::endl; |
---|
424 | // std::cout << "synt_reop = " << signal_vci_ini_synth_c1[0][i].reop.read() << std::endl; |
---|
425 | //} |
---|
426 | //for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
427 | // ram_c1[i].print_trace(); |
---|
428 | // std::cout << std::hex; |
---|
429 | // std::cout << "ram_cmdval = " << signal_vci_ini_synth_c0[1][i].cmdval.read() << std::endl; |
---|
430 | // std::cout << "ram_address = " << signal_vci_ini_synth_c0[1][i].address.read() << std::endl; |
---|
431 | // std::cout << "ram_cmd = " << signal_vci_ini_synth_c0[1][i].cmd.read() << std::endl; |
---|
432 | // std::cout << "ram_srcid = " << signal_vci_ini_synth_c0[1][i].srcid.read() << std::endl; |
---|
433 | // std::cout << "ram_plen = " << signal_vci_ini_synth_c0[1][i].plen.read() << std::endl; |
---|
434 | // std::cout << "ram_eop = " << signal_vci_ini_synth_c0[1][i].eop.read() << std::endl; |
---|
435 | // std::cout << "ram_rspval = " << signal_vci_ini_synth_c0[1][i].rspval.read() << std::endl; |
---|
436 | // std::cout << "ram_rerror = " << signal_vci_ini_synth_c0[1][i].rerror.read() << std::endl; |
---|
437 | // std::cout << "ram_reop = " << signal_vci_ini_synth_c0[1][i].reop.read() << std::endl; |
---|
438 | //} |
---|
439 | |
---|
440 | } |
---|
441 | |
---|
442 | return EXIT_SUCCESS; |
---|
443 | } |
---|
444 | |
---|
445 | int sc_main (int argc, char *argv[]) |
---|
446 | { |
---|
447 | try { |
---|
448 | return _main(argc, argv); |
---|
449 | } catch (std::exception &e) { |
---|
450 | std::cout << e.what() << std::endl; |
---|
451 | } catch (...) { |
---|
452 | std::cout << "Unknown exception occured" << std::endl; |
---|
453 | throw; |
---|
454 | } |
---|
455 | return 1; |
---|
456 | } |
---|