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

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

Modify the tsar_generic_iob platform:
The vci_multi_dma component replicated in all cluster is replaced by a vci_mwmr_dma component.
This new component supports all hardware coprocessors respection the "coproc" interface.
Amongst the available coprocessors (defined in the SocLib? "coprocessor_components" directory)
the MWR_CPY coprocessor provide an improved memory copy service throughput x 2).

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