Index: trunk/platforms/tsar_generic_xbar/top.cpp
===================================================================
--- trunk/platforms/tsar_generic_xbar/top.cpp	(revision 512)
+++ trunk/platforms/tsar_generic_xbar/top.cpp	(revision 547)
@@ -125,4 +125,6 @@
 #define cluster(x,y)   (y + YMAX * x)
 
+#define min(x, y) (x < y ? x : y)
+
 ///////////////////////////////////////////////////////////
 //          DSPIN parameters           
@@ -229,5 +231,5 @@
 //////////////////////i/////////////////////////////////////
 
-#define MAX_FROZEN_CYCLES     100000
+#define MAX_FROZEN_CYCLES     1000000
 
 /////////////////////////////////////////////////////////
@@ -239,45 +241,73 @@
 /////////////////////////////////////////////////////////
 
-// specific segments in "IO" cluster : absolute physical address
-
-#define BROM_BASE       0x00BFC00000      
-#define BROM_SIZE       0x0000100000   // 1 Mbytes
-
-#define FBUF_BASE       0x00B2000000      
-#define FBUF_SIZE       (FBUF_X_SIZE * FBUF_Y_SIZE * 2)
-
-#define BDEV_BASE       0x00B3000000      
-#define BDEV_SIZE       0x0000001000   // 4 Kbytes
-
-#define MTTY_BASE       0x00B4000000      
-#define MTTY_SIZE       0x0000001000   // 4 Kbytes
-
-#define MNIC_BASE       0x00B5000000      
-#define MNIC_SIZE       0x0000080000   // 512 Kbytes (for 8 channels)
-
-#define CDMA_BASE       0x00B6000000      
-#define CDMA_SIZE       0x0000004000 * NB_CMA_CHANNELS 
-
-// replicated segments : address is incremented by a cluster offset 
-//     offset  = cluster(x,y) << (address_width-x_width-y_width);
-
-#define MEMC_BASE       0x0000000000      
-#define MEMC_SIZE       0x0010000000   // 256 Mbytes per cluster
+#ifdef USE_GIET
+   // specific segments in "IO" cluster : absolute physical address
+   #define BROM_BASE    0x00BFC00000
+   #define BROM_SIZE    0x0000100000   // 1 Mbytes
+
+   #define FBUF_BASE    0x00B2000000
+   #define FBUF_SIZE    (FBUF_X_SIZE * FBUF_Y_SIZE * 2)
+
+   #define BDEV_BASE    0x00B3000000
+   #define BDEV_SIZE    0x0000001000   // 4 Kbytes
+
+   #define MTTY_BASE    0x00B4000000
+   #define MTTY_SIZE    0x0000001000   // 4 Kbytes
+
+   #define MNIC_BASE    0x00B5000000
+   #define MNIC_SIZE    0x0000080000   // 512 Kbytes (for 8 channels)
+
+   #define CDMA_BASE    0x00B6000000
+   #define CDMA_SIZE    0x0000004000 * NB_CMA_CHANNELS
+
+   // replicated segments : address is incremented by a cluster offset
+   //     offset  = cluster(x,y) << (address_width-x_width-y_width);
+
+   #define MEMC_BASE    0x0000000000
+   #define MEMC_SIZE    0x0010000000   // 256 Mbytes per cluster
+
+   #define XICU_BASE    0x00B0000000
+   #define XICU_SIZE    0x0000001000   // 4 Kbytes
+
+   #define MDMA_BASE    0x00B1000000
+   #define MDMA_SIZE    0x0000001000 * NB_DMA_CHANNELS  // 4 Kbytes per channel
+
+   #define SIMH_BASE    0x00B7000000
+   #define SIMH_SIZE    0x0000001000
+#endif
 
 #ifdef USE_ALMOS
-   #define XICU_BASE    0x0030000000
-#endif
-#ifdef USE_GIET
-   #define XICU_BASE    0x00B0000000
-#endif
-#define XICU_SIZE       0x0000001000   // 4 Kbytes
-
-#ifdef USE_ALMOS
-   #define MDMA_BASE    0x0031000000
-#endif
-#ifdef USE_GIET
-   #define MDMA_BASE    0x00B1000000
-#endif
-#define MDMA_SIZE       0x0000001000 * NB_DMA_CHANNELS  // 4 Kbytes per channel  
+   #define CLUSTER_INC  (0x80000000ULL / (XMAX * YMAX) * 2)
+
+   #define MEMC_BASE    0x0000000000
+   #define MEMC_SIZE    min(0x02000000, (0x80000000 / (XMAX * YMAX)))
+
+   #define BROM_BASE    0x00BFC00000
+   #define BROM_SIZE    0x0000100000   // 1 Mbytes
+
+   #define XICU_BASE    (MEMC_SIZE)
+   #define XICU_SIZE    0x0000001000   // 4 Kbytes
+
+   #define MDMA_BASE    (XICU_BASE + XICU_SIZE)
+   #define MDMA_SIZE    0x0000001000 * NB_DMA_CHANNELS  // 4 Kbytes per channel  
+
+   #define BDEV_BASE    ((cluster_io_id * (CLUSTER_INC)) + MDMA_BASE + MDMA_SIZE)
+   #define BDEV_SIZE    0x0000001000   // 4 Kbytes
+
+   #define MTTY_BASE    (BDEV_BASE + BDEV_SIZE)
+   #define MTTY_SIZE    0x0000001000   // 4 Kbytes
+
+   #define FBUF_BASE    (MTTY_BASE + MTTY_SIZE)
+   #define FBUF_SIZE    (FBUF_X_SIZE * FBUF_Y_SIZE * 2) // Should be 0x80000
+
+   // Unused in almos
+   #define MNIC_BASE    (FBUF_BASE + FBUF_SIZE)
+   #define MNIC_SIZE    0x0000001000
+
+   #define CDMA_BASE    (MNIC_BASE + MNIC_SIZE)
+   #define CDMA_SIZE    0x0000004000 * NB_CMA_CHANNELS
+
+#endif
+
 
 ////////////////////////////////////////////////////////////////////
