source: branches/reconfiguration/platforms/tsar_generic_iob/top.cpp @ 774

Last change on this file since 774 was 769, checked in by cfuguet, 10 years ago

reconfiguration/tsar_generic_iob: introducing simhelper component

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