Index: trunk/platforms/tsar_generic_xbar/scripts/run_simus.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/run_simus.py	(revision 752)
+++ trunk/platforms/tsar_generic_xbar/scripts/run_simus.py	(revision 779)
@@ -6,30 +6,61 @@
 import shutil
 
-#TODO: recopier les fichiers d'entrees dans le script en fonction de l'appli selectionnee
+#TODO (?): recopier les fichiers d'entrees dans le script en fonction de l'appli selectionnee
 # Par exemple, tk14.O pour LU, img.raw pour ep_filter, etc.
 
-data_dir = 'data'
-log_init_name = 'log_init_'
-log_term_name = 'log_term_'
-
-
+
+# User parameters
 nb_procs = [ 4 ]
 #nb_procs = [ 16, 32, 64, 128, 256 ]
-rerun_stats = True
+rerun_stats = False
 use_omp = False
+protocol = 'rwt'
 
 #apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga', 'kmeans' ]
 #apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga' ]
-
+apps = [ 'radix' ]
+
+
+# Variables which could be changed but ought not to because they are reflected in the create_graphs.py script
+data_dir = 'data'
+log_init_name = protocol + '_stdo_'
+log_term_name = protocol + '_term_'
+
+# Global Variables
 
 all_apps = [ 'cholesky', 'fft', 'fft_ga', 'filter', 'filt_ga', 'histogram', 'kmeans', 'lu', 'mandel', 'mat_mult', 'pca', 'radix', 'radix_ga', 'showimg', ]
 # to come: 'barnes', 'fmm', 'ocean', 'raytrace', 'radiosity', 'waters', 'watern'
 
-apps = [ 'cholesky' ]
-
-
+all_protocols = [ 'dhccp', 'rwt', 'mesi' ]
+
+top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
 config_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.py")
+
+scripts_path       = os.path.join(top_path, 'scripts')
+almos_path         = os.path.join(top_path, 'almos')
+soclib_conf_name   = os.path.join(top_path, "soclib.conf")
+topcell_name       = os.path.join(top_path, "top.cpp")
+arch_info_name     = os.path.join(almos_path, "arch-info-gen.info")
+arch_info_bib_name = os.path.join(almos_path, 'arch-info.bib')
+hdd_img_file_name  = os.path.join(almos_path, "hdd-img.bin")
+shrc_file_name     = os.path.join(almos_path, "shrc")
+hard_config_name   = os.path.join(almos_path, "hard_config.h")
+
+
+# Checks
+if protocol not in all_protocols:
+    help_str = '''
+*** Error: variable protocol has an unsupported value
+'''
+    print help_str
+    sys.exit()
+
+for the_app in apps:
+    if the_app not in all_apps:
+        print "*** Error: application %s is not defined" % (the_app)
+        sys.exit()
+
 if not os.path.isfile(config_name):
-   help_str = '''
+    help_str = '''
 You should create a file named config.py in this directory with the following definitions:
  - apps_dir:      path to almos-tsar-mipsel/apps directory
