Index: trunk/platforms/tsar_generic_iob/top.cpp
===================================================================
--- trunk/platforms/tsar_generic_iob/top.cpp	(revision 1062)
+++ trunk/platforms/tsar_generic_iob/top.cpp	(revision 1064)
@@ -119,6 +119,6 @@
 //
 // The NIC controler has one VCI target port, and one VCI initiator port,
-// but it uses two different LOCAL_SRCID values to distinguish TX and TX
-// transactions, because there is not enough bits in 4 bits TRDID field.
+// but it uses several LOCAL_SRCID values to distinguish channels.
+// because there is not enough bits in 4 bits TRDID field.
 /////////////////////////////////////////////////////////////////////////
 
@@ -221,7 +221,4 @@
 #define MEMC_SETS             256
 
-#define MNIC_MAC_4            0x33445566        // 32 LSB bits
-#define MNIC_MAC_2            0X1122            // 16 MSB bits
-
 #define L1_IWAYS              4
 #define L1_ISETS              64
@@ -261,14 +258,20 @@
 // - The 8 MSB bits define the cluster index.
 // - The 6  LSB bits define the local index.
+//
 // Two different initiators cannot have the same SRCID, but a given
 // initiator can have two alias SRCIDs:
 // - Internal initiators (procs, mdma) are replicated in all clusters,
 //   and each initiator has one single SRCID.
-// - External initiators (disk, cdma) are not replicated, but can be
-//   accessed in 2 clusters : cluster_iob0 and cluster_iob1.
+// - External initiators (DISK,IOPI,MNIC) are not replicated, but can 
+//   be accessed in 2 clusters : cluster_iob0 and cluster_iob1.
 //   They have the same local index, but two different cluster indexes.
+//   As cluster_iob0 and cluster_iob1 contain both internal initiators
+//   and external initiators, they must have different local indexes.
+// - Moreover, the MNIC has one single initiator port but can starts
+//   64 parallel transactions: 8 channels * 4 bursts * 2 directions.
+//   The direction and burst index are specified in the TRDID field,
+//   but the channel is specified in the SRCID field (8 values for
+//   one single port).
 //
-// As cluster_iob0 and cluster_iob1 contain both internal initiators
-// and external initiators, they must have different local indexes.
 // Consequence: For a local interconnect, the INI_ID port index
 // is NOT equal to the SRCID local index, and the local interconnect
@@ -276,12 +279,19 @@
 ////////////////////////////////////////////////////////////////////////
 
-#define PROC_LOCAL_SRCID             0x0    // from 0 to 7
-#define MDMA_LOCAL_SRCID             0x8
-#define IOBX_LOCAL_SRCID             0x9
-#define MEMC_LOCAL_SRCID             0xA
-#define DISK_LOCAL_SRCID             0xC
-#define IOPI_LOCAL_SRCID             0xD
-#define MNRX_LOCAL_SRCID             0xE    // NIC_RX transactions
-#define MNTX_LOCAL_SRCID             0xF    // NIC_TX transactions
+#define PROC_LOCAL_SRCID             0x00    // from 0x0 to 0x7
+#define MDMA_LOCAL_SRCID             0x08
+#define IOBX_LOCAL_SRCID             0x09
+#define MEMC_LOCAL_SRCID             0x0A
+#define DISK_LOCAL_SRCID             0x0C
+#define IOPI_LOCAL_SRCID             0x0D
+
+#define MNI0_LOCAL_SRCID             0x10   // NIC channel 0
+#define MNI1_LOCAL_SRCID             0x11   // NIC channel 1
+#define MNI2_LOCAL_SRCID             0x12   // NIC channel 2
+#define MNI3_LOCAL_SRCID             0x13   // NIC channel 3
+#define MNI4_LOCAL_SRCID             0x14   // NIC channel 4
+#define MNI5_LOCAL_SRCID             0x15   // NIC channel 5
+#define MNI6_LOCAL_SRCID             0x16   // NIC channel 6
+#define MNI7_LOCAL_SRCID             0x17   // NIC channel 7
 
 ///////////////////////////////////////////////////////////////////////
@@ -338,9 +348,15 @@
    char     disk_name[256]   = DISK_IMAGE_NAME;         // pathname: disk image
    ssize_t  threads          = 1;                       // simulator's threads number
