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

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

Introduce a new parameter in the tsar_generic_iob SystemC architecture:
The top cell use now the hard_config.h file to select the block_device type:
If USE_IOC_HBA is set, it use the vci_multi_ahci controller.
Else, it use the vci_block_device_tsar component.

File size: 71.8 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2// File: top.cpp  (for tsar_generic_iob platform)
3// Author: Alain Greiner
4// Copyright: UPMC/LIP6
5// Date : august 2013
6// This program is released under the GNU public license
7///////////////////////////////////////////////////////////////////////////////
8// This file define a generic TSAR architecture with an 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// - DISK : Block device controler (BDV / HBA / SDC)
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_DISK
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// - DISK_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_multi_ahci.h"
135#include "vci_block_device_tsar.h"
136#include "vci_framebuffer.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 DISK_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 (disk, 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 DISK_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_DISK_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_DISK_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   char     soft_name[256]   = ROM_SOFT_NAME;           // pathname: binary code
319   size_t   ncycles          = 4000000000;              // simulated cycles
320   char     disk_name[256]   = DISK_IMAGE_NAME;         // pathname: disk image
321   ssize_t  threads_nr       = 1;                       // simulator's threads number
322   bool     debug_ok         = false;                   // trace activated
323   size_t   debug_memc_id    = 0xFFFFFFFF;              // index of traced memc
324   size_t   debug_proc_id    = 0xFFFFFFFF;              // index of traced proc
325   size_t   debug_xram_id    = 0xFFFFFFFF;              // index of traced xram
326   bool     debug_iob        = false;                   // trace iob0 & iob1 when true
327   uint32_t debug_from       = 0;                       // trace start cycle
328   uint32_t frozen_cycles    = MAX_FROZEN_CYCLES;       // monitoring frozen processor
329   size_t   cluster_iob0     = cluster(0,0);            // cluster containing IOB0
330   size_t   cluster_iob1     = cluster(XMAX-1,YMAX-1);  // cluster containing IOB1
331   size_t   x_width          = X_WIDTH;                 // # of bits for x
332   size_t   y_width          = Y_WIDTH;                 // # of bits for y
333   size_t   p_width          = P_WIDTH;                 // # of bits for lpid
334
335#if USING_OPENMP
336   size_t   simul_period     = 1000000;
337#else
338   size_t   simul_period     = 1;
339#endif
340
341   assert( (X_WIDTH == 4) and (Y_WIDTH == 4) and
342   "ERROR: we must have X_WIDTH == Y_WIDTH == 4");
343
344   assert( P_WIDTH <= 4 and
345   "ERROR: we must have P_WIDTH <= 4");
346
347   ////////////// command line arguments //////////////////////
348   if (argc > 1)
349   {
350      for (int n = 1; n < argc; n = n + 2)
351      {
352         if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc))
353         {
354            ncycles = atoi(argv[n+1]);
355         }
356         else if ((strcmp(argv[n],"-ROM") == 0) && (n+1<argc) )
357         {
358            strcpy(soft_name, argv[n+1]);
359         }
360         else if ((strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) )
361         {
362            debug_ok = true;
363            debug_from = atoi(argv[n+1]);
364         }
365         else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
366         {
367            strcpy(disk_name, argv[n+1]);
368         }
369         else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) )
370         {
371            debug_memc_id = atoi(argv[n+1]);
372            size_t x = debug_memc_id >> 4;
373            size_t y = debug_memc_id & 0xF;
374            if( (x>=XMAX) || (y>=YMAX) )
375            {
376                std::cout << "MEMCID parameter does'nt fit XMAX/YMAX" << std::endl;
377                std::cout << " - MEMCID = " << std::hex << debug_memc_id << std::endl;
378                std::cout << " - XMAX   = " << std::hex << XMAX          << std::endl;
379                std::cout << " - YMAX   = " << std::hex << YMAX          << std::endl;
380                exit(0);
381            }
382         }
383         else if ((strcmp(argv[n],"-XRAMID") == 0) && (n+1<argc) )
384         {
385            debug_xram_id = atoi(argv[n+1]);
386            size_t x = debug_xram_id >> 4;
387            size_t y = debug_xram_id & 0xF;
388            if( (x>=XMAX) || (y>=YMAX) )
389            {
390                std::cout << "XRAMID parameter does'nt fit XMAX/YMAX" << std::endl;
391                exit(0);
392            }
393         }
394         else if ((strcmp(argv[n],"-IOB") == 0) && (n+1<argc) )
395         {
396            debug_iob = atoi(argv[n+1]);
397         }
398         else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) )
399         {
400            debug_proc_id     = atoi(argv[n+1]);
401            size_t cluster_xy = debug_proc_id >> P_WIDTH ;
402            size_t x          = cluster_xy >> 4;
403            size_t y          = cluster_xy & 0xF;
404            if( (x>=XMAX) || (y>=YMAX) )
405            {
406                std::cout << "PROCID parameter does'nt fit XMAX/YMAX" << std::endl;
407                std::cout << " - PROCID = " << std::hex << debug_proc_id << std::endl;
408                std::cout << " - XMAX   = " << std::hex << XMAX          << std::endl;
409                std::cout << " - YMAX   = " << std::hex << YMAX          << std::endl;
410                exit(0);
411            }
412         }
413         else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc))
414         {
415            threads_nr = atoi(argv[n+1]);
416            threads_nr = (threads_nr < 1) ? 1 : threads_nr;
417         }
418         else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc))
419         {
420            frozen_cycles = atoi(argv[n+1]);
421         }
422         else
423         {
424            std::cout << "   Arguments are (key,value) couples." << std::endl;
425            std::cout << "   The order is not important." << std::endl;
426            std::cout << "   Accepted arguments are :" << std::endl << std::endl;
427            std::cout << "     - ROM  pathname_for_embedded_soft" << std::endl;
428            std::cout << "     - DISK pathname_for_disk_image" << std::endl;
429            std::cout << "     - NCYCLES number_of_simulated_cycles" << std::endl;
430            std::cout << "     - DEBUG debug_start_cycle" << std::endl;
431            std::cout << "     - THREADS simulator's threads number" << std::endl;
432            std::cout << "     - FROZEN max_number_of_lines" << std::endl;
433            std::cout << "     - MEMCID index_memc_to_be_traced" << std::endl;
434            std::cout << "     - XRAMID index_xram_to_be_traced" << std::endl;
435            std::cout << "     - PROCID index_proc_to_be_traced" << std::endl;
436            std::cout << "     - IOB    non_zero_value" << std::endl;
437            exit(0);
438         }
439      }
440   }
441
442   // checking hardware parameters
443   assert( (XMAX <= 16) and
444           "The XMAX parameter cannot be larger than 16" );
445
446   assert( (YMAX <= 16) and
447           "The YMAX parameter cannot be larger than 16" );
448
449   assert( (NB_PROCS_MAX <= 8) and
450           "NB_PROCS_MAX parameter cannot be larger than 8" );
451
452   assert( (XCU_NB_HWI > NB_PROCS_MAX) and
453           "XCU_NB_HWI must be larger than NB_PROCS_MAX" );
454
455   assert( (XCU_NB_PTI >= NB_PROCS_MAX) and
456           "XCU_NB_PTI cannot be smaller than NB_PROCS_MAX" );
457
458   assert( (XCU_NB_WTI >= 4*NB_PROCS_MAX) and
459           "XCU_NB_WTI cannot be smaller than 4*NB_PROCS_MAX" );
460
461   assert( (XCU_NB_OUT >= 4*NB_PROCS_MAX) and
462           "XCU_NB_OUT cannot be smaller than 4*NB_PROCS_MAX" );
463   
464   assert( (NB_DMA_CHANNELS >= NB_PROCS_MAX) and
465           "The NB_DMA_CHANNELS parameter cannot be larger than 8" );
466
467   assert( (NB_TTY_CHANNELS >= 1) and (NB_TTY_CHANNELS <= 16) and
468           "The NB_TTY_CHANNELS parameter cannot be larger than 16" );
469
470   assert( (NB_NIC_CHANNELS <= 2) and
471           "The NB_NIC_CHANNELS parameter cannot be larger than 2" );
472
473   assert( (NB_CMA_CHANNELS <= 4) and
474           "The NB_CMA_CHANNELS parameter cannot be larger than 4" );
475
476   std::cout << std::endl << std::dec
477             << " - XMAX            = " << XMAX << std::endl
478             << " - YMAX            = " << YMAX << std::endl
479             << " - NB_PROCS_MAX    = " << NB_PROCS_MAX << std::endl
480             << " - NB_DMA_CHANNELS = " << NB_DMA_CHANNELS <<  std::endl
481             << " - NB_TTY_CHANNELS = " << NB_TTY_CHANNELS <<  std::endl
482             << " - NB_NIC_CHANNELS = " << NB_NIC_CHANNELS <<  std::endl
483             << " - NB_CMA_CHANNELS = " << NB_CMA_CHANNELS <<  std::endl
484             << " - MEMC_WAYS       = " << MEMC_WAYS << std::endl
485             << " - MEMC_SETS       = " << MEMC_SETS << std::endl
486             << " - RAM_LATENCY     = " << XRAM_LATENCY << std::endl
487             << " - MAX_FROZEN      = " << frozen_cycles << std::endl
488             << " - NCYCLES         = " << ncycles << std::endl
489             << " - DEBUG_PROCID    = " << debug_proc_id << std::endl
490             << " - DEBUG_MEMCID    = " << debug_memc_id << std::endl
491             << " - DEBUG_XRAMID    = " << debug_xram_id << std::endl;
492
493   std::cout << std::endl;
494
495#if USING_OPENMP
496   omp_set_dynamic(false);
497   omp_set_num_threads(threads_nr);
498   std::cerr << "Built with openmp version " << _OPENMP << std::endl;
499#endif
500
501   // Define VciParams objects
502   typedef soclib::caba::VciParams<vci_cell_width_int,
503                                   vci_plen_width,
504                                   vci_address_width,
505                                   vci_rerror_width,
506                                   vci_clen_width,
507                                   vci_rflag_width,
508                                   vci_srcid_width,
509                                   vci_pktid_width,
510                                   vci_trdid_width,
511                                   vci_wrplen_width> vci_param_int;
512
513   typedef soclib::caba::VciParams<vci_cell_width_ext,
514                                   vci_plen_width,
515                                   vci_address_width,
516                                   vci_rerror_width,
517                                   vci_clen_width,
518                                   vci_rflag_width,
519                                   vci_srcid_width,
520                                   vci_pktid_width,
521                                   vci_trdid_width,
522                                   vci_wrplen_width> vci_param_ext;
523
524   /////////////////////////////////////////////////////////////////////
525   // INT network mapping table
526   // - two levels address decoding for commands
527   // - two levels srcid decoding for responses
528   // - NB_PROCS_MAX + 2 (MDMA, IOBX) local initiators per cluster
529   // - 4 local targets (MEMC, XICU, MDMA, IOBX) per cluster
530   /////////////////////////////////////////////////////////////////////
531   MappingTable maptab_int( vci_address_width,
532                            IntTab(x_width + y_width, 16 - x_width - y_width),
533                            IntTab(x_width + y_width, vci_srcid_width - x_width - y_width),
534                            0x00FF000000);
535
536   for (size_t x = 0; x < XMAX; x++)
537   {
538      for (size_t y = 0; y < YMAX; y++)
539      {
540         uint64_t offset = ((uint64_t)cluster(x,y))
541                              << (vci_address_width-x_width-y_width);
542         bool config    = true;
543         bool cacheable = true;
544
545         // the four following segments are defined in all clusters
546
547         std::ostringstream    smemc_conf;
548         smemc_conf << "int_seg_memc_conf_" << x << "_" << y;
549         maptab_int.add(Segment(smemc_conf.str(), SEG_MMC_BASE+offset, SEG_MMC_SIZE,
550                     IntTab(cluster(x,y), INT_MEMC_TGT_ID), not cacheable, config ));
551
552         std::ostringstream    smemc_xram;
553         smemc_xram << "int_seg_memc_xram_" << x << "_" << y;
554         maptab_int.add(Segment(smemc_xram.str(), SEG_RAM_BASE+offset, SEG_RAM_SIZE,
555                     IntTab(cluster(x,y), INT_MEMC_TGT_ID), cacheable));
556
557         std::ostringstream    sxicu;
558         sxicu << "int_seg_xicu_" << x << "_" << y;
559         maptab_int.add(Segment(sxicu.str(), SEG_XCU_BASE+offset, SEG_XCU_SIZE,
560                     IntTab(cluster(x,y), INT_XICU_TGT_ID), not cacheable));
561
562         std::ostringstream    smdma;
563         smdma << "int_seg_mdma_" << x << "_" << y;
564         maptab_int.add(Segment(smdma.str(), SEG_DMA_BASE+offset, SEG_DMA_SIZE,
565                     IntTab(cluster(x,y), INT_MDMA_TGT_ID), not cacheable));
566
567         // the following segments are only defined in cluster_iob0 or in cluster_iob1
568
569         if ( (cluster(x,y) == cluster_iob0) or (cluster(x,y) == cluster_iob1) )
570         {
571            std::ostringstream    siobx;
572            siobx << "int_seg_iobx_" << x << "_" << y;
573            maptab_int.add(Segment(siobx.str(), SEG_IOB_BASE+offset, SEG_IOB_SIZE,
574                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable, config ));
575
576            std::ostringstream    stty;
577            stty << "int_seg_mtty_" << x << "_" << y;
578            maptab_int.add(Segment(stty.str(), SEG_TTY_BASE+offset, SEG_TTY_SIZE,
579                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
580
581            std::ostringstream    sfbf;
582            sfbf << "int_seg_fbuf_" << x << "_" << y;
583            maptab_int.add(Segment(sfbf.str(), SEG_FBF_BASE+offset, SEG_FBF_SIZE,
584                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
585
586            std::ostringstream    sdsk;
587            sdsk << "int_seg_disk_" << x << "_" << y;
588            maptab_int.add(Segment(sdsk.str(), SEG_IOC_BASE+offset, SEG_IOC_SIZE,
589                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
590
591            std::ostringstream    snic;
592            snic << "int_seg_mnic_" << x << "_" << y;
593            maptab_int.add(Segment(snic.str(), SEG_NIC_BASE+offset, SEG_NIC_SIZE,
594                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
595
596            std::ostringstream    srom;
597            srom << "int_seg_brom_" << x << "_" << y;
598            maptab_int.add(Segment(srom.str(), SEG_ROM_BASE+offset, SEG_ROM_SIZE,
599                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), cacheable ));
600
601            std::ostringstream    sdma;
602            sdma << "int_seg_cdma_" << x << "_" << y;
603            maptab_int.add(Segment(sdma.str(), SEG_CMA_BASE+offset, SEG_CMA_SIZE,
604                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
605
606            std::ostringstream    spic;
607            spic << "int_seg_iopi_" << x << "_" << y;
608            maptab_int.add(Segment(spic.str(), SEG_PIC_BASE+offset, SEG_PIC_SIZE,
609                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
610         }
611
612         // This define the mapping between the SRCIDs
613         // and the port index on the local interconnect.
614
615         maptab_int.srcid_map( IntTab( cluster(x,y), MDMA_LOCAL_SRCID ),
616                               IntTab( cluster(x,y), INT_MDMA_INI_ID ) );
617
618         maptab_int.srcid_map( IntTab( cluster(x,y), IOBX_LOCAL_SRCID ),
619                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
620
621         maptab_int.srcid_map( IntTab( cluster(x,y), IOPI_LOCAL_SRCID ),
622                               IntTab( cluster(x,y), INT_IOBX_INI_ID ) );
623
624         for ( size_t p = 0 ; p < NB_PROCS_MAX; p++ )
625         maptab_int.srcid_map( IntTab( cluster(x,y), PROC_LOCAL_SRCID+p ),
626                               IntTab( cluster(x,y), INT_PROC_INI_ID+p ) );
627      }
628   }
629   std::cout << "INT network " << maptab_int << std::endl;
630
631    /////////////////////////////////////////////////////////////////////////
632    // RAM network mapping table
633    // - two levels address decoding for commands
634    // - two levels srcid decoding for responses
635    // - 2 local initiators (MEMC, IOBX) per cluster
636    //   (IOBX component only in cluster_iob0 and cluster_iob1)
637    // - 1 local target (XRAM) per cluster
638    ////////////////////////////////////////////////////////////////////////
639    MappingTable maptab_ram( vci_address_width,
640                             IntTab(x_width+y_width, 0),
641                             IntTab(x_width+y_width, vci_srcid_width - x_width - y_width),
642                             0x00FF000000);
643
644    for (size_t x = 0; x < XMAX; x++)
645    {
646        for (size_t y = 0; y < YMAX ; y++)
647        {
648            uint64_t offset = ((uint64_t)cluster(x,y))
649                                << (vci_address_width-x_width-y_width);
650
651            std::ostringstream sxram;
652            sxram << "ext_seg_xram_" << x << "_" << y;
653            maptab_ram.add(Segment(sxram.str(), SEG_RAM_BASE+offset,
654                           SEG_RAM_SIZE, IntTab(cluster(x,y), RAM_XRAM_TGT_ID), false));
655        }
656    }
657
658    // This define the mapping between the initiators SRCID
659    // and the port index on the RAM local interconnect.
660    // External initiator have two alias SRCID (iob0 / iob1)
661
662    maptab_ram.srcid_map( IntTab( cluster_iob0, CDMA_LOCAL_SRCID ),
663                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
664
665    maptab_ram.srcid_map( IntTab( cluster_iob1, CDMA_LOCAL_SRCID ),
666                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
667
668    maptab_ram.srcid_map( IntTab( cluster_iob0, DISK_LOCAL_SRCID ),
669                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
670
671    maptab_ram.srcid_map( IntTab( cluster_iob1, DISK_LOCAL_SRCID ),
672                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
673
674    maptab_ram.srcid_map( IntTab( cluster_iob0, IOPI_LOCAL_SRCID ),
675                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
676
677    maptab_ram.srcid_map( IntTab( cluster_iob1, IOPI_LOCAL_SRCID ),
678                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
679
680    maptab_ram.srcid_map( IntTab( cluster_iob0, MEMC_LOCAL_SRCID ),
681                          IntTab( cluster_iob0, RAM_MEMC_INI_ID ) );
682
683    maptab_ram.srcid_map( IntTab( cluster_iob1, MEMC_LOCAL_SRCID ),
684                          IntTab( cluster_iob1, RAM_MEMC_INI_ID ) );
685
686    std::cout << "RAM network " << maptab_ram << std::endl;
687
688    ///////////////////////////////////////////////////////////////////////
689    // IOX network mapping table
690    // - two levels address decoding for commands (9, 7) bits
691    // - two levels srcid decoding for responses
692    // - 5 initiators (IOB0, IOB1, DISK, CDMA, IOPI)
693    // - 9 targets (IOB0, IOB1, DISK, CDMA, MTTY, FBUF, BROM, MNIC, IOPI)
694    //
695    // Address bit 32 is used to determine if a command must be routed to
696    // IOB0 or IOB1.
697    ///////////////////////////////////////////////////////////////////////
698    MappingTable maptab_iox(
699          vci_address_width,
700          IntTab(x_width + y_width - 1, 16 - x_width - y_width + 1),
701          IntTab(x_width + y_width    , vci_param_ext::S - x_width - y_width),
702          0x00FF000000);
703
704    // External peripherals segments
705    // When there is more than one cluster, external peripherals can be accessed
706    // through two segments, depending on the used IOB (IOB0 or IOB1).
707
708    const uint64_t iob0_base = ((uint64_t)cluster_iob0)
709       << (vci_address_width - x_width - y_width);
710
711    maptab_iox.add(Segment("iox_seg_mtty_0", SEG_TTY_BASE + iob0_base, SEG_TTY_SIZE,
712                   IntTab(0, IOX_MTTY_TGT_ID), false));
713    maptab_iox.add(Segment("iox_seg_fbuf_0", SEG_FBF_BASE + iob0_base, SEG_FBF_SIZE,
714                   IntTab(0, IOX_FBUF_TGT_ID), false));
715    maptab_iox.add(Segment("iox_seg_disk_0", SEG_IOC_BASE + iob0_base, SEG_IOC_SIZE,
716                   IntTab(0, IOX_DISK_TGT_ID), false));
717    maptab_iox.add(Segment("iox_seg_mnic_0", SEG_NIC_BASE + iob0_base, SEG_NIC_SIZE,
718                   IntTab(0, IOX_MNIC_TGT_ID), false));
719    maptab_iox.add(Segment("iox_seg_cdma_0", SEG_CMA_BASE + iob0_base, SEG_CMA_SIZE,
720                   IntTab(0, IOX_CDMA_TGT_ID), false));
721    maptab_iox.add(Segment("iox_seg_brom_0", SEG_ROM_BASE + iob0_base, SEG_ROM_SIZE,
722                   IntTab(0, IOX_BROM_TGT_ID), false));
723    maptab_iox.add(Segment("iox_seg_iopi_0", SEG_PIC_BASE + iob0_base, SEG_PIC_SIZE,
724                   IntTab(0, IOX_IOPI_TGT_ID), false));
725
726    if ( cluster_iob0 != cluster_iob1 )
727    {
728       const uint64_t iob1_base = ((uint64_t)cluster_iob1)
729          << (vci_address_width - x_width - y_width);
730
731        maptab_iox.add(Segment("iox_seg_mtty_1", SEG_TTY_BASE + iob1_base, SEG_TTY_SIZE,
732                   IntTab(0, IOX_MTTY_TGT_ID), false));
733        maptab_iox.add(Segment("iox_seg_fbuf_1", SEG_FBF_BASE + iob1_base, SEG_FBF_SIZE,
734                   IntTab(0, IOX_FBUF_TGT_ID), false));
735        maptab_iox.add(Segment("iox_seg_disk_1", SEG_IOC_BASE + iob1_base, SEG_IOC_SIZE,
736                   IntTab(0, IOX_DISK_TGT_ID), false));
737        maptab_iox.add(Segment("iox_seg_mnic_1", SEG_NIC_BASE + iob1_base, SEG_NIC_SIZE,
738                   IntTab(0, IOX_MNIC_TGT_ID), false));
739        maptab_iox.add(Segment("iox_seg_cdma_1", SEG_CMA_BASE + iob1_base, SEG_CMA_SIZE,
740                   IntTab(0, IOX_CDMA_TGT_ID), false));
741        maptab_iox.add(Segment("iox_seg_brom_1", SEG_ROM_BASE + iob1_base, SEG_ROM_SIZE,
742                   IntTab(0, IOX_BROM_TGT_ID), false));
743        maptab_iox.add(Segment("iox_seg_iopi_1", SEG_PIC_BASE + iob1_base, SEG_PIC_SIZE,
744                   IntTab(0, IOX_IOPI_TGT_ID), false));
745    }
746
747    // If there is more than one cluster, external peripherals
748    // can access RAM through two segments (IOB0 / IOB1).
749    // As IOMMU is not activated, addresses are 40 bits (physical addresses),
750    // and the choice depends on address bit A[32].
751    for (size_t x = 0; x < XMAX; x++)
752    {
753        for (size_t y = 0; y < YMAX ; y++)
754        {
755            const bool wti       = true;
756            const bool cacheable = true;
757
758            const uint64_t offset = ((uint64_t)cluster(x,y))
759                << (vci_address_width-x_width-y_width);
760
761            const uint64_t xicu_base = SEG_XCU_BASE + offset;
762
763            if ( (y & 0x1) == 0 ) // use IOB0
764            {
765                std::ostringstream sxcu0;
766                sxcu0 << "iox_seg_xcu0_" << x << "_" << y;
767                maptab_iox.add(Segment(sxcu0.str(), xicu_base, SEG_XCU_SIZE,
768                            IntTab(0, IOX_IOB0_TGT_ID), not cacheable, wti));
769
770                std::ostringstream siob0;
771                siob0 << "iox_seg_ram0_" << x << "_" << y;
772                maptab_iox.add(Segment(siob0.str(), offset, SEG_XCU_BASE,
773                            IntTab(0, IOX_IOB0_TGT_ID), not cacheable, not wti));
774            }
775            else                  // USE IOB1
776            {
777                std::ostringstream sxcu1;
778                sxcu1 << "iox_seg_xcu1_" << x << "_" << y;
779                maptab_iox.add(Segment(sxcu1.str(), xicu_base, SEG_XCU_SIZE,
780                            IntTab(0, IOX_IOB1_TGT_ID), not cacheable, wti));
781
782                std::ostringstream siob1;
783                siob1 << "iox_seg_ram1_" << x << "_" << y;
784                maptab_iox.add(Segment(siob1.str(), offset, SEG_XCU_BASE,
785                            IntTab(0, IOX_IOB1_TGT_ID), not cacheable, not wti));
786            }
787        }
788    }
789
790    // This define the mapping between the external initiators (SRCID)
791    // and the port index on the IOX local interconnect.
792
793    maptab_iox.srcid_map( IntTab( 0, CDMA_LOCAL_SRCID ) ,
794                          IntTab( 0, IOX_CDMA_INI_ID  ) );
795    maptab_iox.srcid_map( IntTab( 0, DISK_LOCAL_SRCID ) ,
796                          IntTab( 0, IOX_DISK_INI_ID  ) );
797    maptab_iox.srcid_map( IntTab( 0, IOPI_LOCAL_SRCID ) ,
798                          IntTab( 0, IOX_IOPI_INI_ID  ) );
799    maptab_iox.srcid_map( IntTab( 0, IOX_IOB0_INI_ID  ) ,
800                          IntTab( 0, IOX_IOB0_INI_ID  ) );
801
802    if ( cluster_iob0 != cluster_iob1 )
803    {
804        maptab_iox.srcid_map( IntTab( 0, IOX_IOB1_INI_ID ) ,
805                              IntTab( 0, IOX_IOB1_INI_ID ) );
806    }
807
808    std::cout << "IOX network " << maptab_iox << std::endl;
809
810    ////////////////////
811    // Signals
812    ///////////////////
813
814    sc_clock                          signal_clk("clk");
815    sc_signal<bool>                   signal_resetn("resetn");
816
817    sc_signal<bool>                   signal_irq_false;
818    sc_signal<bool>                   signal_irq_disk;
819    sc_signal<bool>                   signal_irq_mtty_rx[NB_TTY_CHANNELS];
820    sc_signal<bool>                   signal_irq_mnic_rx[NB_NIC_CHANNELS];
821    sc_signal<bool>                   signal_irq_mnic_tx[NB_NIC_CHANNELS];
822    sc_signal<bool>                   signal_irq_cdma[NB_CMA_CHANNELS];
823
824    // VCI signals for IOX network
825    VciSignals<vci_param_ext>         signal_vci_ini_iob0("signal_vci_ini_iob0");
826    VciSignals<vci_param_ext>         signal_vci_ini_iob1("signal_vci_ini_iob1");
827    VciSignals<vci_param_ext>         signal_vci_ini_disk("signal_vci_ini_disk");
828    VciSignals<vci_param_ext>         signal_vci_ini_cdma("signal_vci_ini_cdma");
829    VciSignals<vci_param_ext>         signal_vci_ini_iopi("signal_vci_ini_iopi");
830
831    VciSignals<vci_param_ext>         signal_vci_tgt_iob0("signal_vci_tgt_iob0");
832    VciSignals<vci_param_ext>         signal_vci_tgt_iob1("signal_vci_tgt_iob1");
833    VciSignals<vci_param_ext>         signal_vci_tgt_mtty("signal_vci_tgt_mtty");
834    VciSignals<vci_param_ext>         signal_vci_tgt_fbuf("signal_vci_tgt_fbuf");
835    VciSignals<vci_param_ext>         signal_vci_tgt_mnic("signal_vci_tgt_mnic");
836    VciSignals<vci_param_ext>         signal_vci_tgt_brom("signal_vci_tgt_brom");
837    VciSignals<vci_param_ext>         signal_vci_tgt_disk("signal_vci_tgt_disk");
838    VciSignals<vci_param_ext>         signal_vci_tgt_cdma("signal_vci_tgt_cdma");
839    VciSignals<vci_param_ext>         signal_vci_tgt_iopi("signal_vci_tgt_iopi");
840
841   // Horizontal inter-clusters INT network DSPIN
842   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_inc =
843      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_inc", XMAX-1, YMAX, 3);
844   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_h_dec =
845      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_h_dec", XMAX-1, YMAX, 3);
846   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_inc =
847      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_inc", XMAX-1, YMAX, 2);
848   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_h_dec =
849      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_h_dec", XMAX-1, YMAX, 2);
850
851   // Vertical inter-clusters INT network DSPIN
852   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_inc =
853      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_inc", XMAX, YMAX-1, 3);
854   DspinSignals<dspin_int_cmd_width>*** signal_dspin_int_cmd_v_dec =
855      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_int_cmd_v_dec", XMAX, YMAX-1, 3);
856   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_inc =
857      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_inc", XMAX, YMAX-1, 2);
858   DspinSignals<dspin_int_rsp_width>*** signal_dspin_int_rsp_v_dec =
859      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_int_rsp_v_dec", XMAX, YMAX-1, 2);
860
861   // Mesh boundaries INT network DSPIN
862   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_in =
863      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_in", XMAX, YMAX, 4, 3);
864   DspinSignals<dspin_int_cmd_width>**** signal_dspin_false_int_cmd_out =
865      alloc_elems<DspinSignals<dspin_int_cmd_width> >("signal_dspin_false_int_cmd_out", XMAX, YMAX, 4, 3);
866   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_in =
867      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_in", XMAX, YMAX, 4, 2);
868   DspinSignals<dspin_int_rsp_width>**** signal_dspin_false_int_rsp_out =
869      alloc_elems<DspinSignals<dspin_int_rsp_width> >("signal_dspin_false_int_rsp_out", XMAX, YMAX, 4, 2);
870
871
872   // Horizontal inter-clusters RAM network DSPIN
873   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_inc =
874      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_inc", XMAX-1, YMAX);
875   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_h_dec =
876      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_h_dec", XMAX-1, YMAX);
877   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_inc =
878      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_inc", XMAX-1, YMAX);
879   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_h_dec =
880      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_h_dec", XMAX-1, YMAX);
881
882   // Vertical inter-clusters RAM network DSPIN
883   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_inc =
884      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_inc", XMAX, YMAX-1);
885   DspinSignals<dspin_ram_cmd_width>** signal_dspin_ram_cmd_v_dec =
886      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_ram_cmd_v_dec", XMAX, YMAX-1);
887   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_inc =
888      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_inc", XMAX, YMAX-1);
889   DspinSignals<dspin_ram_rsp_width>** signal_dspin_ram_rsp_v_dec =
890      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_ram_rsp_v_dec", XMAX, YMAX-1);
891
892   // Mesh boundaries RAM network DSPIN
893   DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_in =
894      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_in", XMAX, YMAX, 4);
895   DspinSignals<dspin_ram_cmd_width>*** signal_dspin_false_ram_cmd_out =
896      alloc_elems<DspinSignals<dspin_ram_cmd_width> >("signal_dspin_false_ram_cmd_out", XMAX, YMAX, 4);
897   DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_in =
898      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_in", XMAX, YMAX, 4);
899   DspinSignals<dspin_ram_rsp_width>*** signal_dspin_false_ram_rsp_out =
900      alloc_elems<DspinSignals<dspin_ram_rsp_width> >("signal_dspin_false_ram_rsp_out", XMAX, YMAX, 4);
901
902    ////////////////////////////
903    //      Loader
904    ////////////////////////////
905
906#if USE_ALMOS
907    soclib::common::Loader loader(almos_bootloader_pathname,
908                                 almos_archinfo_pathname,
909                                 almos_kernel_pathname);
910#else
911    soclib::common::Loader loader(soft_name);
912#endif
913
914    typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss;
915    proc_iss::set_loader(loader);
916
917    ////////////////////////////////////////
918    //  Instanciated Hardware Components
919    ////////////////////////////////////////
920
921    std::cout << std::endl << "External Bus and Peripherals" << std::endl << std::endl;
922
923    const size_t nb_iox_initiators = (cluster_iob0 != cluster_iob1) ? 5 : 4;
924    const size_t nb_iox_targets = (cluster_iob0 != cluster_iob1) ? 9 : 8;
925
926    // IOX network
927    VciIoxNetwork<vci_param_ext>* iox_network;
928    iox_network = new VciIoxNetwork<vci_param_ext>( "iox_network",
929                                                    maptab_iox,
930                                                    nb_iox_targets,
931                                                    nb_iox_initiators );
932    // boot ROM
933    VciSimpleRom<vci_param_ext>*  brom;
934    brom = new VciSimpleRom<vci_param_ext>( "brom",
935                                            IntTab(0, IOX_BROM_TGT_ID),
936                                            maptab_iox,
937                                            loader );
938    // Network Controller
939    VciMultiNic<vci_param_ext>*  mnic;
940    mnic = new VciMultiNic<vci_param_ext>( "mnic",
941                                           IntTab(0, IOX_MNIC_TGT_ID),
942                                           maptab_iox,
943                                           NB_NIC_CHANNELS,
944                                           0,                // mac_4 address
945                                           0,                // mac_2 address
946                                           1 );              // NIC_MODE_SYNTHESIS
947
948    // Frame Buffer
949    VciFrameBuffer<vci_param_ext>*  fbuf;
950    fbuf = new VciFrameBuffer<vci_param_ext>( "fbuf",
951                                              IntTab(0, IOX_FBUF_TGT_ID),
952                                              maptab_iox,
953                                              FBUF_X_SIZE, FBUF_Y_SIZE );
954
955    // Disk
956    std::vector<std::string> filenames;
957    filenames.push_back(disk_name);            // one single disk
958
959#if ( USE_IOC_HBA )
960    VciMultiAhci<vci_param_ext>*  disk;
961    disk = new VciMultiAhci<vci_param_ext>( "disk",
962                                            maptab_iox,
963                                            IntTab(0, DISK_LOCAL_SRCID),
964                                            IntTab(0, IOX_DISK_TGT_ID),
965                                            filenames,
966                                            512,        // block size
967                                            64,         // burst size (bytes)
968                                            0 );        // disk latency
969#elif ( USE_IOC_BDV )
970    VciBlockDeviceTsar<vci_param_ext>*  disk;
971    disk = new VciBlockDeviceTsar<vci_param_ext>( "disk",
972                                                  maptab_iox,
973                                                  IntTab(0, DISK_LOCAL_SRCID),
974                                                  IntTab(0, IOX_DISK_TGT_ID),
975                                                  disk_name,
976                                                  512,        // block size
977                                                  64,         // burst size (bytes)
978                                                  0 );        // disk latency
979#else
980    std::cout << "Error in tsar_generic_iob : only HBA & BDV are supported" << std::endl;
981    exit(0);
982#endif
983
984    // Chained Buffer DMA controller
985    VciChbufDma<vci_param_ext>*  cdma;
986    cdma = new VciChbufDma<vci_param_ext>( "cdma",
987                                           maptab_iox,
988                                           IntTab(0, CDMA_LOCAL_SRCID),
989                                           IntTab(0, IOX_CDMA_TGT_ID),
990                                           64,          // burst size (bytes)
991                                           NB_CMA_CHANNELS );
992    // Multi-TTY controller
993    std::vector<std::string> vect_names;
994    for( size_t tid = 0 ; tid < NB_TTY_CHANNELS ; tid++ )
995    {
996        std::ostringstream term_name;
997          term_name <<  "term" << tid;
998 
999         vect_names.push_back(term_name.str().c_str());
1000      }
1001      VciMultiTty<vci_param_ext>*  mtty;
1002      mtty = new VciMultiTty<vci_param_ext>( "mtty",
1003                                             IntTab(0, IOX_MTTY_TGT_ID),
1004                                             maptab_iox,
1005                                             vect_names);
1006
1007    // IOPIC
1008    VciIopic<vci_param_ext>* iopi;
1009    iopi = new VciIopic<vci_param_ext>( "iopi",
1010                                        maptab_iox,
1011                                        IntTab(0, IOPI_LOCAL_SRCID),
1012                                        IntTab(0, IOX_IOPI_TGT_ID),
1013                                        32 );        // number of input HWI
1014    // Clusters
1015    TsarIobCluster<vci_param_int,
1016                   vci_param_ext,
1017                   dspin_int_cmd_width,
1018                   dspin_int_rsp_width,
1019                   dspin_ram_cmd_width,
1020                   dspin_ram_rsp_width>* clusters[XMAX][YMAX];
1021
1022#if USING_OPENMP
1023#pragma omp parallel
1024    {
1025#pragma omp for
1026#endif
1027        for(size_t i = 0; i  < (XMAX * YMAX); i++)
1028        {
1029            size_t x = i / YMAX;
1030            size_t y = i % YMAX;
1031
1032#if USING_OPENMP
1033#pragma omp critical
1034            {
1035#endif
1036            std::cout << std::endl;
1037            std::cout << "Cluster_" << std::dec << x << "_" << y << std::endl;
1038            std::cout << std::endl;
1039
1040            const bool is_iob0 = (cluster(x,y) == cluster_iob0);
1041            const bool is_iob1 = (cluster(x,y) == cluster_iob1);
1042            const bool is_io_cluster = is_iob0 || is_iob1;
1043
1044            const int iox_iob_ini_id = is_iob0 ?
1045                IOX_IOB0_INI_ID :
1046                IOX_IOB1_INI_ID ;
1047            const int iox_iob_tgt_id = is_iob0 ?
1048                IOX_IOB0_TGT_ID :
1049                IOX_IOB1_TGT_ID ;
1050
1051            std::ostringstream sc;
1052            sc << "cluster_" << x << "_" << y;
1053            clusters[x][y] = new TsarIobCluster<vci_param_int,
1054                                                vci_param_ext,
1055                                                dspin_int_cmd_width,
1056                                                dspin_int_rsp_width,
1057                                                dspin_ram_cmd_width,
1058                                                dspin_ram_rsp_width>
1059            (
1060                sc.str().c_str(),
1061                NB_PROCS_MAX,
1062                NB_DMA_CHANNELS,
1063                x,
1064                y,
1065                XMAX,
1066                YMAX,
1067
1068                maptab_int,
1069                maptab_ram,
1070                maptab_iox,
1071
1072                x_width,
1073                y_width,
1074                vci_srcid_width - x_width - y_width,            // l_id width,
1075                p_width,
1076
1077                INT_MEMC_TGT_ID,
1078                INT_XICU_TGT_ID,
1079                INT_MDMA_TGT_ID,
1080                INT_IOBX_TGT_ID,
1081
1082                INT_PROC_INI_ID,
1083                INT_MDMA_INI_ID,
1084                INT_IOBX_INI_ID,
1085
1086                RAM_XRAM_TGT_ID,
1087
1088                RAM_MEMC_INI_ID,
1089                RAM_IOBX_INI_ID,
1090
1091                is_io_cluster,
1092                iox_iob_tgt_id,
1093                iox_iob_ini_id,
1094
1095                MEMC_WAYS,
1096                MEMC_SETS,
1097                L1_IWAYS,
1098                L1_ISETS,
1099                L1_DWAYS,
1100                L1_DSETS,
1101                XRAM_LATENCY,
1102                XCU_NB_HWI,
1103                XCU_NB_PTI,
1104                XCU_NB_WTI,
1105                XCU_NB_OUT,
1106
1107                loader,
1108
1109                frozen_cycles,
1110                debug_from,
1111                debug_ok and (cluster(x,y) == debug_memc_id),
1112                debug_ok and (cluster(x,y) == debug_proc_id),
1113                debug_ok and debug_iob
1114            );
1115
1116#if USING_OPENMP
1117            } // end critical
1118#endif
1119        } // end for
1120#if USING_OPENMP
1121    }
1122#endif
1123
1124    std::cout << std::endl;
1125
1126    ///////////////////////////////////////////////////////////////////////////////
1127    //     Net-list
1128    ///////////////////////////////////////////////////////////////////////////////
1129
1130    // IOX network connexion
1131    iox_network->p_clk                                   (signal_clk);
1132    iox_network->p_resetn                                (signal_resetn);
1133    iox_network->p_to_ini[IOX_IOB0_INI_ID]               (signal_vci_ini_iob0);
1134    iox_network->p_to_ini[IOX_DISK_INI_ID]               (signal_vci_ini_disk);
1135    iox_network->p_to_ini[IOX_CDMA_INI_ID]               (signal_vci_ini_cdma);
1136    iox_network->p_to_ini[IOX_IOPI_INI_ID]               (signal_vci_ini_iopi);
1137
1138    iox_network->p_to_tgt[IOX_IOB0_TGT_ID]               (signal_vci_tgt_iob0);
1139    iox_network->p_to_tgt[IOX_MTTY_TGT_ID]               (signal_vci_tgt_mtty);
1140    iox_network->p_to_tgt[IOX_FBUF_TGT_ID]               (signal_vci_tgt_fbuf);
1141    iox_network->p_to_tgt[IOX_MNIC_TGT_ID]               (signal_vci_tgt_mnic);
1142    iox_network->p_to_tgt[IOX_BROM_TGT_ID]               (signal_vci_tgt_brom);
1143    iox_network->p_to_tgt[IOX_DISK_TGT_ID]               (signal_vci_tgt_disk);
1144    iox_network->p_to_tgt[IOX_CDMA_TGT_ID]               (signal_vci_tgt_cdma);
1145    iox_network->p_to_tgt[IOX_IOPI_TGT_ID]               (signal_vci_tgt_iopi);
1146
1147    if (cluster_iob0 != cluster_iob1)
1148    {
1149        iox_network->p_to_ini[IOX_IOB1_INI_ID]           (signal_vci_ini_iob1);
1150        iox_network->p_to_tgt[IOX_IOB1_TGT_ID]           (signal_vci_tgt_iob1);
1151    }
1152
1153    // DISK connexion
1154    disk->p_clk                                          (signal_clk);
1155    disk->p_resetn                                       (signal_resetn);
1156    disk->p_vci_target                                   (signal_vci_tgt_disk);
1157    disk->p_vci_initiator                                (signal_vci_ini_disk);
1158#if ( USE_IOC_HBA )
1159    disk->p_channel_irq[0]                               (signal_irq_disk);
1160#else
1161    disk->p_irq                                          (signal_irq_disk);
1162#endif
1163
1164    std::cout << "  - DISK connected" << std::endl;
1165
1166    // FBUF connexion
1167    fbuf->p_clk                                          (signal_clk);
1168    fbuf->p_resetn                                       (signal_resetn);
1169    fbuf->p_vci                                          (signal_vci_tgt_fbuf);
1170
1171    std::cout << "  - FBUF connected" << std::endl;
1172
1173    // MNIC connexion
1174    mnic->p_clk                                          (signal_clk);
1175    mnic->p_resetn                                       (signal_resetn);
1176    mnic->p_vci                                          (signal_vci_tgt_mnic);
1177    for ( size_t i=0 ; i<NB_NIC_CHANNELS ; i++ )
1178    {
1179         mnic->p_rx_irq[i]                               (signal_irq_mnic_rx[i]);
1180         mnic->p_tx_irq[i]                               (signal_irq_mnic_tx[i]);
1181    }
1182
1183    std::cout << "  - MNIC connected" << std::endl;
1184
1185    // BROM connexion
1186    brom->p_clk                                          (signal_clk);
1187    brom->p_resetn                                       (signal_resetn);
1188    brom->p_vci                                          (signal_vci_tgt_brom);
1189
1190    std::cout << "  - BROM connected" << std::endl;
1191
1192    // MTTY connexion
1193    mtty->p_clk                                          (signal_clk);
1194    mtty->p_resetn                                       (signal_resetn);
1195    mtty->p_vci                                          (signal_vci_tgt_mtty);
1196    for ( size_t i=0 ; i<NB_TTY_CHANNELS ; i++ )
1197    {
1198        mtty->p_irq[i]                                   (signal_irq_mtty_rx[i]);
1199    }
1200    std::cout << "  - MTTY connected" << std::endl;
1201
1202    // CDMA connexion
1203    cdma->p_clk                                          (signal_clk);
1204    cdma->p_resetn                                       (signal_resetn);
1205    cdma->p_vci_target                                   (signal_vci_tgt_cdma);
1206    cdma->p_vci_initiator                                (signal_vci_ini_cdma);
1207    for ( size_t i=0 ; i<(NB_CMA_CHANNELS) ; i++)
1208    {
1209        cdma->p_irq[i]                                   (signal_irq_cdma[i]);
1210    }
1211
1212    std::cout << "  - CDMA connected" << std::endl;
1213
1214    // IOPI connexion
1215    iopi->p_clk                                          (signal_clk);
1216    iopi->p_resetn                                       (signal_resetn);
1217    iopi->p_vci_target                                   (signal_vci_tgt_iopi);
1218    iopi->p_vci_initiator                                (signal_vci_ini_iopi);
1219    for ( size_t i=0 ; i<32 ; i++)
1220    {
1221       if     (i < NB_NIC_CHANNELS)    iopi->p_hwi[i] (signal_irq_mnic_rx[i]);
1222       else if(i < 2 )                 iopi->p_hwi[i] (signal_irq_false);
1223       else if(i < 2+NB_NIC_CHANNELS)  iopi->p_hwi[i] (signal_irq_mnic_tx[i-2]);
1224       else if(i < 4 )                 iopi->p_hwi[i] (signal_irq_false);
1225       else if(i < 4+NB_CMA_CHANNELS)  iopi->p_hwi[i] (signal_irq_cdma[i-4]);
1226       else if(i < 8)                  iopi->p_hwi[i] (signal_irq_false);
1227       else if(i < 9)                  iopi->p_hwi[i] (signal_irq_disk);
1228       else if(i < 16)                 iopi->p_hwi[i] (signal_irq_false);
1229       else if(i < 16+NB_TTY_CHANNELS) iopi->p_hwi[i] (signal_irq_mtty_rx[i-16]);
1230       else                            iopi->p_hwi[i] (signal_irq_false);
1231    }
1232
1233    std::cout << "  - IOPIC connected" << std::endl;
1234
1235
1236    // IOB0 cluster connexion to IOX network
1237    (*clusters[0][0]->p_vci_iob_iox_ini) (signal_vci_ini_iob0);
1238    (*clusters[0][0]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob0);
1239
1240    // IOB1 cluster connexion to IOX network
1241    // (only when there is more than 1 cluster)
1242    if ( cluster_iob0 != cluster_iob1 )
1243    {
1244        (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_ini) (signal_vci_ini_iob1);
1245        (*clusters[XMAX-1][YMAX-1]->p_vci_iob_iox_tgt) (signal_vci_tgt_iob1);
1246    }
1247
1248    // All clusters Clock & RESET connexions
1249    for ( size_t x = 0; x < (XMAX); x++ )
1250    {
1251        for (size_t y = 0; y < YMAX; y++)
1252        {
1253            clusters[x][y]->p_clk     (signal_clk);
1254            clusters[x][y]->p_resetn  (signal_resetn);
1255        }
1256    }
1257
1258   // Inter Clusters horizontal connections
1259   if (XMAX > 1)
1260   {
1261      for (size_t x = 0; x < (XMAX-1); x++)
1262      {
1263         for (size_t y = 0; y < YMAX; y++)
1264         {
1265            for (size_t k = 0; k < 3; k++)
1266            {
1267               clusters[x][y]->p_dspin_int_cmd_out[EAST][k]      (signal_dspin_int_cmd_h_inc[x][y][k]);
1268               clusters[x+1][y]->p_dspin_int_cmd_in[WEST][k]     (signal_dspin_int_cmd_h_inc[x][y][k]);
1269               clusters[x][y]->p_dspin_int_cmd_in[EAST][k]       (signal_dspin_int_cmd_h_dec[x][y][k]);
1270               clusters[x+1][y]->p_dspin_int_cmd_out[WEST][k]    (signal_dspin_int_cmd_h_dec[x][y][k]);
1271            }
1272
1273            for (size_t k = 0; k < 2; k++)
1274            {
1275               clusters[x][y]->p_dspin_int_rsp_out[EAST][k]      (signal_dspin_int_rsp_h_inc[x][y][k]);
1276               clusters[x+1][y]->p_dspin_int_rsp_in[WEST][k]     (signal_dspin_int_rsp_h_inc[x][y][k]);
1277               clusters[x][y]->p_dspin_int_rsp_in[EAST][k]       (signal_dspin_int_rsp_h_dec[x][y][k]);
1278               clusters[x+1][y]->p_dspin_int_rsp_out[WEST][k]    (signal_dspin_int_rsp_h_dec[x][y][k]);
1279            }
1280
1281            clusters[x][y]->p_dspin_ram_cmd_out[EAST]      (signal_dspin_ram_cmd_h_inc[x][y]);
1282            clusters[x+1][y]->p_dspin_ram_cmd_in[WEST]     (signal_dspin_ram_cmd_h_inc[x][y]);
1283            clusters[x][y]->p_dspin_ram_cmd_in[EAST]       (signal_dspin_ram_cmd_h_dec[x][y]);
1284            clusters[x+1][y]->p_dspin_ram_cmd_out[WEST]    (signal_dspin_ram_cmd_h_dec[x][y]);
1285            clusters[x][y]->p_dspin_ram_rsp_out[EAST]      (signal_dspin_ram_rsp_h_inc[x][y]);
1286            clusters[x+1][y]->p_dspin_ram_rsp_in[WEST]     (signal_dspin_ram_rsp_h_inc[x][y]);
1287            clusters[x][y]->p_dspin_ram_rsp_in[EAST]       (signal_dspin_ram_rsp_h_dec[x][y]);
1288            clusters[x+1][y]->p_dspin_ram_rsp_out[WEST]    (signal_dspin_ram_rsp_h_dec[x][y]);
1289         }
1290      }
1291   }
1292
1293   std::cout << std::endl << "Horizontal connections established" << std::endl;
1294
1295   // Inter Clusters vertical connections
1296   if (YMAX > 1)
1297   {
1298      for (size_t y = 0; y < (YMAX-1); y++)
1299      {
1300         for (size_t x = 0; x < XMAX; x++)
1301         {
1302            for (size_t k = 0; k < 3; k++)
1303            {
1304               clusters[x][y]->p_dspin_int_cmd_out[NORTH][k]     (signal_dspin_int_cmd_v_inc[x][y][k]);
1305               clusters[x][y+1]->p_dspin_int_cmd_in[SOUTH][k]    (signal_dspin_int_cmd_v_inc[x][y][k]);
1306               clusters[x][y]->p_dspin_int_cmd_in[NORTH][k]      (signal_dspin_int_cmd_v_dec[x][y][k]);
1307               clusters[x][y+1]->p_dspin_int_cmd_out[SOUTH][k]   (signal_dspin_int_cmd_v_dec[x][y][k]);
1308            }
1309
1310            for (size_t k = 0; k < 2; k++)
1311            {
1312               clusters[x][y]->p_dspin_int_rsp_out[NORTH][k]     (signal_dspin_int_rsp_v_inc[x][y][k]);
1313               clusters[x][y+1]->p_dspin_int_rsp_in[SOUTH][k]    (signal_dspin_int_rsp_v_inc[x][y][k]);
1314               clusters[x][y]->p_dspin_int_rsp_in[NORTH][k]      (signal_dspin_int_rsp_v_dec[x][y][k]);
1315               clusters[x][y+1]->p_dspin_int_rsp_out[SOUTH][k]   (signal_dspin_int_rsp_v_dec[x][y][k]);
1316            }
1317
1318            clusters[x][y]->p_dspin_ram_cmd_out[NORTH]     (signal_dspin_ram_cmd_v_inc[x][y]);
1319            clusters[x][y+1]->p_dspin_ram_cmd_in[SOUTH]    (signal_dspin_ram_cmd_v_inc[x][y]);
1320            clusters[x][y]->p_dspin_ram_cmd_in[NORTH]      (signal_dspin_ram_cmd_v_dec[x][y]);
1321            clusters[x][y+1]->p_dspin_ram_cmd_out[SOUTH]   (signal_dspin_ram_cmd_v_dec[x][y]);
1322            clusters[x][y]->p_dspin_ram_rsp_out[NORTH]     (signal_dspin_ram_rsp_v_inc[x][y]);
1323            clusters[x][y+1]->p_dspin_ram_rsp_in[SOUTH]    (signal_dspin_ram_rsp_v_inc[x][y]);
1324            clusters[x][y]->p_dspin_ram_rsp_in[NORTH]      (signal_dspin_ram_rsp_v_dec[x][y]);
1325            clusters[x][y+1]->p_dspin_ram_rsp_out[SOUTH]   (signal_dspin_ram_rsp_v_dec[x][y]);
1326         }
1327      }
1328   }
1329
1330   std::cout << "Vertical connections established" << std::endl;
1331
1332   // East & West boundary cluster connections
1333   for (size_t y = 0; y < YMAX; y++)
1334   {
1335      for (size_t k = 0; k < 3; k++)
1336      {
1337         clusters[0][y]->p_dspin_int_cmd_in[WEST][k]          (signal_dspin_false_int_cmd_in[0][y][WEST][k]);
1338         clusters[0][y]->p_dspin_int_cmd_out[WEST][k]         (signal_dspin_false_int_cmd_out[0][y][WEST][k]);
1339         clusters[XMAX-1][y]->p_dspin_int_cmd_in[EAST][k]     (signal_dspin_false_int_cmd_in[XMAX-1][y][EAST][k]);
1340         clusters[XMAX-1][y]->p_dspin_int_cmd_out[EAST][k]    (signal_dspin_false_int_cmd_out[XMAX-1][y][EAST][k]);
1341      }
1342
1343      for (size_t k = 0; k < 2; k++)
1344      {
1345         clusters[0][y]->p_dspin_int_rsp_in[WEST][k]          (signal_dspin_false_int_rsp_in[0][y][WEST][k]);
1346         clusters[0][y]->p_dspin_int_rsp_out[WEST][k]         (signal_dspin_false_int_rsp_out[0][y][WEST][k]);
1347         clusters[XMAX-1][y]->p_dspin_int_rsp_in[EAST][k]     (signal_dspin_false_int_rsp_in[XMAX-1][y][EAST][k]);
1348         clusters[XMAX-1][y]->p_dspin_int_rsp_out[EAST][k]    (signal_dspin_false_int_rsp_out[XMAX-1][y][EAST][k]);
1349      }
1350
1351     clusters[0][y]->p_dspin_ram_cmd_in[WEST]       (signal_dspin_false_ram_cmd_in[0][y][WEST]);
1352     clusters[0][y]->p_dspin_ram_cmd_out[WEST]      (signal_dspin_false_ram_cmd_out[0][y][WEST]);
1353     clusters[0][y]->p_dspin_ram_rsp_in[WEST]       (signal_dspin_false_ram_rsp_in[0][y][WEST]);
1354     clusters[0][y]->p_dspin_ram_rsp_out[WEST]      (signal_dspin_false_ram_rsp_out[0][y][WEST]);
1355
1356     clusters[XMAX-1][y]->p_dspin_ram_cmd_in[EAST]  (signal_dspin_false_ram_cmd_in[XMAX-1][y][EAST]);
1357     clusters[XMAX-1][y]->p_dspin_ram_cmd_out[EAST] (signal_dspin_false_ram_cmd_out[XMAX-1][y][EAST]);
1358     clusters[XMAX-1][y]->p_dspin_ram_rsp_in[EAST]  (signal_dspin_false_ram_rsp_in[XMAX-1][y][EAST]);
1359     clusters[XMAX-1][y]->p_dspin_ram_rsp_out[EAST] (signal_dspin_false_ram_rsp_out[XMAX-1][y][EAST]);
1360   }
1361
1362   std::cout << "East & West boundaries established" << std::endl;
1363
1364   // North & South boundary clusters connections
1365   for (size_t x = 0; x < XMAX; x++)
1366   {
1367      for (size_t k = 0; k < 3; k++)
1368      {
1369         clusters[x][0]->p_dspin_int_cmd_in[SOUTH][k]         (signal_dspin_false_int_cmd_in[x][0][SOUTH][k]);
1370         clusters[x][0]->p_dspin_int_cmd_out[SOUTH][k]        (signal_dspin_false_int_cmd_out[x][0][SOUTH][k]);
1371         clusters[x][YMAX-1]->p_dspin_int_cmd_in[NORTH][k]    (signal_dspin_false_int_cmd_in[x][YMAX-1][NORTH][k]);
1372         clusters[x][YMAX-1]->p_dspin_int_cmd_out[NORTH][k]   (signal_dspin_false_int_cmd_out[x][YMAX-1][NORTH][k]);
1373      }
1374
1375      for (size_t k = 0; k < 2; k++)
1376      {
1377         clusters[x][0]->p_dspin_int_rsp_in[SOUTH][k]         (signal_dspin_false_int_rsp_in[x][0][SOUTH][k]);
1378         clusters[x][0]->p_dspin_int_rsp_out[SOUTH][k]        (signal_dspin_false_int_rsp_out[x][0][SOUTH][k]);
1379         clusters[x][YMAX-1]->p_dspin_int_rsp_in[NORTH][k]    (signal_dspin_false_int_rsp_in[x][YMAX-1][NORTH][k]);
1380         clusters[x][YMAX-1]->p_dspin_int_rsp_out[NORTH][k]   (signal_dspin_false_int_rsp_out[x][YMAX-1][NORTH][k]);
1381      }
1382
1383      clusters[x][0]->p_dspin_ram_cmd_in[SOUTH]       (signal_dspin_false_ram_cmd_in[x][0][SOUTH]);
1384      clusters[x][0]->p_dspin_ram_cmd_out[SOUTH]      (signal_dspin_false_ram_cmd_out[x][0][SOUTH]);
1385      clusters[x][0]->p_dspin_ram_rsp_in[SOUTH]       (signal_dspin_false_ram_rsp_in[x][0][SOUTH]);
1386      clusters[x][0]->p_dspin_ram_rsp_out[SOUTH]      (signal_dspin_false_ram_rsp_out[x][0][SOUTH]);
1387
1388      clusters[x][YMAX-1]->p_dspin_ram_cmd_in[NORTH]  (signal_dspin_false_ram_cmd_in[x][YMAX-1][NORTH]);
1389      clusters[x][YMAX-1]->p_dspin_ram_cmd_out[NORTH] (signal_dspin_false_ram_cmd_out[x][YMAX-1][NORTH]);
1390      clusters[x][YMAX-1]->p_dspin_ram_rsp_in[NORTH]  (signal_dspin_false_ram_rsp_in[x][YMAX-1][NORTH]);
1391      clusters[x][YMAX-1]->p_dspin_ram_rsp_out[NORTH] (signal_dspin_false_ram_rsp_out[x][YMAX-1][NORTH]);
1392   }
1393
1394   std::cout << "North & South boundaries established" << std::endl << std::endl;
1395
1396   ////////////////////////////////////////////////////////
1397   //   Simulation
1398   ///////////////////////////////////////////////////////
1399
1400   sc_start(sc_core::sc_time(0, SC_NS));
1401
1402   signal_resetn = false;
1403   signal_irq_false = false;
1404
1405   // network boundaries signals
1406   for (size_t x = 0; x < XMAX ; x++)
1407   {
1408      for (size_t y = 0; y < YMAX ; y++)
1409      {
1410         for (size_t a = 0; a < 4; a++)
1411         {
1412            for (size_t k = 0; k < 3; k++)
1413            {
1414               signal_dspin_false_int_cmd_in[x][y][a][k].write = false;
1415               signal_dspin_false_int_cmd_in[x][y][a][k].read = true;
1416               signal_dspin_false_int_cmd_out[x][y][a][k].write = false;
1417               signal_dspin_false_int_cmd_out[x][y][a][k].read = true;
1418            }
1419
1420            for (size_t k = 0; k < 2; k++)
1421            {
1422               signal_dspin_false_int_rsp_in[x][y][a][k].write = false;
1423               signal_dspin_false_int_rsp_in[x][y][a][k].read = true;
1424               signal_dspin_false_int_rsp_out[x][y][a][k].write = false;
1425               signal_dspin_false_int_rsp_out[x][y][a][k].read = true;
1426            }
1427
1428            signal_dspin_false_ram_cmd_in[x][y][a].write = false;
1429            signal_dspin_false_ram_cmd_in[x][y][a].read = true;
1430            signal_dspin_false_ram_cmd_out[x][y][a].write = false;
1431            signal_dspin_false_ram_cmd_out[x][y][a].read = true;
1432
1433            signal_dspin_false_ram_rsp_in[x][y][a].write = false;
1434            signal_dspin_false_ram_rsp_in[x][y][a].read = true;
1435            signal_dspin_false_ram_rsp_out[x][y][a].write = false;
1436            signal_dspin_false_ram_rsp_out[x][y][a].read = true;
1437         }
1438      }
1439   }
1440
1441    sc_start(sc_core::sc_time(1, SC_NS));
1442    signal_resetn = true;
1443
1444
1445    // simulation loop
1446    struct timeval t1,t2;
1447    gettimeofday(&t1, NULL);
1448
1449
1450    for ( size_t n = 0; n < ncycles ; n += simul_period )
1451    {
1452        // stats display
1453        if( (n % 1000000) == 0)
1454        {
1455            gettimeofday(&t2, NULL);
1456
1457            uint64_t ms1 = (uint64_t) t1.tv_sec  * 1000ULL +
1458                           (uint64_t) t1.tv_usec / 1000;
1459            uint64_t ms2 = (uint64_t) t2.tv_sec  * 1000ULL +
1460                           (uint64_t) t2.tv_usec / 1000;
1461            std::cerr << "### cycle = " << std::dec << n
1462                      << " / frequency = "
1463                      << (double) 1000000 / (double) (ms2 - ms1) << "Khz"
1464                      << std::endl;
1465
1466            gettimeofday(&t1, NULL);
1467        }
1468
1469        // Monitor a specific address for one L1 cache
1470        // clusters[0][0]->proc[0]->cache_monitor(0x800080ULL);
1471
1472        // Monitor a specific address for one L2 cache
1473        // clusters[0][0]->memc->cache_monitor( 0x800080ULL, false );   // full line
1474
1475        // Monitor a specific address for one XRAM
1476        // clusters[0][0]->xram->start_monitor( 0x600800ULL , 64);
1477
1478        if ( debug_ok and (n > debug_from) )
1479        {
1480            std::cout << "****************** cycle " << std::dec << n ;
1481            std::cout << " ************************************************" << std::endl;
1482
1483            // trace proc[debug_proc_id]
1484            if ( debug_proc_id != 0xFFFFFFFF )
1485            {
1486                size_t l          = debug_proc_id & ((1<<P_WIDTH)-1) ;
1487                size_t cluster_xy = debug_proc_id >> P_WIDTH ;
1488                size_t x          = cluster_xy >> 4;
1489                size_t y          = cluster_xy & 0xF;
1490
1491                clusters[x][y]->proc[l]->print_trace(0x1);
1492                std::ostringstream proc_signame;
1493                proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
1494                clusters[x][y]->signal_int_vci_ini_proc[l].print_trace(proc_signame.str());
1495
1496                clusters[x][y]->xicu->print_trace(1);
1497                std::ostringstream xicu_signame;
1498                xicu_signame << "[SIG]XICU_" << x << "_" << y;
1499                clusters[x][y]->signal_int_vci_tgt_xicu.print_trace(xicu_signame.str());
1500
1501//              clusters[x][y]->mdma->print_trace();
1502//              std::ostringstream mdma_tgt_signame;
1503//              mdma_tgt_signame << "[SIG]MDMA_TGT_" << x << "_" << y;
1504//              clusters[x][y]->signal_int_vci_tgt_mdma.print_trace(mdma_tgt_signame.str());
1505//              std::ostringstream mdma_ini_signame;
1506//              mdma_ini_signame << "[SIG]MDMA_INI_" << x << "_" << y;
1507//              clusters[x][y]->signal_int_vci_ini_mdma.print_trace(mdma_ini_signame.str());
1508
1509                // local interrupts in cluster(x,y)
1510                if( clusters[x][y]->signal_irq_memc.read() )
1511                std::cout << "### IRQ_MMC_" << std::dec << x << "_" << y
1512                          << " ACTIVE" << std::endl;
1513
1514                for ( size_t c = 0 ; c < NB_DMA_CHANNELS ; c++ )
1515                {
1516                    if( clusters[x][y]->signal_irq_mdma[c].read() )
1517                    std::cout << "### IRQ_DMA_" << std::dec << x << "_" << y << "_" << c
1518                              << " ACTIVE" << std::endl;
1519                }
1520
1521                for ( size_t c = 0 ; c < NB_PROCS_MAX ; c++ )
1522                {
1523                    if( clusters[x][y]->signal_proc_it[c].read() )
1524                    std::cout << "### IRQ_PROC_" << std::dec << x << "_" << y << "_" << c
1525                              << " ACTIVE" << std::endl;
1526                }
1527            }
1528
1529            // trace memc[debug_memc_id]
1530            if ( debug_memc_id != 0xFFFFFFFF )
1531            {
1532                size_t x = debug_memc_id >> 4;
1533                size_t y = debug_memc_id & 0xF;
1534
1535                clusters[x][y]->memc->print_trace(0);
1536                std::ostringstream smemc_tgt;
1537                smemc_tgt << "[SIG]MEMC_TGT_" << x << "_" << y;
1538                clusters[x][y]->signal_int_vci_tgt_memc.print_trace(smemc_tgt.str());
1539                std::ostringstream smemc_ini;
1540                smemc_ini << "[SIG]MEMC_INI_" << x << "_" << y;
1541                clusters[x][y]->signal_ram_vci_ini_memc.print_trace(smemc_ini.str());
1542
1543                clusters[x][y]->xram->print_trace();
1544                std::ostringstream sxram_tgt;
1545                sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y;
1546                clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str());
1547            }
1548
1549
1550            // trace XRAM and XRAM network routers in cluster[debug_xram_id]
1551            if ( debug_xram_id != 0xFFFFFFFF )
1552            {
1553                size_t x = debug_xram_id >> 4;
1554                size_t y = debug_xram_id & 0xF;
1555
1556                clusters[x][y]->xram->print_trace();
1557                std::ostringstream sxram_tgt;
1558                sxram_tgt << "[SIG]XRAM_TGT_" << x << "_" << y;
1559                clusters[x][y]->signal_ram_vci_tgt_xram.print_trace(sxram_tgt.str());
1560
1561                clusters[x][y]->ram_router_cmd->print_trace();
1562                clusters[x][y]->ram_router_rsp->print_trace();
1563            }
1564
1565            // trace iob, iox and external peripherals
1566            if ( debug_iob )
1567            {
1568//              clusters[0][0]->iob->print_trace();
1569//              clusters[0][0]->signal_int_vci_tgt_iobx.print_trace( "[SIG]IOB0_INT_TGT");
1570//              clusters[0][0]->signal_int_vci_ini_iobx.print_trace( "[SIG]IOB0_INT_INI");
1571//              clusters[0][0]->signal_ram_vci_ini_iobx.print_trace( "[SIG]IOB0_RAM_INI");
1572//              signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI");
1573//              signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT");
1574
1575                cdma->print_trace();
1576                signal_vci_tgt_cdma.print_trace("[SIG]CDMA_TGT");
1577                signal_vci_ini_cdma.print_trace("[SIG]CDMA_INI");
1578
1579//              brom->print_trace();
1580//              signal_vci_tgt_brom.print_trace("[SIG]BROM_TGT");
1581
1582//              mtty->print_trace();
1583//              signal_vci_tgt_mtty.print_trace("[SIG]MTTY_TGT");
1584
1585//              disk->print_trace();
1586//              signal_vci_tgt_disk.print_trace("[SIG]DISK_TGT");
1587//              signal_vci_ini_disk.print_trace("[SIG]DISK_INI");
1588
1589                mnic->print_trace( 0x000 );
1590                signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
1591
1592//              fbuf->print_trace();
1593//              signal_vci_tgt_fbuf.print_trace("[SIG]FBUF_TGT");
1594
1595//              iopi->print_trace();
1596//              signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI");
1597//              signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT");
1598
1599//              iox_network->print_trace();
1600
1601                // interrupts
1602                if (signal_irq_disk)       std::cout << "### IRQ_DISK ACTIVE"       << std::endl;
1603                if (signal_irq_mtty_rx[0]) std::cout << "### IRQ_MTTY_RX[0] ACTIVE" << std::endl;
1604                if (signal_irq_mnic_rx[0]) std::cout << "### IRQ_MNIC_RX[0] ACTIVE" << std::endl;
1605                if (signal_irq_mnic_rx[1]) std::cout << "### IRQ_MNIC_RX[1] ACTIVE" << std::endl;
1606                if (signal_irq_mnic_tx[0]) std::cout << "### IRQ_MNIC_TX[0] ACTIVE" << std::endl;
1607                if (signal_irq_mnic_tx[1]) std::cout << "### IRQ_MNIC_TX[1] ACTIVE" << std::endl;
1608            }
1609        }
1610
1611        sc_start(sc_core::sc_time(simul_period, SC_NS));
1612    }
1613    return EXIT_SUCCESS;
1614}
1615
1616int sc_main (int argc, char *argv[])
1617{
1618   try {
1619      return _main(argc, argv);
1620   } catch (std::exception &e) {
1621      std::cout << e.what() << std::endl;
1622   } catch (...) {
1623      std::cout << "Unknown exception occured" << std::endl;
1624      throw;
1625   }
1626   return 1;
1627}
1628
1629
1630// Local Variables:
1631// tab-width: 3
1632// c-basic-offset: 3
1633// c-file-offsets:((innamespace . 0)(inline-open . 0))
1634// indent-tabs-mode: nil
1635// End:
1636
1637// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
1638
1639
1640
Note: See TracBrowser for help on using the repository browser.