Index: branches/reconfiguration/platforms/tsar_generic_iob/top.cpp
===================================================================
--- branches/reconfiguration/platforms/tsar_generic_iob/top.cpp	(revision 747)
+++ branches/reconfiguration/platforms/tsar_generic_iob/top.cpp	(revision 748)
@@ -9,5 +9,4 @@
 // an external bus (i.e. Hypertransport) to access 7 external peripherals:
 //
-// - BROM : boot ROM
 // - FBUF : Frame Buffer
 // - MTTY : multi TTY (one channel)
@@ -44,4 +43,5 @@
 // - IOPIC HWI[8]       connected to IRQ_BDEV
 // - IOPIC HWI[9]       connected to IRQ_TTY_RX[0]
+// - IOPIC HWI[31:9]    unused       (grounded)
 //
 // Besides the external peripherals, each cluster contains one XICU component,
@@ -228,5 +228,5 @@
 //////////////////////i/////////////////////////////////////
 
-#define MAX_FROZEN_CYCLES     20000000
+#define MAX_FROZEN_CYCLES     200000
 
 /////////////////////////////////////////////////////////
@@ -276,5 +276,6 @@
 #define INT_XICU_TGT_ID              1
 #define INT_MDMA_TGT_ID              2
-#define INT_IOBX_TGT_ID              3
+#define INT_BROM_TGT_ID              3
+#define INT_IOBX_TGT_ID              4
 
 #define INT_PROC_INI_ID              0   // from 0 to (NB_PROCS_MAX-1)
@@ -299,9 +300,8 @@
 #define IOX_MNIC_TGT_ID              2
 #define IOX_CDMA_TGT_ID              3
-#define IOX_BROM_TGT_ID              4
-#define IOX_MTTY_TGT_ID              5
-#define IOX_IOPI_TGT_ID              6
-#define IOX_IOB0_TGT_ID              7
-#define IOX_IOB1_TGT_ID              8
+#define IOX_MTTY_TGT_ID              4
+#define IOX_IOPI_TGT_ID              5
+#define IOX_IOB0_TGT_ID              6
+#define IOX_IOB1_TGT_ID              7
 
 #define IOX_BDEV_INI_ID              0