-   bool     debug_ok         = false;                   // trace activated
+   bool     debug_ok         = false;                   // trace activated when non-zero
+   uint32_t debug_from       = 0;                       // trace start cycle
+   uint32_t debug_order      = 0;                       // ln2( trace_period )
+   uint32_t debug_mask       = 0;                       // trace_period - 1
    uint32_t debug_memc_id    = 0xFFFFFFFF;              // index of traced memc
    uint32_t debug_proc_id    = 0xFFFFFFFF;              // index of traced proc
-   bool     debug_iob        = false;                   // trace iob0 & iob1 when true
-   uint32_t debug_from       = 0;                       // trace start cycle
+   bool     debug_iob        = false;                   // trace iob0 (& iob1) when true
+   bool     debug_ioc        = false;                   // trace disk when true
+   bool     debug_nic        = false;                   // trace mnic when true
+   bool     debug_txt        = false;                   // trace mtty when true
+   bool     debug_fbf        = false;                   // trace fbuf when true
    uint32_t frozen_cycles    = MAX_FROZEN_CYCLES;       // monitoring frozen processor
    size_t   cluster_iob0     = cluster(0,0);            // cluster containing IOB0
@@ -375,4 +391,9 @@
             debug_ok = true;
             debug_from = atoi(argv[n+1]);
+         }
+         else if ((strcmp(argv[n],"-ORDER") == 0) && (n+1<argc) )
+         {
+            debug_order = atoi(argv[n+1]);
+            debug_mask  = (1<<debug_order) - 1;
          }
          else if ((strcmp(argv[n],"-DISK") == 0) && (n+1<argc) )
@@ -397,4 +418,20 @@
          {
             debug_iob = atoi(argv[n+1]);
+         }
+         else if ((strcmp(argv[n],"-IOC") == 0) && (n+1<argc) )
+         {
+            debug_ioc = atoi(argv[n+1]);
+         }
+         else if ((strcmp(argv[n],"-NIC") == 0) && (n+1<argc) )
+         {
+            debug_nic = atoi(argv[n+1]);
+         }
+         else if ((strcmp(argv[n],"-TXT") == 0) && (n+1<argc) )
+         {
+            debug_txt = atoi(argv[n+1]);
+         }
+         else if ((strcmp(argv[n],"-FBF") == 0) && (n+1<argc) )
+         {
+            debug_fbf = atoi(argv[n+1]);
          }
          else if ((strcmp(argv[n],"-PROCID") == 0) && (n+1<argc) )
@@ -434,4 +471,8 @@
             std::cout << "     - PROCID index_proc_to_be_traced" << std::endl;
             std::cout << "     - IOB    non_zero_value" << std::endl;
+            std::cout << "     - IOC    non_zero_value" << std::endl;
+            std::cout << "     - NIC    non_zero_value" << std::endl;
+            std::cout << "     - TXT    non_zero_value" << std::endl;
+            std::cout << "     - FBF    non_zero_value" << std::endl;
             exit(0);
          }
@@ -464,5 +505,5 @@
    "Error in tsar_generic_iob : NB_TXT_CHANNELS parameter cannot be larger than 16" );
 
