source: branches/fault_tolerance/platforms/tsar_generic_iob/top.cpp @ 736

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

fault_tolerance/tsar_generic_iob: architecture desc

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