source: trunk/platforms/tsar_generic_xbar/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: 35.3 KB
Line 
1/////////////////////////////////////////////////////////////////////////
2// File: top.cpp
3// Author: Alain Greiner
4// Copyright: UPMC/LIP6
5// Date : may 2013
6// This program is released under the GNU public license
7/////////////////////////////////////////////////////////////////////////
8// This file define a generic TSAR architecture.
9// The physical address space is 40 bits.
10//
11// The number of clusters cannot be larger than 256.
12// The number of processors per cluster cannot be larger than 8.
13//
14// - It uses four dspin_local_crossbar per cluster as local interconnect
15// - It uses two virtual_dspin routers per cluster as global interconnect
16// - It uses the vci_cc_vcache_wrapper
17// - It uses the vci_mem_cache
18// - It contains one vci_xicu per cluster.
19// - It contains one vci_multi_dma per cluster.
20// - It contains one vci_simple_ram per cluster to model the L3 cache.
21//
22// The communication between the MemCache and the Xram is 64 bits.
23//
24// All clusters are identical, but the cluster 0 (called io_cluster),
25// contains 5 extra components:
26// - the boot rom (BROM)
27// - the disk controller (BDEV)
28// - the multi-channel network controller (MNIC)
29// - the multi-channel tty controller (MTTY)
30// - the frame buffer controller (FBUF)
31//
32// It is build with one single component implementing a cluster,
33// defined in files tsar_xbar_cluster.* (with * = cpp, h, sd)
34//
35// The IRQs are connected to XICUs as follow:
36// - The IRQ_IN[0] to IRQ_IN[7] ports are not used in all clusters.
37// - The DMA IRQs are connected to IRQ_IN[8] to IRQ_IN[15] in all clusters.
38// - The TTY IRQs are connected to IRQ_IN[16] to IRQ_IN[30] in I/O cluster.
39// - The BDEV IRQ is connected to IRQ_IN[31] in I/O cluster.
40//
41// Some hardware parameters are used when compiling the OS, and are used
42// by this top.cpp file. They must be defined in the hard_config.h file :
43// - CLUSTER_X        : number of clusters in a row (power of 2)
44// - CLUSTER_Y        : number of clusters in a column (power of 2)
45// - CLUSTER_SIZE     : size of the segment allocated to a cluster
46// - NB_PROCS_MAX     : number of processors per cluster (power of 2)
47// - NB_DMA_CHANNELS  : number of DMA channels per cluster (< 9)
48// - NB_TTY_CHANNELS  : number of TTY channels in I/O cluster (< 16)
49// - NB_NIC_CHANNELS  : number of NIC channels in I/O cluster (< 9)
50//
51// Some other hardware parameters are not used when compiling the OS,
52// and can be directly defined in this top.cpp file:
53// - XRAM_LATENCY     : external ram latency
54// - MEMC_WAYS        : L2 cache number of ways
55// - MEMC_SETS        : L2 cache number of sets
56// - L1_IWAYS     
57// - L1_ISETS   
58// - L1_DWAYS   
59// - L1_DSETS 
60// - FBUF_X_SIZE      : width of frame buffer (pixels)
61// - FBUF_Y_SIZE      : heigth of frame buffer (lines)
62// - BDEV_SECTOR_SIZE : block size for block drvice
63// - BDEV_IMAGE_NAME  : file pathname for block device
64// - NIC_RX_NAME      : file pathname for NIC received packets
65// - NIC_TX_NAME      : file pathname for NIC transmited packets
66// - NIC_TIMEOUT      : max number of cycles before closing a container
67/////////////////////////////////////////////////////////////////////////
68// General policy for 40 bits physical address decoding:
69// All physical segments base addresses are multiple of 1 Mbytes
70// (=> the 24 LSB bits = 0, and the 16 MSB bits define the target)
71// The (x_width + y_width) MSB bits (left aligned) define
72// the cluster index, and the LADR bits define the local index:
73//      | X_ID  | Y_ID  |---| LADR |     OFFSET          |
74//      |x_width|y_width|---|  8   |       24            |
75/////////////////////////////////////////////////////////////////////////
76// General policy for 14 bits SRCID decoding:
77// Each component is identified by (x_id, y_id, l_id) tuple.
78//      | X_ID  | Y_ID  |---| L_ID |
79//      |x_width|y_width|---|  6   |
80/////////////////////////////////////////////////////////////////////////
81
82#include <systemc>
83#include <sys/time.h>
84#include <iostream>
85#include <sstream>
86#include <cstdlib>
87#include <cstdarg>
88#include <stdint.h>
89
90#include "gdbserver.h"
91#include "mapping_table.h"
92#include "tsar_xbar_cluster.h"
93#include "alloc_elems.h"
94
95///////////////////////////////////////////////////
96//      OS
97///////////////////////////////////////////////////
98
99//#define USE_ALMOS
100#define USE_GIET
101
102#ifdef USE_ALMOS
103#ifdef USE_GIET
104#error "Can't use Two different OS"
105#endif
106#endif
107
108#ifndef USE_ALMOS
109#ifndef USE_GIET
110#error "You need to specify one OS"
111#endif
112#endif
113
114///////////////////////////////////////////////////
115//               Parallelisation
116///////////////////////////////////////////////////
117#define USE_OPENMP               0
118
119#if USE_OPENMP
120#include <omp.h>
121#endif
122
123//  cluster index (computed from x,y coordinates)
124#define cluster(x,y)   (y + YMAX*x)
125
126///////////////////////////////////////////////////////////
127//          DSPIN parameters           
128///////////////////////////////////////////////////////////
129
130#define dspin_cmd_width      39
131#define dspin_rsp_width      32
132
133///////////////////////////////////////////////////////////
134//          VCI parameters           
135///////////////////////////////////////////////////////////
136
137#define vci_cell_width_int    4
138#define vci_cell_width_ext    8
139
140#define vci_plen_width        8
141#define vci_address_width     40
142#define vci_rerror_width      1
143#define vci_clen_width        1
144#define vci_rflag_width       1
145#define vci_srcid_width       14
146#define vci_pktid_width       4
147#define vci_trdid_width       4
148#define vci_wrplen_width      1
149////////////////////////////////////////////////////////////
150//    Main Hardware Parameters values         
151//////////////////////i/////////////////////////////////////
152
153#ifdef USE_ALMOS
154#include "almos/hard_config.h"
155#define PREFIX_OS "almos/"
156#endif
157#ifdef USE_GIET
158#include "giet_vm/hard_config.h"
159#define PREFIX_OS "giet_vm/"
160#endif
161
162////////////////////////////////////////////////////////////
163//    Secondary Hardware Parameters         
164//////////////////////i/////////////////////////////////////
165
166#define XMAX                  CLUSTER_X
167#define YMAX                  CLUSTER_Y
168
169#define XRAM_LATENCY          0
170
171#define MEMC_WAYS             16
172#define MEMC_SETS             256
173
174#define L1_IWAYS              4
175#define L1_ISETS              64
176
177#define L1_DWAYS              4
178#define L1_DSETS              64
179
180#ifdef USE_ALMOS
181#define FBUF_X_SIZE           512
182#define FBUF_Y_SIZE           512
183#endif
184#ifdef USE_GIET
185#define FBUF_X_SIZE           128
186#define FBUF_Y_SIZE           128
187#endif
188
189#ifdef USE_GIET
190#define BDEV_SECTOR_SIZE      512
191#define BDEV_IMAGE_NAME       PREFIX_OS"display/images.raw"
192#endif
193#ifdef USE_ALMOS
194#define BDEV_SECTOR_SIZE      4096
195#define BDEV_IMAGE_NAME       PREFIX_OS"hdd-img.bin"
196#endif
197
198#define NIC_RX_NAME           PREFIX_OS"nic/rx_packets.txt"
199#define NIC_TX_NAME           PREFIX_OS"nic/tx_packets.txt"
200#define NIC_TIMEOUT           10000
201
202#define NORTH                 0
203#define SOUTH                 1
204#define EAST                  2
205#define WEST                  3
206
207////////////////////////////////////////////////////////////
208//    Software to be loaded in ROM & RAM         
209//////////////////////i/////////////////////////////////////
210
211#ifdef USE_ALMOS
212#define soft_name       PREFIX_OS"bootloader.bin",\
213                        PREFIX_OS"kernel-soclib.bin@0xbfc10000:D",\
214                        PREFIX_OS"arch-info.bib@0xBFC08000:D"
215#endif
216#ifdef USE_GIET
217#define soft_pathname   PREFIX_OS"soft.elf"
218#endif
219
220////////////////////////////////////////////////////////////
221//     DEBUG Parameters default values         
222//////////////////////i/////////////////////////////////////
223
224#define MAX_FROZEN_CYCLES     10000
225
226/////////////////////////////////////////////////////////
227//    Physical segments definition
228/////////////////////////////////////////////////////////
229// There is 3 segments replicated in all clusters
230// and 5 specific segments in the "IO" cluster
231// (containing address 0xBF000000)
232/////////////////////////////////////////////////////////
233
234// specific segments in "IO" cluster : absolute physical address
235
236#define BROM_BASE       0x00BFC00000     
237#define BROM_SIZE       0x0000100000   // 1 Mbytes
238
239#define FBUF_BASE       0x00B2000000     
240#define FBUF_SIZE       FBUF_X_SIZE * FBUF_Y_SIZE * 2
241
242#define BDEV_BASE       0x00B3000000     
243#define BDEV_SIZE       0x0000001000   // 4 Kbytes
244
245#define MTTY_BASE       0x00B4000000     
246#define MTTY_SIZE       0x0000001000   // 4 Kbytes
247
248#define MNIC_BASE       0x00B5000000     
249#define MNIC_SIZE       0x0000080000   // 512 Kbytes (for 8 channels)
250
251// replicated segments : address is incremented by a cluster offset
252//     offset  = cluster(x,y) << (address_width-x_width-y_width);
253
254#define MEMC_BASE       0x0000000000     
255#define MEMC_SIZE       0x0010000000   // 256 Mbytes per cluster
256
257#define XICU_BASE       0x00B0000000     
258#define XICU_SIZE       0x0000001000   // 4 Kbytes
259
260#define MDMA_BASE       0x00B1000000     
261#define MDMA_SIZE       0x0000001000 * NB_DMA_CHANNELS  // 4 Kbytes per channel 
262
263////////////////////////////////////////////////////////////////////
264//     TGTID definition in direct space
265// For all components:  global TGTID = global SRCID = cluster_index
266////////////////////////////////////////////////////////////////////
267
268#define MEMC_TGTID      0
269#define XICU_TGTID      1
270#define MDMA_TGTID      2
271#define MTTY_TGTID      3
272#define FBUF_TGTID      4
273#define BDEV_TGTID      5
274#define MNIC_TGTID      6
275#define BROM_TGTID      7
276
277/////////////////////////////////
278int _main(int argc, char *argv[])
279{
280   using namespace sc_core;
281   using namespace soclib::caba;
282   using namespace soclib::common;
283
284#ifdef USE_GIET
285   char     soft_name[256]   = soft_pathname;      // pathname to binary code
286#endif
287   uint64_t ncycles          = 100000000000;       // simulated cycles
288   char     disk_name[256]   = BDEV_IMAGE_NAME;    // pathname to the disk image
289   char     nic_rx_name[256] = NIC_RX_NAME;        // pathname to the rx packets file
290   char     nic_tx_name[256] = NIC_TX_NAME;        // pathname to the tx packets file
291   ssize_t  threads_nr       = 1;                  // simulator's threads number
292   bool     debug_ok         = false;              // trace activated
293   size_t   debug_period     = 1;                  // trace period
294   size_t   debug_memc_id    = 0;                  // index of memc to be traced
295   size_t   debug_proc_id    = 0;                  // index of proc to be traced
296   uint32_t debug_from       = 0;                  // trace start cycle
297   uint32_t frozen_cycles    = MAX_FROZEN_CYCLES;  // monitoring frozen processor
298   size_t   cluster_io_id    = 0;                  // index of cluster containing IOs
299   struct   timeval t1,t2;
300   uint64_t ms1,ms2;
301
302   ////////////// command line arguments //////////////////////
303   if (argc > 1)
304   {
305      for (int n = 1; n < argc; n = n + 2)
306      {
307         if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc))
308         {
309            ncycles = atoi(argv[n+1]);
310         }
311         else if ((strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
312         {
313#ifdef USE_ALMOS
314            assert( 0 && "Can't define almos soft name" );
315#endif
316#ifdef USE_GIET
317            strcpy(soft_name, argv[n+1]);
318#endif
319         }
320         else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
321         {
322            strcpy(disk_name, argv[n+1]);
323         }
324         else if ((strcmp(argv[n],"-DEBUG") == 0) && (n+1<argc) )
325         {
326            debug_ok = true;
327            debug_from = atoi(argv[n+1]);
328         }
329         else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) )
330         {
331            debug_memc_id = atoi(argv[n+1]);
332            assert( (debug_memc_id < (XMAX*YMAX) ) && 
333                   "debug_memc_id larger than XMAX * YMAX" );
334         }
335         else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) )
336         {
337            debug_proc_id = atoi(argv[n+1]);
338            assert( (debug_proc_id < (XMAX * YMAX * NB_PROCS_MAX) ) && 
339                   "debug_proc_id larger than XMAX * YMAX * NB_PROCS" );
340         }
341         else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc))
342         {
343            threads_nr = atoi(argv[n+1]);
344            threads_nr = (threads_nr < 1) ? 1 : threads_nr;
345         }
346         else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc))
347         {
348            frozen_cycles = atoi(argv[n+1]);
349         }
350         else if ((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc))
351         {
352            debug_period = atoi(argv[n+1]);
353         }
354         else
355         {
356            std::cout << "   Arguments are (key,value) couples." << std::endl;
357            std::cout << "   The order is not important." << std::endl;
358            std::cout << "   Accepted arguments are :" << std::endl << std::endl;
359            std::cout << "     -SOFT pathname_for_embedded_soft" << std::endl;
360            std::cout << "     -DISK pathname_for_disk_image" << std::endl;
361            std::cout << "     -NCYCLES number_of_simulated_cycles" << std::endl;
362            std::cout << "     -DEBUG debug_start_cycle" << std::endl;
363            std::cout << "     -THREADS simulator's threads number" << std::endl;
364            std::cout << "     -FROZEN max_number_of_lines" << std::endl;
365            std::cout << "     -PERIOD number_of_cycles between trace" << std::endl;
366            std::cout << "     -MEMCID index_memc_to_be_traced" << std::endl;
367            std::cout << "     -PROCID index_proc_to_be_traced" << std::endl;
368            exit(0);
369         }
370      }
371   }
372
373    // checking hardware parameters
374    assert( ( (XMAX == 1) or (XMAX == 2) or (XMAX == 4) or
375              (XMAX == 8) or (XMAX == 16) ) and
376              "The XMAX parameter must be 1, 2, 4, 8 or 16" );
377
378    assert( ( (YMAX == 1) or (YMAX == 2) or (YMAX == 4) or
379              (YMAX == 8) or (YMAX == 16) ) and
380              "The YMAX parameter must be 1, 2, 4, 8 or 16" );
381
382    assert( ( (NB_PROCS_MAX == 1) or (NB_PROCS_MAX == 2) or
383              (NB_PROCS_MAX == 4) or (NB_PROCS_MAX == 8) ) and
384             "The NB_PROCS_MAX parameter must be 1, 2, 4 or 8" );
385
386    assert( (NB_DMA_CHANNELS < 9) and
387            "The NB_DMA_CHANNELS parameter must be smaller than 9" );
388
389    assert( (NB_TTY_CHANNELS < 15) and
390            "The NB_TTY_CHANNELS parameter must be smaller than 15" );
391
392    assert( (NB_NIC_CHANNELS < 9) and
393            "The NB_NIC_CHANNELS parameter must be smaller than 9" );
394
395#ifdef USE_GIET
396    assert( (vci_address_width == 40) and
397            "VCI address width must be 40 bits" );
398#endif
399
400    std::cout << std::endl;
401    std::cout << " - XMAX             = " << XMAX << std::endl;
402    std::cout << " - YMAX             = " << YMAX << std::endl;
403    std::cout << " - NB_PROCS_MAX     = " << NB_PROCS_MAX <<  std::endl;
404    std::cout << " - NB_DMA_CHANNELS  = " << NB_DMA_CHANNELS <<  std::endl;
405    std::cout << " - NB_TTY_CHANNELS  = " << NB_TTY_CHANNELS <<  std::endl;
406    std::cout << " - NB_NIC_CHANNELS  = " << NB_NIC_CHANNELS <<  std::endl;
407    std::cout << " - MEMC_WAYS        = " << MEMC_WAYS << std::endl;
408    std::cout << " - MEMC_SETS        = " << MEMC_SETS << std::endl;
409    std::cout << " - RAM_LATENCY      = " << XRAM_LATENCY << std::endl;
410    std::cout << " - MAX_FROZEN       = " << frozen_cycles << std::endl;
411
412    std::cout << std::endl;
413    // Internal and External VCI parameters definition
414    typedef soclib::caba::VciParams<vci_cell_width_int,
415                                    vci_plen_width,
416                                    vci_address_width,
417                                    vci_rerror_width,
418                                    vci_clen_width,
419                                    vci_rflag_width,
420                                    vci_srcid_width,
421                                    vci_pktid_width,
422                                    vci_trdid_width,
423                                    vci_wrplen_width> vci_param_int;
424
425    typedef soclib::caba::VciParams<vci_cell_width_ext,
426                                    vci_plen_width,
427                                    vci_address_width,
428                                    vci_rerror_width,
429                                    vci_clen_width,
430                                    vci_rflag_width,
431                                    vci_srcid_width,
432                                    vci_pktid_width,
433                                    vci_trdid_width,
434                                    vci_wrplen_width> vci_param_ext;
435
436#if USE_OPENMP
437   omp_set_dynamic(false);
438   omp_set_num_threads(threads_nr);
439   std::cerr << "Built with openmp version " << _OPENMP << std::endl;
440#endif
441
442   // Define parameters depending on mesh size
443   size_t   x_width;
444   size_t   y_width;
445
446   if      (XMAX == 1) x_width = 0;
447   else if (XMAX == 2) x_width = 1;
448   else if (XMAX <= 4) x_width = 2;
449   else if (XMAX <= 8) x_width = 3;
450   else                     x_width = 4;
451
452   if      (YMAX == 1) y_width = 0;
453   else if (YMAX == 2) y_width = 1;
454   else if (YMAX <= 4) y_width = 2;
455   else if (YMAX <= 8) y_width = 3;
456   else                     y_width = 4;
457
458   /////////////////////
459   //  Mapping Tables
460   /////////////////////
461
462   // internal network
463   MappingTable maptabd(vci_address_width, 
464                        IntTab(x_width + y_width, 16 - x_width - y_width), 
465                        IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), 
466                        0x00FF000000);
467
468   for (size_t x = 0; x < XMAX; x++)
469   {
470      for (size_t y = 0; y < YMAX; y++)
471      {
472         sc_uint<vci_address_width> offset;
473         offset = (sc_uint<vci_address_width>)cluster(x,y) 
474                   << (vci_address_width-x_width-y_width);
475
476         std::ostringstream    sh;
477         sh << "seg_memc_" << x << "_" << y;
478         maptabd.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, 
479                             IntTab(cluster(x,y),MEMC_TGTID), true));
480
481         std::ostringstream    si;
482         si << "seg_xicu_" << x << "_" << y;
483         maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, 
484                             IntTab(cluster(x,y),XICU_TGTID), false));
485
486         std::ostringstream    sd;
487         sd << "seg_mdma_" << x << "_" << y;
488         maptabd.add(Segment(sd.str(), MDMA_BASE+offset, MDMA_SIZE, 
489                             IntTab(cluster(x,y),MDMA_TGTID), false));
490
491         if ( cluster(x,y) == cluster_io_id )
492         {
493            maptabd.add(Segment("seg_mtty", MTTY_BASE, MTTY_SIZE, 
494                        IntTab(cluster(x,y),MTTY_TGTID), false));
495            maptabd.add(Segment("seg_fbuf", FBUF_BASE, FBUF_SIZE, 
496                        IntTab(cluster(x,y),FBUF_TGTID), false));
497            maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, 
498                        IntTab(cluster(x,y),BDEV_TGTID), false));
499            maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, 
500                        IntTab(cluster(x,y),MNIC_TGTID), false));
501            maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, 
502                        IntTab(cluster(x,y),BROM_TGTID), true));
503         }
504      }
505   }
506   std::cout << maptabd << std::endl;
507
508   // external network
509   MappingTable maptabx(vci_address_width, 
510                        IntTab(x_width+y_width), 
511                        IntTab(x_width+y_width), 
512                        0xFFFF000000ULL);
513
514   for (size_t x = 0; x < XMAX; x++)
515   {
516      for (size_t y = 0; y < YMAX ; y++)
517      { 
518
519         sc_uint<vci_address_width> offset;
520         offset = (sc_uint<vci_address_width>)cluster(x,y) 
521                   << (vci_address_width-x_width-y_width);
522
523         std::ostringstream sh;
524         sh << "x_seg_memc_" << x << "_" << y;
525
526         maptabx.add(Segment(sh.str(), MEMC_BASE+offset, 
527                     MEMC_SIZE, IntTab(cluster(x,y)), false));
528      }
529   }
530   std::cout << maptabx << std::endl;
531
532   ////////////////////
533   // Signals
534   ///////////////////
535
536   sc_clock           signal_clk("clk");
537   sc_signal<bool>    signal_resetn("resetn");
538
539   // Horizontal inter-clusters DSPIN signals
540   DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_inc =
541      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_inc", XMAX-1, YMAX, 3);
542   DspinSignals<dspin_cmd_width>*** signal_dspin_h_cmd_dec =
543      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_h_cmd_dec", XMAX-1, YMAX, 3);
544   DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_inc =
545      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_inc", XMAX-1, YMAX, 2);
546   DspinSignals<dspin_rsp_width>*** signal_dspin_h_rsp_dec =
547      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_h_rsp_dec", XMAX-1, YMAX, 2);
548
549   // Vertical inter-clusters DSPIN signals
550   DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_inc =
551      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_inc", XMAX, YMAX-1, 3);
552   DspinSignals<dspin_cmd_width>*** signal_dspin_v_cmd_dec =
553      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_v_cmd_dec", XMAX, YMAX-1, 3);
554   DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_inc =
555      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_inc", XMAX, YMAX-1, 2);
556   DspinSignals<dspin_rsp_width>*** signal_dspin_v_rsp_dec =
557      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_v_rsp_dec", XMAX, YMAX-1, 2);
558
559   // Mesh boundaries DSPIN signals
560   DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_in =
561      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_in" , XMAX, YMAX, 4, 3);
562   DspinSignals<dspin_cmd_width>**** signal_dspin_false_cmd_out =
563      alloc_elems<DspinSignals<dspin_cmd_width> >("signal_dspin_false_cmd_out", XMAX, YMAX, 4, 3);
564   DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_in =
565      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_in" , XMAX, YMAX, 4, 2);
566   DspinSignals<dspin_rsp_width>**** signal_dspin_false_rsp_out =
567      alloc_elems<DspinSignals<dspin_rsp_width> >("signal_dspin_false_rsp_out", XMAX, YMAX, 4, 2);
568
569
570   ////////////////////////////
571   //      Loader   
572   ////////////////////////////
573
574   soclib::common::Loader loader(soft_name);
575
576   typedef soclib::common::GdbServer<soclib::common::Mips32ElIss> proc_iss;
577   proc_iss::set_loader(loader);
578
579   ////////////////////////////
580   // Clusters construction
581   ////////////////////////////
582
583   TsarXbarCluster<dspin_cmd_width,
584                   dspin_rsp_width,
585                   vci_param_int,
586                   vci_param_ext>*          clusters[XMAX][YMAX];
587
588#if USE_OPENMP
589#pragma omp parallel
590    {
591#pragma omp for
592#endif
593        for(size_t i = 0; i  < (XMAX * YMAX); i++)
594        {
595            size_t x = i / YMAX;
596            size_t y = i % YMAX;
597
598#if USE_OPENMP
599#pragma omp critical
600            {
601#endif
602            std::cout << std::endl;
603            std::cout << "Cluster_" << x << "_" << y << std::endl;
604            std::cout << std::endl;
605
606            std::ostringstream sc;
607            sc << "cluster_" << x << "_" << y;
608            clusters[x][y] = new TsarXbarCluster<dspin_cmd_width,
609                                                 dspin_rsp_width,
610                                                 vci_param_int,
611                                                 vci_param_ext>
612            (
613                sc.str().c_str(),
614                NB_PROCS_MAX,
615                NB_TTY_CHANNELS, 
616                NB_DMA_CHANNELS, 
617                x,
618                y,
619                cluster(x,y),
620                maptabd,
621                maptabx,
622                x_width,
623                y_width,
624                vci_srcid_width - x_width - y_width,   // l_id width,
625                MEMC_TGTID,
626                XICU_TGTID,
627                MDMA_TGTID,
628                FBUF_TGTID,
629                MTTY_TGTID,
630                BROM_TGTID,
631                MNIC_TGTID,
632                BDEV_TGTID,
633                MEMC_WAYS,
634                MEMC_SETS,
635                L1_IWAYS,
636                L1_ISETS,
637                L1_DWAYS,
638                L1_DSETS,
639                XRAM_LATENCY,
640                (cluster(x,y) == cluster_io_id),
641                FBUF_X_SIZE,
642                FBUF_Y_SIZE,
643                disk_name,
644                BDEV_SECTOR_SIZE,
645                NB_NIC_CHANNELS,
646                nic_rx_name,
647                nic_tx_name,
648                NIC_TIMEOUT,
649                loader,
650                frozen_cycles,
651                debug_from   ,
652                debug_ok and (cluster(x,y) == debug_memc_id),
653                debug_ok and (cluster(x,y) == debug_proc_id) 
654            );
655
656#if USE_OPENMP
657            } // end critical
658#endif
659        } // end for
660#if USE_OPENMP
661    }
662#endif
663
664   ///////////////////////////////////////////////////////////////
665   //     Net-list
666   ///////////////////////////////////////////////////////////////
667
668   // Clock & RESET
669   for (size_t x = 0; x < (XMAX); x++){
670      for (size_t y = 0; y < YMAX; y++){
671         clusters[x][y]->p_clk                         (signal_clk);
672         clusters[x][y]->p_resetn                      (signal_resetn);
673      }
674   }
675
676   // Inter Clusters horizontal connections
677   if (XMAX > 1){
678      for (size_t x = 0; x < (XMAX-1); x++){
679         for (size_t y = 0; y < YMAX; y++){
680            for (size_t k = 0; k < 3; k++){
681               clusters[x][y]->p_cmd_out[EAST][k]      (signal_dspin_h_cmd_inc[x][y][k]);
682               clusters[x+1][y]->p_cmd_in[WEST][k]     (signal_dspin_h_cmd_inc[x][y][k]);
683               clusters[x][y]->p_cmd_in[EAST][k]       (signal_dspin_h_cmd_dec[x][y][k]);
684               clusters[x+1][y]->p_cmd_out[WEST][k]    (signal_dspin_h_cmd_dec[x][y][k]);
685            }
686
687            for (size_t k = 0; k < 2; k++){
688               clusters[x][y]->p_rsp_out[EAST][k]      (signal_dspin_h_rsp_inc[x][y][k]);
689               clusters[x+1][y]->p_rsp_in[WEST][k]     (signal_dspin_h_rsp_inc[x][y][k]);
690               clusters[x][y]->p_rsp_in[EAST][k]       (signal_dspin_h_rsp_dec[x][y][k]);
691               clusters[x+1][y]->p_rsp_out[WEST][k]    (signal_dspin_h_rsp_dec[x][y][k]);
692            }
693         }
694      }
695   }
696   std::cout << std::endl << "Horizontal connections established" << std::endl;   
697
698   // Inter Clusters vertical connections
699   if (YMAX > 1) {
700      for (size_t y = 0; y < (YMAX-1); y++){
701         for (size_t x = 0; x < XMAX; x++){
702            for (size_t k = 0; k < 3; k++){
703               clusters[x][y]->p_cmd_out[NORTH][k]     (signal_dspin_v_cmd_inc[x][y][k]);
704               clusters[x][y+1]->p_cmd_in[SOUTH][k]    (signal_dspin_v_cmd_inc[x][y][k]);
705               clusters[x][y]->p_cmd_in[NORTH][k]      (signal_dspin_v_cmd_dec[x][y][k]);
706               clusters[x][y+1]->p_cmd_out[SOUTH][k]   (signal_dspin_v_cmd_dec[x][y][k]);
707            }
708
709            for (size_t k = 0; k < 2; k++){
710               clusters[x][y]->p_rsp_out[NORTH][k]     (signal_dspin_v_rsp_inc[x][y][k]);
711               clusters[x][y+1]->p_rsp_in[SOUTH][k]    (signal_dspin_v_rsp_inc[x][y][k]);
712               clusters[x][y]->p_rsp_in[NORTH][k]      (signal_dspin_v_rsp_dec[x][y][k]);
713               clusters[x][y+1]->p_rsp_out[SOUTH][k]   (signal_dspin_v_rsp_dec[x][y][k]);
714            }
715         }
716      }
717   }
718   std::cout << "Vertical connections established" << std::endl;
719
720   // East & West boundary cluster connections
721   for (size_t y = 0; y < YMAX; y++)
722   {
723      for (size_t k = 0; k < 3; k++)
724      {
725         clusters[0][y]->p_cmd_in[WEST][k]        (signal_dspin_false_cmd_in[0][y][WEST][k]);
726         clusters[0][y]->p_cmd_out[WEST][k]       (signal_dspin_false_cmd_out[0][y][WEST][k]);
727         clusters[XMAX-1][y]->p_cmd_in[EAST][k]   (signal_dspin_false_cmd_in[XMAX-1][y][EAST][k]);
728         clusters[XMAX-1][y]->p_cmd_out[EAST][k]  (signal_dspin_false_cmd_out[XMAX-1][y][EAST][k]);
729      }
730
731      for (size_t k = 0; k < 2; k++)
732      {
733         clusters[0][y]->p_rsp_in[WEST][k]        (signal_dspin_false_rsp_in[0][y][WEST][k]);
734         clusters[0][y]->p_rsp_out[WEST][k]       (signal_dspin_false_rsp_out[0][y][WEST][k]);
735         clusters[XMAX-1][y]->p_rsp_in[EAST][k]   (signal_dspin_false_rsp_in[XMAX-1][y][EAST][k]);
736         clusters[XMAX-1][y]->p_rsp_out[EAST][k]  (signal_dspin_false_rsp_out[XMAX-1][y][EAST][k]);
737      }
738   }
739
740   // North & South boundary clusters connections
741   for (size_t x = 0; x < XMAX; x++)
742   {
743      for (size_t k = 0; k < 3; k++)
744      {
745         clusters[x][0]->p_cmd_in[SOUTH][k]       (signal_dspin_false_cmd_in[x][0][SOUTH][k]);
746         clusters[x][0]->p_cmd_out[SOUTH][k]      (signal_dspin_false_cmd_out[x][0][SOUTH][k]);
747         clusters[x][YMAX-1]->p_cmd_in[NORTH][k]  (signal_dspin_false_cmd_in[x][YMAX-1][NORTH][k]);
748         clusters[x][YMAX-1]->p_cmd_out[NORTH][k] (signal_dspin_false_cmd_out[x][YMAX-1][NORTH][k]);
749      }
750
751      for (size_t k = 0; k < 2; k++)
752      {
753         clusters[x][0]->p_rsp_in[SOUTH][k]       (signal_dspin_false_rsp_in[x][0][SOUTH][k]);
754         clusters[x][0]->p_rsp_out[SOUTH][k]      (signal_dspin_false_rsp_out[x][0][SOUTH][k]);
755         clusters[x][YMAX-1]->p_rsp_in[NORTH][k]  (signal_dspin_false_rsp_in[x][YMAX-1][NORTH][k]);
756         clusters[x][YMAX-1]->p_rsp_out[NORTH][k] (signal_dspin_false_rsp_out[x][YMAX-1][NORTH][k]);
757      }
758   }
759   std::cout << "North, South, West, East connections established" << std::endl;
760   std::cout << std::endl;
761
762
763   ////////////////////////////////////////////////////////
764   //   Simulation
765   ///////////////////////////////////////////////////////
766
767   sc_start(sc_core::sc_time(0, SC_NS));
768   signal_resetn = false;
769
770   // network boundaries signals
771   for (size_t x = 0; x < XMAX ; x++){
772      for (size_t y = 0; y < YMAX ; y++){
773         for (size_t a = 0; a < 4; a++){
774            for (size_t k = 0; k < 3; k++){
775               signal_dspin_false_cmd_in [x][y][a][k].write = false;
776               signal_dspin_false_cmd_in [x][y][a][k].read  = true;
777               signal_dspin_false_cmd_out[x][y][a][k].write = false;
778               signal_dspin_false_cmd_out[x][y][a][k].read  = true;
779            }
780
781            for (size_t k = 0; k < 2; k++){
782               signal_dspin_false_rsp_in [x][y][a][k].write = false;
783               signal_dspin_false_rsp_in [x][y][a][k].read  = true;
784               signal_dspin_false_rsp_out[x][y][a][k].write = false;
785               signal_dspin_false_rsp_out[x][y][a][k].read  = true;
786            }
787         }
788      }
789   }
790
791   sc_start(sc_core::sc_time(1, SC_NS));
792   signal_resetn = true;
793
794   if (gettimeofday(&t1, NULL) != 0) 
795   {
796      perror("gettimeofday");
797      return EXIT_FAILURE;
798   }
799
800   for (uint64_t n = 1; n < ncycles; n++)
801   {
802      // Monitor a specific address for L1 & L2 caches
803      //clusters[0][0]->proc[0]->cache_monitor(0x800002c000ULL);
804      //clusters[1][0]->memc->copies_monitor(0x800002C000ULL);
805
806      if( (n % 5000000) == 0)
807      {
808
809         if (gettimeofday(&t2, NULL) != 0) 
810         {
811            perror("gettimeofday");
812            return EXIT_FAILURE;
813         }
814
815         ms1 = (uint64_t)t1.tv_sec * 1000ULL + (uint64_t)t1.tv_usec / 1000;
816         ms2 = (uint64_t)t2.tv_sec * 1000ULL + (uint64_t)t2.tv_usec / 1000;
817         std::cerr << "platform clock frequency " << (double)5000000 / (double)(ms2 - ms1) << "Khz" << std::endl;
818
819         if (gettimeofday(&t1, NULL) != 0) 
820         {
821            perror("gettimeofday");
822            return EXIT_FAILURE;
823         }
824      }
825
826      if (debug_ok and (n > debug_from) and (n % debug_period == 0))
827      {
828         std::cout << "****************** cycle " << std::dec << n ;
829         std::cout << " ************************************************" << std::endl;
830
831        // trace proc[debug_proc_id]
832        size_t l = debug_proc_id % NB_PROCS_MAX ;
833        size_t y = (debug_proc_id / NB_PROCS_MAX) % YMAX ;
834        size_t x = debug_proc_id / (YMAX * NB_PROCS_MAX) ;
835
836        std::ostringstream proc_signame;
837        proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
838        std::ostringstream p2m_signame;
839        p2m_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " P2M" ;
840        std::ostringstream m2p_signame;
841        m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ;
842        std::ostringstream p_cmd_signame;
843        p_cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ;
844        std::ostringstream p_rsp_signame;
845        p_rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ;
846
847        clusters[x][y]->proc[l]->print_trace();
848        clusters[x][y]->wi_proc[l]->print_trace();
849        clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str());
850        clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str());
851        clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str());
852        clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(p_cmd_signame.str());
853        clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(p_rsp_signame.str());
854
855        clusters[x][y]->xbar_rsp_d->print_trace();
856        clusters[x][y]->xbar_cmd_d->print_trace();
857        clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD");
858        clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD");
859        clusters[x][y]->signal_dspin_rsp_l2g_d.print_trace("[SIG]L2G RSP");
860        clusters[x][y]->signal_dspin_rsp_g2l_d.print_trace("[SIG]G2L RSP");
861
862        // trace memc[debug_memc_id]
863        x = debug_memc_id / YMAX;
864        y = debug_memc_id % YMAX;
865
866        std::ostringstream smemc;
867        smemc << "[SIG]MEMC_" << x << "_" << y;
868        std::ostringstream sxram;
869        sxram << "[SIG]XRAM_" << x << "_" << y;
870        std::ostringstream sm2p;
871        sm2p << "[SIG]MEMC_" << x << "_" << y << " M2P" ;
872        std::ostringstream sp2m;
873        sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ;
874        std::ostringstream m_cmd_signame;
875        m_cmd_signame << "[SIG]MEMC_" << x << "_" << y <<  " CMD" ;
876        std::ostringstream m_rsp_signame;
877        m_rsp_signame << "[SIG]MEMC_" << x << "_" << y <<  " RSP" ;
878
879        clusters[x][y]->memc->print_trace();
880        clusters[x][y]->wt_memc->print_trace();
881        clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str());
882        clusters[x][y]->signal_vci_xram.print_trace(sxram.str());
883        clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str());
884        clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str());
885        clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(m_cmd_signame.str());
886        clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(m_rsp_signame.str());
887       
888        // trace replicated peripherals
889//        clusters[1][1]->mdma->print_trace();
890//        clusters[1][1]->signal_vci_tgt_mdma.print_trace("[SIG]MDMA_TGT_1_1");
891//        clusters[1][1]->signal_vci_ini_mdma.print_trace("[SIG]MDMA_INI_1_1");
892       
893
894        // trace external peripherals
895        size_t io_x   = cluster_io_id / YMAX;
896        size_t io_y   = cluster_io_id % YMAX;
897       
898        clusters[io_x][io_y]->brom->print_trace();
899        clusters[io_x][io_y]->wt_brom->print_trace();
900        clusters[io_x][io_y]->signal_vci_tgt_brom.print_trace("[SIG]BROM");
901        clusters[io_x][io_y]->signal_dspin_cmd_brom_t.print_trace("[SIG]BROM CMD");
902        clusters[io_x][io_y]->signal_dspin_rsp_brom_t.print_trace("[SIG]BROM RSP");
903
904//        clusters[io_x][io_y]->bdev->print_trace();
905//        clusters[io_x][io_y]->signal_vci_tgt_bdev.print_trace("[SIG]BDEV_TGT");
906//        clusters[io_x][io_y]->signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI");
907      }
908
909      sc_start(sc_core::sc_time(1, SC_NS));
910   }
911   return EXIT_SUCCESS;
912}
913
914int sc_main (int argc, char *argv[])
915{
916   try {
917      return _main(argc, argv);
918   } catch (std::exception &e) {
919      std::cout << e.what() << std::endl;
920   } catch (...) {
921      std::cout << "Unknown exception occured" << std::endl;
922      throw;
923   }
924   return 1;
925}
926
927
928// Local Variables:
929// tab-width: 3
930// c-basic-offset: 3
931// c-file-offsets:((innamespace . 0)(inline-open . 0))
932// indent-tabs-mode: nil
933// End:
934
935// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
Note: See TracBrowser for help on using the repository browser.