@@ -349,5 +349,5 @@
          if ((strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc))
          {
-            ncycles = atoi(argv[n+1]);
+            ncycles = strtol(argv[n+1], NULL, 0);
          }
          else if ((strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
@@ -358,5 +358,5 @@
          {
             debug_ok = true;
-            debug_from = atoi(argv[n+1]);
+            debug_from = strtol(argv[n+1], NULL, 0);
          }
          else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
@@ -366,5 +366,5 @@
          else if ((strcmp(argv[n],"-MEMCID") == 0) && (n+1<argc) )
          {
-            debug_memc_id = atoi(argv[n+1]);
+            debug_memc_id = strtol(argv[n+1], NULL, 0);
             size_t x = debug_memc_id >> 4;
             size_t y = debug_memc_id & 0xF;
@@ -377,5 +377,5 @@
          else if ((strcmp(argv[n],"-XRAMID") == 0) && (n+1<argc) )
          {
-            debug_xram_id = atoi(argv[n+1]);
+            debug_xram_id = strtol(argv[n+1], NULL, 0);
             size_t x = debug_xram_id >> 4;
             size_t y = debug_xram_id & 0xF;
@@ -388,9 +388,9 @@
          else if ((strcmp(argv[n],"-IOB") == 0) && (n+1<argc) )
          {
-            debug_iob = atoi(argv[n+1]);
+            debug_iob = strtol(argv[n+1], NULL, 0);
          }
          else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) )
          {
-            debug_proc_id     = atoi(argv[n+1]);
+            debug_proc_id     = strtol(argv[n+1], NULL, 0);
             size_t cluster_xy = debug_proc_id / NB_PROCS_MAX ;
             size_t x          = cluster_xy >> 4;
@@ -404,14 +404,14 @@
          else if ((strcmp(argv[n], "-THREADS") == 0) && ((n+1) < argc))
          {
-            threads_nr = atoi(argv[n+1]);
+            threads_nr = strtol(argv[n+1], NULL, 0);
             threads_nr = (threads_nr < 1) ? 1 : threads_nr;
          }
          else if ((strcmp(argv[n], "-FROZEN") == 0) && (n+1 < argc))
          {
-            frozen_cycles = atoi(argv[n+1]);
+            frozen_cycles = strtol(argv[n+1], NULL, 0);
          }
          else if ((strcmp(argv[n], "-PERIOD") == 0) && (n+1 < argc))
          {
-            debug_period = atoi(argv[n+1]);
+            debug_period = strtol(argv[n+1], NULL, 0);
          }
          else
@@ -436,4 +436,12 @@
    }
 
+   // Activate Distributed Boot (set by environment variable)
+   // When this is activated, every processor boots with its instruction and data
+   // physical address extension register initialized to its cluster index
+   // (X_LOCAL, Y_LOCAL). To support this feature, a distributed ROM is
+   // implemented in each cluster.
+
+   const bool distributed_boot = (getenv("DISTRIBUTED_BOOT") != NULL);
+
    // checking hardware parameters
    assert( (XMAX <= 16) and
@@ -466,4 +474,5 @@
              << " - RAM_LATENCY     = " << XRAM_LATENCY << std::endl
              << " - MAX_FROZEN      = " << frozen_cycles << std::endl
+             << " - DIST_BOOT       = " << distributed_boot << std::endl
              << " - DEBUG_PROCID    = " << debug_proc_id << std::endl
              << " - DEBUG_MEMCID    = " << debug_memc_id << std::endl
@@ -544,4 +553,9 @@
                      IntTab(cluster(x,y), INT_MDMA_TGT_ID), not cacheable));
 
+         std::ostringstream    sbrom;
+         sbrom << "int_seg_brom_" << x << "_" << y;
+         maptab_int.add(Segment(sbrom.str(), SEG_ROM_BASE+offset, SEG_ROM_SIZE,
+                     IntTab(cluster(x,y), INT_BROM_TGT_ID), cacheable));
+
          // the following segments are only defined in cluster_iob0 or in cluster_iob1
 
@@ -572,9 +586,4 @@
             maptab_int.add(Segment(snic.str(), SEG_NIC_BASE+offset, SEG_NIC_SIZE,
                         IntTab(cluster(x,y), INT_IOBX_TGT_ID), not cacheable));
-
-            std::ostringstream    srom;
-            srom << "int_seg_brom_" << x << "_" << y;
-            maptab_int.add(Segment(srom.str(), SEG_ROM_BASE+offset, SEG_ROM_SIZE,
-                        IntTab(cluster(x,y), INT_IOBX_TGT_ID), cacheable ));
 
             std::ostringstream    sdma;
@@ -698,6 +707,4 @@
     maptab_iox.add(Segment("iox_seg_cdma_0", SEG_CMA_BASE + iob0_base, SEG_CMA_SIZE,
                    IntTab(0, IOX_CDMA_TGT_ID), false));
-    maptab_iox.add(Segment("iox_seg_brom_0", SEG_ROM_BASE + iob0_base, SEG_ROM_SIZE,
-                   IntTab(0, IOX_BROM_TGT_ID), false));
     maptab_iox.add(Segment("iox_seg_iopi_0", SEG_PIC_BASE + iob0_base, SEG_PIC_SIZE,
                    IntTab(0, IOX_IOPI_TGT_ID), false));
@@ -718,6 +725,4 @@
         maptab_iox.add(Segment("iox_seg_cdma_1", SEG_CMA_BASE + iob1_base, SEG_CMA_SIZE,
                    IntTab(0, IOX_CDMA_TGT_ID), false));
-        maptab_iox.add(Segment("iox_seg_brom_1", SEG_ROM_BASE + iob1_base, SEG_ROM_SIZE,
-                   IntTab(0, IOX_BROM_TGT_ID), false));
         maptab_iox.add(Segment("iox_seg_iopi_1", SEG_PIC_BASE + iob1_base, SEG_PIC_SIZE,
                    IntTab(0, IOX_IOPI_TGT_ID), false));
@@ -813,5 +818,4 @@
     VciSignals<vci_param_ext>         signal_vci_tgt_fbuf("signal_vci_tgt_fbuf");
     VciSignals<vci_param_ext>         signal_vci_tgt_mnic("signal_vci_tgt_mnic");
-    VciSignals<vci_param_ext>         signal_vci_tgt_brom("signal_vci_tgt_brom");
     VciSignals<vci_param_ext>         signal_vci_tgt_bdev("signal_vci_tgt_bdev");
     VciSignals<vci_param_ext>         signal_vci_tgt_cdma("signal_vci_tgt_cdma");
@@ -901,5 +905,5 @@
 
    const size_t nb_iox_initiators = (cluster_iob0 != cluster_iob1) ? 5 : 4;
-   const size_t nb_iox_targets = (cluster_iob0 != cluster_iob1) ? 9 : 8;
+   const size_t nb_iox_targets = (cluster_iob0 != cluster_iob1) ? 8 : 7;
 
    // IOX network
@@ -909,10 +913,5 @@
                                                    nb_iox_targets,
                                                    nb_iox_initiators );
-   // boot ROM
-   VciSimpleRom<vci_param_ext>*  brom;
-   brom = new VciSimpleRom<vci_param_ext>( "brom",
-                                           IntTab(0, IOX_BROM_TGT_ID),
-                                           maptab_iox,
-                                           loader );
+
    // Network Controller
    VciMultiNic<vci_param_ext>*  mnic;
@@ -976,4 +975,5 @@
                                        IntTab(0, IOX_IOPI_TGT_ID),
                                        32 );        // number of input HWI
+
    // Clusters
    TsarIobCluster<vci_param_int,
@@ -1041,4 +1041,5 @@
                 INT_XICU_TGT_ID,
                 INT_MDMA_TGT_ID,