-   assert( (NB_NIC_CHANNELS <= 4) and
+   assert( (NB_NIC_CHANNELS <= 8) and
    "Error in tsar_generic_iob :  NB_NIC_CHANNELS parameter cannot be larger than 4" );
 
@@ -658,5 +699,4 @@
     maptab_ram.srcid_map( IntTab( cluster_iob0, DISK_LOCAL_SRCID ),
                           IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
-
     maptab_ram.srcid_map( IntTab( cluster_iob1, DISK_LOCAL_SRCID ),
                           IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
@@ -664,23 +704,49 @@
     maptab_ram.srcid_map( IntTab( cluster_iob0, IOPI_LOCAL_SRCID ),
                           IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
-
     maptab_ram.srcid_map( IntTab( cluster_iob1, IOPI_LOCAL_SRCID ),
                           IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
 
-    maptab_ram.srcid_map( IntTab( cluster_iob0, MNRX_LOCAL_SRCID ),
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI0_LOCAL_SRCID ),
                           IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
-
-    maptab_ram.srcid_map( IntTab( cluster_iob1, MNRX_LOCAL_SRCID ),
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI0_LOCAL_SRCID ),
                           IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
 
-    maptab_ram.srcid_map( IntTab( cluster_iob0, MNTX_LOCAL_SRCID ),
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI1_LOCAL_SRCID ),
                           IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
-
-    maptab_ram.srcid_map( IntTab( cluster_iob1, MNTX_LOCAL_SRCID ),
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI1_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI2_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI2_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI3_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI3_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI4_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI4_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI5_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI5_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI6_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI6_LOCAL_SRCID ),
+                          IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
+
+    maptab_ram.srcid_map( IntTab( cluster_iob0, MNI7_LOCAL_SRCID ),
+                          IntTab( cluster_iob0, RAM_IOBX_INI_ID ) );
+    maptab_ram.srcid_map( IntTab( cluster_iob1, MNI7_LOCAL_SRCID ),
                           IntTab( cluster_iob1, RAM_IOBX_INI_ID ) );
 
     maptab_ram.srcid_map( IntTab( cluster_iob0, MEMC_LOCAL_SRCID ),
                           IntTab( cluster_iob0, RAM_MEMC_INI_ID ) );
-
     maptab_ram.srcid_map( IntTab( cluster_iob1, MEMC_LOCAL_SRCID ),
                           IntTab( cluster_iob1, RAM_MEMC_INI_ID ) );
@@ -798,8 +864,19 @@
                           IntTab( 0, IOX_IOB0_INI_ID  ) );
 
-    maptab_iox.srcid_map( IntTab( 0, MNRX_LOCAL_SRCID ) ,
+    maptab_iox.srcid_map( IntTab( 0, MNI0_LOCAL_SRCID ) ,
                           IntTab( 0, IOX_MNIC_INI_ID  ) );
-
-    maptab_iox.srcid_map( IntTab( 0, MNTX_LOCAL_SRCID ) ,
+    maptab_iox.srcid_map( IntTab( 0, MNI1_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI2_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI3_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI4_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI5_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI6_LOCAL_SRCID ) ,
+                          IntTab( 0, IOX_MNIC_INI_ID  ) );
+    maptab_iox.srcid_map( IntTab( 0, MNI7_LOCAL_SRCID ) ,
                           IntTab( 0, IOX_MNIC_INI_ID  ) );
 
@@ -1016,11 +1093,8 @@
     mnic = new VciMasterNic<vci_param_ext>( "mnic",
                                             maptab_iox,
-                                            IntTab(0, MNRX_LOCAL_SRCID), 
-                                            IntTab(0, MNTX_LOCAL_SRCID), 
+                                            IntTab(0, MNI0_LOCAL_SRCID), 
                                             IntTab(0, IOX_MNIC_TGT_ID),
                                             NB_NIC_CHANNELS,
-                                            64,               // burst length
-                                            MNIC_MAC_4,       // default MAC address (LSB)
-                                            MNIC_MAC_2,       // default MAC address (MSB)
+                                            6,                // burst order
                                             1,                // NIC_MODE_SYNTHESIS
                                             12);              // INTER_FRAME_GAP
@@ -1656,16 +1730,16 @@
 
         // Monitor a specific address for one L1 data cache
-        // clusters[0][1]->proc[0]->cache_monitor( 0x10003ddb4ULL );
+        // clusters[0][0]->proc[0]->cache_monitor( 0x100055574ULL );
 
         // Monitor a specific address for L2 cache (single word if second argument true)
-        // clusters[0][0]->memc->cache_monitor( 0xcfe90ULL , true );
+        clusters[0][0]->memc->cache_monitor( 0x001EE87CULL , true );
 
         // Monitor a specific address for one XRAM
-        // clusters[0][1]->xram->start_monitor( 0x100094000ULL , 64);
+        clusters[0][0]->xram->start_monitor( 0x001EE87CULL , 4 );
 
         // Monitor the MMU  for one L1 cache
         // clusters[0][0]->proc[0]->mmu_monitor();
 
-        if ( debug_ok and (n > debug_from) )
+        if ( debug_ok and (n >= debug_from) and ((n & debug_mask) == 0) )
         {
             std::cout << "****************** cycle " << std::dec << n ;
@@ -1689,9 +1763,9 @@
                 size_t y          = cluster_xy & 0xF;
 /*
-            size_t l          = 0;
-            size_t x          = 0;
-            size_t y;
+            size_t l;
+            size_t x = 0;
+            size_t y = 0;
             
-            for( y = 0 ; y < 2 ; y++ )
+            for( l = 0 ; l < 2 ; l++ )
             {
 */
@@ -1762,41 +1836,18 @@
             if ( debug_iob )
             {
-//              clusters[0][0]->iob->print_trace();
-//              clusters[0][0]->signal_int_vci_tgt_iobx.print_trace( "[SIG]IOB0_INT_TGT");
-//              clusters[0][0]->signal_int_vci_ini_iobx.print_trace( "[SIG]IOB0_INT_INI");
-//              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");
-
-//              brom->print_trace();
-//              signal_vci_tgt_brom.print_trace("[SIG]BROM_TGT");
-
-//              mtty->print_trace( 1 );
-//              signal_vci_tgt_mtty.print_trace("[SIG]MTTY_TGT");
-
-                disk->print_trace();
-                signal_vci_tgt_disk.print_trace("[SIG]DISK_TGT");
-                signal_vci_ini_disk.print_trace("[SIG]DISK_INI");
-
-#if ( USE_IOC_SDC )
-//              card->print_trace();
-#endif
-
-//              mnic->print_trace( 0 );
-//              signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
-//              signal_vci_ini_mnic.print_trace("[SIG]MNIC_INI");
-
-//              fbuf->print_trace();
-//              signal_vci_tgt_fbuf.print_trace("[SIG]FBUF_TGT");
-
-                iopi->print_trace();
-                signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI");
-                signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT");
-
-//              iox_network->print_trace();
-
-                // interrupts
-                if ( signal_irq_disk.read() )      
-                std::cout << "### IRQ_DISK ACTIVE" << std::endl;
+                clusters[0][0]->iob->print_trace();
+                clusters[0][0]->signal_int_vci_tgt_iobx.print_trace( "[SIG]IOB0_INT_TGT");
+                clusters[0][0]->signal_int_vci_ini_iobx.print_trace( "[SIG]IOB0_INT_INI");
+                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");
+
+                iox_network->print_trace();
+            }
+
+            if ( debug_txt )
+            {
+                mtty->print_trace( 1 );
+                signal_vci_tgt_mtty.print_trace("[SIG]MTTY_TGT");
 
                 for( size_t k = 0 ; k < NB_TXT_CHANNELS ; k++ )
@@ -1808,15 +1859,53 @@
                     std::cout << "### IRQ_MTTY_TX[" << k << "] ACTIVE" << std::endl;
                 }
-
-                for( size_t k = 0 ; k < NB_NIC_CHANNELS ; k++ )
+            }
+
+            if ( debug_ioc )
+            {
+                disk->print_trace();
+                signal_vci_tgt_disk.print_trace("[SIG]DISK_TGT");
+                signal_vci_ini_disk.print_trace("[SIG]DISK_INI");
+
+#if ( USE_IOC_SDC )
+                card->print_trace();
+#endif
+                if ( signal_irq_disk.read() )      
+                std::cout << "### IRQ_DISK ACTIVE" << std::endl;
+            }
+
+            if ( debug_nic )
+            {
+                mnic->print_trace( 
+                                   NIC_MODE_TX_DMA         | 
+                                   NIC_MODE_RX_DMA         | 
+                                   NIC_MODE_RX_CHBUF       |
+                                   NIC_MODE_TX_CHBUF       |
+                                   NIC_MODE_VCI_CMD        |
+                                   NIC_MODE_VCI_RSP        
+                                 );
+
+                signal_vci_tgt_mnic.print_trace("[SIG]MNIC_TGT");
+                signal_vci_ini_mnic.print_trace("[SIG]MNIC_INI");
+
+                for( size_t k = 0 ; k < NB_TXT_CHANNELS ; k++ )
                 {
-                    if ( signal_irq_mnic_rx[k].read() ) 
-                    std::cout << "### IRQ_MNIC_RX[" << k << "] ACTIVE" << std::endl;
-
-                    if ( signal_irq_mnic_tx[k].read() ) 
-                    std::cout << "### IRQ_MNIC_TX[" << k << "] ACTIVE" << std::endl;
+                    if ( signal_irq_mtty_rx[k].read() ) 
+                    std::cout << "### IRQ_MTTY_RX[" << k << "] ACTIVE" << std::endl;
+
+                    if ( signal_irq_mtty_tx[k].read() ) 
+                    std::cout << "### IRQ_MTTY_TX[" << k << "] ACTIVE" << std::endl;
                 }
             }
-        }
+
+            if ( debug_fbf )
+            {
+                fbuf->print_trace();
+                signal_vci_tgt_fbuf.print_trace("[SIG]FBUF_TGT");
+  
+                iopi->print_trace();
+                signal_vci_ini_iopi.print_trace("[SIG]IOPI_INI");
+                signal_vci_tgt_iopi.print_trace("[SIG]IOPI_TGT");
+            }
+        }  // end if debug
 
         sc_start(sc_core::sc_time(simul_period, SC_NS));
