1 | ///////////////////////////////////////////////////////////////////////// |
---|
2 | // File: tsarv4_vgmn_generic_32_top.cpp |
---|
3 | // Author: Alain Greiner |
---|
4 | // Copyright: UPMC/LIP6 |
---|
5 | // Date : november 5 2010 |
---|
6 | // This program is released under the GNU public license |
---|
7 | ///////////////////////////////////////////////////////////////////////// |
---|
8 | // This file define a generic TSAR architecture without virtual memory. |
---|
9 | // - It uses the vci_vgmn as global interconnect |
---|
10 | // - It uses the vci_local_crossbar as local interconnect |
---|
11 | // - It uses the vci_cc_xcache (No MMU) |
---|
12 | // The physical address space is 32 bits. |
---|
13 | // The number of clusters cannot be larger than 256. |
---|
14 | // The three parameters are |
---|
15 | // - xmax : number of clusters in a row |
---|
16 | // - ymax : number of clusters in a column |
---|
17 | // - nprocs : number of processor per cluster |
---|
18 | // |
---|
19 | // Each cluster contains nprocs processors, one Memory Cache, |
---|
20 | // and one XICU component. |
---|
21 | // The peripherals BDEV, CDMA, FBUF, MTTY and the boot BROM |
---|
22 | // are in the cluster containing address 0xBFC00000. |
---|
23 | // - The bdev_irq is connected to IRQ_IN[0] |
---|
24 | // - The cdma_irq is connected to IRQ_IN[1] |
---|
25 | // - The tty_irq[i] is connected to IRQ_IN[i+2] |
---|
26 | // For all clusters, the XICU component contains nprocs timers. |
---|
27 | // |
---|
28 | // As we target up to 256 clusters, each cluster can contain |
---|
29 | // at most 16 Mbytes (in a 4Gbytes address space). |
---|
30 | // - Each memory cache contains 9 Mbytes. |
---|
31 | // - The Frame buffer contains 2 Mbytes. |
---|
32 | // - The Boot ROM contains 1 Mbytes. |
---|
33 | // |
---|
34 | // General policy for 32 bits address decoding: |
---|
35 | // To simplifly, all segments base addresses are aligned |
---|
36 | // on 1 Mbyte addresses. Therefore the 12 address MSB bits |
---|
37 | // define the target in the direct address space. |
---|
38 | // In these 12 bits, the (x_width + y_width) MSB bits define |
---|
39 | // the cluster index, and the 4 LSB bits define the local index: |
---|
40 | // |
---|
41 | // | X_ID | Y_ID |---| L_ID | OFFSET | |
---|
42 | // |x_width|y_width|---| 4 | 20 | |
---|
43 | ///////////////////////////////////////////////////////////////////////// |
---|
44 | |
---|
45 | #include <systemc> |
---|
46 | #include <sys/time.h> |
---|
47 | #include <iostream> |
---|
48 | #include <sstream> |
---|
49 | #include <cstdlib> |
---|
50 | #include <cstdarg> |
---|
51 | #include <stdint.h> |
---|
52 | |
---|
53 | #include "mapping_table.h" |
---|
54 | #include "mips32.h" |
---|
55 | #include "vci_simple_ram.h" |
---|
56 | #include "vci_multi_tty.h" |
---|
57 | #include "vci_mem_cache_v4.h" |
---|
58 | #include "vci_cc_xcache_wrapper_v4.h" |
---|
59 | #include "vci_xicu.h" |
---|
60 | #include "vci_vgmn.h" |
---|
61 | #include "vci_local_crossbar.h" |
---|
62 | #include "vci_framebuffer.h" |
---|
63 | #include "vci_dma_tsar_v2.h" |
---|
64 | #include "vci_block_device_tsar_v2.h" |
---|
65 | #include "gdbserver.h" |
---|
66 | |
---|
67 | #define SECTOR_SIZE 2048 |
---|
68 | |
---|
69 | #define FBUF_XSIZE 960 |
---|
70 | #define FBUF_YSIZE 960 |
---|
71 | |
---|
72 | #define N_TTYS 4 |
---|
73 | |
---|
74 | ////////////////////////////////////////////// |
---|
75 | // segments definition in direct space. |
---|
76 | // There is 16 Mbytes address space per cluster. |
---|
77 | // The 8 MSB bits define the cluster index (x,y), |
---|
78 | // even if the number of clusters is less than 256. |
---|
79 | // Each memory cache contains up to 9 Mbytes. |
---|
80 | // There is one MEMC segment and one XICU segment per cluster |
---|
81 | // The peripherals BDEV, FBUF, MTTY, CDMA and the boot BROM |
---|
82 | // are mapped in cluster containing address 0xBFC00000 |
---|
83 | |
---|
84 | #define MEMC_BASE 0x00000000 |
---|
85 | #define MEMC_SIZE 0x00900000 |
---|
86 | |
---|
87 | #define XICU_BASE 0x00900000 |
---|
88 | #define XICU_SIZE 0x00001000 |
---|
89 | |
---|
90 | #define FBUF_BASE 0xBFA00000 |
---|
91 | #define FBUF_SIZE 0x00200000 |
---|
92 | |
---|
93 | #define BROM_BASE 0xBFC00000 |
---|
94 | #define BROM_SIZE 0x00100000 |
---|
95 | |
---|
96 | #define BDEV_BASE 0xBFD00000 |
---|
97 | #define BDEV_SIZE 0x00000100 |
---|
98 | |
---|
99 | #define MTTY_BASE 0xBFE00000 |
---|
100 | #define MTTY_SIZE 0x00000100 |
---|
101 | |
---|
102 | #define CDMA_BASE 0xBFF00000 |
---|
103 | #define CDMA_SIZE 0x00000100 |
---|
104 | |
---|
105 | /* Pour ALMOS |
---|
106 | |
---|
107 | #define BOOT_INFO_BLOCK 0xbfc08000 |
---|
108 | #define KERNEL_BIN_IMG 0xbfc10000 |
---|
109 | |
---|
110 | */ |
---|
111 | |
---|
112 | //////////////////////////////////////////////////////////////////// |
---|
113 | // TGTID & SRCID definition in direct space |
---|
114 | // For all components: global TGTID = global SRCID = cluster_index |
---|
115 | // For processors, the local SRCID is between 0 & nprocs-1 |
---|
116 | |
---|
117 | #define MEMC_TGTID 0 |
---|
118 | #define XICU_TGTID 1 |
---|
119 | #define FBUF_TGTID 2 |
---|
120 | #define MTTY_TGTID 3 |
---|
121 | #define BROM_TGTID 4 |
---|
122 | #define BDEV_TGTID 5 |
---|
123 | #define CDMA_TGTID 6 |
---|
124 | |
---|
125 | #define PROC_SRCID 0 |
---|
126 | #define BDEV_SRCID nprocs |
---|
127 | #define CDMA_SRCID (nprocs+1) |
---|
128 | |
---|
129 | //////////////////////////////////////////////////////// |
---|
130 | // TGTID & SRCID definition in coherence space |
---|
131 | // For all components: global TGTID = global SRCID = cluster_index |
---|
132 | // For MEMC : local SRCID = local TGTID = nprocs |
---|
133 | // For processors : local SRCID = local TGTID = PROC_ID |
---|
134 | |
---|
135 | ////////////////////// |
---|
136 | // Router ports index |
---|
137 | |
---|
138 | #define NORTH 0 |
---|
139 | #define SOUTH 1 |
---|
140 | #define EAST 2 |
---|
141 | #define WEST 3 |
---|
142 | #define LOCAL 4 |
---|
143 | |
---|
144 | /////////////// |
---|
145 | // VCI format |
---|
146 | #define cell_width 4 |
---|
147 | #define address_width 32 |
---|
148 | #define plen_width 8 |
---|
149 | #define error_width 1 |
---|
150 | #define clen_width 1 |
---|
151 | #define rflag_width 1 |
---|
152 | #define srcid_width 14 |
---|
153 | #define pktid_width 4 |
---|
154 | #define trdid_width 4 |
---|
155 | #define wrplen_width 1 |
---|
156 | |
---|
157 | // cluster index (computed from x,y coordinates) |
---|
158 | #define cluster(x,y) (y + ymax*x) |
---|
159 | |
---|
160 | ///////////////////////////////// |
---|
161 | int _main(int argc, char *argv[]) |
---|
162 | { |
---|
163 | using namespace sc_core; |
---|
164 | using namespace soclib::caba; |
---|
165 | using namespace soclib::common; |
---|
166 | |
---|
167 | char soft_name[128] = "undefined_binary_code"; // pathname to binary code |
---|
168 | char disk_name[128] = "undefined_disk_image"; // pathname to the disk image |
---|
169 | size_t ncycles = 1000000000; // simulated cycles |
---|
170 | size_t xmax = 2; // number of clusters in a row |
---|
171 | size_t ymax = 2; // number of clusters in a column |
---|
172 | size_t nprocs = 1; // number of processors per cluster |
---|
173 | bool debug_ok = false; // debug activated |
---|
174 | size_t from_cycle = 0; // debug start cycle |
---|
175 | size_t to_cycle = 1000000000; // debug end cycle |
---|
176 | |
---|
177 | ////////////// command line arguments ////////////////////// |
---|
178 | if (argc > 1) |
---|
179 | { |
---|
180 | for( int n=1 ; n<argc ; n=n+2 ) |
---|
181 | { |
---|
182 | if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) ) |
---|
183 | { |
---|
184 | ncycles = atoi(argv[n+1]); |
---|
185 | } |
---|
186 | else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) ) |
---|
187 | { |
---|
188 | nprocs = atoi(argv[n+1]); |
---|
189 | assert( (nprocs <= 8) && "The number of processors per cluster cannot be larger than 8"); |
---|
190 | } |
---|
191 | else if( (strcmp(argv[n],"-XMAX") == 0) && (n+1<argc) ) |
---|
192 | { |
---|
193 | xmax = atoi(argv[n+1]); |
---|
194 | assert( ((xmax >= 2) && (xmax <= 16)) |
---|
195 | && "The XMAX parameter (number of clusters in a row) must be in the range [2,16]" ); |
---|
196 | } |
---|
197 | else if( (strcmp(argv[n],"-YMAX") == 0) && (n+1<argc) ) |
---|
198 | { |
---|
199 | ymax = atoi(argv[n+1]); |
---|
200 | assert( ((ymax >= 2) && (ymax <= 16)) |
---|
201 | && "The YMAX parameter (number of clusters in a column) must be in the range [2,16]" ); |
---|
202 | } |
---|
203 | else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) ) |
---|
204 | { |
---|
205 | strcpy(soft_name, argv[n+1]); |
---|
206 | } |
---|
207 | else if( (strcmp(argv[n],"-DISK") == 0) && (n+1<argc) ) |
---|
208 | { |
---|
209 | strcpy(disk_name, argv[n+1]); |
---|
210 | } |
---|
211 | else if( (strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) ) |
---|
212 | { |
---|
213 | debug_ok = true; |
---|
214 | from_cycle = atoi(argv[n+1]); |
---|
215 | } |
---|
216 | else if( (strcmp(argv[n],"-TOCYCLE") == 0) && (n+1<argc) ) |
---|
217 | { |
---|
218 | to_cycle = atoi(argv[n+1]); |
---|
219 | } |
---|
220 | else |
---|
221 | { |
---|
222 | std::cout << " Arguments on the command line are (key,value) couples." << std::endl; |
---|
223 | std::cout << " The order is not important." << std::endl; |
---|
224 | std::cout << " Accepted arguments are :" << std::endl << std::endl; |
---|
225 | std::cout << " -SOFT elf_file_name" << std::endl; |
---|
226 | std::cout << " -DISK disk_image_file_name" << std::endl; |
---|
227 | std::cout << " -NCYCLES number_of_simulated_cycles" << std::endl; |
---|
228 | std::cout << " -NPROCS number_of_processors_per_cluster" << std::endl; |
---|
229 | std::cout << " -XMAX number_of_clusters_in_a_row" << std::endl; |
---|
230 | std::cout << " -YMAX number_of_clusters_in_a_column" << std::endl; |
---|
231 | std::cout << " -DEBUG debug_start_cycle" << std::endl; |
---|
232 | std::cout << " -TOCYCLE debug_end_cycle" << std::endl; |
---|
233 | exit(0); |
---|
234 | } |
---|
235 | } |
---|
236 | } |
---|
237 | |
---|
238 | std::cout << std::endl << "*********** TSAR ARCHITECTURE **************" << std::endl |
---|
239 | << " - Interconnect = VGMN & CROSSBAR" << std::endl |
---|
240 | << " - Number of clusters = " << xmax << " * " << ymax << std::endl |
---|
241 | << " - Number of processors per cluster = " << nprocs << std::endl |
---|
242 | << "**********************************************" << std::endl |
---|
243 | << std::endl; |
---|
244 | |
---|
245 | |
---|
246 | // Define VCI parameters |
---|
247 | typedef soclib::caba::VciParams<cell_width, |
---|
248 | plen_width, |
---|
249 | address_width, |
---|
250 | error_width, |
---|
251 | clen_width, |
---|
252 | rflag_width, |
---|
253 | srcid_width, |
---|
254 | pktid_width, |
---|
255 | trdid_width, |
---|
256 | wrplen_width> vci_param; |
---|
257 | |
---|
258 | size_t cluster_io_index; |
---|
259 | size_t x_width; |
---|
260 | size_t y_width; |
---|
261 | |
---|
262 | if (xmax == 2) x_width = 1; |
---|
263 | else if (xmax <= 4) x_width = 2; |
---|
264 | else if (xmax <= 8) x_width = 3; |
---|
265 | else x_width = 4; |
---|
266 | |
---|
267 | if (ymax == 2) y_width = 1; |
---|
268 | else if (ymax <= 4) y_width = 2; |
---|
269 | else if (ymax <= 8) y_width = 3; |
---|
270 | else y_width = 4; |
---|
271 | |
---|
272 | cluster_io_index = 0xBF >> (8 - x_width - y_width); |
---|
273 | |
---|
274 | ///////////////////// |
---|
275 | // Mapping Tables |
---|
276 | ///////////////////// |
---|
277 | |
---|
278 | // direct network |
---|
279 | MappingTable maptabd(address_width, |
---|
280 | IntTab(x_width + y_width, 12 - x_width - y_width), |
---|
281 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
282 | 0x00F00000); |
---|
283 | for ( size_t x = 0 ; x < xmax ; x++) |
---|
284 | { |
---|
285 | for ( size_t y = 0 ; y < ymax ; y++) |
---|
286 | { |
---|
287 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
288 | std::ostringstream sm; |
---|
289 | sm << "d_seg_memc_" << x << "_" << y; |
---|
290 | maptabd.add(Segment(sm.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y),MEMC_TGTID), true)); |
---|
291 | std::ostringstream si; |
---|
292 | si << "d_seg_xicu_" << x << "_" << y; |
---|
293 | maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, IntTab(cluster(x,y),XICU_TGTID), false)); |
---|
294 | if ( cluster(x,y) == cluster_io_index ) |
---|
295 | { |
---|
296 | maptabd.add(Segment("d_seg_fbuf", FBUF_BASE, FBUF_SIZE, IntTab(cluster(x,y),FBUF_TGTID), false)); |
---|
297 | maptabd.add(Segment("d_seg_bdev", BDEV_BASE, BDEV_SIZE, IntTab(cluster(x,y),BDEV_TGTID), false)); |
---|
298 | maptabd.add(Segment("d_seg_mtty", MTTY_BASE, MTTY_SIZE, IntTab(cluster(x,y),MTTY_TGTID), false)); |
---|
299 | maptabd.add(Segment("d_seg_brom", BROM_BASE, BROM_SIZE, IntTab(cluster(x,y),BROM_TGTID), true)); |
---|
300 | maptabd.add(Segment("d_seg_cdma", CDMA_BASE, CDMA_SIZE, IntTab(cluster(x,y),CDMA_TGTID), false)); |
---|
301 | } |
---|
302 | } |
---|
303 | } |
---|
304 | std::cout << maptabd << std::endl; |
---|
305 | |
---|
306 | // coherence network |
---|
307 | MappingTable maptabc(address_width, |
---|
308 | IntTab(x_width + y_width, 12 - x_width - y_width), |
---|
309 | IntTab(x_width + y_width, srcid_width - x_width - y_width), |
---|
310 | 0xF0000000); |
---|
311 | |
---|
312 | for ( size_t x = 0 ; x < xmax ; x++) |
---|
313 | { |
---|
314 | for ( size_t y = 0 ; y < ymax ; y++) |
---|
315 | { |
---|
316 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
317 | |
---|
318 | std::ostringstream sm; |
---|
319 | sm << "c_seg_memc_" << x << "_" << y; |
---|
320 | maptabc.add(Segment(sm.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y), nprocs), false)); |
---|
321 | // the segment base and size will be modified |
---|
322 | // when the segmentation of the coherence space will be simplified |
---|
323 | |
---|
324 | if ( cluster(x,y) == cluster_io_index ) |
---|
325 | { |
---|
326 | std::ostringstream sr; |
---|
327 | sr << "c_seg_brom_" << x << "_" << y; |
---|
328 | maptabc.add(Segment(sr.str(), BROM_BASE, BROM_SIZE, IntTab(cluster(x,y), nprocs), false)); |
---|
329 | } |
---|
330 | |
---|
331 | sc_uint<address_width> avoid_collision = 0; |
---|
332 | for ( size_t p = 0 ; p < nprocs ; p++) |
---|
333 | { |
---|
334 | sc_uint<address_width> base = MEMC_SIZE + (p*0x100000) + offset; |
---|
335 | // the following test is to avoid a collision between the c_seg_brom segment |
---|
336 | // and a c_seg_proc segment (all segments base addresses being multiple of 1Mbytes) |
---|
337 | if ( base == BROM_BASE ) avoid_collision = 0x100000; |
---|
338 | std::ostringstream sp; |
---|
339 | sp << "c_seg_proc_" << x << "_" << y << "_" << p; |
---|
340 | maptabc.add(Segment(sp.str(), base + avoid_collision, 0x20, IntTab(cluster(x,y), p), false, |
---|
341 | true, IntTab(cluster(x,y), p))); |
---|
342 | // the two last arguments will be removed |
---|
343 | // when the segmentation of the coherence space will be simplified |
---|
344 | } |
---|
345 | } |
---|
346 | } |
---|
347 | std::cout << maptabc << std::endl; |
---|
348 | |
---|
349 | // external network |
---|
350 | MappingTable maptabx(address_width, IntTab(1), IntTab(10), 0xF0000000); |
---|
351 | |
---|
352 | for ( size_t x = 0 ; x < xmax ; x++) |
---|
353 | { |
---|
354 | for ( size_t y = 0 ; y < ymax ; y++) |
---|
355 | { |
---|
356 | sc_uint<address_width> offset = cluster(x,y) << (address_width-x_width-y_width); |
---|
357 | std::ostringstream sx; |
---|
358 | |
---|
359 | sx << "seg_xram_" << x << "_" << y; |
---|
360 | maptabx.add(Segment(sx.str(), MEMC_BASE + offset, MEMC_SIZE, IntTab(0), false)); |
---|
361 | } |
---|
362 | } |
---|
363 | std::cout << maptabx << std::endl; |
---|
364 | |
---|
365 | //////////////////// |
---|
366 | // Signals |
---|
367 | /////////////////// |
---|
368 | |
---|
369 | sc_clock signal_clk("clk"); |
---|
370 | sc_signal<bool> signal_resetn("resetn"); |
---|
371 | sc_signal<bool> signal_false; |
---|
372 | |
---|
373 | // IRQ signals (one signal per proc) |
---|
374 | sc_signal<bool>*** signal_proc_it = |
---|
375 | alloc_elems<sc_signal<bool> >("signal_proc_it", xmax, ymax, nprocs); |
---|
376 | |
---|
377 | sc_signal<bool>* signal_irq_mtty = |
---|
378 | alloc_elems<sc_signal<bool> >("signal_irq_mtty", N_TTYS); |
---|
379 | |
---|
380 | sc_signal<bool> signal_irq_bdev; |
---|
381 | sc_signal<bool> signal_irq_cdma; |
---|
382 | |
---|
383 | // Direct VCI signals |
---|
384 | |
---|
385 | VciSignals<vci_param>*** signal_vci_ini_d_proc = |
---|
386 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_d_proc", xmax, ymax, nprocs); |
---|
387 | |
---|
388 | VciSignals<vci_param>** signal_vci_tgt_d_memc = |
---|
389 | alloc_elems<VciSignals<vci_param> >("signal_vci_tgt_d_memc", xmax, ymax); |
---|
390 | |
---|
391 | VciSignals<vci_param>** signal_vci_tgt_d_xicu = |
---|
392 | alloc_elems<VciSignals<vci_param> >("signal_vci_tgt_d_xicu", xmax, ymax); |
---|
393 | |
---|
394 | VciSignals<vci_param>** signal_vci_l2g_d = |
---|
395 | alloc_elems<VciSignals<vci_param> >("signal_vci_l2g_d", xmax, ymax); |
---|
396 | |
---|
397 | VciSignals<vci_param>** signal_vci_g2l_d = |
---|
398 | alloc_elems<VciSignals<vci_param> >("signal_vci_g2l_d", xmax, ymax); |
---|
399 | |
---|
400 | VciSignals<vci_param> signal_vci_tgt_d_mtty("signal_vci_tgt_d_mtty"); |
---|
401 | VciSignals<vci_param> signal_vci_tgt_d_brom("signal_vci_tgt_d_brom"); |
---|
402 | VciSignals<vci_param> signal_vci_tgt_d_bdev("signal_vci_tgt_d_bdev"); |
---|
403 | VciSignals<vci_param> signal_vci_tgt_d_fbuf("signal_vci_tgt_d_fbuf"); |
---|
404 | VciSignals<vci_param> signal_vci_tgt_d_cdma("signal_vci_tgt_d_cdma"); |
---|
405 | |
---|
406 | VciSignals<vci_param> signal_vci_ini_d_bdev("signal_vci_ini_d_bdev"); |
---|
407 | VciSignals<vci_param> signal_vci_ini_d_cdma("signal_vci_ini_d_cdma"); |
---|
408 | |
---|
409 | // Coherence VCI signals |
---|
410 | |
---|
411 | VciSignals<vci_param>*** signal_vci_ini_c_proc = |
---|
412 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_c_proc", xmax, ymax, nprocs); |
---|
413 | |
---|
414 | VciSignals<vci_param>*** signal_vci_tgt_c_proc = |
---|
415 | alloc_elems<VciSignals<vci_param> >("signal_vci_tgt_c_proc", xmax, ymax, nprocs); |
---|
416 | |
---|
417 | VciSignals<vci_param>** signal_vci_ini_c_memc = |
---|
418 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_c_memc", xmax, ymax); |
---|
419 | |
---|
420 | VciSignals<vci_param>** signal_vci_tgt_c_memc = |
---|
421 | alloc_elems<VciSignals<vci_param> >("signal_vci_tgt_c_memc", xmax, ymax); |
---|
422 | |
---|
423 | VciSignals<vci_param>** signal_vci_l2g_c = |
---|
424 | alloc_elems<VciSignals<vci_param> >("signal_vci_l2g_c", xmax, ymax); |
---|
425 | |
---|
426 | VciSignals<vci_param>** signal_vci_g2l_c = |
---|
427 | alloc_elems<VciSignals<vci_param> >("signal_vci_g2l_c", xmax, ymax); |
---|
428 | |
---|
429 | // Xternal network VCI signals |
---|
430 | |
---|
431 | VciSignals<vci_param> signal_vci_tgt_x_xram("signal_vci_tgt_x_xram"); |
---|
432 | VciSignals<vci_param>** signal_vci_ini_x_memc = |
---|
433 | alloc_elems<VciSignals<vci_param> >("signal_vci_ini_x_memc", xmax, ymax); |
---|
434 | |
---|
435 | //////////////////////////// |
---|
436 | // Components |
---|
437 | //////////////////////////// |
---|
438 | |
---|
439 | typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss; |
---|
440 | |
---|
441 | soclib::common::Loader loader(soft_name); |
---|
442 | proc_iss::set_loader(loader); |
---|
443 | |
---|
444 | /* code specifique ALMOS pour chargement du binaire |
---|
445 | |
---|
446 | #define _TO_STR(_str) #_str |
---|
447 | #define TO_STR(_str) _TO_STR(_str) |
---|
448 | |
---|
449 | soclib::common::Loader loader("bootloader.bin", |
---|
450 | "arch-info.bin@"TO_STR(BOOT_INFO_BLOCK)":D", |
---|
451 | "kernel-soclib.bin@"TO_STR(KERNEL_BIN_IMG)":D"); |
---|
452 | */ |
---|
453 | |
---|
454 | // External RAM |
---|
455 | VciSimpleRam<vci_param> xram( |
---|
456 | "xram", |
---|
457 | IntTab(0), |
---|
458 | maptabx, |
---|
459 | loader); |
---|
460 | |
---|
461 | // Direct network |
---|
462 | VciVgmn<vci_param> dnoc( |
---|
463 | "dnoc", |
---|
464 | maptabd, |
---|
465 | xmax*ymax, |
---|
466 | xmax*ymax, |
---|
467 | 2, 2); |
---|
468 | |
---|
469 | // Coherence network |
---|
470 | VciVgmn<vci_param> cnoc( |
---|
471 | "cnoc", |
---|
472 | maptabc, |
---|
473 | xmax*ymax, |
---|
474 | xmax*ymax, |
---|
475 | 2, 2); |
---|
476 | |
---|
477 | // External network |
---|
478 | VciVgmn<vci_param> xnoc( |
---|
479 | "xnoc", |
---|
480 | maptabx, |
---|
481 | xmax*ymax, |
---|
482 | 1, |
---|
483 | 2, 2); |
---|
484 | |
---|
485 | // Peripherals : TTY, Frame Buffer, Block Device, Boot ROM, & DMA |
---|
486 | VciSimpleRam<vci_param> brom( |
---|
487 | "brom", |
---|
488 | IntTab(cluster_io_index, BROM_TGTID), |
---|
489 | maptabd, |
---|
490 | loader); |
---|
491 | |
---|
492 | VciMultiTty<vci_param> mtty( |
---|
493 | "mtty", |
---|
494 | IntTab(cluster_io_index, MTTY_TGTID), |
---|
495 | maptabd, |
---|
496 | "tty0","tty1","tty2","tty3",NULL); |
---|
497 | |
---|
498 | VciFrameBuffer<vci_param> fbuf( |
---|
499 | "fbuf", |
---|
500 | IntTab(cluster_io_index, FBUF_TGTID), |
---|
501 | maptabd, |
---|
502 | FBUF_XSIZE, |
---|
503 | FBUF_YSIZE); |
---|
504 | |
---|
505 | VciBlockDeviceTsarV2<vci_param> bdev( |
---|
506 | "bdev", |
---|
507 | maptabd, |
---|
508 | IntTab(cluster_io_index, BDEV_SRCID), // SRCID_D |
---|
509 | IntTab(cluster_io_index, BDEV_TGTID), // TGTID_D |
---|
510 | disk_name, |
---|
511 | SECTOR_SIZE); |
---|
512 | |
---|
513 | VciDmaTsarV2<vci_param> cdma( |
---|
514 | "cdma", |
---|
515 | maptabd, |
---|
516 | IntTab(cluster_io_index,CDMA_SRCID), // SRCID_D |
---|
517 | IntTab(cluster_io_index,CDMA_TGTID), // TGTID_D |
---|
518 | 64); |
---|
519 | |
---|
520 | // processors (nprocs per cluster) |
---|
521 | |
---|
522 | VciCcXCacheWrapperV4<vci_param, proc_iss> *proc[xmax][ymax][nprocs]; |
---|
523 | |
---|
524 | for( size_t x = 0 ; x < xmax ; x++ ) |
---|
525 | { |
---|
526 | for( size_t y = 0 ; y < ymax ; y++ ) |
---|
527 | { |
---|
528 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
529 | { |
---|
530 | |
---|
531 | std::ostringstream sp; |
---|
532 | sp << "proc_" << x << "_" << y << "_" << p; |
---|
533 | |
---|
534 | proc[x][y][p] = new VciCcXCacheWrapperV4<vci_param, proc_iss>( |
---|
535 | sp.str().c_str(), |
---|
536 | p+nprocs*cluster(x,y), |
---|
537 | maptabd, maptabc, |
---|
538 | IntTab(cluster(x,y), PROC_SRCID+p), // SRCID_D |
---|
539 | IntTab(cluster(x,y), PROC_SRCID+p), // SRCID_C |
---|
540 | IntTab(cluster(x,y), PROC_SRCID+p), // TGTID_C |
---|
541 | 4,64,16,4,64,16 // Icache and Dcache sizes |
---|
542 | ,4,8,16 |
---|
543 | ); |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | |
---|
548 | // memory caches (one per cluster) |
---|
549 | VciMemCacheV4<vci_param>* memc[xmax][ymax]; |
---|
550 | |
---|
551 | for( size_t x = 0 ; x < xmax ; x++ ) |
---|
552 | { |
---|
553 | for( size_t y = 0 ; y < ymax ; y++ ) |
---|
554 | { |
---|
555 | std::ostringstream sm; |
---|
556 | sm << "memc_" << x << "_" << y; |
---|
557 | |
---|
558 | memc[x][y] = new VciMemCacheV4<vci_param>( |
---|
559 | sm.str().c_str(), |
---|
560 | maptabd, maptabc, maptabx, |
---|
561 | IntTab(cluster(x,y)), // SRCID_X |
---|
562 | IntTab(cluster(x,y), nprocs), // SRCID_C |
---|
563 | IntTab(cluster(x,y), MEMC_TGTID), // TGTID_D |
---|
564 | IntTab(cluster(x,y), nprocs), // TGTID_C |
---|
565 | 16,256,16, // CACHE SIZE |
---|
566 | 4096); // HEAP SIZE |
---|
567 | } |
---|
568 | } |
---|
569 | |
---|
570 | // XICU (one per cluster) |
---|
571 | VciXicu<vci_param> *xicu[xmax][ymax]; |
---|
572 | |
---|
573 | for( size_t x = 0 ; x < xmax ; x++ ) |
---|
574 | { |
---|
575 | for( size_t y = 0 ; y < ymax ; y++ ) |
---|
576 | { |
---|
577 | std::ostringstream si; |
---|
578 | si << "xicu_" << x << "_" << y; |
---|
579 | size_t nhwi; |
---|
580 | if ( cluster(x,y) == cluster_io_index ) nhwi = N_TTYS + 2; |
---|
581 | else nhwi = 0; |
---|
582 | xicu[x][y] = new VciXicu<vci_param>( |
---|
583 | si.str().c_str(), |
---|
584 | maptabd, |
---|
585 | IntTab(cluster(x,y), XICU_TGTID), // TGTID_D |
---|
586 | nprocs, // number of TIMERS |
---|
587 | nhwi, // number of hard IRQs |
---|
588 | nprocs, // number of soft IRQs |
---|
589 | nprocs); // number of output IRQ lines |
---|
590 | } |
---|
591 | } |
---|
592 | |
---|
593 | // Local interconnects : one direct crossbar & one coherence crossbar per cluster |
---|
594 | VciLocalCrossbar<vci_param>* dxbar[xmax][ymax]; |
---|
595 | |
---|
596 | VciLocalCrossbar<vci_param>* cxbar[xmax][ymax]; |
---|
597 | |
---|
598 | for( size_t x = 0 ; x < xmax ; x++ ) |
---|
599 | { |
---|
600 | for( size_t y = 0 ; y < ymax ; y++ ) |
---|
601 | { |
---|
602 | std::ostringstream sd; |
---|
603 | sd << "dxbar_" << x << "_" << y; |
---|
604 | size_t nb_direct_initiators = nprocs; |
---|
605 | size_t nb_direct_targets = 2; |
---|
606 | if ( cluster(x,y) == cluster_io_index ) |
---|
607 | { |
---|
608 | nb_direct_initiators = nprocs + 2; |
---|
609 | nb_direct_targets = 7; |
---|
610 | } |
---|
611 | dxbar[x][y] = new VciLocalCrossbar<vci_param>( |
---|
612 | sd.str().c_str(), |
---|
613 | maptabd, |
---|
614 | IntTab(cluster(x,y)), // global initiator index |
---|
615 | IntTab(cluster(x,y)), // global target index |
---|
616 | nb_direct_initiators, // number of initiators |
---|
617 | nb_direct_targets); // number of targets |
---|
618 | |
---|
619 | std::ostringstream sc; |
---|
620 | sc << "cxbar_" << x << "_" << y; |
---|
621 | cxbar[x][y] = new VciLocalCrossbar<vci_param>( |
---|
622 | sc.str().c_str(), |
---|
623 | maptabc, |
---|
624 | IntTab(cluster(x,y)), // global initiator index |
---|
625 | IntTab(cluster(x,y)), // global target index |
---|
626 | nprocs+1, // number of initiators |
---|
627 | nprocs+1); // number of targets |
---|
628 | } |
---|
629 | } |
---|
630 | |
---|
631 | std::cout << "all components created" << std::endl; |
---|
632 | |
---|
633 | /////////////////////////////////////////////////////////////// |
---|
634 | // Net-list |
---|
635 | /////////////////////////////////////////////////////////////// |
---|
636 | |
---|
637 | // External Ram (one instance) |
---|
638 | xram.p_clk (signal_clk); |
---|
639 | xram.p_resetn (signal_resetn); |
---|
640 | xram.p_vci (signal_vci_tgt_x_xram); |
---|
641 | |
---|
642 | // External Network (one instance) |
---|
643 | xnoc.p_clk (signal_clk); |
---|
644 | xnoc.p_resetn (signal_resetn); |
---|
645 | xnoc.p_to_target[0] (signal_vci_tgt_x_xram); |
---|
646 | for ( size_t x = 0 ; x < xmax ; x++ ) |
---|
647 | { |
---|
648 | for ( size_t y = 0 ; y < ymax ; y++ ) |
---|
649 | { |
---|
650 | xnoc.p_to_initiator[cluster(x,y)] (signal_vci_ini_x_memc[x][y]); |
---|
651 | } |
---|
652 | } |
---|
653 | |
---|
654 | // Direct Network (one instance) |
---|
655 | dnoc.p_clk (signal_clk); |
---|
656 | dnoc.p_resetn (signal_resetn); |
---|
657 | for ( size_t x = 0 ; x < xmax ; x++ ) |
---|
658 | { |
---|
659 | for ( size_t y = 0 ; y < ymax ; y++ ) |
---|
660 | { |
---|
661 | dnoc.p_to_initiator[cluster(x,y)] (signal_vci_l2g_d[x][y]); |
---|
662 | dnoc.p_to_target[cluster(x,y)] (signal_vci_g2l_d[x][y]); |
---|
663 | } |
---|
664 | } |
---|
665 | |
---|
666 | // Coherence Network (one instance) |
---|
667 | cnoc.p_clk (signal_clk); |
---|
668 | cnoc.p_resetn (signal_resetn); |
---|
669 | for ( size_t x = 0 ; x < xmax ; x++ ) |
---|
670 | { |
---|
671 | for ( size_t y = 0 ; y < ymax ; y++ ) |
---|
672 | { |
---|
673 | cnoc.p_to_initiator[cluster(x,y)] (signal_vci_l2g_c[x][y]); |
---|
674 | cnoc.p_to_target[cluster(x,y)] (signal_vci_g2l_c[x][y]); |
---|
675 | } |
---|
676 | } |
---|
677 | |
---|
678 | // Distributed components (in clusters) |
---|
679 | |
---|
680 | for ( size_t x = 0 ; x < xmax ; x++ ) |
---|
681 | { |
---|
682 | for ( size_t y = 0 ; y < ymax ; y++ ) |
---|
683 | { |
---|
684 | // direct local crossbar |
---|
685 | dxbar[x][y]->p_clk (signal_clk); |
---|
686 | dxbar[x][y]->p_resetn (signal_resetn); |
---|
687 | dxbar[x][y]->p_initiator_to_up (signal_vci_l2g_d[x][y]); |
---|
688 | dxbar[x][y]->p_target_to_up (signal_vci_g2l_d[x][y]); |
---|
689 | dxbar[x][y]->p_to_target[MEMC_TGTID] (signal_vci_tgt_d_memc[x][y]); |
---|
690 | dxbar[x][y]->p_to_target[XICU_TGTID] (signal_vci_tgt_d_xicu[x][y]); |
---|
691 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
692 | { |
---|
693 | dxbar[x][y]->p_to_initiator[p] (signal_vci_ini_d_proc[x][y][p]); |
---|
694 | } |
---|
695 | |
---|
696 | // coherence local crossbar |
---|
697 | cxbar[x][y]->p_clk (signal_clk); |
---|
698 | cxbar[x][y]->p_resetn (signal_resetn); |
---|
699 | cxbar[x][y]->p_initiator_to_up (signal_vci_l2g_c[x][y]); |
---|
700 | cxbar[x][y]->p_target_to_up (signal_vci_g2l_c[x][y]); |
---|
701 | cxbar[x][y]->p_to_initiator[nprocs] (signal_vci_ini_c_memc[x][y]); |
---|
702 | cxbar[x][y]->p_to_target[nprocs] (signal_vci_tgt_c_memc[x][y]); |
---|
703 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
704 | { |
---|
705 | cxbar[x][y]->p_to_initiator[p] (signal_vci_ini_c_proc[x][y][p]); |
---|
706 | cxbar[x][y]->p_to_target[p] (signal_vci_tgt_c_proc[x][y][p]); |
---|
707 | } |
---|
708 | |
---|
709 | // Processors |
---|
710 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
711 | { |
---|
712 | proc[x][y][p]->p_clk (signal_clk); |
---|
713 | proc[x][y][p]->p_resetn (signal_resetn); |
---|
714 | proc[x][y][p]->p_vci_ini_rw (signal_vci_ini_d_proc[x][y][p]); |
---|
715 | proc[x][y][p]->p_vci_ini_c (signal_vci_ini_c_proc[x][y][p]); |
---|
716 | proc[x][y][p]->p_vci_tgt (signal_vci_tgt_c_proc[x][y][p]); |
---|
717 | proc[x][y][p]->p_irq[0] (signal_proc_it[x][y][p]); |
---|
718 | for ( size_t j = 1 ; j < 6 ; j++ ) |
---|
719 | { |
---|
720 | proc[x][y][p]->p_irq[j] (signal_false); |
---|
721 | } |
---|
722 | } |
---|
723 | |
---|
724 | // XICU |
---|
725 | xicu[x][y]->p_clk (signal_clk); |
---|
726 | xicu[x][y]->p_resetn (signal_resetn); |
---|
727 | xicu[x][y]->p_vci (signal_vci_tgt_d_xicu[x][y]); |
---|
728 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
729 | { |
---|
730 | xicu[x][y]->p_irq[p] (signal_proc_it[x][y][p]); |
---|
731 | } |
---|
732 | |
---|
733 | // MEMC |
---|
734 | memc[x][y]->p_clk (signal_clk); |
---|
735 | memc[x][y]->p_resetn (signal_resetn); |
---|
736 | memc[x][y]->p_vci_tgt (signal_vci_tgt_d_memc[x][y]); |
---|
737 | memc[x][y]->p_vci_ini (signal_vci_ini_c_memc[x][y]); |
---|
738 | memc[x][y]->p_vci_tgt_cleanup (signal_vci_tgt_c_memc[x][y]); |
---|
739 | memc[x][y]->p_vci_ixr (signal_vci_ini_x_memc[x][y]); |
---|
740 | |
---|
741 | // I/O peripherals |
---|
742 | if ( cluster(x,y) == cluster_io_index ) |
---|
743 | { |
---|
744 | bdev.p_clk (signal_clk); |
---|
745 | bdev.p_resetn (signal_resetn); |
---|
746 | bdev.p_irq (signal_irq_bdev); |
---|
747 | bdev.p_vci_target (signal_vci_tgt_d_bdev); |
---|
748 | bdev.p_vci_initiator (signal_vci_ini_d_bdev); |
---|
749 | |
---|
750 | cdma.p_clk (signal_clk); |
---|
751 | cdma.p_resetn (signal_resetn); |
---|
752 | cdma.p_irq (signal_irq_cdma); |
---|
753 | cdma.p_vci_target (signal_vci_tgt_d_cdma); |
---|
754 | cdma.p_vci_initiator (signal_vci_ini_d_cdma); |
---|
755 | |
---|
756 | fbuf.p_clk (signal_clk); |
---|
757 | fbuf.p_resetn (signal_resetn); |
---|
758 | fbuf.p_vci (signal_vci_tgt_d_fbuf); |
---|
759 | |
---|
760 | brom.p_clk (signal_clk); |
---|
761 | brom.p_resetn (signal_resetn); |
---|
762 | brom.p_vci (signal_vci_tgt_d_brom); |
---|
763 | |
---|
764 | mtty.p_clk (signal_clk); |
---|
765 | mtty.p_resetn (signal_resetn); |
---|
766 | mtty.p_vci (signal_vci_tgt_d_mtty); |
---|
767 | for(size_t i=0 ; i<N_TTYS ; i++) |
---|
768 | { |
---|
769 | mtty.p_irq[i] (signal_irq_mtty[i]); |
---|
770 | } |
---|
771 | |
---|
772 | dxbar[x][y]->p_to_target[BROM_TGTID] (signal_vci_tgt_d_brom); |
---|
773 | dxbar[x][y]->p_to_target[MTTY_TGTID] (signal_vci_tgt_d_mtty); |
---|
774 | dxbar[x][y]->p_to_target[BDEV_TGTID] (signal_vci_tgt_d_bdev); |
---|
775 | dxbar[x][y]->p_to_target[FBUF_TGTID] (signal_vci_tgt_d_fbuf); |
---|
776 | dxbar[x][y]->p_to_target[CDMA_TGTID] (signal_vci_tgt_d_cdma); |
---|
777 | |
---|
778 | dxbar[x][y]->p_to_initiator[BDEV_SRCID] (signal_vci_ini_d_bdev); |
---|
779 | dxbar[x][y]->p_to_initiator[CDMA_SRCID] (signal_vci_ini_d_cdma); |
---|
780 | |
---|
781 | xicu[x][y]->p_hwi[0] (signal_irq_bdev); |
---|
782 | xicu[x][y]->p_hwi[1] (signal_irq_cdma); |
---|
783 | |
---|
784 | for(size_t i=0 ; i<N_TTYS ; i++) |
---|
785 | { |
---|
786 | xicu[x][y]->p_hwi[2+i] (signal_irq_mtty[i]); |
---|
787 | } |
---|
788 | } |
---|
789 | } // end for y |
---|
790 | } // end for x |
---|
791 | |
---|
792 | std::cout << "all components connected" << std::endl; |
---|
793 | |
---|
794 | //////////////////////////////////////////////////////// |
---|
795 | // Simulation |
---|
796 | /////////////////////////////////////////////////////// |
---|
797 | |
---|
798 | sc_start(sc_core::sc_time(0, SC_NS)); |
---|
799 | signal_resetn = false; |
---|
800 | |
---|
801 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
802 | signal_resetn = true; |
---|
803 | |
---|
804 | for(size_t i=1 ; i<ncycles ; i++) |
---|
805 | { |
---|
806 | sc_start(sc_core::sc_time(1, SC_NS)); |
---|
807 | |
---|
808 | if( debug_ok && (i > from_cycle) && (i < to_cycle) ) |
---|
809 | { |
---|
810 | std::cout << std::dec << "*************** cycle " << i << " ***********************" << std::endl; |
---|
811 | proc[0][0][0]->print_trace(); |
---|
812 | proc[0][1][0]->print_trace(); |
---|
813 | proc[1][0][0]->print_trace(); |
---|
814 | proc[1][1][0]->print_trace(); |
---|
815 | std::cout << std::endl; |
---|
816 | dxbar[0][0]->print_trace(); |
---|
817 | dxbar[0][1]->print_trace(); |
---|
818 | dxbar[1][0]->print_trace(); |
---|
819 | dxbar[1][1]->print_trace(); |
---|
820 | std::cout << std::endl; |
---|
821 | cxbar[0][0]->print_trace(); |
---|
822 | cxbar[0][1]->print_trace(); |
---|
823 | cxbar[1][0]->print_trace(); |
---|
824 | cxbar[1][1]->print_trace(); |
---|
825 | std::cout << std::endl; |
---|
826 | memc[0][0]->print_trace(); |
---|
827 | memc[0][1]->print_trace(); |
---|
828 | memc[1][0]->print_trace(); |
---|
829 | memc[1][1]->print_trace(); |
---|
830 | std::cout << std::endl; |
---|
831 | } |
---|
832 | } |
---|
833 | |
---|
834 | std::cout << "Hit ENTER to end simulation" << std::endl; |
---|
835 | char buf[1]; |
---|
836 | std::cin.getline(buf,1); |
---|
837 | |
---|
838 | for( size_t x = 0 ; x < xmax ; x++ ) |
---|
839 | for( size_t y = 0 ; y < ymax ; y++ ) |
---|
840 | for ( size_t p = 0 ; p < nprocs ; p++ ) |
---|
841 | proc[x][y][p]->print_stats(); |
---|
842 | |
---|
843 | return EXIT_SUCCESS; |
---|
844 | } |
---|
845 | |
---|
846 | int sc_main (int argc, char *argv[]) |
---|
847 | { |
---|
848 | try { |
---|
849 | return _main(argc, argv); |
---|
850 | } catch (std::exception &e) { |
---|
851 | std::cout << e.what() << std::endl; |
---|
852 | } catch (...) { |
---|
853 | std::cout << "Unknown exception occured" << std::endl; |
---|
854 | throw; |
---|
855 | } |
---|
856 | return 1; |
---|
857 | } |
---|