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

Last change on this file since 468 was 468, checked in by cfuguet, 11 years ago


Merging vci_mem_cache from branches/v5 to trunk [441-467]

=-----------------------------------------------------------------------
r441 | cfuguet | 2013-07-17 10:54:07 +0200 (Wed, 17 Jul 2013) | 14 lines

Modifications in branches/v5/vci_mem_cache:

  • Changing name of CC DSPIN ports: + p_dspin_in => p_dspin_p2m + p_dspin_out => p_dspin_m2p
  • Splitting the Update Table in two tables: + UPT (Update Table): Stores the MULTI-UPDATE transactions + IVT (Invalidate Table): Stores the MULTI/BROADCAST INVALIDATE

transactions

Each table has its own allocator FSM: r_alloc_upt and r_alloc_ivt

=-----------------------------------------------------------------------
r442 | cfuguet | 2013-07-17 12:13:51 +0200 (Wed, 17 Jul 2013) | 13 lines

Modifications in branches/v5/modules/vci_mem_cache:

  • Introducing third port for the CLACK network.
  • CLEANUP FSM is no more a CC_SEND FSM client.
  • CLEANUP FSM controls directly the p_dspin_clack port

=-----------------------------------------------------------------------
r445 | cfuguet | 2013-07-18 10:49:36 +0200 (Thu, 18 Jul 2013) | 7 lines

Bugfix in vci_mem_cache:

  • Adding missing "strings" for print_trace() function
  • Adding alloc_ivt fsm (Invalidate Table) in the

print_trace() function

=-----------------------------------------------------------------------
r455 | cfuguet | 2013-07-19 10:16:17 +0200 (Fri, 19 Jul 2013) | 8 lines

Merged

/trunk/modules/vci_mem_cache:449 with
/branches/v5/modules/vci_mem_cache:446.

This merge introduces into the branch the last modifications concerning
the VCI memory cache configuration interface


Merging vci_cc_vcache_wrapper from branches/v5 to trunk [444-467]

=-----------------------------------------------------------------------
r444 | cfuguet | 2013-07-17 14:46:46 +0200 (Wed, 17 Jul 2013) | 7 lines

Modifications in branches/v5/modules/vci_cc_vcache_wrapper:

  • Renaming FROM_MC DSPIN flits fields in M2P
  • Renaming FROM_L1 DSPIN flits fields in P2M
  • Renaming CLEANUP_ACK DSPIN flits fields in CLACK

=-----------------------------------------------------------------------
r446 | cfuguet | 2013-07-18 11:37:47 +0200 (Thu, 18 Jul 2013) | 13 lines

Modifications in vci_cc_vcache_wrapper:

  • Merging the states DCACHE/ICACHE_CC_BROADCAST and DCACHE/ICACHE_CC_INVAL. This is because, the BROADCAST INVALIDATE and the MULTICAST INVALIDATE are both acknowledged by a CLEANUP.
  • Adding third port for the clack coherence network.
  • Renaming the port dspin_in to dspin_m2p and the port dspin_out to dspin_p2m

=-----------------------------------------------------------------------
r454 | haoliu | 2013-07-19 10:15:13 +0200 (Fri, 19 Jul 2013) | 2 lines

modified CC_RECEIVE FSM and CC_CHECK FSM (icache and dcache) for new
version V5

=-----------------------------------------------------------------------
r461 | cfuguet | 2013-07-19 15:49:43 +0200 (Fri, 19 Jul 2013) | 9 lines

Bugfix in vci_cc_vcache_wrapper:

  • In the states DCACHE/ICACHE CC_UPDT the FSM returns to the state CC_CHECK only when the cc_send_req is occupied.

We must not return to the CC_CHECK state if not ROK of the
DATA FIFO because the counter word counter will be reset.

=-----------------------------------------------------------------------
r462 | cfuguet | 2013-07-19 16:26:26 +0200 (Fri, 19 Jul 2013) | 8 lines

Modification in vci_cc_vcache_wrapper:

  • Optimization in DCACHE/ICACHE CC_CHECK state. We can handle a CLACK and a CC request if the latter does a MISS match. This is because the CC request doing MISS match does not need to access the directory

=-----------------------------------------------------------------------
r463 | cfuguet | 2013-07-19 16:52:06 +0200 (Fri, 19 Jul 2013) | 12 lines

Modification in vci_cc_vcache_wrapper:

  • Optimization in DCACHE/ICACHE CC_CHECK state. If pending request to CC_SEND, we wait in the CC_CHECK state. Doing this, during the wait, we can handle incoming CLACK avoiding any deadlock situation.

The states CC_UPDT and CC_INVAL do not need to test anymore if
there is a pending request to CC_SEND.


Merging tsar_generic_xbar from branches/v5 to trunk [447-467]

=-----------------------------------------------------------------------
r447 | cfuguet | 2013-07-18 16:12:05 +0200 (Thu, 18 Jul 2013) | 8 lines

Adding tsar_generic_xbar platform in branches/v5/platforms:

  • This platform contains a third local crossbar interconnect for the CLACK network.
  • It works only in a monocluster topology

=-----------------------------------------------------------------------
r448 | cfuguet | 2013-07-18 17:51:18 +0200 (Thu, 18 Jul 2013) | 9 lines

Modification in branches/v5/platforms/tsar_generic_xbar:

  • Adding a DSPIN router to the platform to allow the inter-cluster communication for the CLACK commands.

With this modification, the tsar_generic_xbar platform can be used
for multi-cluster simulations

=-----------------------------------------------------------------------
r466 | cfuguet | 2013-07-23 17:01:49 +0200 (Tue, 23 Jul 2013) | 9 lines

Modifications in branches/v5 vci_mem_cache:

  • Replacing the third router CLACK by a third virtual channel in the new virtual_dspin_router supporting several virtual channels.

The third channel has been added in the COMMAND router.

=-----------------------------------------------------------------------
r467 | cfuguet | 2013-07-23 17:23:13 +0200 (Tue, 23 Jul 2013) | 5 lines

Modifications in branches/v5 tsar_generic_xbar:

  • Adding preprocessor conditional statements for ALMOS support


Merging dspin_dhccp_param from branches/v5 to trunk [377-467]

=-----------------------------------------------------------------------
r442 | cfuguet | 2013-07-17 12:13:51 +0200 (Wed, 17 Jul 2013) | 13 lines

Modifications in branches/v5/communication/dspin_dhccp_param:

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