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 16 |
---|
19 | #define Y_MAX 16 |
---|
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 | // FIFO depth in the gateways |
---|
45 | #define DEPTH 2 |
---|
46 | // LENGTH of packets |
---|
47 | #define PACKET_LENGTH 2 |
---|
48 | // FIFO depth in the routers |
---|
49 | #define DSPIN_FIFO 4 |
---|
50 | // DEBUG MODE : 0 OFF, 1 only the initiators and the targets, 2 only network |
---|
51 | #define DEBUG 0 |
---|
52 | |
---|
53 | |
---|
54 | int _main(int argc, char *argv[]) |
---|
55 | { |
---|
56 | using namespace sc_core; |
---|
57 | // Avoid repeating these everywhere |
---|
58 | using soclib::common::IntTab; |
---|
59 | using soclib::common::Segment; |
---|
60 | |
---|
61 | using soclib::common::uint32_log2; |
---|
62 | |
---|
63 | // Define VCI parameters |
---|
64 | typedef soclib::caba::VciParams<cell_width, |
---|
65 | plen_width, |
---|
66 | address_width, |
---|
67 | error_width, |
---|
68 | clen_width, |
---|
69 | rflag_width, |
---|
70 | srcid_width, |
---|
71 | pktid_width, |
---|
72 | trdid_width, |
---|
73 | wrplen_width> vci_param; |
---|
74 | |
---|
75 | // Mapping table primary network |
---|
76 | 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)), |
---|
77 | 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); |
---|
78 | 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)), |
---|
79 | 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); |
---|
80 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
81 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
82 | std::ostringstream str0; |
---|
83 | std::ostringstream str1; |
---|
84 | str0 << "Target_c0_" << (i*Y_MAX+j) ; |
---|
85 | str1 << "Target_c1_" << (i*Y_MAX+j) ; |
---|
86 | 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)); |
---|
87 | 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)); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | // std::cout << maptab0 << std::endl; |
---|
93 | |
---|
94 | sc_clock signal_clk("clk"); |
---|
95 | sc_signal<bool> signal_resetn("resetn"); |
---|
96 | |
---|
97 | 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); |
---|
98 | 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); |
---|
99 | /////////////////////////////////////////////////////////////// |
---|
100 | // VDSPIN Signals : one level for in and out, one level for X length in the mesh, |
---|
101 | // one level for Y length in the mesh, last level for each port of the router |
---|
102 | /////////////////////////////////////////////////////////////// |
---|
103 | soclib::caba::DspinSignals<WIDTH_CMD> **** dspin_signals_cmd_c0 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_CMD> >("Dspin_cmd_signals_channel_0", 2, X_MAX, Y_MAX, 5 ); |
---|
104 | soclib::caba::DspinSignals<WIDTH_CMD> **** dspin_signals_cmd_c1 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_CMD> >("Dspin_cmd_signals_channel_1", 2, X_MAX, Y_MAX, 5 ); |
---|
105 | soclib::caba::DspinSignals<WIDTH_RSP> **** dspin_signals_rsp_c0 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_RSP> >("Dspin_rsp_signals_channel_0", 2, X_MAX, Y_MAX, 5 ); |
---|
106 | soclib::caba::DspinSignals<WIDTH_RSP> **** dspin_signals_rsp_c1 = soclib::common::alloc_elems<soclib::caba::DspinSignals<WIDTH_RSP> >("Dspin_rsp_signals_channel_2", 2, X_MAX, Y_MAX, 5 ); |
---|
107 | |
---|
108 | |
---|
109 | // N_CLUSTERS ring. |
---|
110 | 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) ; |
---|
111 | 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) ; |
---|
112 | for(int i = 0 ; i < N_CLUSTERS ; i++){ // ringid, fifo, fifo, nb_init, nb_tgt |
---|
113 | std::ostringstream str0; |
---|
114 | std::ostringstream str1; |
---|
115 | str0 << "cluster_c0_" << i ; |
---|
116 | str1 << "cluster_c1_" << i ; |
---|
117 | new(&local_ring_c0[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str0.str().c_str(), |
---|
118 | maptab0, |
---|
119 | IntTab(i), |
---|
120 | 2, |
---|
121 | DEPTH, |
---|
122 | 1, |
---|
123 | 1); |
---|
124 | new(&local_ring_c1[i]) soclib::caba::VciLocalRingFast<vci_param, WIDTH_CMD, WIDTH_RSP> (str1.str().c_str(), |
---|
125 | maptab1, |
---|
126 | IntTab(i), |
---|
127 | 2, |
---|
128 | DEPTH, |
---|
129 | 1, |
---|
130 | 1); |
---|
131 | } |
---|
132 | |
---|
133 | // Virtual dspin routers |
---|
134 | soclib::caba::VirtualDspinRouter<WIDTH_CMD> ** routers_cmd = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD> *) * X_MAX); |
---|
135 | soclib::caba::VirtualDspinRouter<WIDTH_RSP> ** routers_rsp = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> **) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP> *) * X_MAX); |
---|
136 | |
---|
137 | for(int i = 0; i < X_MAX; i++ ){ |
---|
138 | routers_cmd[i] = (soclib::caba::VirtualDspinRouter<WIDTH_CMD> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_CMD>) * Y_MAX); |
---|
139 | routers_rsp[i] = (soclib::caba::VirtualDspinRouter<WIDTH_RSP> * ) malloc(sizeof(soclib::caba::VirtualDspinRouter<WIDTH_RSP>) * Y_MAX); |
---|
140 | for(int j = 0; j < Y_MAX; j++){ |
---|
141 | std::ostringstream str0; |
---|
142 | std::ostringstream str1; |
---|
143 | str0 << "VDspinRouterCMD" << i << j; |
---|
144 | str1 << "VDspinRouterRSP" << i << j; |
---|
145 | 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), DSPIN_FIFO, DSPIN_FIFO); |
---|
146 | 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), DSPIN_FIFO, DSPIN_FIFO); |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | /////////////////////////////////////////////////////////////// |
---|
152 | // Components |
---|
153 | /////////////////////////////////////////////////////////////// |
---|
154 | |
---|
155 | // N_CLUSTERS VCI Synthetic Initiator (1 initiator per cluster/network) |
---|
156 | soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c0 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS); |
---|
157 | soclib::caba::VciSyntheticInitiator<vci_param> * initiator_c1 = (soclib::caba::VciSyntheticInitiator<vci_param> *) malloc(sizeof(soclib::caba::VciSyntheticInitiator<vci_param> )* N_CLUSTERS); |
---|
158 | for(int i = 0 ; i < X_MAX; i++) |
---|
159 | for(int j = 0 ; j < Y_MAX ; j++){ |
---|
160 | std::ostringstream str0; |
---|
161 | std::ostringstream str1; |
---|
162 | str0 << "Initiator_c0_" << (i*Y_MAX+j) ; |
---|
163 | str1 << "Initiator_c1_" << (i*Y_MAX+j) ; |
---|
164 | //if( (i == X_MAX-1) && (j == Y_MAX-1)){ |
---|
165 | new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j) ,0), PACKET_LENGTH, 40, 8, X_MAX, Y_MAX); //, 250, 0, X_MAX, 0, Y_MAX); |
---|
166 | new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j) ,0), PACKET_LENGTH, 40, 8, X_MAX, Y_MAX); //, 250, 0, X_MAX, 0, Y_MAX); |
---|
167 | //} else { |
---|
168 | // new(&initiator_c0[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str0.str().c_str() , maptab0, IntTab((i*Y_MAX+j),0), 16, 50, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
169 | // new(&initiator_c1[Y_MAX*i+j]) soclib::caba::VciSyntheticInitiator<vci_param> (str1.str().c_str() , maptab1, IntTab((i*Y_MAX+j),0), 16, 50, 2, X_MAX, Y_MAX); //, 0, 0, 0, 0, 0); |
---|
170 | //} |
---|
171 | } |
---|
172 | |
---|
173 | soclib::caba::VciSimpleRam<vci_param> * ram_c0 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS); |
---|
174 | soclib::caba::VciSimpleRam<vci_param> * ram_c1 = (soclib::caba::VciSimpleRam<vci_param> *) malloc(sizeof(soclib::caba::VciSimpleRam<vci_param>) * N_CLUSTERS); |
---|
175 | for(int i = 0 ; i < X_MAX ; i++) |
---|
176 | for(int j = 0 ; j < Y_MAX ; j++){ |
---|
177 | std::ostringstream str0; |
---|
178 | std::ostringstream str1; |
---|
179 | str0 << "Ram_c0_" << (i*Y_MAX+j) ; |
---|
180 | str1 << "Ram_c1_" << (i*Y_MAX+j) ; |
---|
181 | 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); |
---|
182 | 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); |
---|
183 | } |
---|
184 | |
---|
185 | /////////////////////////////////////////////////////////////// |
---|
186 | // Connection of Synthetic Initiator to each local ring per cluster |
---|
187 | /////////////////////////////////////////////////////////////// |
---|
188 | for(int i = 0 ; i < N_CLUSTERS ; i++){ |
---|
189 | local_ring_c0[i].p_clk(signal_clk); |
---|
190 | local_ring_c0[i].p_resetn(signal_resetn); |
---|
191 | local_ring_c0[i].p_to_initiator[0](signal_vci_ini_synth_c0[0][i]); |
---|
192 | local_ring_c0[i].p_to_target[0](signal_vci_ini_synth_c0[1][i]); |
---|
193 | initiator_c0[i].p_clk(signal_clk); |
---|
194 | initiator_c0[i].p_resetn(signal_resetn); |
---|
195 | initiator_c0[i].p_vci(signal_vci_ini_synth_c0[0][i]); |
---|
196 | ram_c0[i].p_clk(signal_clk); |
---|
197 | ram_c0[i].p_resetn(signal_resetn); |
---|
198 | ram_c0[i].p_vci(signal_vci_ini_synth_c0[1][i]); |
---|
199 | local_ring_c1[i].p_clk(signal_clk); |
---|
200 | local_ring_c1[i].p_resetn(signal_resetn); |
---|
201 | local_ring_c1[i].p_to_initiator[0](signal_vci_ini_synth_c1[0][i]); |
---|
202 | local_ring_c1[i].p_to_target[0](signal_vci_ini_synth_c1[1][i]); |
---|
203 | initiator_c1[i].p_clk(signal_clk); |
---|
204 | initiator_c1[i].p_resetn(signal_resetn); |
---|
205 | initiator_c1[i].p_vci(signal_vci_ini_synth_c1[0][i]); |
---|
206 | ram_c1[i].p_clk(signal_clk); |
---|
207 | ram_c1[i].p_resetn(signal_resetn); |
---|
208 | ram_c1[i].p_vci(signal_vci_ini_synth_c1[1][i]); |
---|
209 | } |
---|
210 | |
---|
211 | /////////////////////////////////////////////////////////////// |
---|
212 | // Connection of each VDspin Router to each local ring and |
---|
213 | // neighbors VDspin Router |
---|
214 | /////////////////////////////////////////////////////////////// |
---|
215 | for(int i = 0; i < X_MAX ; i++){ |
---|
216 | for(int j = 0; j < Y_MAX ; j++){ |
---|
217 | routers_cmd[i][j].p_clk(signal_clk); |
---|
218 | routers_cmd[i][j].p_resetn(signal_resetn); |
---|
219 | routers_rsp[i][j].p_clk(signal_clk); |
---|
220 | routers_rsp[i][j].p_resetn(signal_resetn); |
---|
221 | local_ring_c0[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c0[0][i][j][LOCAL]); |
---|
222 | local_ring_c1[i*Y_MAX+j].p_gate_cmd_in( dspin_signals_cmd_c1[0][i][j][LOCAL]); |
---|
223 | local_ring_c0[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c0[1][i][j][LOCAL]); |
---|
224 | local_ring_c1[i*Y_MAX+j].p_gate_cmd_out(dspin_signals_cmd_c1[1][i][j][LOCAL]); |
---|
225 | local_ring_c0[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c0[0][i][j][LOCAL]); |
---|
226 | local_ring_c1[i*Y_MAX+j].p_gate_rsp_in( dspin_signals_rsp_c1[0][i][j][LOCAL]); |
---|
227 | local_ring_c0[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c0[1][i][j][LOCAL]); |
---|
228 | local_ring_c1[i*Y_MAX+j].p_gate_rsp_out(dspin_signals_rsp_c1[1][i][j][LOCAL]); |
---|
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 | // Simulation Loop // |
---|
308 | //////////////////////////////////////////////// |
---|
309 | int ncycles; |
---|
310 | |
---|
311 | |
---|
312 | if(argc == 2){ |
---|
313 | ncycles = std::atoi(argv[1]); |
---|
314 | } else { |
---|
315 | exit(1); |
---|
316 | } |
---|
317 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
318 | signal_resetn = false; |
---|
319 | |
---|
320 | for(int i = 0; i < X_MAX ; i++){ |
---|
321 | for(int j = 0; j < Y_MAX ; j++){ |
---|
322 | if(j == 0){ |
---|
323 | dspin_signals_cmd_c0[0][i][j][SOUTH].read = true ; |
---|
324 | dspin_signals_cmd_c0[1][i][j][SOUTH].write = false ; |
---|
325 | dspin_signals_cmd_c1[0][i][j][SOUTH].read = true ; |
---|
326 | dspin_signals_cmd_c1[1][i][j][SOUTH].write = false ; |
---|
327 | dspin_signals_rsp_c0[0][i][j][SOUTH].read = true ; |
---|
328 | dspin_signals_rsp_c0[1][i][j][SOUTH].write = false ; |
---|
329 | dspin_signals_rsp_c1[0][i][j][SOUTH].read = true ; |
---|
330 | dspin_signals_rsp_c1[1][i][j][SOUTH].write = false ; |
---|
331 | } |
---|
332 | if(j == Y_MAX-1){ |
---|
333 | dspin_signals_cmd_c0[0][i][j][NORTH].read = true ; |
---|
334 | dspin_signals_cmd_c0[1][i][j][NORTH].write = false ; |
---|
335 | dspin_signals_cmd_c1[0][i][j][NORTH].read = true ; |
---|
336 | dspin_signals_cmd_c1[1][i][j][NORTH].write = false ; |
---|
337 | dspin_signals_rsp_c0[0][i][j][NORTH].read = true ; |
---|
338 | dspin_signals_rsp_c0[1][i][j][NORTH].write = false ; |
---|
339 | dspin_signals_rsp_c1[0][i][j][NORTH].read = true ; |
---|
340 | dspin_signals_rsp_c1[1][i][j][NORTH].write = false ; |
---|
341 | } |
---|
342 | if(i == 0){ |
---|
343 | dspin_signals_cmd_c0[0][i][j][WEST].read = true ; |
---|
344 | dspin_signals_cmd_c0[1][i][j][WEST].write = false ; |
---|
345 | dspin_signals_cmd_c1[0][i][j][WEST].read = true ; |
---|
346 | dspin_signals_cmd_c1[1][i][j][WEST].write = false ; |
---|
347 | dspin_signals_rsp_c0[0][i][j][WEST].read = true ; |
---|
348 | dspin_signals_rsp_c0[1][i][j][WEST].write = false ; |
---|
349 | dspin_signals_rsp_c1[0][i][j][WEST].read = true ; |
---|
350 | dspin_signals_rsp_c1[1][i][j][WEST].write = false ; |
---|
351 | } |
---|
352 | if(i == X_MAX-1){ |
---|
353 | dspin_signals_cmd_c0[0][i][j][EAST].read = true ; |
---|
354 | dspin_signals_cmd_c0[1][i][j][EAST].write = false ; |
---|
355 | dspin_signals_cmd_c1[0][i][j][EAST].read = true ; |
---|
356 | dspin_signals_cmd_c1[1][i][j][EAST].write = false ; |
---|
357 | dspin_signals_rsp_c0[0][i][j][EAST].read = true ; |
---|
358 | dspin_signals_rsp_c0[1][i][j][EAST].write = false ; |
---|
359 | dspin_signals_rsp_c1[0][i][j][EAST].read = true ; |
---|
360 | dspin_signals_rsp_c1[1][i][j][EAST].write = false ; |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
366 | signal_resetn = true; |
---|
367 | |
---|
368 | for(int t = 0; t < ncycles; t++){ |
---|
369 | sc_start(sc_time(1, SC_NS)); |
---|
370 | #if defined(DEBUG) |
---|
371 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
372 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
373 | #endif |
---|
374 | #if DEBUG==1 |
---|
375 | initiator_c0[i*Y_MAX+j].print_trace(); |
---|
376 | std::cout << std::hex; |
---|
377 | std::cout << "synt_cmdval = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].cmdval.read() << std::endl; |
---|
378 | std::cout << "synt_cmdack = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].cmdack.read() << std::endl; |
---|
379 | std::cout << "synt_address = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].address.read() << std::endl; |
---|
380 | std::cout << "synt_cmd = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].cmd.read() << std::endl; |
---|
381 | std::cout << "synt_srcid = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].srcid.read() << std::endl; |
---|
382 | std::cout << "synt_plen = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].plen.read() << std::endl; |
---|
383 | std::cout << "synt_eop = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].eop.read() << std::endl; |
---|
384 | std::cout << "synt_rspval = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].rspval.read() << std::endl; |
---|
385 | std::cout << "synt_rerror = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].rerror.read() << std::endl; |
---|
386 | std::cout << "synt_reop = " << signal_vci_ini_synth_c0[0][i*Y_MAX+j].reop.read() << std::endl; |
---|
387 | ram_c0[i*Y_MAX+j].print_trace(); |
---|
388 | std::cout << std::hex; |
---|
389 | std::cout << "ram_cmdval = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].cmdval.read() << std::endl; |
---|
390 | std::cout << "ram_address = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].address.read() << std::endl; |
---|
391 | std::cout << "ram_cmd = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].cmd.read() << std::endl; |
---|
392 | std::cout << "ram_srcid = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].srcid.read() << std::endl; |
---|
393 | std::cout << "ram_plen = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].plen.read() << std::endl; |
---|
394 | std::cout << "ram_eop = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].eop.read() << std::endl; |
---|
395 | std::cout << "ram_rspval = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].rspval.read() << std::endl; |
---|
396 | std::cout << "ram_rspack = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].rspack.read() << std::endl; |
---|
397 | std::cout << "ram_rsrcid = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].rsrcid.read() << std::endl; |
---|
398 | std::cout << "ram_rerror = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].rerror.read() << std::endl; |
---|
399 | std::cout << "ram_reop = " << signal_vci_ini_synth_c0[1][i*Y_MAX+j].reop.read() << std::endl; |
---|
400 | #endif |
---|
401 | #if DEBUG==2 |
---|
402 | local_ring_c0[i*Y_MAX+j].print_trace(); |
---|
403 | routers_cmd[i][j].print_trace(0); |
---|
404 | std::cout << std::dec << t << " ns" << std::endl; |
---|
405 | routers_rsp[i][j].print_trace(0); |
---|
406 | #endif |
---|
407 | #ifdef DEBUG |
---|
408 | } |
---|
409 | } |
---|
410 | #endif |
---|
411 | |
---|
412 | } |
---|
413 | |
---|
414 | std::cout << "Results : " << std::endl; |
---|
415 | for(int i = 0 ; i < Y_MAX ; i++){ |
---|
416 | for(int j = 0 ; j < X_MAX ; j++){ |
---|
417 | initiator_c0[i*Y_MAX+j].printStats(); |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | |
---|
422 | std::cout << "Simulation Ends" << std::endl; |
---|
423 | |
---|
424 | |
---|
425 | return EXIT_SUCCESS; |
---|
426 | } |
---|
427 | |
---|
428 | int sc_main (int argc, char *argv[]) |
---|
429 | { |
---|
430 | try { |
---|
431 | return _main(argc, argv); |
---|
432 | } catch (std::exception &e) { |
---|
433 | std::cout << e.what() << std::endl; |
---|
434 | } catch (...) { |
---|
435 | std::cout << "Unknown exception occured" << std::endl; |
---|
436 | throw; |
---|
437 | } |
---|
438 | return 1; |
---|
439 | } |
---|
440 | |
---|