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

Last change on this file since 959 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
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 external IO network
9// emulating a PCI or Hypertransport I/O bus to access 7 external peripherals:
10//
11// - BROM : boot ROM
12// - FBUF : Frame Buffer
13// - MTTY : multi TTY (one channel)
14// - MNIC : Network controller (up to 2 channels)
15// - CDMA : Chained Buffer DMA controller (up to 4 channels)
16// - BDEV : Dlock Device controler (one channel)
17// - IOPI : HWI to SWI translator.
18//
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//
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,
24// Y is encoded on 4 bits, whatever the actual mesh size.
25// => at most 16 * 16 clusters. Each cluster contains up to 4 processors.
26//
27// It contains 3 networks:
28//
29// 1) the "INT" network supports Read/Write transactions
30//    between processors and L2 caches or peripherals.
31//    (VCI ADDDRESS = 40 bits / VCI DATA width = 32 bits)
32//    It supports also coherence transactions between L1 & L2 caches.
33// 3) the "RAM" network emulates the 3D network between L2 caches
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.
36//    (VCI ADDRESS = 40 bits / VCI DATA = 64 bits)
37// 4) the IOX network connects the two IO bridge components to the
38//    7 external peripheral controllers.
39//    (VCI ADDDRESS = 40 bits / VCI DATA width = 64 bits)
40//
41// The external peripherals HWI IRQs are translated to WTI IRQs by the
42// external IOPIC component, that must be configured by the OS to route
43// these WTI IRQS to one or several internal XICU components.
44// - IOPIC HWI[1:0]     connected to IRQ_NIC_RX[1:0]
45// - IOPIC HWI[3:2]     connected to IRQ_NIC_TX[1:0]
46// - IOPIC HWI[7:4]     connected to IRQ_CMA_TX[3:0]]
47// - IOPIC HWI[8]       connected to IRQ_BDEV
48// - IOPIC HWI[31:16]   connected to IRQ_TTY_RX[15:0]
49//
50// Besides the external peripherals, each cluster contains one XICU component,
51// and one multi channels DMA component.
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
59//
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).
63//
64// - It uses two dspin_local_crossbar per cluster to implement the
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.
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 :
80// - X_SIZE           : number of clusters in a row
81// - Y_SIZE           : number of clusters in a column
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)
84// - NB_TTY_CHANNELS  : number of TTY channels in I/O network (up to 16)
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)
87// - FBUF_X_SIZE      : width of frame buffer (pixels)
88// - FBUF_Y_SIZE      : heigth of frame buffer (lines)
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)
93//
94// Some secondary hardware parameters must be defined in this top.cpp file:
95// - XRAM_LATENCY     : external ram latency
96// - MEMC_WAYS        : L2 cache number of ways
97// - MEMC_SETS        : L2 cache number of sets
98// - L1_IWAYS
99// - L1_ISETS
100// - L1_DWAYS
101// - L1_DSETS
102// - BDEV_IMAGE_NAME  : file pathname for block device
103//
104// General policy for 40 bits physical address decoding:
105// All physical segments base addresses are multiple of 1 Mbytes
106// (=> the 24 LSB bits = 0, and the 16 MSB bits define the target)
107// The (x_width + y_width) MSB bits (left aligned) define
108// the cluster index, and the LADR bits define the local index:
109//      |X_ID|Y_ID|  LADR  |     OFFSET          |
110//      |  4 |  4 |   8    |       24            |
111//
112// General policy for 14 bits SRCID decoding:
113// Each component is identified by (x_id, y_id, l_id) tuple.
114//      |X_ID|Y_ID| L_ID |
115//      |  4 |  4 |  6   |
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"
137#include "vci_iox_network.h"
138#include "vci_iopic.h"
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
155#define USING_OPENMP           0
156
157#if USING_OPENMP
158#include <omp.h>
159#endif
160
161///////////////////////////////////////////////////////////
162//          DSPIN parameters
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///////////////////////////////////////////////////////////
172//         VCI fields width  for the 3 VCI networks
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////////////////////////////////////////////////////////////
189//    Main Hardware Parameters values
190//////////////////////i/////////////////////////////////////
191
192#include "hard_config.h"
193
194////////////////////////////////////////////////////////////
195//    Secondary Hardware Parameters values
196//////////////////////i/////////////////////////////////////
197
198#define XMAX                  X_SIZE
199#define YMAX                  Y_SIZE
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
212#define BDEV_IMAGE_NAME       "../../../giet_vm/hdd/virt_hdd.dmg"
213
214#define ROM_SOFT_NAME         "../../softs/tsar_boot/preloader.elf"
215
216#define NORTH                 0
217#define SOUTH                 1
218#define EAST                  2
219#define WEST                  3
220
221#define cluster(x,y)   ((y) + ((x) << 4))
222
223////////////////////////////////////////////////////////////
224//     DEBUG Parameters default values
225//////////////////////i/////////////////////////////////////
226
227#define MAX_FROZEN_CYCLES     1000000
228
229/////////////////////////////////////////////////////////
230//    Physical segments definition
231/////////////////////////////////////////////////////////
232
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);
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:
243// - The 8 MSB bits define the cluster index (left aligned)
244// - The 6  LSB bits define the local index.
245// Two different initiators cannot have the same SRCID, but a given
246// initiator can have two alias SRCIDs:
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
250//   accessed in 2 clusters : cluster_iob0 and cluster_iob1.
251//   They have the same local index, but two different cluster indexes.
252//
253// As cluster_iob0 and cluster_iob1 contain both internal initiators
254// and external initiators, they must have different local indexes.
255// Consequence: For a local interconnect, the INI_ID port index
256// is NOT equal to the SRCID local index, and the local interconnect
257// must make a translation: SRCID => INI_ID
258////////////////////////////////////////////////////////////////////////
259
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
264#define CDMA_LOCAL_SRCID             0xB
265#define BDEV_LOCAL_SRCID             0xC
266#define IOPI_LOCAL_SRCID             0xD
267
268///////////////////////////////////////////////////////////////////////
269//     TGT_ID and INI_ID port indexing for INT local interconnect
270///////////////////////////////////////////////////////////////////////
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)
278#define INT_MDMA_INI_ID              (NB_PROCS_MAX)
279#define INT_IOBX_INI_ID              (NB_PROCS_MAX+1)
280
281///////////////////////////////////////////////////////////////////////
282//     TGT_ID and INI_ID port indexing for RAM local interconnect
283///////////////////////////////////////////////////////////////////////
284
285#define RAM_XRAM_TGT_ID              0
286
287#define RAM_MEMC_INI_ID              0
288#define RAM_IOBX_INI_ID              1
289
290///////////////////////////////////////////////////////////////////////
291//     TGT_ID and INI_ID port indexing for I0X local interconnect
292///////////////////////////////////////////////////////////////////////
293
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
303
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
309
310////////////////////////////////////////////////////////////////////////
311int _main(int argc, char *argv[])
312////////////////////////////////////////////////////////////////////////
313{
314   using namespace sc_core;
315   using namespace soclib::caba;
316   using namespace soclib::common;
317
318
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
335
336#if USING_OPENMP
337   size_t   simul_period     = 1000000;
338#else
339   size_t   simul_period     = 1;
340#endif
341
342   assert( (X_WIDTH == 4) and (Y_WIDTH == 4) and
343   "ERROR: we must have X_WIDTH == Y_WIDTH == 4");
344
345   assert( P_WIDTH <= 4 and
346   "ERROR: we must have P_WIDTH <= 4");
347
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         }
357         else if ((strcmp(argv[n],"-ROM") == 0) && (n+1<argc) )
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]);
373            size_t x = debug_memc_id >> 4;
374            size_t y = debug_memc_id & 0xF;
375            if( (x>=XMAX) || (y>=YMAX) )
376            {
377                std::cout << "MEMCID parameter does'nt fit XMAX/YMAX" << std::endl;
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;
381                exit(0);
382            }
383         }
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         }
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         {
401            debug_proc_id     = atoi(argv[n+1]);
402            size_t cluster_xy = debug_proc_id >> P_WIDTH ;
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;
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;
411                exit(0);
412            }
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;
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;
438            exit(0);
439         }
440      }
441   }
442
443   // checking hardware parameters
444   assert( (XMAX <= 16) and
445           "The XMAX parameter cannot be larger than 16" );
446
447   assert( (YMAX <= 16) and
448           "The YMAX parameter cannot be larger than 16" );
449
450   assert( (NB_PROCS_MAX <= 8) and
451           "NB_PROCS_MAX parameter cannot be larger than 8" );
452
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
466           "The NB_DMA_CHANNELS parameter cannot be larger than 8" );
467
468   assert( (NB_TTY_CHANNELS >= 1) and (NB_TTY_CHANNELS <= 16) and
469           "The NB_TTY_CHANNELS parameter cannot be larger than 16" );
470
471   assert( (NB_NIC_CHANNELS <= 2) and
472           "The NB_NIC_CHANNELS parameter cannot be larger than 2" );
473
474   assert( (NB_CMA_CHANNELS <= 4) and
475           "The NB_CMA_CHANNELS parameter cannot be larger than 4" );
476
477   std::cout << std::endl << std::dec
478             << " - XMAX            = " << XMAX << std::endl
479             << " - YMAX            = " << YMAX << std::endl
480             << " - NB_PROCS_MAX    = " << NB_PROCS_MAX << std::endl
481             << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS <<  std::endl
482             << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS <<  std::endl
483             << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS <<  std::endl
484             << " - NB_CMA_CHANNELS = " << NB_CMA_CHANNELS <<  std::endl
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
489             << " - NCYCLES         = " << ncycles << std::endl
490             << " - DEBUG_PROCID    = " << debug_proc_id << std::endl
491             << " - DEBUG_MEMCID    = " << debug_memc_id << std::endl
492             << " - DEBUG_XRAMID    = " << debug_xram_id << std::endl;
493
494   std::cout << std::endl;
495
496#if USING_OPENMP
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,
517                                   vci_rerror_width,
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   /////////////////////////////////////////////////////////////////////
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),
535                            0x00FF000000);
536
537   for (size_t x = 0; x < XMAX; x++)
538   {
539      for (size_t y = 0; y < YMAX; y++)
540      {
541         uint64_t offset = ((uint64_t)cluster(x,y))
542                              << (vci_address_width-x_width-y_width);
543         bool config    = true;
544         bool cacheable = true;
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;
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 ));
552
553         std::ostringstream    smemc_xram;
554         smemc_xram << "int_seg_memc_xram_" << x << "_" << y;
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));
557
558         std::ostringstream    sxicu;
559         sxicu << "int_seg_xicu_" << x << "_" << y;
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));
562
563         std::ostringstream    smdma;
564         smdma << "int_seg_mdma_" << x << "_" << y;
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));
567
568         // the following segments are only defined in cluster_iob0 or in cluster_iob1
569
570         if ( (cluster(x,y) == cluster_iob0) or (cluster(x,y) == cluster_iob1) )
571         {
572            std::ostringstream    siobx;
573            siobx << "int_seg_iobx_" << x << "_" << y;
574            maptab_int.add(Segment(siobx.str(), SEG_IOB_BASE+offset, SEG_IOB_SIZE,
575                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable, config ));
576
577            std::ostringstream    stty;
578            stty << "int_seg_mtty_" << x << "_" << y;
579            maptab_int.add(Segment(stty.str(), SEG_TTY_BASE+offset, SEG_TTY_SIZE,
580                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
581
582            std::ostringstream    sfbf;
583            sfbf << "int_seg_fbuf_" << x << "_" << y;
584            maptab_int.add(Segment(sfbf.str(), SEG_FBF_BASE+offset, SEG_FBF_SIZE,
585                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
586
587            std::ostringstream    sbdv;
588            sbdv << "int_seg_bdev_" << x << "_" << y;
589            maptab_int.add(Segment(sbdv.str(), SEG_IOC_BASE+offset, SEG_IOC_SIZE,
590                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
591
592            std::ostringstream    snic;
593            snic << "int_seg_mnic_" << x << "_" << y;
594            maptab_int.add(Segment(snic.str(), SEG_NIC_BASE+offset, SEG_NIC_SIZE,
595                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
596
597            std::ostringstream    srom;
598            srom << "int_seg_brom_" << x << "_" << y;
599            maptab_int.add(Segment(srom.str(), SEG_ROM_BASE+offset, SEG_ROM_SIZE,
600                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), cacheable ));
601
602            std::ostringstream    sdma;
603            sdma << "int_seg_cdma_" << x << "_" << y;
604            maptab_int.add(Segment(sdma.str(), SEG_CMA_BASE+offset, SEG_CMA_SIZE,
605                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
606
607            std::ostringstream    spic;
608            spic << "int_seg_iopi_" << x << "_" << y;
609            maptab_int.add(Segment(spic.str(), SEG_PIC_BASE+offset, SEG_PIC_SIZE,
610                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
611         }
612
613         // This define the mapping between the SRCIDs
614         // and the port index on the local interconnect.
615
616         maptab_int.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ),
617                               IntTab( cluster(x,y), INT_MDMA_INI_ID ) );
618
619         maptab_int.srcid_map( IntTab( cluster(x,y), IOBX_LOCAL_SRCID ),
620                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
621
622         maptab_int.srcid_map( IntTab( cluster(x,y), IOPI_LOCAL_SRCID ),
623                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
624
625         for ( size_t p = 0 ; p < NB_PROCS_MAX; p++ )
626         maptab_int.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID+p ),
627                               IntTab( cluster(x,y), INT_PROC_INI_ID+p ) );
628      }
629   }
630   std::cout << "INT network " << maptab_int << std::endl;
631
632    /////////////////////////////////////////////////////////////////////////
633    // RAM network mapping table
634    // - two levels address decoding for commands
635    // - two levels srcid decoding for responses
636    // - 2 local initiators (MEMC, IOBX) per cluster
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,
641                             IntTab(x_width+y_width, 0),
642                             IntTab(x_width+y_width, vci_srcid_width - x_width - y_width),
643                             0x00FF000000);
644
645    for (size_t x = 0; x < XMAX; x++)
646    {
647        for (size_t y = 0; y < YMAX ; y++)
648        {
649            uint64_t offset = ((uint64_t)cluster(x,y))
650                                << (vci_address_width-x_width-y_width);
651
652            std::ostringstream sxram;
653            sxram << "ext_seg_xram_" << x << "_" << y;
654            maptab_ram.add(Segment(sxram.str(), SEG_RAM_BASE+offset,
655                           SEG_RAM_SIZE, IntTab(cluster(x,y), RAM_XRAM_TGT_ID), false));
656        }
657    }
658
659    // This define the mapping between the initiators SRCID
660    // and the port index on the RAM local interconnect.
661    // External initiator have two alias SRCID (iob0 / iob1)
662
663    maptab_ram.srcid_map( IntTab( cluster_iob0, CDMA_LOCAL_SRCID ),
664                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
665
666    maptab_ram.srcid_map( IntTab( cluster_iob1, CDMA_LOCAL_SRCID ),
667                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
668
669    maptab_ram.srcid_map( IntTab( cluster_iob0, BDEV_LOCAL_SRCID ),
670                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
671
672    maptab_ram.srcid_map( IntTab( cluster_iob1, BDEV_LOCAL_SRCID ),
673                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
674
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 ),
685                          IntTab( cluster_iob1, RAM_MEMC_INI_ID ) );
686
687    std::cout << "RAM network " << maptab_ram << std::endl;
688
689    ///////////////////////////////////////////////////////////////////////
690    // IOX network mapping table
691    // - two levels address decoding for commands (9, 7) bits
692    // - two levels srcid decoding for responses
693    // - 5 initiators (IOB0, IOB1, BDEV, CDMA, IOPI)
694    // - 9 targets (IOB0, IOB1, BDEV, CDMA, MTTY, FBUF, BROM, MNIC, IOPI)
695    //
696    // Address bit 32 is used to determine if a command must be routed to
697    // IOB0 or IOB1.
698    ///////////////////////////////////////////////////////////////////////
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);
704
705    // External peripherals segments
706    // When there is more than one cluster, external peripherals can be accessed
707    // through two segments, depending on the used IOB (IOB0 or IOB1).
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
727    if ( cluster_iob0 != cluster_iob1 )
728    {
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));
746    }
747
748    // If there is more than one cluster, external peripherals
749    // can access RAM through two segments (IOB0 / IOB1).
750    // As IOMMU is not activated, addresses are 40 bits (physical addresses),
751    // and the choice depends on address bit A[32].
752    for (size_t x = 0; x < XMAX; x++)
753    {
754        for (size_t y = 0; y < YMAX ; y++)
755        {
756            const bool wti       = true;
757            const bool cacheable = true;
758
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
765            {
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));
775            }
776            else                  // USE IOB1
777            {
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));
787            }
788        }
789    }
790
791    // This define the mapping between the external initiators (SRCID)
792    // and the port index on the IOX local interconnect.
793
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
803    if ( cluster_iob0 != cluster_iob1 )
804    {
805        maptab_iox.srcid_map( IntTab( 0, IOX_IOB1_INI_ID ) ,
806                              IntTab( 0, IOX_IOB1_INI_ID ) );
807    }
808
809    std::cout << "IOX network " << maptab_iox << std::endl;
810
811    ////////////////////
812    // Signals
813    ///////////////////
814
815    sc_clock                          signal_clk("clk");
816    sc_signal<bool>                   signal_resetn("resetn");
817
818    sc_signal<bool>                   signal_irq_false;
819    sc_signal<bool>                   signal_irq_bdev;
820    sc_signal<bool>                   signal_irq_mtty_rx[NB_TTY_CHANNELS];
821    sc_signal<bool>                   signal_irq_mnic_rx[NB_NIC_CHANNELS];
822    sc_signal<bool>                   signal_irq_mnic_tx[NB_NIC_CHANNELS];
823    sc_signal<bool>                   signal_irq_cdma[NB_CMA_CHANNELS];
824
825    // VCI signals for IOX network
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");
830    VciSignals<vci_param_ext>         signal_vci_ini_iopi("signal_vci_ini_iopi");
831
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");
840    VciSignals<vci_param_ext>         signal_vci_tgt_iopi("signal_vci_tgt_iopi");
841
842   // Horizontal inter-clusters INT network DSPIN
843   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_inc =
844      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_inc", XMAX-1, YMAX, 3);
845   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_dec =
846      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_dec", XMAX-1, YMAX, 3);
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 =
854      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_inc", XMAX, YMAX-1, 3);
855   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_dec =
856      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_dec", XMAX, YMAX-1, 3);
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
862   // Mesh boundaries INT network DSPIN
863   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_in =
864      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_in", XMAX, YMAX, 4, 3);
865   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_out =
866      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_out", XMAX, YMAX, 4, 3);
867   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_in =
868      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_in", XMAX, YMAX, 4, 2);
869   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_out =
870      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_out", XMAX, YMAX, 4, 2);
871
872
873   // Horizontal inter-clusters RAM network DSPIN
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
893   // Mesh boundaries RAM network DSPIN
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   ////////////////////////////
904   //      Loader
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
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
927   // IOX network
928   VciIoxNetwork<vci_param_ext>* iox_network;
929   iox_network = new VciIoxNetwork<vci_param_ext>( "iox_network",
930                                                   maptab_iox,
931                                                   nb_iox_targets,
932                                                   nb_iox_initiators );
933   // boot ROM
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 );
939   // Network Controller
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,
945                                          0,                // mac_4 address
946                                          0,                // mac_2 address
947                                          1 );              // NIC_MODE_SYNTHESIS
948
949   // Frame Buffer
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 );
955
956   // Block Device
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,
966                                                  512,        // block size
967                                                  64,         // burst size (bytes)
968                                                  0 );        // disk latency
969
970   // Chained Buffer DMA controller
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)
977                                          NB_CMA_CHANNELS );
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;
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),
989                                             maptab_iox,
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),
998                                       32 );        // number of input HWI
999   // Clusters
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
1007#if USING_OPENMP
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
1017#if USING_OPENMP
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
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
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,
1060                p_width,
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,
1074                RAM_IOBX_INI_ID,
1075
1076                is_io_cluster,
1077                iox_iob_tgt_id,
1078                iox_iob_ini_id,
1079
1080                MEMC_WAYS,
1081                MEMC_SETS,
1082                L1_IWAYS,
1083                L1_ISETS,
1084                L1_DWAYS,
1085                L1_DSETS,
1086                XRAM_LATENCY,
1087                XCU_NB_HWI,
1088                XCU_NB_PTI,
1089                XCU_NB_WTI,
1090                XCU_NB_OUT,
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
1101#if USING_OPENMP
1102            } // end critical
1103#endif
1104        } // end for
1105#if USING_OPENMP
1106    }
1107#endif
1108
1109    std::cout << std::endl;
1110
1111    ///////////////////////////////////////////////////////////////////////////////
1112    //     Net-list
1113    ///////////////////////////////////////////////////////////////////////////////
1114
1115    // IOX network connexion
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);
1121    iox_network->p_to_ini[IOX_IOPI_INI_ID]               (signal_vci_ini_iopi);
1122
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);
1130    iox_network->p_to_tgt[IOX_IOPI_TGT_ID]               (signal_vci_tgt_iopi);
1131
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
1138    // BDEV connexion
1139    bdev->p_clk                                          (signal_clk);
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);
1144
1145    std::cout << "  - BDEV connected" << std::endl;
1146
1147    // FBUF connexion
1148    fbuf->p_clk                                          (signal_clk);
1149    fbuf->p_resetn                                       (signal_resetn);
1150    fbuf->p_vci                                          (signal_vci_tgt_fbuf);
1151
1152    std::cout << "  - FBUF connected" << std::endl;
1153
1154    // MNIC connexion
1155    mnic->p_clk                                          (signal_clk);
1156    mnic->p_resetn                                       (signal_resetn);
1157    mnic->p_vci                                          (signal_vci_tgt_mnic);
1158    for ( size_t i=0 ; i<NB_NIC_CHANNELS ; i++ )
1159    {
1160         mnic->p_rx_irq[i]                               (signal_irq_mnic_rx[i]);
1161         mnic->p_tx_irq[i]                               (signal_irq_mnic_tx[i]);
1162    }
1163
1164    std::cout << "  - MNIC connected" << std::endl;
1165
1166    // BROM connexion
1167    brom->p_clk                                          (signal_clk);
1168    brom->p_resetn                                       (signal_resetn);
1169    brom->p_vci                                          (signal_vci_tgt_brom);
1170
1171    std::cout << "  - BROM connected" << std::endl;
1172
1173    // MTTY connexion
1174    mtty->p_clk                                          (signal_clk);
1175    mtty->p_resetn                                       (signal_resetn);
1176    mtty->p_vci                                          (signal_vci_tgt_mtty);
1177    for ( size_t i=0 ; i<NB_TTY_CHANNELS ; i++ )
1178    {
1179        mtty->p_irq[i]                                   (signal_irq_mtty_rx[i]);
1180    }
1181    std::cout << "  - MTTY connected" << std::endl;
1182
1183    // CDMA connexion
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);
1188    for ( size_t i=0 ; i<(NB_CMA_CHANNELS) ; i++)
1189    {
1190        cdma->p_irq[i]                                   (signal_irq_cdma[i]);
1191    }
1192
1193    std::cout << "  - CDMA connected" << std::endl;
1194
1195    // IOPI connexion
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);
1200    for ( size_t i=0 ; i<32 ; i++)
1201    {
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);
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]);
1211       else                            iopi->p_hwi[i] (signal_irq_false);
1212    }
1213
1214    std::cout << "  - IOPIC connected" << std::endl;
1215
1216
1217    // IOB0 cluster connexion to IOX network
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);
1220
1221    // IOB1 cluster connexion to IOX network
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);
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         {
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
1254            for (size_t k = 0; k < 2; k++)
1255            {
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]);
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
1274   std::cout << std::endl << "Horizontal connections established" << std::endl;
1275
1276   // Inter Clusters vertical connections
1277   if (YMAX > 1)
1278   {
1279      for (size_t y = 0; y < (YMAX-1); y++)
1280      {
1281         for (size_t x = 0; x < XMAX; x++)
1282         {
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
1291            for (size_t k = 0; k < 2; k++)
1292            {
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]);
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   {
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
1324      for (size_t k = 0; k < 2; k++)
1325      {
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]);
1330      }
1331
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]);
1336
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]);
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   {
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
1356      for (size_t k = 0; k < 2; k++)
1357      {
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]);
1362      }
1363
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]);
1368
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]);
1373   }
1374
1375   std::cout << "North & South boundaries established" << std::endl << std::endl;
1376
1377   ////////////////////////////////////////////////////////
1378   //   Simulation
1379   ///////////////////////////////////////////////////////
1380
1381   sc_start(sc_core::sc_time(0, SC_NS));
1382
1383   signal_resetn = false;
1384   signal_irq_false = false;
1385
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         {
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
1401            for (size_t k = 0; k < 2; k++)
1402            {
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;
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
1422    sc_start(sc_core::sc_time(1, SC_NS));
1423    signal_resetn = true;
1424
1425
1426    // simulation loop
1427    struct timeval t1,t2;
1428    gettimeofday(&t1, NULL);
1429
1430
1431    for ( size_t n = 0; n < ncycles ; n += simul_period )
1432    {
1433        // stats display
1434        if( (n % 1000000) == 0)
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;
1442            std::cerr << "### cycle = " << std::dec << n
1443                      << " / frequency = "
1444                      << (double) 1000000 / (double) (ms2 - ms1) << "Khz"
1445                      << std::endl;
1446
1447            gettimeofday(&t1, NULL);
1448        }
1449
1450        // Monitor a specific address for one L1 cache
1451        // clusters[0][0]->proc[0]->cache_monitor(0x800080ULL);
1452
1453        // Monitor a specific address for one L2 cache
1454        // clusters[0][0]->memc->cache_monitor( 0x800080ULL, false );   // full line
1455
1456        // Monitor a specific address for one XRAM
1457        // clusters[0][0]->xram->start_monitor( 0x600800ULL , 64);
1458
1459        if ( debug_ok and (n > debug_from) )
1460        {
1461            std::cout << "****************** cycle " << std::dec << n ;
1462            std::cout << " ************************************************" << std::endl;
1463
1464            // trace proc[debug_proc_id]
1465            if ( debug_proc_id != 0xFFFFFFFF )
1466            {
1467                size_t l          = debug_proc_id & ((1<<P_WIDTH)-1) ;
1468                size_t cluster_xy = debug_proc_id >> P_WIDTH ;
1469                size_t x          = cluster_xy >> 4;
1470                size_t y          = cluster_xy & 0xF;
1471
1472                clusters[x][y]->proc[l]->print_trace(0x1);
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());
1476
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());
1481
1482                clusters[x][y]->mdma->print_trace();
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());
1489
1490                // local interrupts in cluster(x,y)
1491                if( clusters[x][y]->signal_irq_memc.read() )
1492                std::cout << "### IRQ_MMC_" << std::dec << x << "_" << y
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() )
1498                    std::cout << "### IRQ_DMA_" << std::dec << x << "_" << y << "_" << c
1499                              << " ACTIVE" << std::endl;
1500                }
1501
1502                for ( size_t c = 0 ; c < NB_PROCS_MAX ; c++ )
1503                {
1504                    if( clusters[x][y]->signal_proc_it[c].read() )
1505                    std::cout << "### IRQ_PROC_" << std::dec << x << "_" << y << "_" << c
1506                              << " ACTIVE" << std::endl;
1507                }
1508            }
1509
1510            // trace memc[debug_memc_id]
1511            if ( debug_memc_id != 0xFFFFFFFF )
1512            {
1513                size_t x = debug_memc_id >> 4;
1514                size_t y = debug_memc_id & 0xF;
1515
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());
1523
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            }
1529
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;
1536
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            }
1545
1546            // trace iob, iox and external peripherals
1547            if ( debug_iob )
1548            {
1549//              clusters[0][0]->iob->print_trace();
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");
1553//              signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI");
1554//              signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT");
1555
1556//              cdma->print_trace();
1557//              signal_vci_tgt_cdma.print_trace("[SIG]CDMA_TGT");
1558//              signal_vci_ini_cdma.print_trace("[SIG]CDMA_INI");
1559
1560//              brom->print_trace();
1561//              signal_vci_tgt_brom.print_trace("[SIG]BROM_TGT");
1562
1563//              mtty->print_trace();
1564//              signal_vci_tgt_mtty.print_trace("[SIG]MTTY_TGT");
1565
1566                bdev->print_trace();
1567                signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT");
1568                signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI");
1569
1570//              mnic->print_trace( 0x000 );
1571//              signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
1572
1573//              fbuf->print_trace();
1574//              signal_vci_tgt_fbuf.print_trace("[SIG]FBUF_TGT");
1575
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();
1580
1581                // interrupts
1582                if (signal_irq_bdev)       std::cout << "### IRQ_BDEV ACTIVE"       << std::endl;
1583                if (signal_irq_mtty_rx[0]) std::cout << "### IRQ_MTTY_RX[0] ACTIVE" << std::endl;
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;
1588            }
1589        }
1590
1591        sc_start(sc_core::sc_time(simul_period, SC_NS));
1592    }
1593    return EXIT_SUCCESS;
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.