@@ -295,4 +325,5 @@
 #define BROM_TGTID      7
 #define CDMA_TGTID      8
+#define SIMH_TGTID      9
 
 bool stop_called = false;
@@ -438,4 +469,5 @@
     std::cout << " - RAM_LATENCY      = " << XRAM_LATENCY << std::endl;
     std::cout << " - MAX_FROZEN       = " << frozen_cycles << std::endl;
+    std::cout << "[PROCS] " << NB_PROCS_MAX * XMAX * YMAX << std::endl;
 
     std::cout << std::endl;
@@ -498,7 +530,7 @@
    // internal network
    MappingTable maptabd(vci_address_width, 
-                        IntTab(x_width + y_width, 16 - x_width - y_width), 
+                        IntTab(x_width + y_width, 20 - x_width - y_width), 
                         IntTab(x_width + y_width, vci_srcid_width - x_width - y_width), 
-                        0x00FF000000);
+                        0x00FF800000);
 
    for (size_t x = 0; x < XMAX; x++)
@@ -510,18 +542,18 @@
                    << (vci_address_width-x_width-y_width);
 
+         std::ostringstream    si;
+         si << "seg_xicu_" << x << "_" << y;
+         maptabd.add(Segment(si.str(), XICU_BASE + offset, XICU_SIZE, 
+                  IntTab(cluster(x,y),XICU_TGTID), false));
+
+         std::ostringstream    sd;
+         sd << "seg_mdma_" << x << "_" << y;
+         maptabd.add(Segment(sd.str(), MDMA_BASE + offset, MDMA_SIZE, 
+                  IntTab(cluster(x,y),MDMA_TGTID), false));
+
          std::ostringstream    sh;
          sh << "seg_memc_" << x << "_" << y;
-         maptabd.add(Segment(sh.str(), MEMC_BASE+offset, MEMC_SIZE, 
-                             IntTab(cluster(x,y),MEMC_TGTID), true));
-
-         std::ostringstream    si;
-         si << "seg_xicu_" << x << "_" << y;
-         maptabd.add(Segment(si.str(), XICU_BASE+offset, XICU_SIZE, 
-                             IntTab(cluster(x,y),XICU_TGTID), false));
-
-         std::ostringstream    sd;
-         sd << "seg_mdma_" << x << "_" << y;
-         maptabd.add(Segment(sd.str(), MDMA_BASE+offset, MDMA_SIZE, 
-                             IntTab(cluster(x,y),MDMA_TGTID), false));
+         maptabd.add(Segment(sh.str(), MEMC_BASE + offset, MEMC_SIZE, 
+                  IntTab(cluster(x,y),MEMC_TGTID), true));
 
          if ( cluster(x,y) == cluster_io_id )
@@ -533,10 +565,12 @@
             maptabd.add(Segment("seg_bdev", BDEV_BASE, BDEV_SIZE, 
                         IntTab(cluster(x,y),BDEV_TGTID), false));
+            maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, 
+                        IntTab(cluster(x,y),BROM_TGTID), true));
             maptabd.add(Segment("seg_mnic", MNIC_BASE, MNIC_SIZE, 
                         IntTab(cluster(x,y),MNIC_TGTID), false));
             maptabd.add(Segment("seg_cdma", CDMA_BASE, CDMA_SIZE, 
                         IntTab(cluster(x,y),CDMA_TGTID), false));
-            maptabd.add(Segment("seg_brom", BROM_BASE, BROM_SIZE, 
-                        IntTab(cluster(x,y),BROM_TGTID), true));
+            maptabd.add(Segment("seg_simh", SIMH_BASE, SIMH_SIZE, 
+                        IntTab(cluster(x,y),SIMH_TGTID), false));
          }
       }
@@ -562,5 +596,5 @@
          sh << "x_seg_memc_" << x << "_" << y;
 
-         maptabx.add(Segment(sh.str(), MEMC_BASE+offset, 
+         maptabx.add(Segment(sh.str(), MEMC_BASE + offset, 
                      MEMC_SIZE, IntTab(cluster(x,y)), false));
       }
@@ -670,4 +704,5 @@
                 CDMA_TGTID,
                 BDEV_TGTID,
+                SIMH_TGTID,
                 MEMC_WAYS,
                 MEMC_SETS,
@@ -981,8 +1016,10 @@
 }
 
+void voidhandler(int dummy = 0) {}
 
 int sc_main (int argc, char *argv[])
 {
    signal(SIGINT, handler);
+   signal(SIGPIPE, voidhandler);
 
    try {