@@ -38,20 +69,36 @@
 *** Stopping execution
 '''
-   print help_str
-   sys.exit()
-
+    print help_str
+    sys.exit()
+
+# Loading config
 exec(file(config_name))
 
-top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
-
-scripts_path       = os.path.join(top_path, 'scripts')
-almos_path         = os.path.join(top_path, 'almos')
-arch_info_name     = os.path.join(almos_path, "arch-info-gen.info")
-arch_info_bib_name = os.path.join(almos_path, 'arch-info.bib')
-hdd_img_file_name  = os.path.join(almos_path, "hdd-img.bin")
-shrc_file_name     = os.path.join(almos_path, "shrc")
-hard_config_name   = os.path.join(almos_path, "hard_config.h")
-
-topcell_name = "top.cpp"
+# Check that variables and paths exist
+for var in [ 'apps_dir', 'almos_src_dir', 'hdd_img_name', 'tsar_dir' ]:
+    if eval(var) == "":
+        print "*** Error: variable %s not defined in config file" % (var)
+        sys.exit()
+    if not os.path.exists(eval(var)):
+        print "*** Error: variable %s does not define a valid path" % (var)
+        sys.exit()
+
+if protocol == "rwt":
+    if rwt_dir == "":
+        print "*** Error: variable rwt_dir not defined in config file"
+        sys.exit()
+    if not os.path.exists(rwt_dir):
+        print "*** Error: variable rwt_dir does not define a valid path"
+        sys.exit()
+
+if protocol == "mesi":
+    if mesi_dir == "":
+        print "*** Error: variable mesi_dir not defined in config file"
+        sys.exit()
+    if not os.path.exists(mesi_dir):
+        print "*** Error: variable mesi_dir does not define a valid path"
+        sys.exit()
+
+
 
 
@@ -65,27 +112,79 @@
 #splash_app_dir['watern'] = 'apps/water-nsquared'
 #splash_app_dir['waters'] = 'apps/water-spatial'
-#
-#splash_app_dir['cholesky'] = 'kernels/cholesky'
-#splash_app_dir['fft'] = 'kernels/fft'
-#splash_app_dir['lu'] = 'kernels/lu/contiguous_blocks'
-#splash_app_dir['radix'] = 'kernels/radix'
-#
-#splash_ga_app_dir = {}
-#splash_ga_app_dir['radix_ga'] = 'apps/radix'
-#splash_ga_app_dir['fft_ga'] = 'apps/fft'
 
 
 def get_x_y(nb_procs):
-   x = 1
-   y = 1
-   to_x = True
-   while (x * y * 4 < nb_procs):
-      if to_x:
-         x = x * 2
-      else:
-         y = y * 2
-      to_x = not to_x
-   return x, y
-
+    x = 1
+    y = 1
+    to_x = True
+    while (x * y * 4 < nb_procs):
+        if to_x:
+            x = x * 2
+        else:
+            y = y * 2
+        to_x = not to_x
+    return x, y
+
+
+def gen_soclib_conf():
+
+    if os.path.isfile(soclib_conf_name):
+        print "Updating file %s" % (soclib_conf_name)
+        # First, remove lines containing "addDescPath"
+        f = open(soclib_conf_name, "r")
+        lines = f.readlines()
+        f.close()
+
+        f = open(soclib_conf_name, "w")
+
+        for line in lines:
+            if not ("addDescPath" in line):
+                f.write(line)
+        f.close()
+    else:
+        print "Creating file %s" % (soclib_conf_name)
+        f = open(soclib_conf_name, "w")
+        f.close()
+
+    # Defining common and specific modules 
+    common_modules = [
+            'lib/generic_llsc_global_table',
+            'modules/dspin_router_tsar', 
+            'modules/sdmmc',
+            'modules/vci_block_device_tsar',
+            'modules/vci_ethernet_tsar',
+            'modules/vci_io_bridge',
+            'modules/vci_iox_network',
+            'modules/vci_spi'
+            'platforms/tsar_generic_xbar/tsar_xbar_cluster'
+    ]
+
+    specific_modules = [
+            'communication',
+            'lib/generic_cache_tsar',
+            'modules/vci_cc_vcache_wrapper',
+            'modules/vci_mem_cache'
+    ]
+
+    f = open(soclib_conf_name, "a")
+    # Adding common modules
+    for common_module in common_modules:
+        f.write("config.addDescPath(\"%s/%s\")\n" % (tsar_dir, common_module))
+    #f.write("\n")
+
+    if protocol == "dhccp":
+        arch_dir = tsar_dir
+    elif protocol == "rwt":
+        arch_dir = rwt_dir
+    elif protocol == "mesi":
+        archi_dir = mesi_dir
+    else:
+        assert(False)
+
+    for specific_module in specific_modules:
+        f.write("config.addDescPath(\"%s/%s\")\n" % (arch_dir, specific_module))
+
+    #f.write("\n")
+    f.close()
 
 
@@ -97,20 +196,20 @@
 #define _HD_CONFIG_H
 
-#define	 X_SIZE              %(x)d
-#define	 Y_SIZE              %(y)d
-#define	 NB_CLUSTERS         %(nb_clus)d
-#define	 NB_PROCS_MAX        4
-#define	 NB_TASKS_MAX        8
-
-#define	 NB_TIM_CHANNELS     32
-#define	 NB_DMA_CHANNELS     1
-
-#define	 NB_TTY_CHANNELS     4
-#define	 NB_IOC_CHANNELS     1
-#define	 NB_NIC_CHANNELS     0
-#define	 NB_CMA_CHANNELS     0
-
-#define	 USE_XICU            1
-#define	 IOMMU_ACTIVE        0
+#define X_SIZE              %(x)d
+#define Y_SIZE              %(y)d
+#define NB_CLUSTERS         %(nb_clus)d
+#define NB_PROCS_MAX        4
+#define NB_TASKS_MAX        8
+
+#define NB_TIM_CHANNELS     32
+#define NB_DMA_CHANNELS     1
+
+#define NB_TTY_CHANNELS     4
+#define NB_IOC_CHANNELS     1
+#define NB_NIC_CHANNELS     0
+#define NB_CMA_CHANNELS     0
+
+#define USE_XICU            1
+#define IOMMU_ACTIVE        0
 
 #define   IRQ_PER_PROCESSOR   1
@@ -194,11 +293,4 @@
    #   subprocess.call([ 'make' ])
 
-   #elif app_name in splash2_ga:
-   #   print "make clean"
-   #   subprocess.call([ 'make', 'clean' ])
-
-   #   print "make"
-   #   subprocess.call([ 'make' ])
-
    #else:
    #   print "make clean"
@@ -212,5 +304,7 @@
  
    print "make TARGET=tsar"
-   subprocess.call([ 'make', 'TARGET=tsar' ])
+   retval = subprocess.call([ 'make', 'TARGET=tsar' ])
+   if retval != 0:
+       sys.exit()
    
    # Creation/Modification du shrc de almos
@@ -281,4 +375,5 @@
 
 gen_sym_links()
+gen_soclib_conf()
 
 for i in nb_procs:
@@ -293,6 +388,8 @@
    subprocess.call([ 'touch', topcell_name ])
    print "make"
-   subprocess.call([ 'make' ])
-   
+   retval = subprocess.call([ 'make' ])
+   if retval != 0:
+       sys.exit()
+
    for app in apps:
       print "cd", top_path
