source: trunk/platforms/almos-tsarv3-platforms/multi-clusters/top.cpp @ 259

Last change on this file since 259 was 259, checked in by almaless, 12 years ago

Introduce ALMOS used platforms for TSAR.
See the package's README file for more information.

File size: 28.2 KB
Line 
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// There is one MEMC segment and one XICU segment per cluster.
31// - Each memory cache contains 8 Mbytes.
32// - The Frame buffer contains 4 Mbytes.
33// - The Boot ROM contains 1 Mbytes
34//
35// General policy for 32 bits address decoding:
36// To simplifly, all segments base addresses are aligned
37// on 64 Kbytes addresses. Therefore the 16 address MSB bits
38// define the target in the direct address space.
39// In these 16 bits, the (x_width + y_width) MSB bits define
40// the cluster index, and the 8 LSB bits define the local index:
41//
42//      | X_ID  | Y_ID  |---| L_ID |     OFFSET          |
43//      |x_width|y_width|---|  8   |       16            |
44/////////////////////////////////////////////////////////////////////////
45
46#include <systemc>
47#include <sys/time.h>
48#include <iostream>
49#include <sstream>
50#include <cstdlib>
51#include <cstdarg>
52#include <stdint.h>
53
54#include "mapping_table.h"
55#include "tsarv4_cluster_xbar.h"
56#include "mips32.h"
57#include "vci_simple_ram.h"
58
59#include "alloc_elems.h"
60#include "config.h"
61
62#if USE_OPENMP
63#include <omp.h>
64#endif
65
66#if USE_VCI_PROFILER
67#include "vci_profiler.h"
68#endif
69
70#if USE_GDBSERVER
71#include "gdbserver.h"
72#endif
73
74
75#if USE_ALMOS
76#define BOOT_INFO_BLOCK 0xbfc08000
77#define KERNEL_BIN_IMG  0xbfc10000
78#endif
79
80//  cluster index (computed from x,y coordinates)
81#define cluster(x,y)    (y + ymax*x)
82
83#define _TO_STR(_str) #_str
84#define  TO_STR(_str) _TO_STR(_str)
85
86// flit widths for the DSPIN network
87#define cmd_width                40
88#define rsp_width                33
89
90// VCI format
91#define cell_width               4
92#define address_width            32
93#define plen_width               8
94#define error_width              1
95#define clen_width               1
96#define rflag_width              1
97#define srcid_width              14
98#define pktid_width              4
99#define trdid_width              4
100#define wrplen_width             1
101
102
103/////////////////////////////////
104int _main(int argc, char *argv[])
105{
106    using namespace sc_core;
107    using namespace soclib::caba;
108    using namespace soclib::common;
109   
110    uint64_t       ms1, ms2;
111    struct timeval t1, t2;
112   
113    char    soft_name[BDEV_NAME_LEN] = "to_be_defined"; // pathname to binary code
114    char    disk_name[BDEV_NAME_LEN] = BDEV_IMAGE_NAME;   // pathname to the disk image
115    size_t  ncycles        = 1000000000;       // simulated cycles
116    size_t  xmax           = 2;                // number of clusters in a row
117    size_t  ymax           = 2;                // number of clusters in a column
118    size_t  nprocs         = 1;         // number of processors per cluster
119    size_t  xfb            = 512;       // frameBuffer column number
120    size_t  yfb            = 512;       // frameBuffer lines number
121    size_t  fb_mode        = 420;
122    #define DEBUG_OK       no
123    size_t  from_cycle     = 0;                // debug start cycle
124    size_t  memc_size      = MEMC_SIZE;
125    size_t  blk_size       = SECTOR_SIZE;
126    size_t  l1_i_ways      = L1_IWAYS;
127    size_t  l1_d_ways      = L1_DWAYS;
128    size_t  l1_i_sets      = L1_ISETS;
129    size_t  l1_d_sets      = L1_DSETS;
130    size_t  memc_sets      = MEMC_SETS;
131    size_t  memc_ways      = MEMC_WAYS;
132    size_t  itlb_ways      = TLB_IWAYS;
133    size_t  itlb_sets      = TLB_ISETS;
134    size_t  dtlb_ways      = TLB_DWAYS;
135    size_t  dtlb_sets      = TLB_DSETS;
136    size_t  xram_latency   = CONFIG_XRAM_LATENCY;
137    size_t  omp_threads    = 1;
138    ////////////// command line arguments //////////////////////
139    if (argc > 1)
140    {
141      for( int n=1 ; n<argc ; n=n+2 )
142      {
143            if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) )
144            {
145                ncycles = atoi(argv[n+1]);
146            }
147            else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) )
148            {
149                nprocs = atoi(argv[n+1]);
150                assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)) &&
151                        "NPROCS must be equal to 1, 2, or 4");
152            }
153            else if( (strcmp(argv[n],"-THREADS") == 0) && (n+1<argc) )
154            {
155                omp_threads = atoi(argv[n+1]);
156            }
157            else if( (strcmp(argv[n],"-XMAX") == 0) && (n+1<argc) )
158            {
159                xmax = atoi(argv[n+1]);
160                assert( ((xmax == 1) || (xmax == 2) || (xmax == 4) || (xmax == 8) || (xmax == 16)) 
161                         && "The XMAX parameter must be 2, 4, 8, or 16" );
162            }
163            else if( (strcmp(argv[n],"-YMAX") == 0) && (n+1<argc) )
164            {
165                ymax = atoi(argv[n+1]);
166                assert( ((ymax == 1) || (ymax == 2) || (ymax == 4) || (ymax == 8) || (ymax == 16)) 
167                         && "The YMAX parameter must be 2, 4, 8, or 16" );
168            }
169            else if( (strcmp(argv[n],"-XFB") == 0) && (n+1<argc) )
170            {
171                xfb = atoi(argv[n+1]);
172            }
173            else if( (strcmp(argv[n],"-YFB") == 0) && (n+1<argc) )
174            {
175                yfb = atoi(argv[n+1]);
176            }
177            else if( (strcmp(argv[n], "-FBMODE") == 0) && (n+1 < argc))
178            {
179              fb_mode = atoi(argv[n+1]);
180            }
181            else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
182            {
183                strcpy(soft_name, argv[n+1]);
184            }
185            else if( (strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
186            {
187                strcpy(disk_name, argv[n+1]);
188            }
189            else if( (strcmp(argv[n],"-BLKSZ") == 0) && (n+1<argc) )
190            {
191              blk_size = atoi(argv[n+1]);
192              assert(((blk_size % 512) == 0) && "BDEV: Block size must be multiple of 512 bytes");
193            }
194            else if( (strcmp(argv[n],"-TRACE") == 0) && (n+1<argc) )
195            {
196                from_cycle = atoi(argv[n+1]);
197            }
198            else if((strcmp(argv[n], "-MEMSZ") == 0) && (n+1 < argc))
199            {
200                memc_size = atoi(argv[n+1]);
201            }
202            else if((strcmp(argv[n], "-MCWAYS") == 0) && (n+1 < argc))
203            {
204                memc_ways = atoi(argv[n+1]);
205            }
206            else if((strcmp(argv[n], "-MCSETS") == 0) && (n+1 < argc))
207            {
208                memc_sets = atoi(argv[n+1]);
209            }
210            else if((strcmp(argv[n], "-L1_IWAYS") == 0) && (n+1 < argc))
211            {
212                l1_i_ways = atoi(argv[n+1]);
213            }
214            else if((strcmp(argv[n], "-L1_ISETS") == 0) && (n+1 < argc))
215            {
216                l1_i_sets = atoi(argv[n+1]);
217            }
218            else if((strcmp(argv[n], "-L1_DWAYS") == 0) && (n+1 < argc))
219            {
220                l1_d_ways = atoi(argv[n+1]);
221            }
222            else if((strcmp(argv[n], "-L1_DSETS") == 0) && (n+1 < argc))
223            {
224                l1_d_sets = atoi(argv[n+1]);
225            }
226            else if((strcmp(argv[n], "-ITLB_WAYS") == 0) && (n+1 < argc))
227            {
228                itlb_ways = atoi(argv[n+1]);
229            }
230            else if((strcmp(argv[n], "-ITLB_SETS") == 0) && (n+1 < argc))
231            {
232                itlb_sets = atoi(argv[n+1]);
233            }
234            else if((strcmp(argv[n], "-DTLB_WAYS") == 0) && (n+1 < argc))
235            {
236                dtlb_ways = atoi(argv[n+1]);
237            }
238            else if((strcmp(argv[n], "-DTLB_SETS") == 0) && (n+1 < argc))
239            {
240                dtlb_sets = atoi(argv[n+1]);
241            }
242            else if((strcmp(argv[n], "-XLATENCY") == 0) && (n+1 < argc))
243            {
244                xram_latency = atoi(argv[n+1]);
245            }
246            else
247            {
248                std::cout << "   Arguments on the command line are (key,value) couples." << std::endl;
249                std::cout << "   The order is not important." << std::endl;
250                std::cout << "   Accepted arguments are :" << std::endl << std::endl;
251                std::cout << "     -SOFT pathname_for_embedded_soft" << std::endl;
252                std::cout << "     -DISK pathname_for_disk_image" << std::endl;
253                std::cout << "     -BLKSZ sector size in bytes ( must be multiple of 512 bytes )" << std::endl;
254                std::cout << "     -NCYCLES number_of_simulated_cycles" << std::endl;
255                std::cout << "     -NPROCS number_of_processors_per_cluster" << std::endl;
256                std::cout << "     -XMAX number_of_clusters_in_a_row" << std::endl;
257                std::cout << "     -YMAX number_of_clusters_in_a_column" << std::endl;
258                std::cout << "     -TRACE debug_start_cycle" << std::endl;
259                std::cout << "     -MCWAYS memory_cache_number_of_ways" << std::endl;
260                std::cout << "     -MCSETS memory_cache_number_of_sets" << std::endl;
261                std::cout << "     -L1_IWAYS L1_instruction_cache_number_of_ways" << std::endl;
262                std::cout << "     -L1_ISETS L1_instruction_cache_number_of_sets" << std::endl;
263                std::cout << "     -L1_DWAYS L1_data_cache_number_of_ways" << std::endl;
264                std::cout << "     -L1_DSETS L1_data_cache_number_of_sets" << std::endl;
265                std::cout << "     -XLATENCY external_ram_latency_value" << std::endl;
266                std::cout << "     -XFB fram_buffer_number_of_pixels" << std::endl;
267                std::cout << "     -YFB fram_buffer_number_of_lines" << std::endl;
268                std::cout << "     -FBMODE fram buffer subsampling integer value (YUV:420,YUV:422,RGB:0,RGB:16,RGB:32,RGBPAL:256)" << std::endl;
269                std::cout << "     -MEMSZ per-cluster memory size ( <= 12 MB )" << std::endl;
270                std::cout << "     -THREADS number_of_cores_for_OpenMP" << std::endl;
271                exit(0);
272            }
273        }
274    }
275
276   
277    std::cout << "Simulation Parameters:" << std::endl;
278    std::cout << "          OMP_THREADS_NR        = " << omp_threads << std::endl;
279    std::cout << "          XFB                   = " << xfb << std::endl;
280    std::cout << "          YFB                   = " << yfb << std::endl;
281    std::cout << "          FB_MODE               = " << fb_mode << std::endl;
282    std::cout << "          SECTOR_SIZE  (Bytes)  = " << blk_size << std::endl;
283    std::cout << "          RAM/CLSTR    (Bytes)  = " << memc_size << std::endl;
284    std::cout << "          XRAM_LATENCY (cycles) = " << xram_latency << std::endl;
285    std::cout << "          MEMC_UPD_TBL          = " << CONFIG_MEMC_UPDATE_TAB_LINES << std::endl;
286    std::cout << "          MEMC_TRN_TLB          = " << CONFIG_MEMC_TRANSACTION_TAB_LINES <<std::endl;
287    std::cout << "          MEMC_WAYS             = " << memc_ways << std::endl;
288    std::cout << "          MEMC_SETS             = " << memc_sets << std::endl;
289    std::cout << "          L1_IWAYS              = " << l1_i_ways << std::endl;
290    std::cout << "          L1_ISETS              = " << l1_i_sets << std::endl;
291    std::cout << "          L1_DWAYS              = " << l1_d_ways << std::endl;
292    std::cout << "          L1_DSETS              = " << l1_d_sets << std::endl;
293    std::cout << "          ITLB_WAYS             = " << itlb_ways << std::endl;
294    std::cout << "          ITLB_SETS             = " << itlb_sets << std::endl;
295    std::cout << "          DTLB_WAYS             = " << dtlb_ways << std::endl;
296    std::cout << "          DTLB_SETS             = " << dtlb_sets << std::endl;
297   
298#define CONFIG_MEMC_TRANSACTION_TAB_LINES     8
299
300#define MEMC_WAYS                             16
301#define MEMC_SETS                             256
302
303#define L1_IWAYS                              4
304#define L1_ISETS                              64
305
306#define L1_DWAYS                              4
307#define L1_DSETS                              64
308
309#define TLB_IWAYS                             4
310#define TLB_ISETS                             16
311
312#define TLB_DWAYS                             4
313#define TLB_DSETS                             16
314
315#define CONFIG_XRAM_LATENCY                   0
316
317
318
319#if USE_OPENMP
320        omp_set_dynamic(false);
321        omp_set_num_threads(omp_threads);
322        std::cerr << "Built with openmp version " << _OPENMP << std::endl;
323#endif
324
325
326    // Define VCI parameters
327    typedef soclib::caba::VciParams<cell_width,
328                                    plen_width,
329                                    address_width,
330                                    error_width,                                   
331                                    clen_width,
332                                    rflag_width,
333                                    srcid_width,
334                                    pktid_width,
335                                    trdid_width,
336                                    wrplen_width> vci_param;
337
338    size_t      cluster_io_index;
339    size_t      x_width;
340    size_t      y_width;
341
342    if      (xmax == 2) x_width = 1;
343    else if (xmax <= 4) x_width = 2;
344    else if (xmax <= 8) x_width = 3;
345    else                x_width = 4;
346
347    if      (ymax == 2) y_width = 1;
348    else if (ymax <= 4) y_width = 2;
349    else if (ymax <= 8) y_width = 3;
350    else                y_width = 4;
351
352    cluster_io_index = 0xBF >> (8 - x_width - y_width);
353   
354    /////////////////////
355    //  Mapping Tables
356    /////////////////////
357
358    // direct network
359    MappingTable maptabd(address_width, 
360                         IntTab(x_width + y_width, 16 - x_width - y_width), 
361                         IntTab(x_width + y_width, srcid_width - x_width - y_width), 
362                         0x00F00000);
363
364    for ( size_t x = 0 ; x < xmax ; x++)
365    {
366        for ( size_t y = 0 ; y < ymax ; y++)
367        {
368            sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
369            std::ostringstream  sm;
370            sm << "d_seg_memc_" << x << "_" << y;
371            maptabd.add(Segment(sm.str(), MEMC_BASE+offset, memc_size, IntTab(cluster(x,y),MEMC_TGTID), true));
372            std::ostringstream  si;
373            si << "d_seg_xicu_" << x << "_" << y;
374            maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, IntTab(cluster(x,y),XICU_TGTID), false));
375            if ( cluster(x,y) == cluster_io_index )
376            {
377              maptabd.add(Segment("d_seg_fbuf", FBUF_BASE, FBUF_SIZE, IntTab(cluster(x,y),FBUF_TGTID), false));
378              maptabd.add(Segment("d_seg_bdev", BDEV_BASE, BDEV_SIZE, IntTab(cluster(x,y),BDEV_TGTID), false));
379              maptabd.add(Segment("d_seg_mtty", MTTY_BASE, MTTY_SIZE, IntTab(cluster(x,y),MTTY_TGTID), false));
380              maptabd.add(Segment("d_seg_brom", BROM_BASE, BROM_SIZE, IntTab(cluster(x,y),BROM_TGTID), true));
381              maptabd.add(Segment("d_seg_cdma", CDMA_BASE, CDMA_SIZE, IntTab(cluster(x,y),CDMA_TGTID), false));
382            }
383        }
384    }
385    std::cout << maptabd << std::endl;
386
387    // coherence network
388    MappingTable maptabc(address_width, 
389                         IntTab(x_width + y_width, 12 - x_width - y_width), 
390                         IntTab(x_width + y_width, srcid_width - x_width - y_width), 
391                         0xF0000000);
392
393    for ( size_t x = 0 ; x < xmax ; x++)
394    {
395        for ( size_t y = 0 ; y < ymax ; y++)
396        {
397            sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
398           
399            std::ostringstream sm;
400            sm << "c_seg_memc_" << x << "_" << y;
401            maptabc.add(Segment(sm.str(), MEMC_BASE+offset, memc_size, IntTab(cluster(x,y), nprocs), false));
402            // the segment base and size will be modified
403            // when the segmentation of the coherence space will be simplified
404
405            if ( cluster(x,y) == cluster_io_index )
406            {
407                std::ostringstream sr;
408                sr << "c_seg_brom_" << x << "_" << y;
409                maptabc.add(Segment(sr.str(), BROM_BASE, BROM_SIZE, IntTab(cluster(x,y), nprocs), false));
410            }
411
412            sc_uint<address_width> avoid_collision  = 0;
413            for ( size_t p = 0 ; p < nprocs ; p++)
414            {
415                sc_uint<address_width> base = memc_size + (p*0x100000) + offset;
416                // the following test is to avoid a collision between the c_seg_brom segment
417                // and a c_seg_proc segment (all segments base addresses being multiple of 1Mbytes)
418                if ( base == BROM_BASE ) avoid_collision = 0x100000;
419                std::ostringstream sp;
420                sp << "c_seg_proc_" << x << "_" << y << "_" << p;
421                maptabc.add(Segment(sp.str(), base + avoid_collision, 0x20, IntTab(cluster(x,y), p), false, 
422                                  true, IntTab(cluster(x,y), p))); 
423                // the two last arguments will be removed
424                // when the segmentation of the coherence space will be simplified
425            }
426        }
427    }
428    std::cout << maptabc << std::endl;
429
430    // external network
431    MappingTable maptabx(address_width, IntTab(1), IntTab(10), 0xF0000000);
432
433    for ( size_t x = 0 ; x < xmax ; x++)
434    {
435        for ( size_t y = 0 ; y < ymax ; y++)
436        { 
437          sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
438          std::ostringstream sx;
439         
440          sx << "seg_xram_" << x << "_" << y;
441          maptabx.add(Segment(sx.str(), MEMC_BASE + offset, memc_size, IntTab(cluster(x,y)), false));
442        }
443    }
444    std::cout << maptabx << std::endl;
445
446    ////////////////////
447    // Signals
448    ///////////////////
449
450    sc_clock            signal_clk("clk");
451    sc_signal<bool>     signal_resetn("resetn");
452    sc_signal<bool>     signal_false;
453   
454
455    // Horizontal inter-clusters DSPIN signals
456    DspinSignals<cmd_width>*** signal_dspin_h_cmd_inc =
457      alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_inc", xmax-1, ymax, 2);
458    DspinSignals<cmd_width>*** signal_dspin_h_cmd_dec =
459      alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_dec", xmax-1, ymax, 2);
460    DspinSignals<rsp_width>*** signal_dspin_h_rsp_inc =
461      alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_inc", xmax-1, ymax, 2);
462    DspinSignals<rsp_width>*** signal_dspin_h_rsp_dec =
463      alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_dec", xmax-1, ymax, 2);
464
465    // Vertical inter-clusters DSPIN signals
466    DspinSignals<cmd_width>*** signal_dspin_v_cmd_inc =
467      alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_inc", xmax, ymax-1, 2);
468    DspinSignals<cmd_width>*** signal_dspin_v_cmd_dec =
469        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_dec", xmax, ymax-1, 2);
470    DspinSignals<rsp_width>*** signal_dspin_v_rsp_inc =
471        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_inc", xmax, ymax-1, 2);
472    DspinSignals<rsp_width>*** signal_dspin_v_rsp_dec =
473        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_dec", xmax, ymax-1, 2);
474
475    // Mesh boundaries DSPIN signals
476    DspinSignals<cmd_width>**** signal_dspin_false_cmd_in =
477        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_in", xmax,  ymax, 2, 4);
478    DspinSignals<cmd_width>**** signal_dspin_false_cmd_out =
479        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_out", xmax, ymax, 2, 4);
480    DspinSignals<rsp_width>**** signal_dspin_false_rsp_in =
481        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_in", xmax, ymax, 2, 4);
482    DspinSignals<rsp_width>**** signal_dspin_false_rsp_out =
483        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_out", xmax, ymax, 2, 4);
484
485    // Xternal network VCI signals
486    VciSignals<vci_param> signal_vci_tgt_x_xram("signal_vci_tgt_x_xram");
487
488    ////////////////////////////
489    //      Components
490    ////////////////////////////
491
492#if USE_ALMOS
493    soclib::common::Loader loader("bootloader.bin",
494                                  "arch-info.bin@"TO_STR(BOOT_INFO_BLOCK)":D",
495                                  "kernel-soclib.bin@"TO_STR(KERNEL_BIN_IMG)":D");
496#else
497    soclib::common::Loader loader(soft_name);
498#endif
499
500#if USE_GDBSERVER
501    typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss;
502    proc_iss::set_loader(loader);
503#else
504    typedef soclib::common::Mips32ElIss proc_iss;
505#endif
506
507
508    TsarV4ClusterXbar<vci_param, proc_iss, cmd_width, rsp_width>* clusters[xmax][ymax];
509
510#if USE_OPENMP
511
512#pragma omp parallel
513    {
514#pragma omp for
515      for( int i = 0 ; i  < (xmax * ymax); i++)
516      {
517        size_t x = i / ymax;
518        size_t y = i % ymax;
519#pragma omp critical
520        {
521          std::ostringstream sc;
522          sc << "cluster_" << x << "_" << y;
523          clusters[x][y] = new TsarV4ClusterXbar<vci_param, proc_iss, cmd_width, rsp_width>
524            (sc.str().c_str(),
525           nprocs,
526             x,
527             y,
528             cluster(x,y),
529             maptabd,
530             maptabc,
531             maptabx,
532             x_width,
533             y_width,
534             MEMC_TGTID,
535             XICU_TGTID,
536             FBUF_TGTID,
537             MTTY_TGTID,
538             BROM_TGTID,
539             BDEV_TGTID,
540             CDMA_TGTID,
541             memc_ways,
542             memc_sets,
543             l1_i_ways,
544             l1_i_sets,
545             l1_d_ways,
546             l1_d_sets,
547             xram_latency,
548             (cluster(x,y) == cluster_io_index),
549             xfb,
550             yfb,
551             fb_mode,
552             disk_name,
553             blk_size,
554             loader);
555        }
556      }
557    }
558
559#else  // USE_OPENMP
560    for( size_t x = 0 ; x  < xmax ; x++)
561    {
562      for( size_t y = 0 ; y < ymax ; y++ )
563      {
564        std::ostringstream sc;
565        sc << "cluster_" << x << "_" << y;
566       
567        clusters[x][y] = new TsarV4ClusterXbar<vci_param, proc_iss, cmd_width, rsp_width>
568          (sc.str().c_str(),
569           nprocs,
570           x,
571           y,
572           cluster(x,y),
573           maptabd,
574           maptabc,
575           maptabx,
576           x_width,
577           y_width,
578           MEMC_TGTID,
579           XICU_TGTID,
580           FBUF_TGTID,
581           MTTY_TGTID,
582           BROM_TGTID,
583           BDEV_TGTID,
584           CDMA_TGTID,
585           memc_ways,
586           memc_sets,
587           l1_i_ways,
588           l1_i_sets,
589           l1_d_ways,
590           l1_d_sets,
591           xram_latency,
592           (cluster(x,y) == cluster_io_index),
593           xfb,
594           yfb,
595           fb_mode,
596           disk_name,
597           blk_size,
598           loader);
599        }
600      }
601#endif  // USE_OPENMP
602
603    ///////////////////////////////////////////////////////////////
604    //     Net-list
605    ///////////////////////////////////////////////////////////////
606
607    // Clock & RESET
608    for ( size_t x = 0 ; x < (xmax) ; x++ )
609    {
610        for ( size_t y = 0 ; y < ymax ; y++ )
611        {
612            clusters[x][y]->p_clk                       (signal_clk);
613            clusters[x][y]->p_resetn                    (signal_resetn);
614        }
615    }
616
617    // Inter Clusters horizontal connections
618    if ( xmax > 1 )
619    {
620        for ( size_t x = 0 ; x < (xmax-1) ; x++ )
621        {
622            for ( size_t y = 0 ; y < ymax ; y++ )
623            {
624                for ( size_t k = 0 ; k < 2 ; k++ )
625                {
626                clusters[x][y]->p_cmd_out[k][EAST]      (signal_dspin_h_cmd_inc[x][y][k]);
627                clusters[x+1][y]->p_cmd_in[k][WEST]     (signal_dspin_h_cmd_inc[x][y][k]);
628                clusters[x][y]->p_cmd_in[k][EAST]       (signal_dspin_h_cmd_dec[x][y][k]);
629                clusters[x+1][y]->p_cmd_out[k][WEST]    (signal_dspin_h_cmd_dec[x][y][k]);
630                clusters[x][y]->p_rsp_out[k][EAST]      (signal_dspin_h_rsp_inc[x][y][k]);
631                clusters[x+1][y]->p_rsp_in[k][WEST]     (signal_dspin_h_rsp_inc[x][y][k]);
632                clusters[x][y]->p_rsp_in[k][EAST]       (signal_dspin_h_rsp_dec[x][y][k]);
633                clusters[x+1][y]->p_rsp_out[k][WEST]    (signal_dspin_h_rsp_dec[x][y][k]);
634                }
635            }
636        }
637    }
638    std::cout << "Horizontal connections established" << std::endl;     
639
640    // Inter Clusters vertical connections
641    if ( ymax > 1 )
642    {
643        for ( size_t y = 0 ; y < (ymax-1) ; y++ )
644        {
645            for ( size_t x = 0 ; x < xmax ; x++ )
646            {
647                for ( size_t k = 0 ; k < 2 ; k++ )
648                {
649                clusters[x][y]->p_cmd_out[k][NORTH]     (signal_dspin_v_cmd_inc[x][y][k]);
650                clusters[x][y+1]->p_cmd_in[k][SOUTH]    (signal_dspin_v_cmd_inc[x][y][k]);
651                clusters[x][y]->p_cmd_in[k][NORTH]      (signal_dspin_v_cmd_dec[x][y][k]);
652                clusters[x][y+1]->p_cmd_out[k][SOUTH]   (signal_dspin_v_cmd_dec[x][y][k]);
653                clusters[x][y]->p_rsp_out[k][NORTH]     (signal_dspin_v_rsp_inc[x][y][k]);
654                clusters[x][y+1]->p_rsp_in[k][SOUTH]    (signal_dspin_v_rsp_inc[x][y][k]);
655                clusters[x][y]->p_rsp_in[k][NORTH]      (signal_dspin_v_rsp_dec[x][y][k]);
656                clusters[x][y+1]->p_rsp_out[k][SOUTH]   (signal_dspin_v_rsp_dec[x][y][k]);
657                }
658            }
659        }
660    }
661
662   std::cout << "Vertical connections established" << std::endl;
663
664    // East & West boundary cluster connections
665    for ( size_t y = 0 ; y < ymax ; y++ )
666    {
667        for ( size_t k = 0 ; k < 2 ; k++ )
668        {
669            clusters[0][y]->p_cmd_in[k][WEST]           (signal_dspin_false_cmd_in[0][y][k][WEST]);
670            clusters[0][y]->p_cmd_out[k][WEST]          (signal_dspin_false_cmd_out[0][y][k][WEST]);
671            clusters[0][y]->p_rsp_in[k][WEST]           (signal_dspin_false_rsp_in[0][y][k][WEST]);
672            clusters[0][y]->p_rsp_out[k][WEST]          (signal_dspin_false_rsp_out[0][y][k][WEST]);
673         
674            clusters[xmax-1][y]->p_cmd_in[k][EAST]      (signal_dspin_false_cmd_in[xmax-1][y][k][EAST]);
675            clusters[xmax-1][y]->p_cmd_out[k][EAST]     (signal_dspin_false_cmd_out[xmax-1][y][k][EAST]);
676            clusters[xmax-1][y]->p_rsp_in[k][EAST]      (signal_dspin_false_rsp_in[xmax-1][y][k][EAST]);
677            clusters[xmax-1][y]->p_rsp_out[k][EAST]     (signal_dspin_false_rsp_out[xmax-1][y][k][EAST]);
678        }
679    }
680   
681    // North & South boundary clusters connections
682    for ( size_t x = 0 ; x < xmax ; x++ )
683    {
684        for ( size_t k = 0 ; k < 2 ; k++ )
685        {
686            clusters[x][0]->p_cmd_in[k][SOUTH]          (signal_dspin_false_cmd_in[x][0][k][SOUTH]);
687            clusters[x][0]->p_cmd_out[k][SOUTH]         (signal_dspin_false_cmd_out[x][0][k][SOUTH]);
688            clusters[x][0]->p_rsp_in[k][SOUTH]          (signal_dspin_false_rsp_in[x][0][k][SOUTH]);
689            clusters[x][0]->p_rsp_out[k][SOUTH]         (signal_dspin_false_rsp_out[x][0][k][SOUTH]);
690           
691            clusters[x][ymax-1]->p_cmd_in[k][NORTH]     (signal_dspin_false_cmd_in[x][ymax-1][k][NORTH]);
692            clusters[x][ymax-1]->p_cmd_out[k][NORTH]    (signal_dspin_false_cmd_out[x][ymax-1][k][NORTH]);
693            clusters[x][ymax-1]->p_rsp_in[k][NORTH]     (signal_dspin_false_rsp_in[x][ymax-1][k][NORTH]);
694            clusters[x][ymax-1]->p_rsp_out[k][NORTH]    (signal_dspin_false_rsp_out[x][ymax-1][k][NORTH]);
695        }
696    }
697     
698    ////////////////////////////////////////////////////////
699    //   Simulation
700    ///////////////////////////////////////////////////////
701
702    sc_start(sc_core::sc_time(0, SC_NS));
703    signal_resetn = false;
704
705    // network boundaries signals
706    for(size_t x=0; x<xmax ; x++)
707    {
708        for(size_t y=0 ; y<ymax ; y++)
709        {
710            for (size_t k=0; k<2; k++)
711            {
712                for(size_t a=0; a<4; a++)
713                {
714                        signal_dspin_false_cmd_in[x][y][k][a].write = false;
715                        signal_dspin_false_cmd_in[x][y][k][a].read = true;
716                        signal_dspin_false_cmd_out[x][y][k][a].write = false;
717                        signal_dspin_false_cmd_out[x][y][k][a].read = true;
718
719                        signal_dspin_false_rsp_in[x][y][k][a].write = false;
720                        signal_dspin_false_rsp_in[x][y][k][a].read = true;
721                        signal_dspin_false_rsp_out[x][y][k][a].write = false;
722                        signal_dspin_false_rsp_out[x][y][k][a].read = true;
723                }
724            }
725        }
726    }
727
728    sc_start(sc_core::sc_time(1, SC_NS));
729    signal_resetn = true;
730
731    if (gettimeofday(&t1, NULL) != 0) 
732    {
733      perror("gettimeofday");
734      return EXIT_FAILURE;
735    }
736
737    while(1)
738    {
739      sc_start(sc_core::sc_time(100000000, SC_NS));
740
741      if (gettimeofday(&t2, NULL) != 0) 
742      {
743        perror("gettimeofday");
744        return EXIT_FAILURE;
745      }
746           
747      ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000;
748      ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000;
749     
750      std::cerr << "platform clock frequency " << (double)100000000ULL / (double)(ms2 - ms1) << "Khz" << std::endl;
751           
752      if (gettimeofday(&t1, NULL) != 0) 
753      {
754        perror("gettimeofday");
755        return EXIT_FAILURE;
756      }
757    }
758
759    return EXIT_SUCCESS;
760}
761
762int sc_main (int argc, char *argv[])
763{
764        try {
765                return _main(argc, argv);
766        } catch (std::exception &e) {
767                std::cout << e.what() << std::endl;
768        } catch (...) {
769                std::cout << "Unknown exception occured" << std::endl;
770                throw;
771        }
772        return 1;
773}
Note: See TracBrowser for help on using the repository browser.