source: trunk/platforms/tsar_generic_iob/top.cpp @ 963

Last change on this file since 963 was 959, checked in by alain, 9 years ago

Fix a bug in platform tsar_generic_iob to support more than 4 processors per cluster.
The hard_config.h file format has also been enriched.

File size: 70.9 KB
RevLine 
[450]1///////////////////////////////////////////////////////////////////////////////
[707]2// File: top.cpp  (for tsar_generic_iob platform)
[718]3// Author: Alain Greiner
[450]4// Copyright: UPMC/LIP6
5// Date : august 2013
6// This program is released under the GNU public license
7///////////////////////////////////////////////////////////////////////////////
[938]8// This file define a generic TSAR architecture with an external IO network
9// emulating a PCI or Hypertransport I/O bus to access 7 external peripherals:
[450]10//
[472]11// - BROM : boot ROM
12// - FBUF : Frame Buffer
[730]13// - MTTY : multi TTY (one channel)
[472]14// - MNIC : Network controller (up to 2 channels)
[498]15// - CDMA : Chained Buffer DMA controller (up to 4 channels)
[730]16// - BDEV : Dlock Device controler (one channel)
[707]17// - IOPI : HWI to SWI translator.
[450]18//
[938]19// This I/0 bus is connected to internal address space through two IOB bridges
20// located in cluster[0][0] and cluster[X_SIZE-1][Åž_SIZE-1].
21//
[707]22// The internal physical address space is 40 bits, and the cluster index
23// is defined by the 8 MSB bits, using a fixed format: X is encoded on 4 bits,
[938]24// Y is encoded on 4 bits, whatever the actual mesh size.
[707]25// => at most 16 * 16 clusters. Each cluster contains up to 4 processors.
[450]26//
[607]27// It contains 3 networks:
28//
[707]29// 1) the "INT" network supports Read/Write transactions
[718]30//    between processors and L2 caches or peripherals.
[450]31//    (VCI ADDDRESS = 40 bits / VCI DATA width = 32 bits)
32//    It supports also coherence transactions between L1 & L2 caches.
[718]33// 3) the "RAM" network emulates the 3D network between L2 caches
[472]34//    and L3 caches, and is implemented as a 2D mesh between the L2 caches,
35//    the two IO bridges and the physical RAMs disributed in all clusters.
[450]36//    (VCI ADDRESS = 40 bits / VCI DATA = 64 bits)
37// 4) the IOX network connects the two IO bridge components to the
[707]38//    7 external peripheral controllers.
[450]39//    (VCI ADDDRESS = 40 bits / VCI DATA width = 64 bits)
[718]40//
41// The external peripherals HWI IRQs are translated to WTI IRQs by the
[707]42// external IOPIC component, that must be configured by the OS to route
[874]43// these WTI IRQS to one or several internal XICU components.
[707]44// - IOPIC HWI[1:0]     connected to IRQ_NIC_RX[1:0]
[718]45// - IOPIC HWI[3:2]     connected to IRQ_NIC_TX[1:0]
[707]46// - IOPIC HWI[7:4]     connected to IRQ_CMA_TX[3:0]]
47// - IOPIC HWI[8]       connected to IRQ_BDEV
[874]48// - IOPIC HWI[31:16]   connected to IRQ_TTY_RX[15:0]
[450]49//
[730]50// Besides the external peripherals, each cluster contains one XICU component,
[707]51// and one multi channels DMA component.
[959]52// The XICU component is mainly used to handle WTI IRQs, as only
53// 1 + NB_PROCS_MAX HWI IRQs are connected to XICU in each cluster:
54// - IRQ_IN[0]            : MMC
55// - IRQ_IN[1]            : DMA channel 0
56// - IRQ_IN[2]            : DMA channel 1
57// - ...                    ...   
58// - IRQ_IN[NB_PROCS_MAX] : DMA channel NB_PROCS_MAX
[718]59//
[450]60// All clusters are identical, but cluster(0,0) and cluster(XMAX-1,YMAX-1)
61// contain an extra IO bridge component. These IOB0 & IOB1 components are
62// connected to the three networks (INT, RAM, IOX).
[718]63//
[450]64// - It uses two dspin_local_crossbar per cluster to implement the
[718]65//   local interconnect correponding to the INT network.
66// - It uses three dspin_local_crossbar per cluster to implement the
67//   local interconnect correponding to the coherence INT network.
[450]68// - It uses two virtual_dspin_router per cluster to implement
69//   the INT network (routing both the direct and coherence trafic).
70// - It uses two dspin_router per cluster to implement the RAM network.
71// - It uses the vci_cc_vcache_wrapper.
72// - It uses the vci_mem_cache.
73// - It contains one vci_xicu and one vci_multi_dma per cluster.
74// - It contains one vci_simple ram per cluster to model the L3 cache.
75//
76// The TsarIobCluster component is defined in files
77// tsar_iob_cluster.* (with * = cpp, h, sd)
78//
79// The main hardware parameters must be defined in the hard_config.h file :
[718]80// - X_SIZE           : number of clusters in a row
[707]81// - Y_SIZE           : number of clusters in a column
[959]82// - NB_PROCS_MAX     : number of processors per cluster (up to 8)
83// - NB_DMA_CHANNELS  : number of DMA channels per cluster    (>= NB_PROCS_MAX)
[874]84// - NB_TTY_CHANNELS  : number of TTY channels in I/O network (up to 16)
[707]85// - NB_NIC_CHANNELS  : number of NIC channels in I/O network (up to 2)
86// - NB_CMA_CHANNELS  : number of CMA channels in I/O network (up to 4)
[714]87// - FBUF_X_SIZE      : width of frame buffer (pixels)
88// - FBUF_Y_SIZE      : heigth of frame buffer (lines)
[959]89// - XCU_NB_HWI       : number of XCU HWIs (>= NB_PROCS_MAX + 1)
90// - XCU_NB_PTI       : number of XCU PTIs (>= NB_PROCS_MAX)
91// - XCU_NB_WTI       : number of XCU WTIs (>= 4*NB_PROCS_MAX)
92// - XCU_NB_OUT       : number of XCU output IRQs (>= 4*NB_PROCS_MAX)
[718]93//
[450]94// Some secondary hardware parameters must be defined in this top.cpp file:
[718]95// - XRAM_LATENCY     : external ram latency
[450]96// - MEMC_WAYS        : L2 cache number of ways
97// - MEMC_SETS        : L2 cache number of sets
[718]98// - L1_IWAYS
99// - L1_ISETS
100// - L1_DWAYS
101// - L1_DSETS
102// - BDEV_IMAGE_NAME  : file pathname for block device
[450]103//
104// General policy for 40 bits physical address decoding:
105// All physical segments base addresses are multiple of 1 Mbytes
[718]106// (=> the 24 LSB bits = 0, and the 16 MSB bits define the target)
[450]107// The (x_width + y_width) MSB bits (left aligned) define
108// the cluster index, and the LADR bits define the local index:
[707]109//      |X_ID|Y_ID|  LADR  |     OFFSET          |
110//      |  4 |  4 |   8    |       24            |
[450]111//
112// General policy for 14 bits SRCID decoding:
113// Each component is identified by (x_id, y_id, l_id) tuple.
[707]114//      |X_ID|Y_ID| L_ID |
115//      |  4 |  4 |  6   |
[450]116/////////////////////////////////////////////////////////////////////////
117
118#include <systemc>
119#include <sys/time.h>
120#include <iostream>
121#include <sstream>
122#include <cstdlib>
123#include <cstdarg>
124#include <stdint.h>
125
126#include "gdbserver.h"
127#include "mapping_table.h"
128
129#include "tsar_iob_cluster.h"
130#include "vci_chbuf_dma.h"
131#include "vci_multi_tty.h"
132#include "vci_multi_nic.h"
133#include "vci_simple_rom.h"
134#include "vci_block_device_tsar.h"
135#include "vci_framebuffer.h"
136#include "vci_iox_network.h"
[707]137#include "vci_iox_network.h"
138#include "vci_iopic.h"
[450]139
140#include "alloc_elems.h"
141
142///////////////////////////////////////////////////
143//      OS
144///////////////////////////////////////////////////
145#define USE_ALMOS 0
146
147#define almos_bootloader_pathname "bootloader.bin"
148#define almos_kernel_pathname     "kernel-soclib.bin@0xbfc10000:D"
149#define almos_archinfo_pathname   "arch-info.bin@0xBFC08000:D"
150
151///////////////////////////////////////////////////
152//               Parallelisation
153///////////////////////////////////////////////////
154
[762]155#define USING_OPENMP           0
156
157#if USING_OPENMP
[450]158#include <omp.h>
159#endif
160
161///////////////////////////////////////////////////////////
[718]162//          DSPIN parameters
[450]163///////////////////////////////////////////////////////////
164
165#define dspin_int_cmd_width   39
166#define dspin_int_rsp_width   32
167
168#define dspin_ram_cmd_width   64
169#define dspin_ram_rsp_width   64
170
171///////////////////////////////////////////////////////////
[718]172//         VCI fields width  for the 3 VCI networks
[450]173///////////////////////////////////////////////////////////
174
175#define vci_cell_width_int    4
176#define vci_cell_width_ext    8
177
178#define vci_plen_width        8
179#define vci_address_width     40
180#define vci_rerror_width      1
181#define vci_clen_width        1
182#define vci_rflag_width       1
183#define vci_srcid_width       14
184#define vci_pktid_width       4
185#define vci_trdid_width       4
186#define vci_wrplen_width      1
187
188////////////////////////////////////////////////////////////
[718]189//    Main Hardware Parameters values
[450]190//////////////////////i/////////////////////////////////////
191
[802]192#include "hard_config.h"
[450]193
194////////////////////////////////////////////////////////////
[718]195//    Secondary Hardware Parameters values
[450]196//////////////////////i/////////////////////////////////////
197
[607]198#define XMAX                  X_SIZE
199#define YMAX                  Y_SIZE
[450]200
201#define XRAM_LATENCY          0
202
203#define MEMC_WAYS             16
204#define MEMC_SETS             256
205
206#define L1_IWAYS              4
207#define L1_ISETS              64
208
209#define L1_DWAYS              4
210#define L1_DSETS              64
211
[765]212#define BDEV_IMAGE_NAME       "../../../giet_vm/hdd/virt_hdd.dmg"
[450]213
[938]214#define ROM_SOFT_NAME         "../../softs/tsar_boot/preloader.elf"
[450]215
216#define NORTH                 0
217#define SOUTH                 1
218#define EAST                  2
219#define WEST                  3
220
[693]221#define cluster(x,y)   ((y) + ((x) << 4))
[450]222
223////////////////////////////////////////////////////////////
[718]224//     DEBUG Parameters default values
[450]225//////////////////////i/////////////////////////////////////
226
[914]227#define MAX_FROZEN_CYCLES     1000000
[450]228
229/////////////////////////////////////////////////////////
230//    Physical segments definition
231/////////////////////////////////////////////////////////
232
[734]233// All physical segments base addresses and sizes are defined
234// in the hard_config.h file. For replicated segments, the
235// base address is incremented by a cluster offset:
236// offset  = cluster(x,y) << (address_width-x_width-y_width);
[450]237
238////////////////////////////////////////////////////////////////////////
239//          SRCID definition
240////////////////////////////////////////////////////////////////////////
241// All initiators are in the same indexing space (14 bits).
242// The SRCID is structured in two fields:
[764]243// - The 8 MSB bits define the cluster index (left aligned)
244// - The 6  LSB bits define the local index.
[718]245// Two different initiators cannot have the same SRCID, but a given
246// initiator can have two alias SRCIDs:
[450]247// - Internal initiators (procs, mdma) are replicated in all clusters,
248//   and each initiator has one single SRCID.
249// - External initiators (bdev, cdma) are not replicated, but can be
[718]250//   accessed in 2 clusters : cluster_iob0 and cluster_iob1.
[450]251//   They have the same local index, but two different cluster indexes.
[707]252//
[450]253// As cluster_iob0 and cluster_iob1 contain both internal initiators
[718]254// and external initiators, they must have different local indexes.
[450]255// Consequence: For a local interconnect, the INI_ID port index
256// is NOT equal to the SRCID local index, and the local interconnect
[718]257// must make a translation: SRCID => INI_ID
[450]258////////////////////////////////////////////////////////////////////////
259
[550]260#define PROC_LOCAL_SRCID             0x0    // from 0 to 7
261#define MDMA_LOCAL_SRCID             0x8
262#define IOBX_LOCAL_SRCID             0x9
263#define MEMC_LOCAL_SRCID             0xA
[718]264#define CDMA_LOCAL_SRCID             0xB
265#define BDEV_LOCAL_SRCID             0xC
[707]266#define IOPI_LOCAL_SRCID             0xD
[450]267
[550]268///////////////////////////////////////////////////////////////////////
[450]269//     TGT_ID and INI_ID port indexing for INT local interconnect
[550]270///////////////////////////////////////////////////////////////////////
[450]271
272#define INT_MEMC_TGT_ID              0
273#define INT_XICU_TGT_ID              1
274#define INT_MDMA_TGT_ID              2
275#define INT_IOBX_TGT_ID              3
276
277#define INT_PROC_INI_ID              0   // from 0 to (NB_PROCS_MAX-1)
[707]278#define INT_MDMA_INI_ID              (NB_PROCS_MAX)
[450]279#define INT_IOBX_INI_ID              (NB_PROCS_MAX+1)
280
[550]281///////////////////////////////////////////////////////////////////////
[450]282//     TGT_ID and INI_ID port indexing for RAM local interconnect
[550]283///////////////////////////////////////////////////////////////////////
[450]284
285#define RAM_XRAM_TGT_ID              0
286
287#define RAM_MEMC_INI_ID              0
288#define RAM_IOBX_INI_ID              1
289
[550]290///////////////////////////////////////////////////////////////////////
[450]291//     TGT_ID and INI_ID port indexing for I0X local interconnect
[550]292///////////////////////////////////////////////////////////////////////
[450]293
[718]294#define IOX_FBUF_TGT_ID              0
295#define IOX_BDEV_TGT_ID              1
296#define IOX_MNIC_TGT_ID              2
297#define IOX_CDMA_TGT_ID              3
298#define IOX_BROM_TGT_ID              4
299#define IOX_MTTY_TGT_ID              5
300#define IOX_IOPI_TGT_ID              6
301#define IOX_IOB0_TGT_ID              7
302#define IOX_IOB1_TGT_ID              8
[450]303
[718]304#define IOX_BDEV_INI_ID              0
305#define IOX_CDMA_INI_ID              1
306#define IOX_IOPI_INI_ID              2
307#define IOX_IOB0_INI_ID              3
308#define IOX_IOB1_INI_ID              4
[450]309
[550]310////////////////////////////////////////////////////////////////////////
[450]311int _main(int argc, char *argv[])
[550]312////////////////////////////////////////////////////////////////////////
[450]313{
314   using namespace sc_core;
315   using namespace soclib::caba;
316   using namespace soclib::common;
317
318
[938]319   char     soft_name[256]   = ROM_SOFT_NAME;           // pathname: binary code
320   size_t   ncycles          = 4000000000;              // simulated cycles
321   char     disk_name[256]   = BDEV_IMAGE_NAME;         // pathname: disk image
322   ssize_t  threads_nr       = 1;                       // simulator's threads number
323   bool     debug_ok         = false;                   // trace activated
324   size_t   debug_memc_id    = 0xFFFFFFFF;              // index of traced memc
325   size_t   debug_proc_id    = 0xFFFFFFFF;              // index of traced proc
326   size_t   debug_xram_id    = 0xFFFFFFFF;              // index of traced xram
327   bool     debug_iob        = false;                   // trace iob0 & iob1 when true
328   uint32_t debug_from       = 0;                       // trace start cycle
329   uint32_t frozen_cycles    = MAX_FROZEN_CYCLES;       // monitoring frozen processor
330   size_t   cluster_iob0     = cluster(0,0);            // cluster containing IOB0
331   size_t   cluster_iob1     = cluster(XMAX-1,YMAX-1);  // cluster containing IOB1
332   size_t   x_width          = X_WIDTH;                 // # of bits for x
333   size_t   y_width          = Y_WIDTH;                 // # of bits for y
334   size_t   p_width          = P_WIDTH;                 // # of bits for lpid
[450]335
[762]336#if USING_OPENMP
337   size_t   simul_period     = 1000000;
338#else
339   size_t   simul_period     = 1;
340#endif
341
[607]342   assert( (X_WIDTH == 4) and (Y_WIDTH == 4) and
343   "ERROR: we must have X_WIDTH == Y_WIDTH == 4");
[718]344
[818]345   assert( P_WIDTH <= 4 and
346   "ERROR: we must have P_WIDTH <= 4");
[802]347
[450]348   ////////////// command line arguments //////////////////////
349   if (argc > 1)
350   {
351      for (int n = 1; n < argc; n = n + 2)
352      {
353         if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc))
354         {
355            ncycles = atoi(argv[n+1]);
356         }
[938]357         else if ((strcmp(argv[n],"-ROM") == 0) && (n+1<argc) )
[450]358         {
359            strcpy(soft_name, argv[n+1]);
360         }
361         else if ((strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) )
362         {
363            debug_ok = true;
364            debug_from = atoi(argv[n+1]);
365         }
366         else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
367         {
368            strcpy(disk_name, argv[n+1]);
369         }
370         else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) )
371         {
372            debug_memc_id = atoi(argv[n+1]);
[607]373            size_t x = debug_memc_id >> 4;
374            size_t y = debug_memc_id & 0xF;
375            if( (x>=XMAX) || (y>=YMAX) )
376            {
[707]377                std::cout << "MEMCID parameter does'nt fit XMAX/YMAX" << std::endl;
[914]378                std::cout << " - MEMCID = " << std::hex << debug_memc_id << std::endl;
379                std::cout << " - XMAX   = " << std::hex << XMAX          << std::endl;
380                std::cout << " - YMAX   = " << std::hex << YMAX          << std::endl;
[607]381                exit(0);
382            }
[450]383         }
[707]384         else if ((strcmp(argv[n],"-XRAMID") == 0) && (n+1<argc) )
385         {
386            debug_xram_id = atoi(argv[n+1]);
387            size_t x = debug_xram_id >> 4;
388            size_t y = debug_xram_id & 0xF;
389            if( (x>=XMAX) || (y>=YMAX) )
390            {
391                std::cout << "XRAMID parameter does'nt fit XMAX/YMAX" << std::endl;
392                exit(0);
393            }
394         }
[450]395         else if ((strcmp(argv[n],"-IOB") == 0) && (n+1<argc) )
396         {
397            debug_iob = atoi(argv[n+1]);
398         }
399         else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) )
400         {
[607]401            debug_proc_id     = atoi(argv[n+1]);
[802]402            size_t cluster_xy = debug_proc_id >> P_WIDTH ;
[607]403            size_t x          = cluster_xy >> 4;
404            size_t y          = cluster_xy & 0xF;
405            if( (x>=XMAX) || (y>=YMAX) )
406            {
407                std::cout << "PROCID parameter does'nt fit XMAX/YMAX" << std::endl;
[914]408                std::cout << " - PROCID = " << std::hex << debug_proc_id << std::endl;
409                std::cout << " - XMAX   = " << std::hex << XMAX          << std::endl;
410                std::cout << " - YMAX   = " << std::hex << YMAX          << std::endl;
[607]411                exit(0);
412            }
[450]413         }
414         else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc))
415         {
416            threads_nr = atoi(argv[n+1]);
417            threads_nr = (threads_nr < 1) ? 1 : threads_nr;
418         }
419         else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc))
420         {
421            frozen_cycles = atoi(argv[n+1]);
422         }
423         else
424         {
425            std::cout << "   Arguments are (key,value) couples." << std::endl;
426            std::cout << "   The order is not important." << std::endl;
427            std::cout << "   Accepted arguments are :" << std::endl << std::endl;
[938]428            std::cout << "     - ROM  pathname_for_embedded_soft" << std::endl;
429            std::cout << "     - DISK pathname_for_disk_image" << std::endl;
430            std::cout << "     - NCYCLES number_of_simulated_cycles" << std::endl;
431            std::cout << "     - DEBUG debug_start_cycle" << std::endl;
432            std::cout << "     - THREADS simulator's threads number" << std::endl;
433            std::cout << "     - FROZEN max_number_of_lines" << std::endl;
434            std::cout << "     - MEMCID index_memc_to_be_traced" << std::endl;
435            std::cout << "     - XRAMID index_xram_to_be_traced" << std::endl;
436            std::cout << "     - PROCID index_proc_to_be_traced" << std::endl;
437            std::cout << "     - IOB    non_zero_value" << std::endl;
[450]438            exit(0);
439         }
440      }
441   }
442
443   // checking hardware parameters
[607]444   assert( (XMAX <= 16) and
445           "The XMAX parameter cannot be larger than 16" );
[450]446
[607]447   assert( (YMAX <= 16) and
448           "The YMAX parameter cannot be larger than 16" );
[450]449
[959]450   assert( (NB_PROCS_MAX <= 8) and
451           "NB_PROCS_MAX parameter cannot be larger than 8" );
[450]452
[959]453   assert( (XCU_NB_HWI > NB_PROCS_MAX) and
454           "XCU_NB_HWI must be larger than NB_PROCS_MAX" );
455
456   assert( (XCU_NB_PTI >= NB_PROCS_MAX) and
457           "XCU_NB_PTI cannot be smaller than NB_PROCS_MAX" );
458
459   assert( (XCU_NB_WTI >= 4*NB_PROCS_MAX) and
460           "XCU_NB_WTI cannot be smaller than 4*NB_PROCS_MAX" );
461
462   assert( (XCU_NB_OUT >= 4*NB_PROCS_MAX) and
463           "XCU_NB_OUT cannot be smaller than 4*NB_PROCS_MAX" );
464   
465   assert( (NB_DMA_CHANNELS >= NB_PROCS_MAX) and
[914]466           "The NB_DMA_CHANNELS parameter cannot be larger than 8" );
[450]467
[874]468   assert( (NB_TTY_CHANNELS >= 1) and (NB_TTY_CHANNELS <= 16) and
469           "The NB_TTY_CHANNELS parameter cannot be larger than 16" );
[450]470
[914]471   assert( (NB_NIC_CHANNELS <= 2) and
472           "The NB_NIC_CHANNELS parameter cannot be larger than 2" );
[450]473
[914]474   assert( (NB_CMA_CHANNELS <= 4) and
475           "The NB_CMA_CHANNELS parameter cannot be larger than 4" );
476
[707]477   std::cout << std::endl << std::dec
478             << " - XMAX            = " << XMAX << std::endl
479             << " - YMAX            = " << YMAX << std::endl
[802]480             << " - NB_PROCS_MAX    = " << NB_PROCS_MAX << std::endl
[914]481             << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS <<  std::endl
[710]482             << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS <<  std::endl
[707]483             << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS <<  std::endl
[914]484             << " - NB_CMA_CHANNELS = " << NB_CMA_CHANNELS <<  std::endl
[707]485             << " - MEMC_WAYS       = " << MEMC_WAYS << std::endl
486             << " - MEMC_SETS       = " << MEMC_SETS << std::endl
487             << " - RAM_LATENCY     = " << XRAM_LATENCY << std::endl
488             << " - MAX_FROZEN      = " << frozen_cycles << std::endl
[914]489             << " - NCYCLES         = " << ncycles << std::endl
[707]490             << " - DEBUG_PROCID    = " << debug_proc_id << std::endl
491             << " - DEBUG_MEMCID    = " << debug_memc_id << std::endl
492             << " - DEBUG_XRAMID    = " << debug_xram_id << std::endl;
[450]493
494   std::cout << std::endl;
495
[762]496#if USING_OPENMP
[450]497   omp_set_dynamic(false);
498   omp_set_num_threads(threads_nr);
499   std::cerr << "Built with openmp version " << _OPENMP << std::endl;
500#endif
501
502   // Define VciParams objects
503   typedef soclib::caba::VciParams<vci_cell_width_int,
504                                   vci_plen_width,
505                                   vci_address_width,
506                                   vci_rerror_width,
507                                   vci_clen_width,
508                                   vci_rflag_width,
509                                   vci_srcid_width,
510                                   vci_pktid_width,
511                                   vci_trdid_width,
512                                   vci_wrplen_width> vci_param_int;
513
514   typedef soclib::caba::VciParams<vci_cell_width_ext,
515                                   vci_plen_width,
516                                   vci_address_width,
[718]517                                   vci_rerror_width,
[450]518                                   vci_clen_width,
519                                   vci_rflag_width,
520                                   vci_srcid_width,
521                                   vci_pktid_width,
522                                   vci_trdid_width,
523                                   vci_wrplen_width> vci_param_ext;
524
525   /////////////////////////////////////////////////////////////////////
526   // INT network mapping table
527   // - two levels address decoding for commands
528   // - two levels srcid decoding for responses
529   // - NB_PROCS_MAX + 2 (MDMA, IOBX) local initiators per cluster
530   // - 4 local targets (MEMC, XICU, MDMA, IOBX) per cluster
531   /////////////////////////////////////////////////////////////////////
[718]532   MappingTable maptab_int( vci_address_width,
533                            IntTab(x_width + y_width, 16 - x_width - y_width),
534                            IntTab(x_width + y_width, vci_srcid_width - x_width - y_width),
[450]535                            0x00FF000000);
536
537   for (size_t x = 0; x < XMAX; x++)
538   {
539      for (size_t y = 0; y < YMAX; y++)
540      {
[718]541         uint64_t offset = ((uint64_t)cluster(x,y))
[450]542                              << (vci_address_width-x_width-y_width);
[550]543         bool config    = true;
544         bool cacheable = true;
[450]545
546         // the four following segments are defined in all clusters
547
548         std::ostringstream    smemc_conf;
549         smemc_conf << "int_seg_memc_conf_" << x << "_" << y;
[718]550         maptab_int.add(Segment(smemc_conf.str(), SEG_MMC_BASE+offset, SEG_MMC_SIZE,
551                     IntTab(cluster(x,y), INT_MEMC_TGT_ID), not cacheable, config ));
[450]552
553         std::ostringstream    smemc_xram;
554         smemc_xram << "int_seg_memc_xram_" << x << "_" << y;
[718]555         maptab_int.add(Segment(smemc_xram.str(), SEG_RAM_BASE+offset, SEG_RAM_SIZE,
556                     IntTab(cluster(x,y), INT_MEMC_TGT_ID), cacheable));
[450]557
558         std::ostringstream    sxicu;
559         sxicu << "int_seg_xicu_" << x << "_" << y;
[718]560         maptab_int.add(Segment(sxicu.str(), SEG_XCU_BASE+offset, SEG_XCU_SIZE,
561                     IntTab(cluster(x,y), INT_XICU_TGT_ID), not cacheable));
[450]562
563         std::ostringstream    smdma;
564         smdma << "int_seg_mdma_" << x << "_" << y;
[718]565         maptab_int.add(Segment(smdma.str(), SEG_DMA_BASE+offset, SEG_DMA_SIZE,
566                     IntTab(cluster(x,y), INT_MDMA_TGT_ID), not cacheable));
[450]567
568         // the following segments are only defined in cluster_iob0 or in cluster_iob1
569
[718]570         if ( (cluster(x,y) == cluster_iob0) or (cluster(x,y) == cluster_iob1) )
[450]571         {
572            std::ostringstream    siobx;
573            siobx << "int_seg_iobx_" << x << "_" << y;
[718]574            maptab_int.add(Segment(siobx.str(), SEG_IOB_BASE+offset, SEG_IOB_SIZE,
[550]575                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable, config ));
[450]576
577            std::ostringstream    stty;
578            stty << "int_seg_mtty_" << x << "_" << y;
[718]579            maptab_int.add(Segment(stty.str(), SEG_TTY_BASE+offset, SEG_TTY_SIZE,
[550]580                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[450]581
582            std::ostringstream    sfbf;
583            sfbf << "int_seg_fbuf_" << x << "_" << y;
[718]584            maptab_int.add(Segment(sfbf.str(), SEG_FBF_BASE+offset, SEG_FBF_SIZE,
[550]585                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[450]586
587            std::ostringstream    sbdv;
588            sbdv << "int_seg_bdev_" << x << "_" << y;
[718]589            maptab_int.add(Segment(sbdv.str(), SEG_IOC_BASE+offset, SEG_IOC_SIZE,
[550]590                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[450]591
592            std::ostringstream    snic;
593            snic << "int_seg_mnic_" << x << "_" << y;
[718]594            maptab_int.add(Segment(snic.str(), SEG_NIC_BASE+offset, SEG_NIC_SIZE,
[550]595                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[450]596
597            std::ostringstream    srom;
598            srom << "int_seg_brom_" << x << "_" << y;
[718]599            maptab_int.add(Segment(srom.str(), SEG_ROM_BASE+offset, SEG_ROM_SIZE,
[550]600                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), cacheable ));
[450]601
602            std::ostringstream    sdma;
603            sdma << "int_seg_cdma_" << x << "_" << y;
[718]604            maptab_int.add(Segment(sdma.str(), SEG_CMA_BASE+offset, SEG_CMA_SIZE,
[550]605                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[707]606
607            std::ostringstream    spic;
608            spic << "int_seg_iopi_" << x << "_" << y;
[718]609            maptab_int.add(Segment(spic.str(), SEG_PIC_BASE+offset, SEG_PIC_SIZE,
[707]610                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
[450]611         }
612
613         // This define the mapping between the SRCIDs
614         // and the port index on the local interconnect.
615
[718]616         maptab_int.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ),
[550]617                               IntTab( cluster(x,y), INT_MDMA_INI_ID ) );
[450]618
[550]619         maptab_int.srcid_map( IntTab( cluster(x,y), IOBX_LOCAL_SRCID ),
620                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
[450]621
[707]622         maptab_int.srcid_map( IntTab( cluster(x,y), IOPI_LOCAL_SRCID ),
623                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
624
[802]625         for ( size_t p = 0 ; p < NB_PROCS_MAX; p++ )
[718]626         maptab_int.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID+p ),
[550]627                               IntTab( cluster(x,y), INT_PROC_INI_ID+p ) );
[450]628      }
629   }
630   std::cout << "INT network " << maptab_int << std::endl;
631
632    /////////////////////////////////////////////////////////////////////////
[718]633    // RAM network mapping table
[450]634    // - two levels address decoding for commands
635    // - two levels srcid decoding for responses
[718]636    // - 2 local initiators (MEMC, IOBX) per cluster
[450]637    //   (IOBX component only in cluster_iob0 and cluster_iob1)
638    // - 1 local target (XRAM) per cluster
639    ////////////////////////////////////////////////////////////////////////
640    MappingTable maptab_ram( vci_address_width,
[718]641                             IntTab(x_width+y_width, 0),
642                             IntTab(x_width+y_width, vci_srcid_width - x_width - y_width),
[450]643                             0x00FF000000);
644
645    for (size_t x = 0; x < XMAX; x++)
646    {
647        for (size_t y = 0; y < YMAX ; y++)
[718]648        {
649            uint64_t offset = ((uint64_t)cluster(x,y))
[450]650                                << (vci_address_width-x_width-y_width);
651
652            std::ostringstream sxram;
653            sxram << "ext_seg_xram_" << x << "_" << y;
[718]654            maptab_ram.add(Segment(sxram.str(), SEG_RAM_BASE+offset,
655                           SEG_RAM_SIZE, IntTab(cluster(x,y), RAM_XRAM_TGT_ID), false));
[450]656        }
657    }
658
[550]659    // This define the mapping between the initiators SRCID
660    // and the port index on the RAM local interconnect.
[718]661    // External initiator have two alias SRCID (iob0 / iob1)
[450]662
[718]663    maptab_ram.srcid_map( IntTab( cluster_iob0, CDMA_LOCAL_SRCID ),
[550]664                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
[450]665
[718]666    maptab_ram.srcid_map( IntTab( cluster_iob1, CDMA_LOCAL_SRCID ),
[550]667                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
[450]668
[550]669    maptab_ram.srcid_map( IntTab( cluster_iob0, BDEV_LOCAL_SRCID ),
670                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
[450]671
[550]672    maptab_ram.srcid_map( IntTab( cluster_iob1, BDEV_LOCAL_SRCID ),
673                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
674
[718]675    maptab_ram.srcid_map( IntTab( cluster_iob0, IOPI_LOCAL_SRCID ),
676                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
677
678    maptab_ram.srcid_map( IntTab( cluster_iob1, IOPI_LOCAL_SRCID ),
679                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
680
681    maptab_ram.srcid_map( IntTab( cluster_iob0, MEMC_LOCAL_SRCID ),
682                          IntTab( cluster_iob0, RAM_MEMC_INI_ID ) );
683
684    maptab_ram.srcid_map( IntTab( cluster_iob1, MEMC_LOCAL_SRCID ),
[550]685                          IntTab( cluster_iob1, RAM_MEMC_INI_ID ) );
686
[450]687    std::cout << "RAM network " << maptab_ram << std::endl;
688
689    ///////////////////////////////////////////////////////////////////////
[718]690    // IOX network mapping table
691    // - two levels address decoding for commands (9, 7) bits
[450]692    // - two levels srcid decoding for responses
[707]693    // - 5 initiators (IOB0, IOB1, BDEV, CDMA, IOPI)
694    // - 9 targets (IOB0, IOB1, BDEV, CDMA, MTTY, FBUF, BROM, MNIC, IOPI)
[718]695    //
696    // Address bit 32 is used to determine if a command must be routed to
697    // IOB0 or IOB1.
[450]698    ///////////////////////////////////////////////////////////////////////
[718]699    MappingTable maptab_iox(
700          vci_address_width,
701          IntTab(x_width + y_width - 1, 16 - x_width - y_width + 1),
702          IntTab(x_width + y_width    , vci_param_ext::S - x_width - y_width),
703          0x00FF000000);
[450]704
[707]705    // External peripherals segments
[718]706    // When there is more than one cluster, external peripherals can be accessed
[707]707    // through two segments, depending on the used IOB (IOB0 or IOB1).
[718]708
709    const uint64_t iob0_base = ((uint64_t)cluster_iob0)
710       << (vci_address_width - x_width - y_width);
711
712    maptab_iox.add(Segment("iox_seg_mtty_0", SEG_TTY_BASE + iob0_base, SEG_TTY_SIZE,
713                   IntTab(0, IOX_MTTY_TGT_ID), false));
714    maptab_iox.add(Segment("iox_seg_fbuf_0", SEG_FBF_BASE + iob0_base, SEG_FBF_SIZE,
715                   IntTab(0, IOX_FBUF_TGT_ID), false));
716    maptab_iox.add(Segment("iox_seg_bdev_0", SEG_IOC_BASE + iob0_base, SEG_IOC_SIZE,
717                   IntTab(0, IOX_BDEV_TGT_ID), false));
718    maptab_iox.add(Segment("iox_seg_mnic_0", SEG_NIC_BASE + iob0_base, SEG_NIC_SIZE,
719                   IntTab(0, IOX_MNIC_TGT_ID), false));
720    maptab_iox.add(Segment("iox_seg_cdma_0", SEG_CMA_BASE + iob0_base, SEG_CMA_SIZE,
721                   IntTab(0, IOX_CDMA_TGT_ID), false));
722    maptab_iox.add(Segment("iox_seg_brom_0", SEG_ROM_BASE + iob0_base, SEG_ROM_SIZE,
723                   IntTab(0, IOX_BROM_TGT_ID), false));
724    maptab_iox.add(Segment("iox_seg_iopi_0", SEG_PIC_BASE + iob0_base, SEG_PIC_SIZE,
725                   IntTab(0, IOX_IOPI_TGT_ID), false));
726
[707]727    if ( cluster_iob0 != cluster_iob1 )
728    {
[718]729       const uint64_t iob1_base = ((uint64_t)cluster_iob1)
730          << (vci_address_width - x_width - y_width);
731
732        maptab_iox.add(Segment("iox_seg_mtty_1", SEG_TTY_BASE + iob1_base, SEG_TTY_SIZE,
733                   IntTab(0, IOX_MTTY_TGT_ID), false));
734        maptab_iox.add(Segment("iox_seg_fbuf_1", SEG_FBF_BASE + iob1_base, SEG_FBF_SIZE,
735                   IntTab(0, IOX_FBUF_TGT_ID), false));
736        maptab_iox.add(Segment("iox_seg_bdev_1", SEG_IOC_BASE + iob1_base, SEG_IOC_SIZE,
737                   IntTab(0, IOX_BDEV_TGT_ID), false));
738        maptab_iox.add(Segment("iox_seg_mnic_1", SEG_NIC_BASE + iob1_base, SEG_NIC_SIZE,
739                   IntTab(0, IOX_MNIC_TGT_ID), false));
740        maptab_iox.add(Segment("iox_seg_cdma_1", SEG_CMA_BASE + iob1_base, SEG_CMA_SIZE,
741                   IntTab(0, IOX_CDMA_TGT_ID), false));
742        maptab_iox.add(Segment("iox_seg_brom_1", SEG_ROM_BASE + iob1_base, SEG_ROM_SIZE,
743                   IntTab(0, IOX_BROM_TGT_ID), false));
744        maptab_iox.add(Segment("iox_seg_iopi_1", SEG_PIC_BASE + iob1_base, SEG_PIC_SIZE,
745                   IntTab(0, IOX_IOPI_TGT_ID), false));
[707]746    }
[450]747
[718]748    // If there is more than one cluster, external peripherals
[707]749    // can access RAM through two segments (IOB0 / IOB1).
750    // As IOMMU is not activated, addresses are 40 bits (physical addresses),
[718]751    // and the choice depends on address bit A[32].
[450]752    for (size_t x = 0; x < XMAX; x++)
753    {
754        for (size_t y = 0; y < YMAX ; y++)
[718]755        {
756            const bool wti       = true;
757            const bool cacheable = true;
[450]758
[718]759            const uint64_t offset = ((uint64_t)cluster(x,y))
760                << (vci_address_width-x_width-y_width);
761
762            const uint64_t xicu_base = SEG_XCU_BASE + offset;
763
764            if ( (y & 0x1) == 0 ) // use IOB0
[450]765            {
[718]766                std::ostringstream sxcu0;
767                sxcu0 << "iox_seg_xcu0_" << x << "_" << y;
768                maptab_iox.add(Segment(sxcu0.str(), xicu_base, SEG_XCU_SIZE,
769                            IntTab(0, IOX_IOB0_TGT_ID), not cacheable, wti));
770
771                std::ostringstream siob0;
772                siob0 << "iox_seg_ram0_" << x << "_" << y;
773                maptab_iox.add(Segment(siob0.str(), offset, SEG_XCU_BASE,
774                            IntTab(0, IOX_IOB0_TGT_ID), not cacheable, not wti));
[707]775            }
[718]776            else                  // USE IOB1
[707]777            {
[718]778                std::ostringstream sxcu1;
779                sxcu1 << "iox_seg_xcu1_" << x << "_" << y;
780                maptab_iox.add(Segment(sxcu1.str(), xicu_base, SEG_XCU_SIZE,
781                            IntTab(0, IOX_IOB1_TGT_ID), not cacheable, wti));
782
783                std::ostringstream siob1;
784                siob1 << "iox_seg_ram1_" << x << "_" << y;
785                maptab_iox.add(Segment(siob1.str(), offset, SEG_XCU_BASE,
786                            IntTab(0, IOX_IOB1_TGT_ID), not cacheable, not wti));
[450]787            }
788        }
789    }
790
[707]791    // This define the mapping between the external initiators (SRCID)
[450]792    // and the port index on the IOX local interconnect.
[550]793
[718]794    maptab_iox.srcid_map( IntTab( 0, CDMA_LOCAL_SRCID ) ,
795                          IntTab( 0, IOX_CDMA_INI_ID  ) );
796    maptab_iox.srcid_map( IntTab( 0, BDEV_LOCAL_SRCID ) ,
797                          IntTab( 0, IOX_BDEV_INI_ID  ) );
798    maptab_iox.srcid_map( IntTab( 0, IOPI_LOCAL_SRCID ) ,
799                          IntTab( 0, IOX_IOPI_INI_ID  ) );
800    maptab_iox.srcid_map( IntTab( 0, IOX_IOB0_INI_ID  ) ,
801                          IntTab( 0, IOX_IOB0_INI_ID  ) );
802
[707]803    if ( cluster_iob0 != cluster_iob1 )
804    {
[718]805        maptab_iox.srcid_map( IntTab( 0, IOX_IOB1_INI_ID ) ,
806                              IntTab( 0, IOX_IOB1_INI_ID ) );
[707]807    }
[550]808
[450]809    std::cout << "IOX network " << maptab_iox << std::endl;
810
811    ////////////////////
812    // Signals
813    ///////////////////
814
[550]815    sc_clock                          signal_clk("clk");
816    sc_signal<bool>                   signal_resetn("resetn");
[450]817
[584]818    sc_signal<bool>                   signal_irq_false;
[550]819    sc_signal<bool>                   signal_irq_bdev;
[874]820    sc_signal<bool>                   signal_irq_mtty_rx[NB_TTY_CHANNELS];
[550]821    sc_signal<bool>                   signal_irq_mnic_rx[NB_NIC_CHANNELS];
822    sc_signal<bool>                   signal_irq_mnic_tx[NB_NIC_CHANNELS];
[707]823    sc_signal<bool>                   signal_irq_cdma[NB_CMA_CHANNELS];
[450]824
825    // VCI signals for IOX network
[550]826    VciSignals<vci_param_ext>         signal_vci_ini_iob0("signal_vci_ini_iob0");
827    VciSignals<vci_param_ext>         signal_vci_ini_iob1("signal_vci_ini_iob1");
828    VciSignals<vci_param_ext>         signal_vci_ini_bdev("signal_vci_ini_bdev");
829    VciSignals<vci_param_ext>         signal_vci_ini_cdma("signal_vci_ini_cdma");
[707]830    VciSignals<vci_param_ext>         signal_vci_ini_iopi("signal_vci_ini_iopi");
[450]831
[550]832    VciSignals<vci_param_ext>         signal_vci_tgt_iob0("signal_vci_tgt_iob0");
833    VciSignals<vci_param_ext>         signal_vci_tgt_iob1("signal_vci_tgt_iob1");
834    VciSignals<vci_param_ext>         signal_vci_tgt_mtty("signal_vci_tgt_mtty");
835    VciSignals<vci_param_ext>         signal_vci_tgt_fbuf("signal_vci_tgt_fbuf");
836    VciSignals<vci_param_ext>         signal_vci_tgt_mnic("signal_vci_tgt_mnic");
837    VciSignals<vci_param_ext>         signal_vci_tgt_brom("signal_vci_tgt_brom");
838    VciSignals<vci_param_ext>         signal_vci_tgt_bdev("signal_vci_tgt_bdev");
839    VciSignals<vci_param_ext>         signal_vci_tgt_cdma("signal_vci_tgt_cdma");
[953]840    VciSignals<vci_param_ext>         signal_vci_tgt_iopi("signal_vci_tgt_iopi");
[450]841
[718]842   // Horizontal inter-clusters INT network DSPIN
[450]843   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_inc =
[468]844      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_inc", XMAX-1, YMAX, 3);
[450]845   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_dec =
[468]846      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_dec", XMAX-1, YMAX, 3);
[450]847   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_inc =
848      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_inc", XMAX-1, YMAX, 2);
849   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_dec =
850      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_dec", XMAX-1, YMAX, 2);
851
852   // Vertical inter-clusters INT network DSPIN
853   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_inc =
[468]854      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_inc", XMAX, YMAX-1, 3);
[450]855   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_dec =
[468]856      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_dec", XMAX, YMAX-1, 3);
[450]857   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_inc =
858      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_inc", XMAX, YMAX-1, 2);
859   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_dec =
860      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_dec", XMAX, YMAX-1, 2);
861
[718]862   // Mesh boundaries INT network DSPIN
[450]863   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_in =
[468]864      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_in", XMAX, YMAX, 4, 3);
[450]865   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_out =
[468]866      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_out", XMAX, YMAX, 4, 3);
[450]867   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_in =
[468]868      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_in", XMAX, YMAX, 4, 2);
[450]869   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_out =
[468]870      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_out", XMAX, YMAX, 4, 2);
[450]871
872
[718]873   // Horizontal inter-clusters RAM network DSPIN
[450]874   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_inc =
875      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_inc", XMAX-1, YMAX);
876   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_dec =
877      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_dec", XMAX-1, YMAX);
878   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_inc =
879      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_inc", XMAX-1, YMAX);
880   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_dec =
881      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_dec", XMAX-1, YMAX);
882
883   // Vertical inter-clusters RAM network DSPIN
884   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_inc =
885      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_inc", XMAX, YMAX-1);
886   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_dec =
887      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_dec", XMAX, YMAX-1);
888   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_inc =
889      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_inc", XMAX, YMAX-1);
890   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_dec =
891      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_dec", XMAX, YMAX-1);
892
[718]893   // Mesh boundaries RAM network DSPIN
[450]894   DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_in =
895      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_in", XMAX, YMAX, 4);
896   DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_out =
897      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_out", XMAX, YMAX, 4);
898   DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_in =
899      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_in", XMAX, YMAX, 4);
900   DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_out =
901      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_out", XMAX, YMAX, 4);
902
903   ////////////////////////////
[718]904   //      Loader
[450]905   ////////////////////////////
906
907#if USE_ALMOS
908   soclib::common::Loader loader(almos_bootloader_pathname,
909                                 almos_archinfo_pathname,
910                                 almos_kernel_pathname);
911#else
912   soclib::common::Loader loader(soft_name);
913#endif
914
915   typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss;
916   proc_iss::set_loader(loader);
917
918   ////////////////////////////////////////
919   //  Instanciated Hardware Components
920   ////////////////////////////////////////
921
922   std::cout << std::endl << "External Bus and Peripherals" << std::endl << std::endl;
923
[718]924   const size_t nb_iox_initiators = (cluster_iob0 != cluster_iob1) ? 5 : 4;
925   const size_t nb_iox_targets = (cluster_iob0 != cluster_iob1) ? 9 : 8;
926
[450]927   // IOX network
928   VciIoxNetwork<vci_param_ext>* iox_network;
[718]929   iox_network = new VciIoxNetwork<vci_param_ext>( "iox_network",
[450]930                                                   maptab_iox,
[718]931                                                   nb_iox_targets,
932                                                   nb_iox_initiators );
[450]933   // boot ROM
[550]934   VciSimpleRom<vci_param_ext>*  brom;
935   brom = new VciSimpleRom<vci_param_ext>( "brom",
936                                           IntTab(0, IOX_BROM_TGT_ID),
937                                           maptab_iox,
938                                           loader );
[450]939   // Network Controller
[550]940   VciMultiNic<vci_param_ext>*  mnic;
941   mnic = new VciMultiNic<vci_param_ext>( "mnic",
942                                          IntTab(0, IOX_MNIC_TGT_ID),
943                                          maptab_iox,
944                                          NB_NIC_CHANNELS,
[914]945                                          0,                // mac_4 address
946                                          0,                // mac_2 address
947                                          1 );              // NIC_MODE_SYNTHESIS
[450]948
949   // Frame Buffer
[550]950   VciFrameBuffer<vci_param_ext>*  fbuf;
951   fbuf = new VciFrameBuffer<vci_param_ext>( "fbuf",
952                                             IntTab(0, IOX_FBUF_TGT_ID),
953                                             maptab_iox,
954                                             FBUF_X_SIZE, FBUF_Y_SIZE );
[450]955
956   // Block Device
[550]957   // for AHCI
958   // std::vector<std::string> filenames;
959   // filenames.push_back(disk_name);            // one single disk
960   VciBlockDeviceTsar<vci_param_ext>*  bdev;
961   bdev = new VciBlockDeviceTsar<vci_param_ext>( "bdev",
962                                                  maptab_iox,
963                                                  IntTab(0, BDEV_LOCAL_SRCID),
964                                                  IntTab(0, IOX_BDEV_TGT_ID),
965                                                  disk_name,
[714]966                                                  512,        // block size
[718]967                                                  64,         // burst size (bytes)
968                                                  0 );        // disk latency
[450]969
970   // Chained Buffer DMA controller
[550]971   VciChbufDma<vci_param_ext>*  cdma;
972   cdma = new VciChbufDma<vci_param_ext>( "cdma",
973                                          maptab_iox,
974                                          IntTab(0, CDMA_LOCAL_SRCID),
975                                          IntTab(0, IOX_CDMA_TGT_ID),
976                                          64,          // burst size (bytes)
[914]977                                          NB_CMA_CHANNELS );
[450]978   // Multi-TTY controller
979   std::vector<std::string> vect_names;
980   for( size_t tid = 0 ; tid < NB_TTY_CHANNELS ; tid++ )
981   {
982      std::ostringstream term_name;
[707]983         term_name <<  "term" << tid;
984         vect_names.push_back(term_name.str().c_str());
985      }
986      VciMultiTty<vci_param_ext>*  mtty;
987      mtty = new VciMultiTty<vci_param_ext>( "mtty",
988                                             IntTab(0, IOX_MTTY_TGT_ID),
[718]989                                             maptab_iox,
[707]990                                             vect_names);
991
992   // IOPIC
993   VciIopic<vci_param_ext>* iopi;
994   iopi = new VciIopic<vci_param_ext>( "iopi",
995                                       maptab_iox,
996                                       IntTab(0, IOPI_LOCAL_SRCID),
997                                       IntTab(0, IOX_IOPI_TGT_ID),
[718]998                                       32 );        // number of input HWI
999   // Clusters
[450]1000   TsarIobCluster<vci_param_int,
1001                  vci_param_ext,
1002                  dspin_int_cmd_width,
1003                  dspin_int_rsp_width,
1004                  dspin_ram_cmd_width,
1005                  dspin_ram_rsp_width>* clusters[XMAX][YMAX];
1006
[762]1007#if USING_OPENMP
[450]1008#pragma omp parallel
1009    {
1010#pragma omp for
1011#endif
1012        for(size_t i = 0; i  < (XMAX * YMAX); i++)
1013        {
1014            size_t x = i / YMAX;
1015            size_t y = i % YMAX;
1016
[762]1017#if USING_OPENMP
[450]1018#pragma omp critical
1019            {
1020#endif
1021            std::cout << std::endl;
1022            std::cout << "Cluster_" << std::dec << x << "_" << y << std::endl;
1023            std::cout << std::endl;
1024
[718]1025            const bool is_iob0 = (cluster(x,y) == cluster_iob0);
1026            const bool is_iob1 = (cluster(x,y) == cluster_iob1);
1027            const bool is_io_cluster = is_iob0 || is_iob1;
1028
1029            const int iox_iob_ini_id = is_iob0 ?
1030                IOX_IOB0_INI_ID :
1031                IOX_IOB1_INI_ID ;
1032            const int iox_iob_tgt_id = is_iob0 ?
1033                IOX_IOB0_TGT_ID :
1034                IOX_IOB1_TGT_ID ;
1035
[450]1036            std::ostringstream sc;
1037            sc << "cluster_" << x << "_" << y;
1038            clusters[x][y] = new TsarIobCluster<vci_param_int,
1039                                                vci_param_ext,
1040                                                dspin_int_cmd_width,
1041                                                dspin_int_rsp_width,
1042                                                dspin_ram_cmd_width,
1043                                                dspin_ram_rsp_width>
1044            (
1045                sc.str().c_str(),
1046                NB_PROCS_MAX,
1047                NB_DMA_CHANNELS,
1048                x,
1049                y,
1050                XMAX,
1051                YMAX,
1052
1053                maptab_int,
1054                maptab_ram,
1055                maptab_iox,
1056
1057                x_width,
1058                y_width,
1059                vci_srcid_width - x_width - y_width,            // l_id width,
[802]1060                p_width,
[450]1061
1062                INT_MEMC_TGT_ID,
1063                INT_XICU_TGT_ID,
1064                INT_MDMA_TGT_ID,
1065                INT_IOBX_TGT_ID,
1066
1067                INT_PROC_INI_ID,
1068                INT_MDMA_INI_ID,
1069                INT_IOBX_INI_ID,
1070
1071                RAM_XRAM_TGT_ID,
1072
1073                RAM_MEMC_INI_ID,
[550]1074                RAM_IOBX_INI_ID,
[450]1075
[718]1076                is_io_cluster,
1077                iox_iob_tgt_id,
1078                iox_iob_ini_id,
1079
[450]1080                MEMC_WAYS,
1081                MEMC_SETS,
1082                L1_IWAYS,
1083                L1_ISETS,
1084                L1_DWAYS,
1085                L1_DSETS,
1086                XRAM_LATENCY,
[959]1087                XCU_NB_HWI,
1088                XCU_NB_PTI,
1089                XCU_NB_WTI,
1090                XCU_NB_OUT,
[450]1091
1092                loader,
1093
1094                frozen_cycles,
1095                debug_from,
1096                debug_ok and (cluster(x,y) == debug_memc_id),
1097                debug_ok and (cluster(x,y) == debug_proc_id),
1098                debug_ok and debug_iob
1099            );
1100
[762]1101#if USING_OPENMP
[450]1102            } // end critical
1103#endif
1104        } // end for
[762]1105#if USING_OPENMP
[450]1106    }
1107#endif
1108
1109    std::cout << std::endl;
1110
1111    ///////////////////////////////////////////////////////////////////////////////
[718]1112    //     Net-list
[450]1113    ///////////////////////////////////////////////////////////////////////////////
1114
1115    // IOX network connexion
[584]1116    iox_network->p_clk                                   (signal_clk);
1117    iox_network->p_resetn                                (signal_resetn);
1118    iox_network->p_to_ini[IOX_IOB0_INI_ID]               (signal_vci_ini_iob0);
1119    iox_network->p_to_ini[IOX_BDEV_INI_ID]               (signal_vci_ini_bdev);
1120    iox_network->p_to_ini[IOX_CDMA_INI_ID]               (signal_vci_ini_cdma);
[707]1121    iox_network->p_to_ini[IOX_IOPI_INI_ID]               (signal_vci_ini_iopi);
1122
[584]1123    iox_network->p_to_tgt[IOX_IOB0_TGT_ID]               (signal_vci_tgt_iob0);
1124    iox_network->p_to_tgt[IOX_MTTY_TGT_ID]               (signal_vci_tgt_mtty);
1125    iox_network->p_to_tgt[IOX_FBUF_TGT_ID]               (signal_vci_tgt_fbuf);
1126    iox_network->p_to_tgt[IOX_MNIC_TGT_ID]               (signal_vci_tgt_mnic);
1127    iox_network->p_to_tgt[IOX_BROM_TGT_ID]               (signal_vci_tgt_brom);
1128    iox_network->p_to_tgt[IOX_BDEV_TGT_ID]               (signal_vci_tgt_bdev);
1129    iox_network->p_to_tgt[IOX_CDMA_TGT_ID]               (signal_vci_tgt_cdma);
[707]1130    iox_network->p_to_tgt[IOX_IOPI_TGT_ID]               (signal_vci_tgt_iopi);
[450]1131
[718]1132    if (cluster_iob0 != cluster_iob1)
1133    {
1134        iox_network->p_to_ini[IOX_IOB1_INI_ID]           (signal_vci_ini_iob1);
1135        iox_network->p_to_tgt[IOX_IOB1_TGT_ID]           (signal_vci_tgt_iob1);
1136    }
1137
[450]1138    // BDEV connexion
[718]1139    bdev->p_clk                                          (signal_clk);
[550]1140    bdev->p_resetn                                       (signal_resetn);
1141    bdev->p_irq                                          (signal_irq_bdev);
1142    bdev->p_vci_target                                   (signal_vci_tgt_bdev);
1143    bdev->p_vci_initiator                                (signal_vci_ini_bdev);
[450]1144
1145    std::cout << "  - BDEV connected" << std::endl;
1146
1147    // FBUF connexion
[550]1148    fbuf->p_clk                                          (signal_clk);
1149    fbuf->p_resetn                                       (signal_resetn);
1150    fbuf->p_vci                                          (signal_vci_tgt_fbuf);
[450]1151
1152    std::cout << "  - FBUF connected" << std::endl;
1153
1154    // MNIC connexion
[550]1155    mnic->p_clk                                          (signal_clk);
1156    mnic->p_resetn                                       (signal_resetn);
1157    mnic->p_vci                                          (signal_vci_tgt_mnic);
[450]1158    for ( size_t i=0 ; i<NB_NIC_CHANNELS ; i++ )
1159    {
[550]1160         mnic->p_rx_irq[i]                               (signal_irq_mnic_rx[i]);
1161         mnic->p_tx_irq[i]                               (signal_irq_mnic_tx[i]);
[450]1162    }
1163
1164    std::cout << "  - MNIC connected" << std::endl;
1165
1166    // BROM connexion
[550]1167    brom->p_clk                                          (signal_clk);
1168    brom->p_resetn                                       (signal_resetn);
1169    brom->p_vci                                          (signal_vci_tgt_brom);
[450]1170
1171    std::cout << "  - BROM connected" << std::endl;
1172
1173    // MTTY connexion
[550]1174    mtty->p_clk                                          (signal_clk);
1175    mtty->p_resetn                                       (signal_resetn);
1176    mtty->p_vci                                          (signal_vci_tgt_mtty);
[874]1177    for ( size_t i=0 ; i<NB_TTY_CHANNELS ; i++ )
1178    {
1179        mtty->p_irq[i]                                   (signal_irq_mtty_rx[i]);
1180    }
[450]1181    std::cout << "  - MTTY connected" << std::endl;
1182
1183    // CDMA connexion
[718]1184    cdma->p_clk                                          (signal_clk);
1185    cdma->p_resetn                                       (signal_resetn);
1186    cdma->p_vci_target                                   (signal_vci_tgt_cdma);
1187    cdma->p_vci_initiator                                (signal_vci_ini_cdma);
[914]1188    for ( size_t i=0 ; i<(NB_CMA_CHANNELS) ; i++)
[450]1189    {
[718]1190        cdma->p_irq[i]                                   (signal_irq_cdma[i]);
[450]1191    }
1192
1193    std::cout << "  - CDMA connected" << std::endl;
1194
[707]1195    // IOPI connexion
[718]1196    iopi->p_clk                                          (signal_clk);
1197    iopi->p_resetn                                       (signal_resetn);
1198    iopi->p_vci_target                                   (signal_vci_tgt_iopi);
1199    iopi->p_vci_initiator                                (signal_vci_ini_iopi);
[707]1200    for ( size_t i=0 ; i<32 ; i++)
[450]1201    {
[707]1202       if     (i < NB_NIC_CHANNELS)    iopi->p_hwi[i] (signal_irq_mnic_rx[i]);
1203       else if(i < 2 )                 iopi->p_hwi[i] (signal_irq_false);
1204       else if(i < 2+NB_NIC_CHANNELS)  iopi->p_hwi[i] (signal_irq_mnic_tx[i-2]);
1205       else if(i < 4 )                 iopi->p_hwi[i] (signal_irq_false);
1206       else if(i < 4+NB_CMA_CHANNELS)  iopi->p_hwi[i] (signal_irq_cdma[i-4]);
1207       else if(i < 8)                  iopi->p_hwi[i] (signal_irq_false);
[874]1208       else if(i < 9)                  iopi->p_hwi[i] (signal_irq_bdev);
1209       else if(i < 16)                 iopi->p_hwi[i] (signal_irq_false);
1210       else if(i < 16+NB_TTY_CHANNELS) iopi->p_hwi[i] (signal_irq_mtty_rx[i-16]);
[707]1211       else                            iopi->p_hwi[i] (signal_irq_false);
1212    }
[584]1213
[707]1214    std::cout << "  - IOPIC connected" << std::endl;
[584]1215
[718]1216
[707]1217    // IOB0 cluster connexion to IOX network
[718]1218    (*clusters[0][0]->p_vci_iob_iox_ini) (signal_vci_ini_iob0);
1219    (*clusters[0][0]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob0);
[584]1220
[718]1221    // IOB1 cluster connexion to IOX network
[707]1222    // (only when there is more than 1 cluster)
1223    if ( cluster_iob0 != cluster_iob1 )
1224    {
1225        (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_ini) (signal_vci_ini_iob1);
1226        (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob1);
[450]1227    }
1228
1229    // All clusters Clock & RESET connexions
1230    for ( size_t x = 0; x < (XMAX); x++ )
1231    {
1232        for (size_t y = 0; y < YMAX; y++)
1233        {
1234            clusters[x][y]->p_clk     (signal_clk);
1235            clusters[x][y]->p_resetn  (signal_resetn);
1236        }
1237    }
1238
1239   // Inter Clusters horizontal connections
1240   if (XMAX > 1)
1241   {
1242      for (size_t x = 0; x < (XMAX-1); x++)
1243      {
1244         for (size_t y = 0; y < YMAX; y++)
1245         {
[468]1246            for (size_t k = 0; k < 3; k++)
1247            {
1248               clusters[x][y]->p_dspin_int_cmd_out[EAST][k]      (signal_dspin_int_cmd_h_inc[x][y][k]);
1249               clusters[x+1][y]->p_dspin_int_cmd_in[WEST][k]     (signal_dspin_int_cmd_h_inc[x][y][k]);
1250               clusters[x][y]->p_dspin_int_cmd_in[EAST][k]       (signal_dspin_int_cmd_h_dec[x][y][k]);
1251               clusters[x+1][y]->p_dspin_int_cmd_out[WEST][k]    (signal_dspin_int_cmd_h_dec[x][y][k]);
1252            }
1253
[450]1254            for (size_t k = 0; k < 2; k++)
1255            {
[468]1256               clusters[x][y]->p_dspin_int_rsp_out[EAST][k]      (signal_dspin_int_rsp_h_inc[x][y][k]);
1257               clusters[x+1][y]->p_dspin_int_rsp_in[WEST][k]     (signal_dspin_int_rsp_h_inc[x][y][k]);
1258               clusters[x][y]->p_dspin_int_rsp_in[EAST][k]       (signal_dspin_int_rsp_h_dec[x][y][k]);
1259               clusters[x+1][y]->p_dspin_int_rsp_out[WEST][k]    (signal_dspin_int_rsp_h_dec[x][y][k]);
[450]1260            }
1261
1262            clusters[x][y]->p_dspin_ram_cmd_out[EAST]      (signal_dspin_ram_cmd_h_inc[x][y]);
1263            clusters[x+1][y]->p_dspin_ram_cmd_in[WEST]     (signal_dspin_ram_cmd_h_inc[x][y]);
1264            clusters[x][y]->p_dspin_ram_cmd_in[EAST]       (signal_dspin_ram_cmd_h_dec[x][y]);
1265            clusters[x+1][y]->p_dspin_ram_cmd_out[WEST]    (signal_dspin_ram_cmd_h_dec[x][y]);
1266            clusters[x][y]->p_dspin_ram_rsp_out[EAST]      (signal_dspin_ram_rsp_h_inc[x][y]);
1267            clusters[x+1][y]->p_dspin_ram_rsp_in[WEST]     (signal_dspin_ram_rsp_h_inc[x][y]);
1268            clusters[x][y]->p_dspin_ram_rsp_in[EAST]       (signal_dspin_ram_rsp_h_dec[x][y]);
1269            clusters[x+1][y]->p_dspin_ram_rsp_out[WEST]    (signal_dspin_ram_rsp_h_dec[x][y]);
1270         }
1271      }
1272   }
1273
[718]1274   std::cout << std::endl << "Horizontal connections established" << std::endl;
[450]1275
1276   // Inter Clusters vertical connections
[718]1277   if (YMAX > 1)
[450]1278   {
1279      for (size_t y = 0; y < (YMAX-1); y++)
1280      {
1281         for (size_t x = 0; x < XMAX; x++)
1282         {
[468]1283            for (size_t k = 0; k < 3; k++)
1284            {
1285               clusters[x][y]->p_dspin_int_cmd_out[NORTH][k]     (signal_dspin_int_cmd_v_inc[x][y][k]);
1286               clusters[x][y+1]->p_dspin_int_cmd_in[SOUTH][k]    (signal_dspin_int_cmd_v_inc[x][y][k]);
1287               clusters[x][y]->p_dspin_int_cmd_in[NORTH][k]      (signal_dspin_int_cmd_v_dec[x][y][k]);
1288               clusters[x][y+1]->p_dspin_int_cmd_out[SOUTH][k]   (signal_dspin_int_cmd_v_dec[x][y][k]);
1289            }
1290
[450]1291            for (size_t k = 0; k < 2; k++)
1292            {
[468]1293               clusters[x][y]->p_dspin_int_rsp_out[NORTH][k]     (signal_dspin_int_rsp_v_inc[x][y][k]);
1294               clusters[x][y+1]->p_dspin_int_rsp_in[SOUTH][k]    (signal_dspin_int_rsp_v_inc[x][y][k]);
1295               clusters[x][y]->p_dspin_int_rsp_in[NORTH][k]      (signal_dspin_int_rsp_v_dec[x][y][k]);
1296               clusters[x][y+1]->p_dspin_int_rsp_out[SOUTH][k]   (signal_dspin_int_rsp_v_dec[x][y][k]);
[450]1297            }
1298
1299            clusters[x][y]->p_dspin_ram_cmd_out[NORTH]     (signal_dspin_ram_cmd_v_inc[x][y]);
1300            clusters[x][y+1]->p_dspin_ram_cmd_in[SOUTH]    (signal_dspin_ram_cmd_v_inc[x][y]);
1301            clusters[x][y]->p_dspin_ram_cmd_in[NORTH]      (signal_dspin_ram_cmd_v_dec[x][y]);
1302            clusters[x][y+1]->p_dspin_ram_cmd_out[SOUTH]   (signal_dspin_ram_cmd_v_dec[x][y]);
1303            clusters[x][y]->p_dspin_ram_rsp_out[NORTH]     (signal_dspin_ram_rsp_v_inc[x][y]);
1304            clusters[x][y+1]->p_dspin_ram_rsp_in[SOUTH]    (signal_dspin_ram_rsp_v_inc[x][y]);
1305            clusters[x][y]->p_dspin_ram_rsp_in[NORTH]      (signal_dspin_ram_rsp_v_dec[x][y]);
1306            clusters[x][y+1]->p_dspin_ram_rsp_out[SOUTH]   (signal_dspin_ram_rsp_v_dec[x][y]);
1307         }
1308      }
1309   }
1310
1311   std::cout << "Vertical connections established" << std::endl;
1312
1313   // East & West boundary cluster connections
1314   for (size_t y = 0; y < YMAX; y++)
1315   {
[468]1316      for (size_t k = 0; k < 3; k++)
1317      {
1318         clusters[0][y]->p_dspin_int_cmd_in[WEST][k]          (signal_dspin_false_int_cmd_in[0][y][WEST][k]);
1319         clusters[0][y]->p_dspin_int_cmd_out[WEST][k]         (signal_dspin_false_int_cmd_out[0][y][WEST][k]);
1320         clusters[XMAX-1][y]->p_dspin_int_cmd_in[EAST][k]     (signal_dspin_false_int_cmd_in[XMAX-1][y][EAST][k]);
1321         clusters[XMAX-1][y]->p_dspin_int_cmd_out[EAST][k]    (signal_dspin_false_int_cmd_out[XMAX-1][y][EAST][k]);
1322      }
1323
[450]1324      for (size_t k = 0; k < 2; k++)
1325      {
[468]1326         clusters[0][y]->p_dspin_int_rsp_in[WEST][k]          (signal_dspin_false_int_rsp_in[0][y][WEST][k]);
1327         clusters[0][y]->p_dspin_int_rsp_out[WEST][k]         (signal_dspin_false_int_rsp_out[0][y][WEST][k]);
1328         clusters[XMAX-1][y]->p_dspin_int_rsp_in[EAST][k]     (signal_dspin_false_int_rsp_in[XMAX-1][y][EAST][k]);
1329         clusters[XMAX-1][y]->p_dspin_int_rsp_out[EAST][k]    (signal_dspin_false_int_rsp_out[XMAX-1][y][EAST][k]);
[450]1330      }
1331
[718]1332     clusters[0][y]->p_dspin_ram_cmd_in[WEST]       (signal_dspin_false_ram_cmd_in[0][y][WEST]);
1333     clusters[0][y]->p_dspin_ram_cmd_out[WEST]      (signal_dspin_false_ram_cmd_out[0][y][WEST]);
1334     clusters[0][y]->p_dspin_ram_rsp_in[WEST]       (signal_dspin_false_ram_rsp_in[0][y][WEST]);
1335     clusters[0][y]->p_dspin_ram_rsp_out[WEST]      (signal_dspin_false_ram_rsp_out[0][y][WEST]);
[450]1336
[718]1337     clusters[XMAX-1][y]->p_dspin_ram_cmd_in[EAST]  (signal_dspin_false_ram_cmd_in[XMAX-1][y][EAST]);
1338     clusters[XMAX-1][y]->p_dspin_ram_cmd_out[EAST] (signal_dspin_false_ram_cmd_out[XMAX-1][y][EAST]);
1339     clusters[XMAX-1][y]->p_dspin_ram_rsp_in[EAST]  (signal_dspin_false_ram_rsp_in[XMAX-1][y][EAST]);
1340     clusters[XMAX-1][y]->p_dspin_ram_rsp_out[EAST] (signal_dspin_false_ram_rsp_out[XMAX-1][y][EAST]);
[450]1341   }
1342
1343   std::cout << "East & West boundaries established" << std::endl;
1344
1345   // North & South boundary clusters connections
1346   for (size_t x = 0; x < XMAX; x++)
1347   {
[468]1348      for (size_t k = 0; k < 3; k++)
1349      {
1350         clusters[x][0]->p_dspin_int_cmd_in[SOUTH][k]         (signal_dspin_false_int_cmd_in[x][0][SOUTH][k]);
1351         clusters[x][0]->p_dspin_int_cmd_out[SOUTH][k]        (signal_dspin_false_int_cmd_out[x][0][SOUTH][k]);
1352         clusters[x][YMAX-1]->p_dspin_int_cmd_in[NORTH][k]    (signal_dspin_false_int_cmd_in[x][YMAX-1][NORTH][k]);
1353         clusters[x][YMAX-1]->p_dspin_int_cmd_out[NORTH][k]   (signal_dspin_false_int_cmd_out[x][YMAX-1][NORTH][k]);
1354      }
1355
[450]1356      for (size_t k = 0; k < 2; k++)
1357      {
[468]1358         clusters[x][0]->p_dspin_int_rsp_in[SOUTH][k]         (signal_dspin_false_int_rsp_in[x][0][SOUTH][k]);
1359         clusters[x][0]->p_dspin_int_rsp_out[SOUTH][k]        (signal_dspin_false_int_rsp_out[x][0][SOUTH][k]);
1360         clusters[x][YMAX-1]->p_dspin_int_rsp_in[NORTH][k]    (signal_dspin_false_int_rsp_in[x][YMAX-1][NORTH][k]);
1361         clusters[x][YMAX-1]->p_dspin_int_rsp_out[NORTH][k]   (signal_dspin_false_int_rsp_out[x][YMAX-1][NORTH][k]);
[450]1362      }
1363
[718]1364      clusters[x][0]->p_dspin_ram_cmd_in[SOUTH]       (signal_dspin_false_ram_cmd_in[x][0][SOUTH]);
1365      clusters[x][0]->p_dspin_ram_cmd_out[SOUTH]      (signal_dspin_false_ram_cmd_out[x][0][SOUTH]);
1366      clusters[x][0]->p_dspin_ram_rsp_in[SOUTH]       (signal_dspin_false_ram_rsp_in[x][0][SOUTH]);
1367      clusters[x][0]->p_dspin_ram_rsp_out[SOUTH]      (signal_dspin_false_ram_rsp_out[x][0][SOUTH]);
[450]1368
[718]1369      clusters[x][YMAX-1]->p_dspin_ram_cmd_in[NORTH]  (signal_dspin_false_ram_cmd_in[x][YMAX-1][NORTH]);
1370      clusters[x][YMAX-1]->p_dspin_ram_cmd_out[NORTH] (signal_dspin_false_ram_cmd_out[x][YMAX-1][NORTH]);
1371      clusters[x][YMAX-1]->p_dspin_ram_rsp_in[NORTH]  (signal_dspin_false_ram_rsp_in[x][YMAX-1][NORTH]);
1372      clusters[x][YMAX-1]->p_dspin_ram_rsp_out[NORTH] (signal_dspin_false_ram_rsp_out[x][YMAX-1][NORTH]);
[450]1373   }
1374
[550]1375   std::cout << "North & South boundaries established" << std::endl << std::endl;
[450]1376
1377   ////////////////////////////////////////////////////////
1378   //   Simulation
1379   ///////////////////////////////////////////////////////
1380
1381   sc_start(sc_core::sc_time(0, SC_NS));
[584]1382
[450]1383   signal_resetn = false;
[584]1384   signal_irq_false = false;
1385
[450]1386   // network boundaries signals
1387   for (size_t x = 0; x < XMAX ; x++)
1388   {
1389      for (size_t y = 0; y < YMAX ; y++)
1390      {
1391         for (size_t a = 0; a < 4; a++)
1392         {
[468]1393            for (size_t k = 0; k < 3; k++)
1394            {
1395               signal_dspin_false_int_cmd_in[x][y][a][k].write = false;
1396               signal_dspin_false_int_cmd_in[x][y][a][k].read = true;
1397               signal_dspin_false_int_cmd_out[x][y][a][k].write = false;
1398               signal_dspin_false_int_cmd_out[x][y][a][k].read = true;
1399            }
1400
[450]1401            for (size_t k = 0; k < 2; k++)
1402            {
[468]1403               signal_dspin_false_int_rsp_in[x][y][a][k].write = false;
1404               signal_dspin_false_int_rsp_in[x][y][a][k].read = true;
1405               signal_dspin_false_int_rsp_out[x][y][a][k].write = false;
1406               signal_dspin_false_int_rsp_out[x][y][a][k].read = true;
[450]1407            }
1408
1409            signal_dspin_false_ram_cmd_in[x][y][a].write = false;
1410            signal_dspin_false_ram_cmd_in[x][y][a].read = true;
1411            signal_dspin_false_ram_cmd_out[x][y][a].write = false;
1412            signal_dspin_false_ram_cmd_out[x][y][a].read = true;
1413
1414            signal_dspin_false_ram_rsp_in[x][y][a].write = false;
1415            signal_dspin_false_ram_rsp_in[x][y][a].read = true;
1416            signal_dspin_false_ram_rsp_out[x][y][a].write = false;
1417            signal_dspin_false_ram_rsp_out[x][y][a].read = true;
1418         }
1419      }
1420   }
1421
[550]1422    sc_start(sc_core::sc_time(1, SC_NS));
1423    signal_resetn = true;
[450]1424
[707]1425
1426    // simulation loop
[693]1427    struct timeval t1,t2;
1428    gettimeofday(&t1, NULL);
[707]1429
[762]1430
1431    for ( size_t n = 0; n < ncycles ; n += simul_period )
[550]1432    {
[693]1433        // stats display
[714]1434        if( (n % 1000000) == 0)
[693]1435        {
1436            gettimeofday(&t2, NULL);
1437
1438            uint64_t ms1 = (uint64_t) t1.tv_sec  * 1000ULL +
1439                           (uint64_t) t1.tv_usec / 1000;
1440            uint64_t ms2 = (uint64_t) t2.tv_sec  * 1000ULL +
1441                           (uint64_t) t2.tv_usec / 1000;
[817]1442            std::cerr << "### cycle = " << std::dec << n
[718]1443                      << " / frequency = "
1444                      << (double) 1000000 / (double) (ms2 - ms1) << "Khz"
[693]1445                      << std::endl;
1446
1447            gettimeofday(&t1, NULL);
1448        }
1449
[607]1450        // Monitor a specific address for one L1 cache
[959]1451        // clusters[0][0]->proc[0]->cache_monitor(0x800080ULL);
[450]1452
[607]1453        // Monitor a specific address for one L2 cache
[959]1454        // clusters[0][0]->memc->cache_monitor( 0x800080ULL, false );   // full line
[607]1455
1456        // Monitor a specific address for one XRAM
[943]1457        // clusters[0][0]->xram->start_monitor( 0x600800ULL , 64);
[607]1458
[764]1459        if ( debug_ok and (n > debug_from) )
[450]1460        {
[550]1461            std::cout << "****************** cycle " << std::dec << n ;
1462            std::cout << " ************************************************" << std::endl;
[450]1463
[718]1464            // trace proc[debug_proc_id]
[607]1465            if ( debug_proc_id != 0xFFFFFFFF )
[550]1466            {
[802]1467                size_t l          = debug_proc_id & ((1<<P_WIDTH)-1) ;
1468                size_t cluster_xy = debug_proc_id >> P_WIDTH ;
[607]1469                size_t x          = cluster_xy >> 4;
1470                size_t y          = cluster_xy & 0xF;
[764]1471
1472                clusters[x][y]->proc[l]->print_trace(0x1);
[550]1473                std::ostringstream proc_signame;
1474                proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
1475                clusters[x][y]->signal_int_vci_ini_proc[l].print_trace(proc_signame.str());
[450]1476
[959]1477                clusters[x][y]->xicu->print_trace(1);
1478                std::ostringstream xicu_signame;
1479                xicu_signame << "[SIG]XICU_" << x << "_" << y;
1480                clusters[x][y]->signal_int_vci_tgt_xicu.print_trace(xicu_signame.str());
[584]1481
[739]1482                clusters[x][y]->mdma->print_trace();
[959]1483                std::ostringstream mdma_tgt_signame;
1484                mdma_tgt_signame << "[SIG]MDMA_TGT_" << x << "_" << y;
1485                clusters[x][y]->signal_int_vci_tgt_mdma.print_trace(mdma_tgt_signame.str());
1486                std::ostringstream mdma_ini_signame;
1487                mdma_ini_signame << "[SIG]MDMA_INI_" << x << "_" << y;
1488                clusters[x][y]->signal_int_vci_ini_mdma.print_trace(mdma_ini_signame.str());
[714]1489
[739]1490                // local interrupts in cluster(x,y)
1491                if( clusters[x][y]->signal_irq_memc.read() )
[802]1492                std::cout << "### IRQ_MMC_" << std::dec << x << "_" << y
[739]1493                          << " ACTIVE" << std::endl;
1494
1495                for ( size_t c = 0 ; c < NB_DMA_CHANNELS ; c++ )
1496                {
1497                    if( clusters[x][y]->signal_irq_mdma[c].read() )
[802]1498                    std::cout << "### IRQ_DMA_" << std::dec << x << "_" << y << "_" << c
[739]1499                              << " ACTIVE" << std::endl;
1500                }
[802]1501
[739]1502                for ( size_t c = 0 ; c < NB_PROCS_MAX ; c++ )
1503                {
1504                    if( clusters[x][y]->signal_proc_it[c].read() )
[802]1505                    std::cout << "### IRQ_PROC_" << std::dec << x << "_" << y << "_" << c
[739]1506                              << " ACTIVE" << std::endl;
1507                }
[718]1508            }
[450]1509
[718]1510            // trace memc[debug_memc_id]
[607]1511            if ( debug_memc_id != 0xFFFFFFFF )
[550]1512            {
[607]1513                size_t x = debug_memc_id >> 4;
1514                size_t y = debug_memc_id & 0xF;
[718]1515
[550]1516                clusters[x][y]->memc->print_trace(0);
1517                std::ostringstream smemc_tgt;
1518                smemc_tgt << "[SIG]MEMC_TGT_" << x << "_" << y;
1519                clusters[x][y]->signal_int_vci_tgt_memc.print_trace(smemc_tgt.str());
1520                std::ostringstream smemc_ini;
1521                smemc_ini << "[SIG]MEMC_INI_" << x << "_" << y;
1522                clusters[x][y]->signal_ram_vci_ini_memc.print_trace(smemc_ini.str());
[707]1523
[550]1524                clusters[x][y]->xram->print_trace();
1525                std::ostringstream sxram_tgt;
1526                sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y;
1527                clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str());
1528            }
[450]1529
[707]1530
1531            // trace XRAM and XRAM network routers in cluster[debug_xram_id]
1532            if ( debug_xram_id != 0xFFFFFFFF )
1533            {
1534                size_t x = debug_xram_id >> 4;
1535                size_t y = debug_xram_id & 0xF;
[718]1536
[707]1537                clusters[x][y]->xram->print_trace();
1538                std::ostringstream sxram_tgt;
1539                sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y;
1540                clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str());
1541
1542                clusters[x][y]->ram_router_cmd->print_trace();
1543                clusters[x][y]->ram_router_rsp->print_trace();
1544            }
[718]1545
1546            // trace iob, iox and external peripherals
[550]1547            if ( debug_iob )
1548            {
[914]1549//              clusters[0][0]->iob->print_trace();
[718]1550//              clusters[0][0]->signal_int_vci_tgt_iobx.print_trace( "[SIG]IOB0_INT_TGT");
1551//              clusters[0][0]->signal_int_vci_ini_iobx.print_trace( "[SIG]IOB0_INT_INI");
1552//              clusters[0][0]->signal_ram_vci_ini_iobx.print_trace( "[SIG]IOB0_RAM_INI");
[730]1553//              signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI");
1554//              signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT");
[450]1555
[914]1556//              cdma->print_trace();
1557//              signal_vci_tgt_cdma.print_trace("[SIG]CDMA_TGT");
1558//              signal_vci_ini_cdma.print_trace("[SIG]CDMA_INI");
[450]1559
[710]1560//              brom->print_trace();
[914]1561//              signal_vci_tgt_brom.print_trace("[SIG]BROM_TGT");
[450]1562
[550]1563//              mtty->print_trace();
[914]1564//              signal_vci_tgt_mtty.print_trace("[SIG]MTTY_TGT");
[450]1565
[914]1566                bdev->print_trace();
1567                signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT");
1568                signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI");
[450]1569
[914]1570//              mnic->print_trace( 0x000 );
[730]1571//              signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
[714]1572
[550]1573//              fbuf->print_trace();
[914]1574//              signal_vci_tgt_fbuf.print_trace("[SIG]FBUF_TGT");
[498]1575
[874]1576//              iopi->print_trace();
1577//              signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI");
1578//              signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT");
1579//              iox_network->print_trace();
[450]1580
[550]1581                // interrupts
[714]1582                if (signal_irq_bdev)       std::cout << "### IRQ_BDEV ACTIVE"       << std::endl;
[874]1583                if (signal_irq_mtty_rx[0]) std::cout << "### IRQ_MTTY_RX[0] ACTIVE" << std::endl;
[714]1584                if (signal_irq_mnic_rx[0]) std::cout << "### IRQ_MNIC_RX[0] ACTIVE" << std::endl;
1585                if (signal_irq_mnic_rx[1]) std::cout << "### IRQ_MNIC_RX[1] ACTIVE" << std::endl;
1586                if (signal_irq_mnic_tx[0]) std::cout << "### IRQ_MNIC_TX[0] ACTIVE" << std::endl;
1587                if (signal_irq_mnic_tx[1]) std::cout << "### IRQ_MNIC_TX[1] ACTIVE" << std::endl;
[550]1588            }
1589        }
[450]1590
[762]1591        sc_start(sc_core::sc_time(simul_period, SC_NS));
[550]1592    }
1593    return EXIT_SUCCESS;
[450]1594}
1595
1596int sc_main (int argc, char *argv[])
1597{
1598   try {
1599      return _main(argc, argv);
1600   } catch (std::exception &e) {
1601      std::cout << e.what() << std::endl;
1602   } catch (...) {
1603      std::cout << "Unknown exception occured" << std::endl;
1604      throw;
1605   }
1606   return 1;
1607}
1608
1609
1610// Local Variables:
1611// tab-width: 3
1612// c-basic-offset: 3
1613// c-file-offsets:((innamespace . 0)(inline-open . 0))
1614// indent-tabs-mode: nil
1615// End:
1616
1617// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
1618
1619
1620
Note: See TracBrowser for help on using the repository browser.