+                INT_BROM_TGT_ID,
                 INT_IOBX_TGT_ID,
 
@@ -1065,4 +1066,6 @@
                 XCU_NB_INPUTS,
 
+                distributed_boot,
+
                 loader,
 
@@ -1100,5 +1103,4 @@
     iox_network->p_to_tgt[IOX_FBUF_TGT_ID]               (signal_vci_tgt_fbuf);
     iox_network->p_to_tgt[IOX_MNIC_TGT_ID]               (signal_vci_tgt_mnic);
-    iox_network->p_to_tgt[IOX_BROM_TGT_ID]               (signal_vci_tgt_brom);
     iox_network->p_to_tgt[IOX_BDEV_TGT_ID]               (signal_vci_tgt_bdev);
     iox_network->p_to_tgt[IOX_CDMA_TGT_ID]               (signal_vci_tgt_cdma);
@@ -1138,11 +1140,4 @@
 
     std::cout << "  - MNIC connected" << std::endl;
-
-    // BROM connexion
-    brom->p_clk                                          (signal_clk);
-    brom->p_resetn                                       (signal_resetn);
-    brom->p_vci                                          (signal_vci_tgt_brom);
-
-    std::cout << "  - BROM connected" << std::endl;
 
     // MTTY connexion
@@ -1423,5 +1418,5 @@
 
         // Monitor a specific address for one L2 cache
-        // clusters[0][0]->memc->cache_monitor( 0x1542c0ULL, true );   // single word
+        // clusters[0][0]->memc->cache_monitor( 0x170000ULL);
 
         // Monitor a specific address for one XRAM
@@ -1440,6 +1435,6 @@
                 size_t x          = cluster_xy >> 4;
                 size_t y          = cluster_xy & 0xF;
-  
-                clusters[x][y]->proc[l]->print_trace(0x40);
+
+                clusters[x][y]->proc[l]->print_trace(1);
                 std::ostringstream proc_signame;
                 proc_signame << "[SIG]PROC_" << x << "_" << y << "_" << l ;
@@ -1451,27 +1446,12 @@
                 clusters[x][y]->signal_int_vci_tgt_xicu.print_trace(xicu_signame.str());
 
-                clusters[x][y]->mdma->print_trace();
-                std::ostringstream mdma_signame;
-                mdma_signame << "[SIG]MDMA_" << x << "_" << y;
-                clusters[x][y]->signal_int_vci_tgt_mdma.print_trace(mdma_signame.str());
-
-                // local interrupts in cluster(x,y)
-                if( clusters[x][y]->signal_irq_memc.read() )
-                std::cout << "### IRQ_MMC_" << std::dec << x << "_" << y 
-                          << " ACTIVE" << std::endl;
-
-                for ( size_t c = 0 ; c < NB_DMA_CHANNELS ; c++ )
-                {
-                    if( clusters[x][y]->signal_irq_mdma[c].read() )
-                    std::cout << "### IRQ_DMA_" << std::dec << x << "_" << y << "_" << c 
-                              << " ACTIVE" << std::endl;
-                }
- 
-                for ( size_t c = 0 ; c < NB_PROCS_MAX ; c++ )
-                {
-                    if( clusters[x][y]->signal_proc_it[c].read() )
-                    std::cout << "### IRQ_PROC_" << std::dec << x << "_" << y << "_" << c 
-                              << " ACTIVE" << std::endl;
-                }
+//              clusters[x][y]->mdma->print_trace();
+//              std::ostringstream mdma_signame;
+//              mdma_signame << "[SIG]MDMA_" << x << "_" << y;
+//              clusters[x][y]->signal_int_vci_tgt_mdma.print_trace(mdma_signame.str());
+
+                if( clusters[x][y]->signal_proc_it[l].read() )
+                    std::cout << "### IRQ_PROC_" << std::dec
+                              << x << "_" << y << "_" << l << " ACTIVE" << std::endl;
             }
 
@@ -1521,6 +1501,6 @@
 //              clusters[0][0]->signal_ram_vci_ini_iobx.print_trace( "[SIG]IOB0_RAM_INI");
 
-//              signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI");
-//              signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT");
+                signal_vci_ini_iob0.print_trace("[SIG]IOB0_IOX_INI");
+                signal_vci_tgt_iob0.print_trace("[SIG]IOB0_IOX_TGT");
 
 //              cdma->print_trace();
@@ -1528,7 +1508,4 @@
 //              signal_vci_ini_cdma.print_trace("[SIG]IOX_CDMA_INI");
 
-//              brom->print_trace();
-//              signal_vci_tgt_brom.print_trace("[SIG]IOX_BROM_TGT");
-
 //              mtty->print_trace();
 //              signal_vci_tgt_mtty.print_trace("[SIG]IOX_MTTY_TGT");
@@ -1538,6 +1515,6 @@
                 signal_vci_ini_bdev.print_trace("[SIG]BDEV_INI");
 
-//              mnic->print_trace();
-//              signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
+                mnic->print_trace();
+                signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
 
 //              fbuf->print_trace();
