source: trunk/platforms/tsarv4_generic_mmu/top.cpp @ 247

Last change on this file since 247 was 247, checked in by cfuguet, 12 years ago

Introducing new CLEANUP transaction address specification in the components:

  • vci_cc_vcache_wrapper_v4
  • vci_mem_cache_v4

The new specification uses the VCI WDATA and the VCI BE to send the cleanup
nline. The VCI ADDRESS is like follows:

  • NLINE MSb | Memory Cache local ID | 00....00

The platforms:

  • tsarv4_mono_mmu
  • tsarv4_generic_mmu

has been modified to use the modified components and the mapping table for the coherence
address space has been updated.

File size: 30.6 KB
Line 
1/////////////////////////////////////////////////////////////////////////
2// File: top.cpp
3// Author: Alain Greiner
4// Copyright: UPMC/LIP6
5// Date : june 2011
6// This program is released under the GNU public license
7/////////////////////////////////////////////////////////////////////////
8// This file define a generic TSAR architecture with virtual memory.
9// - It uses vci_local_crossbar as local interconnect
10// - It uses virtual_dspin as global interconnect
11// - It uses the vci_cc_vcache_wrapper_v4
12// - It uses the vci_mem_cache_v4
13// - It uses one vci_xicu, one vci_multi_tty,
14//   and one vci_multi_dma controler per cluster.
15//
16// It is build with one single component implementing a cluster:
17// The Tsarv4ClusterMmu component is defined in files
18// tsarv4_cluster_mmu.* (with * = cpp, h, sd)
19//
20// The physical address space is 32 bits.
21// The number of clusters cannot be larger than 256.
22// The number of processors per cluster cannot be larger than 4.
23// The parameters must be power of 2.
24// - xmax   : number of clusters in a row
25// - ymax   : number of clusters in a column
26// - nprocs : number of processors per cluster
27//
28// The peripherals BDEV, FBUF, and the boot BROM
29// are in the cluster containing address 0xBFC00000.
30// - The nprocs TTY IRQs are connected to IRQ_IN[0] to IRQ_IN[3]
31// - The nprocs DMA IRQs are connected to IRQ_IN[4] to IRQ_IN[7]
32// - The IOC IRQ is connected to IRQ_IN[8]
33//
34// General policy for 32 bits physical address decoding:
35// All segments base addresses are multiple of 64 Kbytes
36// Therefore the 16 address MSB bits completely define the target:
37// The (x_width + y_width) MSB bits (left aligned) define
38// the cluster index, and the 8 LSB bits define the local index:
39//      | X_ID  | Y_ID  |---| LADR |     OFFSET          |
40//      |x_width|y_width|---|  8   |       16            |
41/////////////////////////////////////////////////////////////////////////
42
43#include <systemc>
44#include <sys/time.h>
45#include <iostream>
46#include <sstream>
47#include <cstdlib>
48#include <cstdarg>
49#include <stdint.h>
50
51#include "gdbserver.h"
52#include "mapping_table.h"
53#include "tsarv4_cluster_mmu.h"
54#include "alloc_elems.h"
55
56///////////////////////////////////////////////////
57//              OS
58///////////////////////////////////////////////////
59
60#define USE_ALMOS 0
61#define almos_bootloader_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/bootloader/bin/bootloader-soclib-mipsel.bin"
62#define almos_kernel_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/kernel/bin/kernel-soclib-mipsel.bin@0xbfc10000:D"
63#define almos_archinfo_pathname "/Users/alain/soc/tsar-svn-june-2010/softs/almos/arch_bins/arch-info_4_4.bin@0xBFC08000:D"
64
65///////////////////////////////////////////////////
66//               Parallelisation
67///////////////////////////////////////////////////
68
69#define USE_OPENMP               0
70#define OPENMP_THREADS_NR        8
71
72#if USE_OPENMP
73#include <omp.h>
74#endif
75
76//  cluster index (computed from x,y coordinates)
77#define cluster(x,y)    (y + ymax*x)
78
79// flit widths for the DSPIN network
80#define cmd_width                40
81#define rsp_width                33
82
83// VCI format
84#define cell_width               4
85#define address_width            32
86#define plen_width               8
87#define error_width              2
88#define clen_width               1
89#define rflag_width              1
90#define srcid_width              14
91#define pktid_width              4
92#define trdid_width              4
93#define wrplen_width             1
94
95///////////////////////////////////////////////////
96//     Parameters default values         
97///////////////////////////////////////////////////
98
99#define MESH_XMAX               2
100#define MESH_YMAX               2
101
102#define NPROCS                  4
103#define XRAM_LATENCY            0
104
105#define MEMC_WAYS               16
106#define MEMC_SETS               256
107
108#define L1_IWAYS                4
109#define L1_ISETS                64
110
111#define L1_DWAYS                4
112#define L1_DSETS                64
113
114#define FBUF_X_SIZE             512
115#define FBUF_Y_SIZE             512
116
117#define BDEV_SECTOR_SIZE        128
118#define BDEV_IMAGE_NAME         "../../softs/soft_transpose_giet/images.raw"
119
120#define BOOT_SOFT_NAME          "../../softs/soft_transpose_giet/bin.soft"
121
122#define MAX_FROZEN_CYCLES       100000
123
124/////////////////////////////////////////////////////////
125//      Physical segments definition
126/////////////////////////////////////////////////////////
127// There is 3 segments replicated in all clusters:
128// - seg_memc   -> MEMC / BASE = 0x**000000     (12 M bytes)
129// - seg_icu    -> ICU  / BASE = 0x**F00000
130// - seg_dma    -> CDMA / BASE = 0x**F30000
131//
132// There is 4 specific segments in the "IO" cluster
133// (containing address 0xBF000000)
134// - seg_reset  -> BROM / BASE = 0xBFC00000     (1 Mbytes)
135// - seg_fbuf   -> FBUF / BASE = 0xBFD00000     (2 M bytes)
136// - seg_bdev   -> BDEV / BASE = 0xBFF10000
137// - seg_tty    -> MTTY / BASE = 0x**F20000
138//
139// There is one special segment corresponding to
140// the processors in the coherence address space
141// - seg_proc   -> PROC / BASE = 0x**B0 to 0xBF
142///////////////////////////////////////////////////
143
144// specific segments in "IO" cluster
145
146#define BROM_BASE               0xBFC00000     
147#define BROM_SIZE               0x00100000
148
149#define FBUF_BASE               0xBFD00000     
150#define FBUF_SIZE               0x00200000
151
152#define BDEV_BASE               0xBFF10000     
153#define BDEV_SIZE               0x00000020
154
155#define MTTY_BASE               0xBFF20000     
156#define MTTY_SIZE               0x00000040
157
158// replicated segments
159
160#define MEMC_BASE               0x00000000     
161#define MEMC_SIZE               0x00C00000
162
163#define XICU_BASE               0x00F00000     
164#define XICU_SIZE               0x00001000
165
166#define CDMA_BASE               0x00F30000     
167#define CDMA_SIZE               0x00004000
168
169#define PROC_BASE               0x00D00000     
170#define PROC_SIZE               0x00000010
171
172////////////////////////////////////////////////////////////////////
173//     TGTID definition in direct space
174// For all components:  global TGTID = global SRCID = cluster_index
175////////////////////////////////////////////////////////////////////
176
177#define MEMC_TGTID               0
178#define XICU_TGTID               1
179#define CDMA_TGTID               2
180#define MTTY_TGTID               3
181#define FBUF_TGTID               4
182#define BROM_TGTID               5
183#define BDEV_TGTID               6
184
185/////////////////////////////////
186int _main(int argc, char *argv[])
187{
188    using namespace sc_core;
189    using namespace soclib::caba;
190    using namespace soclib::common;
191   
192   
193    char     soft_name[256] = BOOT_SOFT_NAME;     // pathname to binary code
194    size_t   ncycles        = 1000000000;         // simulated cycles
195    size_t   xmax           = MESH_XMAX;          // number of clusters in a row
196    size_t   ymax           = MESH_YMAX;          // number of clusters in a column
197    size_t   nprocs         = NPROCS;             // number of processors per cluster
198    size_t   xfb            = FBUF_X_SIZE;        // frameBuffer column number
199    size_t   yfb            = FBUF_Y_SIZE;        // frameBuffer lines number
200    size_t   memc_ways      = MEMC_WAYS;
201    size_t   memc_sets      = MEMC_SETS;
202    size_t   l1_d_ways      = L1_DWAYS;
203    size_t   l1_d_sets      = L1_DSETS;
204    size_t   l1_i_ways      = L1_IWAYS;
205    size_t   l1_i_sets      = L1_ISETS;
206    char     disk_name[256] = BDEV_IMAGE_NAME;    // pathname to the disk image
207    size_t   blk_size       = BDEV_SECTOR_SIZE;   // block size (in bytes)
208    size_t   xram_latency   = XRAM_LATENCY;       // external RAM latency
209    bool     trace_ok       = false;              // trace activated
210    size_t   trace_period   = 1;                  // trace period
211    uint32_t from_cycle     = 0;                  // debug start cycle
212    uint32_t frozen_cycles  = MAX_FROZEN_CYCLES;  // monitoring frozen processor
213
214    ////////////// command line arguments //////////////////////
215    if (argc > 1)
216    {
217        for( int n=1 ; n<argc ; n=n+2 )
218        {
219            if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) )
220            {
221                ncycles = atoi(argv[n+1]);
222            }
223            else if( (strcmp(argv[n],"-NPROCS") == 0) && (n+1<argc) )
224            {
225                nprocs = atoi(argv[n+1]);
226                assert( ((nprocs == 1) || (nprocs == 2) || (nprocs == 4)) &&
227                        "NPROCS must be equal to 1, 2, or 4");
228            }
229            else if( (strcmp(argv[n],"-XMAX") == 0) && (n+1<argc) )
230            {
231                xmax = atoi(argv[n+1]);
232                assert( ((xmax == 1) || (xmax == 2) || (xmax == 4) || (xmax == 8) || (xmax == 16)) 
233                         && "The XMAX parameter must be 2, 4, 8, or 16" );
234            }
235           
236            else if( (strcmp(argv[n],"-YMAX") == 0) && (n+1<argc) )
237            {
238                ymax = atoi(argv[n+1]);
239                assert( ((ymax == 1) || (ymax == 2) || (ymax == 4) || (ymax == 8) || (ymax == 16)) 
240                         && "The YMAX parameter must be 2, 4, 8, or 16" );
241            }
242            else if( (strcmp(argv[n],"-XFB") == 0) && (n+1<argc) )
243            {
244                xfb = atoi(argv[n+1]);
245            }
246            else if( (strcmp(argv[n],"-YFB") == 0) && (n+1<argc) )
247            {
248                yfb = atoi(argv[n+1]);
249            }
250            else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
251            {
252                strcpy(soft_name, argv[n+1]);
253            }
254            else if( (strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
255            {
256                strcpy(disk_name, argv[n+1]);
257            }
258            else if( (strcmp(argv[n],"-TRACE") == 0) && (n+1<argc) )
259            {
260                trace_ok = true;
261                from_cycle = atoi(argv[n+1]);
262            }
263            else if((strcmp(argv[n], "-MCWAYS") == 0) && (n+1 < argc))
264            {
265                memc_ways = atoi(argv[n+1]);
266            }
267            else if((strcmp(argv[n], "-MCSETS") == 0) && (n+1 < argc))
268            {
269                memc_sets = atoi(argv[n+1]);
270            }
271            else if((strcmp(argv[n], "-XLATENCY") == 0) && (n+1 < argc))
272            {
273                xram_latency = atoi(argv[n+1]);
274            }
275            else if((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc))
276            {
277                frozen_cycles = atoi(argv[n+1]);
278            }
279            else if((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc))
280            {
281                trace_period = atoi(argv[n+1]);
282            }
283            else
284            {
285                std::cout << "   Arguments on the command line are (key,value) couples." << std::endl;
286                std::cout << "   The order is not important." << std::endl;
287                std::cout << "   Accepted arguments are :" << std::endl << std::endl;
288                std::cout << "     -SOFT pathname_for_embedded_soft" << std::endl;
289                std::cout << "     -DISK pathname_for_disk_image" << std::endl;
290                std::cout << "     -NCYCLES number_of_simulated_cycles" << std::endl;
291                std::cout << "     -NPROCS number_of_processors_per_cluster" << std::endl;
292                std::cout << "     -XMAX number_of_clusters_in_a_row" << std::endl;
293                std::cout << "     -YMAX number_of_clusters_in_a_column" << std::endl;
294                std::cout << "     -TRACE debug_start_cycle" << std::endl;
295                std::cout << "     -MCWAYS memory_cache_number_of_ways" << std::endl;
296                std::cout << "     -MCSETS memory_cache_number_of_sets" << std::endl;
297                std::cout << "     -XLATENCY external_ram_latency_value" << std::endl;
298                std::cout << "     -XFB fram_buffer_number_of_pixels" << std::endl;
299                std::cout << "     -YFB fram_buffer_number_of_lines" << std::endl;
300                std::cout << "     -FROZEN max_number_of_lines" << std::endl;
301                std::cout << "     -PERIOD number_of_cycles between trace" << std::endl;
302                exit(0);
303            }
304        }
305    }
306
307    std::cout << std::endl;
308    std::cout << " - NPROCS      = " << nprocs <<  std::endl;
309    std::cout << " - NCLUSTERS   = " << xmax*ymax << std::endl;
310    std::cout << " - MAX FROZEN  = " << frozen_cycles << std::endl;
311    std::cout << " - MEMC_WAYS   = " << memc_ways << std::endl;
312    std::cout << " - MEMC_SETS   = " << memc_sets << std::endl;
313    std::cout << " - RAM_LATENCY = " << xram_latency << std::endl;
314
315    std::cout << std::endl;
316
317#if USE_OPENMP
318        omp_set_dynamic(false);
319        omp_set_num_threads(threads_nr);
320        std::cerr << "Built with openmp version " << _OPENMP << std::endl;
321#endif
322
323    // Define VCI parameters
324    typedef soclib::caba::VciParams<cell_width,
325                                    plen_width,
326                                    address_width,
327                                    error_width,                                   
328                                    clen_width,
329                                    rflag_width,
330                                    srcid_width,
331                                    pktid_width,
332                                    trdid_width,
333                                    wrplen_width> vci_param;
334
335    size_t      cluster_io_index;
336    size_t      x_width;
337    size_t      y_width;
338
339    if      (xmax == 1) x_width = 0;
340    else if (xmax == 2) x_width = 1;
341    else if (xmax <= 4) x_width = 2;
342    else if (xmax <= 8) x_width = 3;
343    else                x_width = 4;
344
345    if      (ymax == 1) y_width = 0;
346    else if (ymax == 2) y_width = 1;
347    else if (ymax <= 4) y_width = 2;
348    else if (ymax <= 8) y_width = 3;
349    else                y_width = 4;
350
351    cluster_io_index = 0xBF >> (8 - x_width - y_width);
352   
353    /////////////////////
354    //  Mapping Tables
355    /////////////////////
356
357    // direct network
358    MappingTable maptabd(address_width, 
359                         IntTab(x_width + y_width, 16 - x_width - y_width), 
360                         IntTab(x_width + y_width, srcid_width - x_width - y_width), 
361                         0x00FF0000);
362
363    for ( size_t x = 0 ; x < xmax ; x++)
364    {
365        for ( size_t y = 0 ; y < ymax ; y++)
366        {
367            sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
368
369            std::ostringstream  sh;
370            sh << "d_seg_memc_" << x << "_" << y;
371            maptabd.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y),MEMC_TGTID), true));
372
373            std::ostringstream  si;
374            si << "d_seg_xicu_" << x << "_" << y;
375            maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, IntTab(cluster(x,y),XICU_TGTID), false));
376
377            std::ostringstream  sd;
378            sd << "d_seg_mdma_" << x << "_" << y;
379            maptabd.add(Segment(sd.str(), CDMA_BASE+offset, CDMA_SIZE, IntTab(cluster(x,y),CDMA_TGTID), false));
380
381            if ( cluster(x,y) == cluster_io_index )
382            {
383              maptabd.add(Segment("d_seg_mtty    ", MTTY_BASE, MTTY_SIZE, IntTab(cluster(x,y),MTTY_TGTID), false));
384              maptabd.add(Segment("d_seg_fbuf    ", FBUF_BASE, FBUF_SIZE, IntTab(cluster(x,y),FBUF_TGTID), false));
385              maptabd.add(Segment("d_seg_bdev    ", BDEV_BASE, BDEV_SIZE, IntTab(cluster(x,y),BDEV_TGTID), false));
386              maptabd.add(Segment("d_seg_brom    ", BROM_BASE, BROM_SIZE, IntTab(cluster(x,y),BROM_TGTID), true));
387            }
388        }
389    }
390    std::cout << maptabd << std::endl;
391
392    // coherence network
393    // - tgtid_c_proc = srcid_c_proc = local procid
394    // - tgtid_c_memc = srcid_c_memc = nprocs
395    MappingTable maptabc(address_width, 
396                         IntTab(x_width + y_width, srcid_width - x_width - y_width), 
397                         IntTab(x_width + y_width, srcid_width - x_width - y_width), 
398                         0x00FF0000);
399
400    for ( size_t x = 0 ; x < xmax ; x++)
401    {
402        for ( size_t y = 0 ; y < ymax ; y++)
403        {
404            sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
405
406            // cleanup requests regarding the memc segment must be routed to the memory cache
407            std::ostringstream sh;
408            sh << "c_seg_memc_" << x << "_" << y;
409            maptabc.add(
410                Segment(
411                    sh.str()
412                  , (nprocs << (address_width - srcid_width)) + offset
413                  , 0x10
414                  , IntTab(cluster(x,y), nprocs)
415                  , false
416                )
417            );
418
419            // update & invalidate requests must be routed to the proper processor
420            for ( size_t p = 0 ; p < nprocs ; p++)
421            {
422                std::ostringstream sp;
423                sp << "c_seg_proc_" << x << "_" << y << "_" << p;
424                maptabc.add(
425                    Segment(
426                        sp.str()
427                      , (p << (address_width - srcid_width)) + offset
428                      , 0x10
429                      , IntTab(cluster(x,y), p)
430                      , false
431                    )
432                ); 
433            }
434        }
435    }
436    std::cout << maptabc << std::endl;
437
438    // external network
439    MappingTable maptabx(address_width, IntTab(1), IntTab(x_width+y_width), 0xF0000000);
440
441    for ( size_t x = 0 ; x < xmax ; x++)
442    {
443        for ( size_t y = 0 ; y < ymax ; y++)
444        { 
445            sc_uint<address_width> offset  = cluster(x,y) << (address_width-x_width-y_width);
446            std::ostringstream sh;
447            sh << "x_seg_memc_" << x << "_" << y;
448            maptabx.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, IntTab(cluster(x,y)), false));
449        }
450    }
451    std::cout << maptabx << std::endl;
452
453    ////////////////////
454    // Signals
455    ///////////////////
456
457    sc_clock            signal_clk("clk");
458    sc_signal<bool>     signal_resetn("resetn");
459
460    // Horizontal inter-clusters DSPIN signals
461    DspinSignals<cmd_width>*** signal_dspin_h_cmd_inc =
462      alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_inc", xmax-1, ymax, 2);
463    DspinSignals<cmd_width>*** signal_dspin_h_cmd_dec =
464      alloc_elems<DspinSignals<cmd_width> >("signal_dspin_h_cmd_dec", xmax-1, ymax, 2);
465    DspinSignals<rsp_width>*** signal_dspin_h_rsp_inc =
466      alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_inc", xmax-1, ymax, 2);
467    DspinSignals<rsp_width>*** signal_dspin_h_rsp_dec =
468      alloc_elems<DspinSignals<rsp_width> >("signal_dspin_h_rsp_dec", xmax-1, ymax, 2);
469
470    // Vertical inter-clusters DSPIN signals
471    DspinSignals<cmd_width>*** signal_dspin_v_cmd_inc =
472        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_inc", xmax, ymax-1, 2);
473    DspinSignals<cmd_width>*** signal_dspin_v_cmd_dec =
474        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_v_cmd_dec", xmax, ymax-1, 2);
475    DspinSignals<rsp_width>*** signal_dspin_v_rsp_inc =
476        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_inc", xmax, ymax-1, 2);
477    DspinSignals<rsp_width>*** signal_dspin_v_rsp_dec =
478        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_v_rsp_dec", xmax, ymax-1, 2);
479
480    // Mesh boundaries DSPIN signals
481    DspinSignals<cmd_width>**** signal_dspin_false_cmd_in =
482        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_in", xmax, ymax, 2, 4);
483    DspinSignals<cmd_width>**** signal_dspin_false_cmd_out =
484        alloc_elems<DspinSignals<cmd_width> >("signal_dspin_false_cmd_out", xmax, ymax, 2, 4);
485    DspinSignals<rsp_width>**** signal_dspin_false_rsp_in =
486        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_in", xmax, ymax, 2, 4);
487    DspinSignals<rsp_width>**** signal_dspin_false_rsp_out =
488        alloc_elems<DspinSignals<rsp_width> >("signal_dspin_false_rsp_out", xmax, ymax, 2, 4);
489
490
491    ////////////////////////////
492    //      Components
493    ////////////////////////////
494
495#if USE_ALMOS
496    soclib::common::Loader loader(almos_bootloader_pathname,
497                                  almos_archinfo_pathname,
498                                  almos_kernel_pathname);
499#else
500    soclib::common::Loader loader(soft_name);
501#endif
502
503    typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss;
504    proc_iss::set_loader(loader);
505
506    TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width>* clusters[xmax][ymax];
507
508#if USE_OPENMP
509
510#pragma omp parallel
511{
512#pragma omp for
513    for( size_t i = 0 ; i  < (xmax * ymax); i++)
514    {
515        size_t x = i / ymax;
516        size_t y = i % ymax;
517
518#pragma omp critical
519        std::ostringstream sc;
520        sc << "cluster_" << x << "_" << y;
521        clusters[x][y] = new TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width>
522            (sc.str().c_str(),
523             nprocs,
524             x,
525             y,
526             cluster(x,y),
527             maptabd,
528             maptabc,
529             maptabx,
530             x_width,
531             y_width,
532             MEMC_TGTID,
533             XICU_TGTID,
534             FBUF_TGTID,
535             MTTY_TGTID,
536             BROM_TGTID,
537             BDEV_TGTID,
538             CDMA_TGTID,
539             memc_ways,
540             memc_sets,
541             l1_i_ways,
542             l1_i_sets,
543             l1_d_ways,
544             l1_d_sets,
545             xram_latency,
546             (cluster(x,y) == cluster_io_index),
547             xfb,
548             yfb,
549             disk_name,
550             blk_size,
551             loader,
552             frozen_cycles,
553             from_cycle,
554             trace_ok and (cluster_io_index == cluster(x,y)) );
555        }
556
557#else  // NO OPENMP
558
559    for( size_t x = 0 ; x  < xmax ; x++)
560    {
561        for( size_t y = 0 ; y < ymax ; y++ )
562        {
563
564std::cout << "building cluster_" << x << "_" << y << std::endl;
565
566            std::ostringstream sc;
567            sc << "cluster_" << x << "_" << y;
568            clusters[x][y] = new TsarV4ClusterMmu<vci_param, proc_iss, cmd_width, rsp_width>
569            (sc.str().c_str(),
570             nprocs,
571             x,
572             y,
573             cluster(x,y),
574             maptabd,
575             maptabc,
576             maptabx,
577             x_width,
578             y_width,
579             MEMC_TGTID,
580             XICU_TGTID,
581             FBUF_TGTID,
582             MTTY_TGTID,
583             BROM_TGTID,
584             BDEV_TGTID,
585             CDMA_TGTID,
586             memc_ways,
587             memc_sets,
588             l1_i_ways,
589             l1_i_sets,
590             l1_d_ways,
591             l1_d_sets,
592             xram_latency,
593             (cluster(x,y) == cluster_io_index),
594             xfb,
595             yfb,
596             disk_name,
597             blk_size,
598             loader,
599             frozen_cycles,
600             from_cycle,
601             trace_ok and (cluster_io_index == cluster(x,y)) );
602
603std::cout << "cluster_" << x << "_" << y << " constructed" << std::endl;
604
605        }
606    }
607   
608#endif  // USE_OPENMP
609
610    ///////////////////////////////////////////////////////////////
611    //     Net-list
612    ///////////////////////////////////////////////////////////////
613
614    // Clock & RESET
615    for ( size_t x = 0 ; x < (xmax) ; x++ )
616    {
617        for ( size_t y = 0 ; y < ymax ; y++ )
618        {
619            clusters[x][y]->p_clk                       (signal_clk);
620            clusters[x][y]->p_resetn                    (signal_resetn);
621        }
622    }
623
624    // Inter Clusters horizontal connections
625    if ( xmax > 1 )
626    {
627        for ( size_t x = 0 ; x < (xmax-1) ; x++ )
628        {
629            for ( size_t y = 0 ; y < ymax ; y++ )
630            {
631                for ( size_t k = 0 ; k < 2 ; k++ )
632                {
633                clusters[x][y]->p_cmd_out[k][EAST]      (signal_dspin_h_cmd_inc[x][y][k]);
634                clusters[x+1][y]->p_cmd_in[k][WEST]     (signal_dspin_h_cmd_inc[x][y][k]);
635                clusters[x][y]->p_cmd_in[k][EAST]       (signal_dspin_h_cmd_dec[x][y][k]);
636                clusters[x+1][y]->p_cmd_out[k][WEST]    (signal_dspin_h_cmd_dec[x][y][k]);
637                clusters[x][y]->p_rsp_out[k][EAST]      (signal_dspin_h_rsp_inc[x][y][k]);
638                clusters[x+1][y]->p_rsp_in[k][WEST]     (signal_dspin_h_rsp_inc[x][y][k]);
639                clusters[x][y]->p_rsp_in[k][EAST]       (signal_dspin_h_rsp_dec[x][y][k]);
640                clusters[x+1][y]->p_rsp_out[k][WEST]    (signal_dspin_h_rsp_dec[x][y][k]);
641                }
642            }
643        }
644    }
645    std::cout << "Horizontal connections established" << std::endl;     
646
647    // Inter Clusters vertical connections
648    if ( ymax > 1 )
649    {
650        for ( size_t y = 0 ; y < (ymax-1) ; y++ )
651        {
652            for ( size_t x = 0 ; x < xmax ; x++ )
653            {
654                for ( size_t k = 0 ; k < 2 ; k++ )
655                {
656                clusters[x][y]->p_cmd_out[k][NORTH]     (signal_dspin_v_cmd_inc[x][y][k]);
657                clusters[x][y+1]->p_cmd_in[k][SOUTH]    (signal_dspin_v_cmd_inc[x][y][k]);
658                clusters[x][y]->p_cmd_in[k][NORTH]      (signal_dspin_v_cmd_dec[x][y][k]);
659                clusters[x][y+1]->p_cmd_out[k][SOUTH]   (signal_dspin_v_cmd_dec[x][y][k]);
660                clusters[x][y]->p_rsp_out[k][NORTH]     (signal_dspin_v_rsp_inc[x][y][k]);
661                clusters[x][y+1]->p_rsp_in[k][SOUTH]    (signal_dspin_v_rsp_inc[x][y][k]);
662                clusters[x][y]->p_rsp_in[k][NORTH]      (signal_dspin_v_rsp_dec[x][y][k]);
663                clusters[x][y+1]->p_rsp_out[k][SOUTH]   (signal_dspin_v_rsp_dec[x][y][k]);
664                }
665            }
666        }
667    }
668    std::cout << "Vertical connections established" << std::endl;
669
670    // East & West boundary cluster connections
671    for ( size_t y = 0 ; y < ymax ; y++ )
672    {
673        for ( size_t k = 0 ; k < 2 ; k++ )
674        {
675            clusters[0][y]->p_cmd_in[k][WEST]           (signal_dspin_false_cmd_in[0][y][k][WEST]);
676            clusters[0][y]->p_cmd_out[k][WEST]          (signal_dspin_false_cmd_out[0][y][k][WEST]);
677            clusters[0][y]->p_rsp_in[k][WEST]           (signal_dspin_false_rsp_in[0][y][k][WEST]);
678            clusters[0][y]->p_rsp_out[k][WEST]          (signal_dspin_false_rsp_out[0][y][k][WEST]);
679         
680            clusters[xmax-1][y]->p_cmd_in[k][EAST]      (signal_dspin_false_cmd_in[xmax-1][y][k][EAST]);
681            clusters[xmax-1][y]->p_cmd_out[k][EAST]     (signal_dspin_false_cmd_out[xmax-1][y][k][EAST]);
682            clusters[xmax-1][y]->p_rsp_in[k][EAST]      (signal_dspin_false_rsp_in[xmax-1][y][k][EAST]);
683            clusters[xmax-1][y]->p_rsp_out[k][EAST]     (signal_dspin_false_rsp_out[xmax-1][y][k][EAST]);
684        }
685    }
686   
687    // North & South boundary clusters connections
688    for ( size_t x = 0 ; x < xmax ; x++ )
689    {
690        for ( size_t k = 0 ; k < 2 ; k++ )
691        {
692            clusters[x][0]->p_cmd_in[k][SOUTH]          (signal_dspin_false_cmd_in[x][0][k][SOUTH]);
693            clusters[x][0]->p_cmd_out[k][SOUTH]         (signal_dspin_false_cmd_out[x][0][k][SOUTH]);
694            clusters[x][0]->p_rsp_in[k][SOUTH]          (signal_dspin_false_rsp_in[x][0][k][SOUTH]);
695            clusters[x][0]->p_rsp_out[k][SOUTH]         (signal_dspin_false_rsp_out[x][0][k][SOUTH]);
696           
697            clusters[x][ymax-1]->p_cmd_in[k][NORTH]     (signal_dspin_false_cmd_in[x][ymax-1][k][NORTH]);
698            clusters[x][ymax-1]->p_cmd_out[k][NORTH]    (signal_dspin_false_cmd_out[x][ymax-1][k][NORTH]);
699            clusters[x][ymax-1]->p_rsp_in[k][NORTH]     (signal_dspin_false_rsp_in[x][ymax-1][k][NORTH]);
700            clusters[x][ymax-1]->p_rsp_out[k][NORTH]    (signal_dspin_false_rsp_out[x][ymax-1][k][NORTH]);
701        }
702    }
703     
704
705    ////////////////////////////////////////////////////////
706    //   Simulation
707    ///////////////////////////////////////////////////////
708
709    sc_start(sc_core::sc_time(0, SC_NS));
710    signal_resetn = false;
711
712    // network boundaries signals
713    for(size_t x=0; x<xmax ; x++)
714    {
715        for(size_t y=0 ; y<ymax ; y++)
716        {
717            for (size_t k=0; k<2; k++)
718            {
719                for(size_t a=0; a<4; a++)
720                {
721                        signal_dspin_false_cmd_in[x][y][k][a].write = false;
722                        signal_dspin_false_cmd_in[x][y][k][a].read = true;
723                        signal_dspin_false_cmd_out[x][y][k][a].write = false;
724                        signal_dspin_false_cmd_out[x][y][k][a].read = true;
725
726                        signal_dspin_false_rsp_in[x][y][k][a].write = false;
727                        signal_dspin_false_rsp_in[x][y][k][a].read = true;
728                        signal_dspin_false_rsp_out[x][y][k][a].write = false;
729                        signal_dspin_false_rsp_out[x][y][k][a].read = true;
730                }
731            }
732        }
733    }
734
735    sc_start(sc_core::sc_time(1, SC_NS));
736    signal_resetn = true;
737
738    for ( size_t n=1 ; n<ncycles ; n++)
739    {
740        if ( trace_ok and (n > from_cycle) and (n%trace_period == 0) )
741        {
742            std::cout << "****************** cycle " << std::dec << n ;
743            std::cout << " ************************************************" << std::endl;
744
745            // components cluster 00 /////////////////////
746//            clusters[0][0]->proc[0]->print_trace();
747//            clusters[0][0]->memc->print_trace();
748
749            // signals cluster 00 ////////////////////////
750//            clusters[0][0]->signal_vci_ini_d_proc[0].print_trace("proc_0_0_0_ini_d");
751//            clusters[0][0]->signal_vci_ini_c_proc[0].print_trace("proc_0_0_0_ini_c");
752//            clusters[0][0]->signal_vci_tgt_c_proc[0].print_trace("proc_0_0_0_tgt_c");
753//            clusters[0][0]->signal_vci_xram.print_trace("memc_0_0_xram");
754
755            // components cluster 01 /////////////////////
756//            clusters[0][1]->proc[0]->print_trace();
757//            clusters[0][1]->memc->print_trace();
758
759            // signals cluster 01 ///////////////////////
760//            clusters[0][1]->signal_vci_ini_d_proc[0].print_trace("proc_0_1_0_ini_d");
761//            clusters[0][1]->signal_vci_ini_c_proc[0].print_trace("proc_0_1_0_ini_c");
762//            clusters[0][1]->signal_vci_tgt_c_proc[0].print_trace("proc_0_1_0_tgt_c");
763//            clusters[0][1]->signal_vci_xram.print_trace("memc_0_1_xram");
764
765            // components cluster 10 ////////////////////
766            clusters[1][0]->proc[0]->print_trace(1);
767            clusters[1][0]->memc->print_trace();
768//            clusters[1][0]->bdev->print_trace();
769//            clusters[1][0]->mdma->print_trace();
770
771            // signals cluster 10 ///////////////////////
772            clusters[1][0]->signal_vci_ini_d_proc[0].print_trace("proc_1_0_0_ini_d");
773//            clusters[1][0]->signal_vci_ini_c_proc[0].print_trace("proc_1_0_0_ini_c");
774//            clusters[1][0]->signal_vci_tgt_c_proc[0].print_trace("proc_1_0_0_tgt_c");
775            clusters[1][0]->signal_vci_tgt_d_memc.print_trace("memc_1_0_tgt_d  ");
776//            clusters[1][0]->signal_vci_ini_c_memc.print_trace("memc_1_0_ini_c  ");
777//            clusters[1][0]->signal_vci_tgt_c_memc.print_trace("memc_1_0_tgt_c  ");
778//            clusters[1][0]->signal_vci_tgt_d_bdev.print_trace("bdev_1_0_tgt_d  ");
779//            clusters[1][0]->signal_vci_ini_d_bdev.print_trace("bdev_1_0_ini_d  ");
780//            clusters[1][0]->signal_vci_tgt_d_mdma.print_trace("mdma_1_0_tgt_d  ");
781//            clusters[1][0]->signal_vci_ini_d_mdma.print_trace("mdma_1_0_ini_d  ");
782            clusters[1][0]->signal_vci_tgt_d_mtty.print_trace("mtty_1_0_tgt_d  ");
783            clusters[1][0]->signal_vci_xram.print_trace("memc_1_0_xram");
784 
785            // components cluster 11 /////////////////////
786//            clusters[1][1]->proc[0]->print_trace();
787//            clusters[1][1]->memc->print_trace();
788           
789            // signals cluster 11 ////////////////////////
790//            clusters[1][1]->signal_vci_ini_d_proc[0].print_trace("proc_1_1_0_ini_d");
791//            clusters[1][1]->signal_vci_ini_c_proc[0].print_trace("proc_1_1_0_ini_c");
792//            clusters[1][1]->signal_vci_tgt_c_proc[0].print_trace("proc_1_1_0_tgt_c");
793//            clusters[1][1]->signal_vci_xram.print_trace("memc_1_1_xram");
794        }
795
796        sc_start(sc_core::sc_time(1, SC_NS));
797    }
798    return EXIT_SUCCESS;
799}
800
801int sc_main (int argc, char *argv[])
802{
803        try {
804                return _main(argc, argv);
805        } catch (std::exception &e) {
806                std::cout << e.what() << std::endl;
807        } catch (...) {
808                std::cout << "Unknown exception occured" << std::endl;
809                throw;
810        }
811        return 1;
812}
Note: See TracBrowser for help on using the repository browser.