Index: trunk/platforms/tsar_generic_xbar/scripts/counter_defs.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/counter_defs.py	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/counter_defs.py	(revision 706)
@@ -0,0 +1,177 @@
+
+individual_metrics = [ 'req_trig_update', 'local_update', 'remote_update', 'update_cost', 'req_trig_m_inv', 'local_m_inv', 'remote_m_inv', 'm_inv_cost', 'broadcast', 'total_update', 'total_m_inv' ]
+grouped_metrics = [ 'update_cost', 'm_inv_cost' ]
+stacked_metrics = [ 'nonwrite_broadcast', 'write_broadcast', 'local_m_inv', 'remote_m_inv', 'local_update', 'remote_update' ]
+
+m_app_name = {}
+m_app_name['mandel'] = "Mandelbrot"
+m_app_name['filter'] = "Filter"
+m_app_name['filt_ga'] = "Filter (opt.)"
+m_app_name['histogram'] = "Histogram"
+m_app_name['kmeans'] = "Kmeans"
+m_app_name['barnes'] = "Barnes"
+m_app_name['fmm'] = "FMM"
+m_app_name['ocean'] = "Ocean"
+m_app_name['raytrace'] = "Raytrace"
+m_app_name['radiosity'] = "Radiosity"
+m_app_name['waters'] = "Water Sp."
+m_app_name['watern'] = "Water Nsq."
+m_app_name['cholesky'] = "Cholesky"
+m_app_name['lu'] = "LU"
+m_app_name['fft'] = "FFT"
+m_app_name['radix'] = "Radix"
+m_app_name['fft_ga'] = "FFT"
+m_app_name['radix_ga'] = "Radix"
+
+m_metric_id = {}
+m_metric_tag = {}
+m_metric_tag['counter_reset']      = "[000]"
+m_metric_tag['ncycles']            = "[001]"
+m_metric_tag['local_read']         = "[002]"
+m_metric_tag['remote_read']        = "[003]"
+m_metric_tag['read_cost']          = "[004]"
+m_metric_tag['local_write']        = "[005]"
+m_metric_tag['remote_write']       = "[006]"
+m_metric_tag['write_flits_local']  = "[007]"
+m_metric_tag['write_flits_remote'] = "[008]"
+m_metric_tag['write_cost']         = "[009]"
+m_metric_tag['local_ll']           = "[010]"
+m_metric_tag['remote_ll']          = "[011]"
+m_metric_tag['ll_cost']            = "[012]"
+m_metric_tag['local_sc']           = "[013]"
+m_metric_tag['remote_sc']          = "[014]"
+m_metric_tag['sc_cost']            = "[015]"
+m_metric_tag['local_cas']          = "[016]"
+m_metric_tag['remote_cas']         = "[017]"
+m_metric_tag['cas_cost']           = "[018]"
+m_metric_tag['req_trig_update']    = "[019]"
+m_metric_tag['local_update']       = "[020]"
+m_metric_tag['remote_update']      = "[021]"
+m_metric_tag['update_cost']        = "[022]"
+m_metric_tag['req_trig_m_inv']     = "[023]"
+m_metric_tag['local_m_inv']        = "[024]"
+m_metric_tag['remote_m_inv']       = "[025]"
+m_metric_tag['m_inv_cost']         = "[026]"
+m_metric_tag['broadcast']          = "[027]"
+m_metric_tag['local_cleanup']      = "[028]"
+m_metric_tag['remote_cleanup']     = "[029]"
+m_metric_tag['cleanup_cost']       = "[030]"
+m_metric_tag['nb_read_miss']       = "[031]"
+m_metric_tag['write_miss']         = "[032]"
+m_metric_tag['write_dirty']        = "[033]"
+m_metric_tag['read_hit_trt']       = "[034]" # Reads blocked by a hit in the TRT
+m_metric_tag['trans_full_trt']     = "[035]" # Transactions blocked because the TRT is full
+m_metric_tag['put']                = "[036]"
+m_metric_tag['get']                = "[037]"
+m_metric_tag['write_broadcast']    = "[038]"
+
+m_metric_tag['total_read']         = "[040]"
+m_metric_tag['total_write']        = "[041]"
+m_metric_tag['total_ll']           = "[042]"
+m_metric_tag['total_sc']           = "[043]"
+m_metric_tag['total_cas']          = "[044]"
+m_metric_tag['total_update']       = "[045]"
+m_metric_tag['total_m_inv']        = "[046]"
+m_metric_tag['total_cleanup']      = "[047]"
+m_metric_tag['total_direct']       = "[048]"
+
+m_metric_tag['nonwrite_broadcast'] = "[050]"
+m_metric_tag['broadcast_cost']     = "[051]"
+m_metric_tag['direct_cost']        = "[052]"
+m_metric_tag['total_stacked']      = "|060]"
+
+all_metrics = m_metric_tag.keys()
+all_tags = m_metric_tag.values()
+
+m_metric_name = {}
+m_metric_name['counter_reset']      = "Counters reset at cycle"
+m_metric_name['ncycles']            = "Number of Cycles"
+m_metric_name['local_read']         = "Number of Local Reads (Miss in L1)"
+m_metric_name['remote_read']        = "Number of Remote Reads (Miss in L1)"
+m_metric_name['read_cost']          = "Read Cost"
+m_metric_name['local_write']        = "Number of Local Writes"
+m_metric_name['remote_write']       = "Number of Remote Writes"
+m_metric_name['write_flits_local']  = "Number of Local Write Flits"
+m_metric_name['write_flits_remote'] = "Number of Remote Write Flits"
+m_metric_name['write_cost']         = "Write Cost"
+m_metric_name['local_ll']           = "Number of Local LL"
+m_metric_name['remote_ll']          = "Number of Remote LL"
+m_metric_name['ll_cost']            = "LL Cost"
+m_metric_name['local_sc']           = "Number of Local SC"
+m_metric_name['remote_sc']          = "Number of Remote SC"
+m_metric_name['sc_cost']            = "SC Cost"
+m_metric_name['local_cas']          = "Number of Local CAS"
+m_metric_name['remote_cas']         = "Number of Remote CAS"
+m_metric_name['cas_cost']           = "CAS Cost"
+m_metric_name['req_trig_update']    = "Number of Requests Triggering an Update"
+m_metric_name['local_update']       = "Number of Local Updates"
+m_metric_name['remote_update']      = "Number of Remote Updates"
+m_metric_name['update_cost']        = "Update Cost"
+m_metric_name['req_trig_m_inv']     = "Number of Requests Triggering a M.inv"
+m_metric_name['local_m_inv']        = "Number of Local Multi Inval"
+m_metric_name['remote_m_inv']       = "Number of Remote Multi Inval"
+m_metric_name['m_inv_cost']         = "Multi Inval Cost"
+m_metric_name['broadcast']          = "Number of Broadcasts"
+m_metric_name['broadcast']          = "Total Number of Broadcasts"
+m_metric_name['local_cleanup']      = "Number of Local Cleanups"
+m_metric_name['remote_cleanup']     = "Number of Remote Cleanups"
+m_metric_name['cleanup_cost']       = "Cleanup Cost"
+m_metric_name['nb_read_miss']       = "Number of Read Miss (in L2)"
+m_metric_name['write_miss']         = "Number of Write Miss (in L2)"
+m_metric_name['write_dirty']        = "Number of Write Dirty (from L2 to Memory)"
+m_metric_name['read_hit_trt']       = "Number of Reads Blocked by a Hit in TRT" # Reads blocked by a hit in the TRT
+m_metric_name['trans_full_trt']     = "Number of Transactions Blocked because the TRT is Full" # Transactions blocked because the TRT is full
+m_metric_name['put']                = "Number of PUT to Memory"
+m_metric_name['get']                = "Number of GET from Memory"
+m_metric_name['write_broadcast']    = "Number of Broadcasts Trig. by Writes"
+
+m_metric_name['total_read']         = "Total Number of Reads"
+m_metric_name['total_write']        = "Total Number of Writes"
+m_metric_name['total_ll']           = "Total Number of LL"
+m_metric_name['total_sc']           = "Total Number of SC"
+m_metric_name['total_cas']          = "Total Number of CAS"
+m_metric_name['total_update']       = "Total Number of Updates"
+m_metric_name['total_m_inv']        = "Total Number of Multi Inval"
+m_metric_name['total_cleanup']      = "Total Number of Cleanups"
+m_metric_name['total_direct']       = "Total Number of Direct Requests"
+m_metric_name['nonwrite_broadcast'] = "Number of Broadcasts not Trig. by Writes"
+m_metric_name['broadcast_cost']     = "Broadcast Cost"
+m_metric_name['direct_cost']        = "Direct Requests Cost"
+m_metric_name['total_stacked']      = "??" # Normalization factor
+
+
+
+m_metric_norm = {} # "N" (None), P (#procs), C (#cycles), W (#writes), R (#reads), D (#direct req -- R ou W), n (value with n proc(s))
+m_metric_norm['req_trig_update']   = "C"
+m_metric_norm['local_update']      = "C"
+m_metric_norm['remote_update']     = "C"
+m_metric_norm['update_cost']       = "C"
+m_metric_norm['req_trig_m_inv']    = "C"
+m_metric_norm['local_m_inv']       = "C"
+m_metric_norm['remote_m_inv']      = "C"
+m_metric_norm['m_inv_cost']        = "C"
+m_metric_norm['broadcast']         = "C"
+m_metric_norm['total_update']      = "C"
+m_metric_norm['total_m_inv']       = "C"
+
+m_norm_factor_name = {}
+m_norm_factor_name['N']   = ""
+m_norm_factor_name['P']   = "Normalized w.r.t.\\nthe Number of Processors"
+m_norm_factor_name['C']   = "Normalized w.r.t.\\nthe Number of Cycles (x 1000)"
+m_norm_factor_name['W']   = "Normalized w.r.t.\\nthe Number of Writes"
+m_norm_factor_name['R']   = "Normalized w.r.t.\\nthe Number of Reads"
+m_norm_factor_name['D']   = "Normalized w.r.t.\\nthe Number of Direct Requests"
+m_norm_factor_name['1']   = "Normalized w.r.t.\\nthe Value on 1 Processor"
+m_norm_factor_name['4']   = "Normalized w.r.t.\\nthe Value on 4 Processors"
+m_norm_factor_name['8']   = "Normalized w.r.t.\\nthe Value on 8 Processors"
+m_norm_factor_name['16']  = "Normalized w.r.t.\\nthe Value on 16 Processors"
+m_norm_factor_name['32']  = "Normalized w.r.t.\\nthe Value on 32 Processors"
+m_norm_factor_name['64']  = "Normalized w.r.t.\\nthe Value on 64 Processors"
+m_norm_factor_name['128'] = "Normalized w.r.t.\\nthe Value on 128 Processors"
+m_norm_factor_name['256'] = "Normalized w.r.t.\\nthe Value on 256 Processors"
+
+
+
+colors = [ "\"#008000\"", "\"#000080\"", "\"#BADC98\"", "\"#BA98DC\"", "\"#98DCBA\"", "\"#98BADC\"", "\"#BA9876\"", "\"#BA7698\"", "\"#98BA76\"", "\"#9876BA\"", "\"#76BA98\"", "\"#7698BA\"" ]
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/create_graphs.py	(revision 706)
@@ -0,0 +1,527 @@
+#!/usr/bin/python
+
+import subprocess
+import os
+import re
+
+
+
+apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga', 'kmeans' ]
+nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
+
+top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
+scripts_path = os.path.join(top_path, 'scripts')
+counter_defs_name = os.path.join(scripts_path, "counter_defs.py")
+
+exec(file(counter_defs_name))
+
+gen_dir = 'generated'
+graph_dir = 'graph'
+template_dir = 'templates'
+data_dir = 'data'
+
+log_init_name = 'log_init_'
+log_term_name = 'log_term_'
+
+coherence_tmpl = os.path.join(scripts_path, template_dir, 'coherence_template.gp') # 1 graph per appli
+speedup_tmpl   = os.path.join(scripts_path, template_dir, 'speedup_template.gp')
+metric_tmpl    = os.path.join(scripts_path, template_dir, 'metric_template.gp') # 1 graph per metric
+stacked_tmpl   = os.path.join(scripts_path, template_dir, 'stacked_template.gp')
+
+
+
+def create_file(name, content):
+   file = open(name, 'w')
+   file.write(content)
+   file.close()
+   
+def is_numeric(s):
+   try:
+      float(s)
+      return True
+   except ValueError:
+      return False
+
+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
+
+
+
+# We first fill the m_metric_id table
+for metric in all_metrics:
+   for tag in all_tags:
+      if m_metric_tag[metric] == tag:
+         m_metric_id[tag] = metric
+         break
+
+
+# We start by processing all the log files
+# Term files are processed for exec time only
+# Init files are processed for all metrics
+exec_time = {}
+metrics_val = {}
+for app in apps:
+   exec_time[app] = {}
+   metrics_val[app] = {}
+   for i in nb_procs:
+      metrics_val[app][i] = {}
+      log_init_file = os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
+      log_term_file = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
+
+      # Term
+      lines = open(log_term_file, 'r')
+      for line in lines:
+         tokens = line[:-1].split()
+         if len(tokens) > 0 and tokens[0] == "[ELAPSED2]":
+            exec_time[app][i] = int(tokens[len(tokens) - 1])
+
+      # Init files
+      lines = open(log_init_file, 'r')
+      for line in lines:
+         tokens = line[:-1].split()
+         if len(tokens) == 0:
+            continue
+         tag = tokens[0]
+         value = tokens[len(tokens) - 1]
+         pattern = re.compile('\[0[0-9][0-9]\]')
+         if pattern.match(tag):
+            metric = m_metric_id[tag]
+            if (not metrics_val[app][i].has_key(metric) or tag == "[000]" or tag == "[001]"):
+               # We don't add cycles of all Memcaches (they must be the same for all)
+               metrics_val[app][i][metric] = int(value)
+            else:
+               metrics_val[app][i][metric] += int(value)
+            
+# We make a 2nd pass to fill the derived fields, e.g. nb_total_updates
+for app in apps:
+   for i in nb_procs:
+      x, y = get_x_y(i)
+      metrics_val[app][i]['total_read']     = metrics_val[app][i]['local_read']    + metrics_val[app][i]['remote_read']
+      metrics_val[app][i]['total_write']    = metrics_val[app][i]['local_write']   + metrics_val[app][i]['remote_write']
+      metrics_val[app][i]['total_ll']       = metrics_val[app][i]['local_ll']      + metrics_val[app][i]['remote_ll']
+      metrics_val[app][i]['total_sc']       = metrics_val[app][i]['local_sc']      + metrics_val[app][i]['remote_sc']
+      metrics_val[app][i]['total_cas']      = metrics_val[app][i]['local_cas']     + metrics_val[app][i]['remote_cas']
+      metrics_val[app][i]['total_update']   = metrics_val[app][i]['local_update']  + metrics_val[app][i]['remote_update']
+      metrics_val[app][i]['total_m_inv']    = metrics_val[app][i]['local_m_inv']   + metrics_val[app][i]['remote_m_inv']
+      metrics_val[app][i]['total_cleanup']  = metrics_val[app][i]['local_cleanup'] + metrics_val[app][i]['remote_cleanup']
+      metrics_val[app][i]['total_direct']   = metrics_val[app][i]['total_read']    + metrics_val[app][i]['total_write']
+      metrics_val[app][i]['direct_cost']    = metrics_val[app][i]['read_cost']     + metrics_val[app][i]['write_cost']
+      metrics_val[app][i]['broadcast_cost'] = metrics_val[app][i]['broadcast'] * (x * y - 1)
+      if metrics_val[app][i]['broadcast'] < metrics_val[app][i]['write_broadcast']:
+         # test to patch a bug in mem_cache
+         metrics_val[app][i]['nonwrite_broadcast'] = 0
+      else:
+         metrics_val[app][i]['nonwrite_broadcast'] = metrics_val[app][i]['broadcast'] - metrics_val[app][i]['write_broadcast']
+
+      metrics_val[app][i]['total_stacked'] = 0
+      for stacked_metric in stacked_metrics:
+         metrics_val[app][i]['total_stacked'] += metrics_val[app][i][stacked_metric]
+
+            
+print "mkdir -p", os.path.join(scripts_path, gen_dir)
+subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, gen_dir) ])
+
+print "mkdir -p", os.path.join(scripts_path, graph_dir)
+subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, graph_dir) ])
+
+############################################################
+### Graph 1 : Coherence traffic Cost per application     ###
+############################################################
+
+for app in apps:
+    
+   data_coherence_name = os.path.join(scripts_path, gen_dir, app + '_coherence.dat')
+   gp_coherence_name   = os.path.join(scripts_path, gen_dir, app + '_coherence.gp')
+
+   # Creating the data file
+   width = 15
+   content = ""
+   
+   for metric in [ '#nb_procs' ] + grouped_metrics:
+      content += metric + " "
+      nb_spaces = width - len(metric)
+      content += nb_spaces * ' '
+   content += "\n"
+
+   for i in nb_procs:
+      content += "%-15d " % i
+      for metric in grouped_metrics:
+         val = float(metrics_val[app][i][metric]) / exec_time[app][i] * 1000
+         content += "%-15f " % val
+      content += "\n"
+   
+   create_file(data_coherence_name, content)
+
+   # Creating the gp file
+   template_file = open(coherence_tmpl, 'r')
+   template = template_file.read()
+   
+   plot_str = ""
+   col = 2
+   for metric in grouped_metrics:
+      if metric != grouped_metrics[0]:
+         plot_str += ", \\\n    "
+      plot_str += "\"" + data_coherence_name + "\" using ($1):($" + str(col) + ") lc rgb " + colors[col - 2] + " title \"" + m_metric_name[metric] + "\" with linespoint"
+      col += 1
+   gp_commands = template % dict(app_name = m_app_name[app], nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, app + '_coherence'))
+   
+   create_file(gp_coherence_name, gp_commands)
+   
+   # Calling gnuplot
+   print "gnuplot", gp_coherence_name
+   subprocess.call([ 'gnuplot', gp_coherence_name ])
+
+
+############################################################
+### Graph 2 : Speedup per Application                    ###
+############################################################
+
+for app in apps:
+
+   data_speedup_name   = os.path.join(scripts_path, gen_dir, app + '_speedup.dat')
+   gp_speedup_name     = os.path.join(scripts_path, gen_dir, app + '_speedup.gp')
+   
+   # Creating data file
+   width = 15
+   content = "#nb_procs"
+   nb_spaces = width - len(content)
+   content += nb_spaces * ' '
+   content += "speedup\n"
+
+   for i in nb_procs:
+      content += "%-15d " % i
+      val = exec_time[app][i]
+      content += "%-15f\n" % (exec_time[app][1] / float(val))
+
+   plot_str = "\"" + data_speedup_name + "\" using ($1):($2) lc rgb \"#654387\" title \"Speedup\" with linespoint"
+   
+   create_file(data_speedup_name, content)
+   
+   # Creating the gp file
+   template_file = open(speedup_tmpl, 'r')
+   template = template_file.read()
+   
+   gp_commands = template % dict(appli = m_app_name[app], nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, app + '_speedup'))
+   
+   create_file(gp_speedup_name, gp_commands)
+   
+   # Calling gnuplot
+   print "gnuplot", gp_speedup_name
+   subprocess.call([ 'gnuplot', gp_speedup_name ])
+
+
+############################################################
+### Graph 3 : All speedups on the same Graph             ###
+############################################################
+
+# This graph uses the same template as the graph 2
+
+data_speedup_name = os.path.join(scripts_path, gen_dir, 'all_speedup.dat')
+gp_speedup_name   = os.path.join(scripts_path, gen_dir, 'all_speedup.gp')
+
+# Creating data file
+width = 15
+content = "#nb_procs"
+nb_spaces = width - len(content)
+content += (nb_spaces + 1) * ' '
+for app in apps:
+   content += app + " "
+   content += (width - len(app)) * " "
+content += "\n"
+
+for i in nb_procs:
+   content += "%-15d " % i
+   for app in apps:
+      val = exec_time[app][i]
+      content += "%-15f " % (exec_time[app][1] / float(val))
+   content += "\n"
+
+create_file(data_speedup_name, content)
+
+# Creating gp file
+template_file = open(speedup_tmpl, 'r')
+template = template_file.read()
+
+plot_str = ""
+col = 2
+for app in apps:
+   if app != apps[0]:
+      plot_str += ", \\\n     "
+   plot_str += "\"" + data_speedup_name + "\" using ($1):($" + str(col) + ") lc rgb %s title \"" % (colors[col - 2])  + m_app_name[app] + "\" with linespoint"
+   col += 1
+
+gp_commands = template % dict(appli = "All Applications", nb_procs = nb_procs[-1] + 1, plot_str = plot_str, svg_name = os.path.join(graph_dir, 'all_speedup'))
+   
+create_file(gp_speedup_name, gp_commands)
+   
+# Calling gnuplot
+print "gnuplot", gp_speedup_name
+subprocess.call([ 'gnuplot', gp_speedup_name ])
+
+
+############################################################
+### Graph 4 : Graph per metric                           ###
+############################################################
+
+# The following section creates the graphs grouped by measure (e.g. #broadcasts)
+# The template file cannot be easily created otherwise it would not be generic
+# in many ways. This is why it is mainly created here.
+# Graphs are created for metric in the "individual_metrics" list
+
+for metric in individual_metrics:
+   data_metric_name = os.path.join(scripts_path, gen_dir, metric + '.dat')
+   gp_metric_name   = os.path.join(scripts_path, gen_dir, metric + '.gp')
+
+   # Creating the gp file
+   # Setting xtics, i.e. number of procs for each application
+   xtics_str = "("
+   first = True
+   xpos = 1
+   app_labels = ""
+   for num_appli in range(0, len(apps)):
+      for i in nb_procs:
+         if not first:
+            xtics_str += ", "
+         first = False
+         if i == nb_procs[0]:
+            xpos_first = xpos
+         xtics_str += "\"%d\" %.1f" % (i, xpos)
+         xpos_last = xpos
+         xpos += 1.5
+      xpos += 0.5
+      app_name_xpos = float((xpos_first + xpos_last)) / 2
+      app_labels += "set label \"%s\" at first %f,character 1 center font\"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+   xtics_str += ")"
+
+   xmax_val = xpos + 0.5
+
+   # Writing the lines of "plot"
+   plot_str = ""
+   xpos = 0
+   first = True
+   column = 2
+   for i in range(0, len(nb_procs)):
+      if not first:
+         plot_str += ", \\\n    "
+      first = False
+      plot_str += "\"%s\" using ($1+%.1f):($%d) lc rgb %s notitle with boxes" % (data_metric_name, xpos, column, colors[i])
+      column += 1
+      xpos += 1.5
+
+   template_file = open(metric_tmpl, 'r')
+   template = template_file.read()
+
+   gp_commands = template % dict(xtics_str = xtics_str, app_labels = app_labels, ylabel_str = m_metric_name[metric], norm_factor_str = m_norm_factor_name[m_metric_norm[metric]], xmax_val = xmax_val, plot_str = plot_str, svg_name = os.path.join(graph_dir, metric))
+
+   create_file(gp_metric_name, gp_commands)
+   
+   # Creating the data file
+   width = 15
+   content = "#x_pos"
+   nb_spaces = width - len(content)
+   content += nb_spaces * ' '
+   for i in nb_procs:
+      content += "%-15d" % i
+   content += "\n"
+
+   x_pos = 1
+   for app in apps:
+      # Computation of x_pos
+      content += "%-15f" % x_pos
+      x_pos += len(nb_procs) * 1.5 + 0.5
+      for i in nb_procs:
+         if m_metric_norm[metric] == "N":
+            content += "%-15d" % (metrics_val[app][i][metric])
+         elif m_metric_norm[metric] == "P":
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / i)
+         elif m_metric_norm[metric] == "C":
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / exec_time[app][i] * 1000)
+         elif m_metric_norm[metric] == "W":
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / float(metrics_val[app][i]['total_write'])) # Number of writes
+         elif m_metric_norm[metric] == "R":
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / float(metrics_val[app][i]['total_read'])) # Number of reads
+         elif m_metric_norm[metric] == "D":
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / float(metrics_val[app][i]['total_direct'])) # Number of req.
+         elif is_numeric(m_metric_norm[metric]):
+            content += "%-15f" % (float(metrics_val[app][i][metric]) / float(metrics_val[app][int(m_metric_norm[metric])][metric]))
+         else:
+            assert(False)
+
+      app_name = m_app_name[app]
+      content += "#" + app_name + "\n"
+   
+   create_file(data_metric_name, content)
+
+   # Calling gnuplot
+   print "gnuplot", gp_metric_name
+   subprocess.call([ 'gnuplot', gp_metric_name ])
+
+
+############################################################
+### Graph 5 : Stacked histogram with counters            ###
+############################################################
+
+# The following section creates a stacked histogram containing
+# the metrics in the "stacked_metric" list
+# It is normalized per application w.r.t the values on 256 procs
+
+data_stacked_name = os.path.join(scripts_path, gen_dir, 'stacked.dat')
+gp_stacked_name   = os.path.join(scripts_path, gen_dir, 'stacked.gp')
+
+norm_factor_value = 256
+
+# Creating the gp file
+template_file = open(stacked_tmpl, 'r')
+template = template_file.read()
+
+xtics_str = "("
+first = True
+xpos = 1
+app_labels = ""
+for num_appli in range(0, len(apps)):
+   for i in nb_procs:
+      if not first:
+         xtics_str += ", "
+      first = False
+      if i == nb_procs[0]:
+         xpos_first = xpos
+      xtics_str += "\"%d\" %d -1" % (i, xpos)
+      xpos_last = xpos
+      xpos += 1
+   xpos += 1
+   app_name_xpos = float((xpos_first + xpos_last)) / 2
+   app_labels += "set label \"%s\" at first %f,character 1 center font\"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+xtics_str += ")"
+
+plot_str = "newhistogram \"\""
+n = 1
+for stacked_metric in stacked_metrics:
+   plot_str += ", \\\n    " + "'" + data_stacked_name + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[stacked_metric] + "\""
+   n += 1
+
+ylabel_str = "Breakdown of Coherence Traffic Normalized w.r.t. \\nthe Values on %d Processors" % norm_factor_value
+content = template % dict(svg_name = os.path.join(graph_dir, 'stacked'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels)
+
+create_file(gp_stacked_name, content)
+
+# Creating the data file
+# Values are normalized by application, w.r.t. the number of requests for a given number of procs
+content = "#"
+for stacked_metric in stacked_metrics:
+   content += stacked_metric
+   content += ' ' + ' ' * (15 - len(stacked_metric))
+content += "\n"
+for app in apps:
+   if app != apps[0]:
+      for i in range(0, len(stacked_metrics)):
+         content += "%-15f" % 0.0
+      content += "\n"
+   for i in nb_procs:
+      for stacked_metric in stacked_metrics:
+         content += "%-15f" % (float(metrics_val[app][i][stacked_metric]) / metrics_val[app][norm_factor_value]['total_stacked'])
+      content += "\n"
+
+create_file(data_stacked_name, content)
+# Calling gnuplot
+print "gnuplot", gp_stacked_name
+subprocess.call([ 'gnuplot', gp_stacked_name ])
+
+
+
+#################################################################################
+### Graph 6 : Stacked histogram with coherence cost compared to r/w cost      ###
+#################################################################################
+
+# The following section creates pairs of stacked histograms, normalized w.r.t. the first one.
+# The first one contains the cost of reads and writes, the second contains the cost
+# of m_inv, m_up and broadcasts (extrapolated)
+
+data_cost_filename = os.path.join(scripts_path, gen_dir, 'relative_cost.dat')
+gp_cost_filename   = os.path.join(scripts_path, gen_dir, 'relative_cost.gp')
+
+direct_cost_metrics = [ 'read_cost', 'write_cost' ]
+coherence_cost_metrics = ['update_cost', 'm_inv_cost', 'broadcast_cost' ]
+
+# Creating the gp file
+template_file = open(stacked_tmpl, 'r')
+template = template_file.read()
+
+xtics_str = "("
+first = True
+xpos = 1.5
+app_labels = ""
+for num_appli in range(0, len(apps)):
+   first_proc = True
+   for i in nb_procs:
+      if i > 4:
+         if not first:
+            xtics_str += ", "
+         first = False
+         if first_proc:
+            first_proc = False
+            xpos_first = xpos
+         xtics_str += "\"%d\" %f -1" % (i, xpos)
+         xpos_last = xpos
+         xpos += 3
+   app_name_xpos = float((xpos_first + xpos_last)) / 2
+   app_labels += "set label \"%s\" at first %f,character 1 center font\"Times,12\"\n" % (m_app_name[apps[num_appli]], app_name_xpos)
+   xpos += 1
+xtics_str += ")"
+
+plot_str = "newhistogram \"\""
+n = 1
+for cost_metric in direct_cost_metrics + coherence_cost_metrics:
+   plot_str += ", \\\n    " + "'" + data_cost_filename + "'" + " using " + str(n) + " lc rgb " + colors[n] + " title \"" + m_metric_name[cost_metric] + "\""
+   n += 1
+
+ylabel_str = "Coherence Cost Compared to Direct Requests Cost,\\nNormalized per Application for each Number of Processors"
+content = template % dict(svg_name = os.path.join(graph_dir, 'rel_cost'), xtics_str = xtics_str, plot_str = plot_str, ylabel_str = ylabel_str, app_labels = app_labels)
+
+create_file(gp_cost_filename, content)
+
+# Creating the data file
+# Values are normalized by application, w.r.t. the number of requests for a given number of procs
+content = "#"
+for cost_metric in direct_cost_metrics:
+   content += cost_metric
+   content += ' ' + ' ' * (15 - len(cost_metric))
+for cost_metric in coherence_cost_metrics:
+   content += cost_metric
+   content += ' ' + ' ' * (15 - len(cost_metric))
+content += "\n"
+for app in apps:
+   if app != apps[0]:
+      for i in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)):
+         content += "%-15f" % 0.0
+      content += "\n"
+   for i in nb_procs:
+      if i > 4:
+         for cost_metric in direct_cost_metrics:
+            content += "%-15f" % (float(metrics_val[app][i][cost_metric]) / metrics_val[app][i]['direct_cost'])
+         for cost_metric in coherence_cost_metrics:
+            content += "%-15f" % 0.0
+         content += "\n"
+         for cost_metric in direct_cost_metrics:
+            content += "%-15f" % 0.0
+         for cost_metric in coherence_cost_metrics:
+            content += "%-15f" % (float(metrics_val[app][i][cost_metric]) / metrics_val[app][i]['direct_cost'])
+         content += "\n"
+         for i in range(0, len(direct_cost_metrics) + len(coherence_cost_metrics)):
+            content += "%-15f" % 0.0
+         content += "\n"
+
+create_file(data_cost_filename, content)
+# Calling gnuplot
+print "gnuplot", gp_cost_filename
+subprocess.call([ 'gnuplot', gp_cost_filename ])
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/gen_arch_info_large.sh
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/gen_arch_info_large.sh	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/gen_arch_info_large.sh	(revision 706)
@@ -0,0 +1,236 @@
+#! /bin/bash
+
+#--------------------------------------------------------------------
+# File      : gen_arch_info_large.sh
+#--------------------------------------------------------------------
+
+NB_TTY=4
+TTY_CHANNEL_SIZE=0x10
+TTY_SIZE=0x1000
+
+DMA_SIZE=0x1000
+XICU_SIZE=0x1000
+BDEV_SIZE=0x1000
+# FrameBuffer size
+#FB_SIZE=0x80000
+FB_SIZE=0x200000
+
+MEMC_TGTID=0
+XICU_TGTID=1
+MDMA_TGTID=2
+MTTY_TGTID=3
+BDEV_TGTID=4
+MNIC_TGTID=5
+BROM_TGTID=6
+CDMA_TGTID=7
+SIMH_TGTID=8
+FBUF_TGTID=9
+
+
+# Physical address width
+ADDR_WIDTH=32
+
+# Default values
+DEFAULT_X_MAX=8
+DEFAULT_Y_MAX=8
+DEFAULT_CPU_PER_CLUSTER=4
+
+function mymin()
+{
+   if test $1 -lt $2 ; then
+      echo "$1"
+   else
+      echo "$2"
+   fi
+}
+
+#------------------------
+
+X_MAX=${1-$DEFAULT_X_MAX}
+Y_MAX=${2-$DEFAULT_Y_MAX}
+NPROCS=$DEFAULT_CPU_PER_CLUSTER
+
+#------------------------
+CLUSTER_INC=$((0x80000000 / (X_MAX * Y_MAX) * 2))
+MAX_MEMC_SIZE=$((0x40000000 / (X_MAX * Y_MAX)))
+size=$(mymin $MAX_MEMC_SIZE $((0x04000000)))
+MEMC_SIZE=$(printf "0x%X" $size)
+
+
+print_comments()
+{
+    date=$(date "+%c")
+    echo "# TSAR hardware description in BIB (Boot Information Block) format"
+    echo "# This file is autogenerated by the command: $0 $X_MAX $Y_MAX $NPROCS $BSCPU"
+    echo "# It is ready to be passed to info2bib utility so the binary format can be generated"
+    echo " "
+    echo "# $USER on $HOSTNAME $date" 
+    echo " "
+    echo " "
+}
+
+print_header()
+{
+    echo "[HEADER]"
+    echo "        REVISION=1"
+    echo "        ARCH=SOCLIB-TSAR"
+    echo "        XMAX=$X_MAX"
+    echo "        YMAX=$Y_MAX"
+    echo "        CPU_NR=$NPROCS"
+    echo "        BSCPU=$BSCPU"
+    echo "        BSTTY=$BSTTY"
+    echo "        BSDMA=$BSDMA"
+    echo " "
+    echo " "
+}
+
+print_cluster()
+{
+    offset=$1
+    cid=$2
+    memc_base=$(printf "0x%X" $offset)
+    memc_size=$(printf "0x%X" $MEMC_SIZE)
+    xicu_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19))))
+    dma_base=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (MDMA_TGTID << 19))))
+    
+    echo "[CLUSTER]"
+    echo "         CID="$cid
+    echo "         CPU_NR="$NPROCS
+    echo "         DEV_NR=3"
+    echo "         DEVID=RAM       BASE=$memc_base         SIZE=$memc_size     IRQ=-1"
+    echo "         DEVID=XICU      BASE=$xicu_base         SIZE=$DMA_SIZE         IRQ=-1"
+    echo "         DEVID=DMA       BASE=$dma_base         SIZE=$XICU_SIZE         IRQ=8"
+    echo " "
+    echo " "
+}
+
+print_io_cluster()
+{
+    offset=$1
+    cid=$2
+    memc_base=$(printf "0x%X" $offset)
+    memc_size=$(printf "0x%X" $MEMC_SIZE)
+    xicu_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (XICU_TGTID << 19))))
+    dma_base=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (MDMA_TGTID << 19))))
+    bdev_base=$(printf "0x%X" $((offset + (CLUSTER_INC / 2) + (BDEV_TGTID << 19))))
+    tty_base=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (MTTY_TGTID << 19))))
+    fbf_base=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (FBUF_TGTID << 19))))
+
+    echo "[CLUSTER]"
+    echo "         CID="$cid
+    echo "         CPU_NR="$NPROCS
+    echo "         DEV_NR=9"
+    echo "         DEVID=RAM       BASE=$memc_base         SIZE=$memc_size     IRQ=-1"
+    echo "         DEVID=XICU      BASE=$xicu_base         SIZE=$XICU_SIZE         IRQ=-1"
+    echo "         DEVID=DMA       BASE=$dma_base         SIZE=$DMA_SIZE         IRQ=8"
+    echo "         DEVID=BLKDEV    BASE=$bdev_base         SIZE=$BDEV_SIZE         IRQ=31"
+    ntty=0
+    irq=16
+    while test $ntty -lt $NB_TTY
+    do
+       tty_base_i=$(printf "0x%X" $((tty_base + ntty * TTY_CHANNEL_SIZE)))
+       echo "         DEVID=TTY       BASE=$tty_base_i         SIZE=$TTY_CHANNEL_SIZE           IRQ=$irq"
+       irq=$((irq + 1))
+       ntty=$((ntty + 1))
+    done
+    echo "         DEVID=FB        BASE=$fbf_base         SIZE=$FB_SIZE        IRQ=-1"
+    echo " "
+    echo " "
+}
+
+# Derive X_WIDTH form X_MAX
+case $X_MAX in
+    1)      X_WIDTH=0
+   ;;
+
+    2)      X_WIDTH=1
+	;;
+    
+    [3-4])  X_WIDTH=2
+	;;
+
+    [5-8])  X_WIDTH=3
+	;;
+
+    *)      X_WIDTH=4
+	;;
+esac
+
+# Derive Y_WIDTH form Y_MAX
+case $Y_MAX in
+    1)      Y_WIDTH=0
+   ;;
+
+
+    2)      Y_WIDTH=1
+	;;
+    
+    [3-4])  Y_WIDTH=2
+	;;
+
+    [5-8])  Y_WIDTH=3
+	;;
+
+    *)      Y_WIDTH=4
+	;;
+esac
+
+x=0; y=0
+io_cid=$((0xbf >> (8 - X_WIDTH - Y_WIDTH)))
+BSCPU=$(($io_cid * $NPROCS))
+
+break_loop=0
+while test $x -lt $X_MAX
+do
+   while test $y -lt $Y_MAX
+   do
+      cid=$((x * Y_MAX + y))  
+      offset=$((cid  << (ADDR_WIDTH - X_WIDTH - Y_WIDTH)))
+
+      if [ $cid -eq $io_cid ]
+      then
+         BSDMA=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (MDMA_TGTID << 19))))
+         BSTTY=$(printf "0x%X" $((offset  + (CLUSTER_INC / 2) + (MTTY_TGTID << 19))))
+         break_loop=1
+         break
+      else
+         BSDMA="error"
+      fi
+
+      y=$((y + 1))
+   done
+   if test $break_loop -eq 1 ; then
+      break
+   fi
+   y=0
+   x=$((x + 1))
+done
+
+# Generate the description
+print_comments "$0"
+print_header
+
+x=0; y=0
+while test $x -lt $X_MAX
+do
+   while test $y -lt $Y_MAX
+   do
+      cid=$((x * Y_MAX + y))  
+      offset=$((cid  << (ADDR_WIDTH - X_WIDTH - Y_WIDTH)))
+
+      if [ $cid -eq $io_cid ]
+      then
+         print_io_cluster $offset $cid
+      else
+         print_cluster $offset $cid
+      fi
+
+      y=$((y + 1))
+   done
+   y=0
+   x=$((x + 1))
+done 
+
+#-------------------------------------------------------------------------#
+#                                End of script                            #
+#-------------------------------------------------------------------------#
Index: trunk/platforms/tsar_generic_xbar/scripts/run_simus.py
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/run_simus.py	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/run_simus.py	(revision 706)
@@ -0,0 +1,351 @@
+#!/usr/bin/python
+
+import subprocess
+import os
+import sys
+
+#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_'
+
+
+nb_procs = [ 4 ]
+#nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
+rerun_stats = True
+use_omp = False
+
+#apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga', 'kmeans' ]
+#apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga' ]
+apps = [ 'filt_ga' ]
+
+
+all_apps = [ 'mandel', 'filter', 'filt_ga', 'histogram', 'kmeans', 'barnes', 'fmm', 'ocean', 'raytrace', 'radiosity', 'waters', 'watern', 'cholesky', 'lu', 'fft', 'radix', 'fft_ga', 'radix_ga', 'kmeans' ]
+splash2 = [ 'barnes', 'fmm', 'ocean', 'radiosity', 'raytrace', 'watern', 'waters', 'cholesky', 'lu', 'fft', 'radix' ]
+splash2_ga = [ 'radix_ga', 'fft_ga' ]
+
+
+config_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.py")
+if not os.path.isfile(config_name):
+   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
+ - almos_src_dir: path to almos source directory (for kernel and bootloader binaries)
+ - hdd_img_name:  path to the hdd image to use
+*** Stopping execution
+'''
+   print help_str
+   sys.exit()
+
+exec(file(config_name))
+
+top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
+
+splash2_dir    = os.path.join(apps_dir, 'splash2/codes')
+splash2_ga_dir = os.path.join(apps_dir, 'splash2_ga')
+
+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"
+
+
+splash_app_dir = {}
+splash_app_dir['barnes'] = 'apps/barnes'
+splash_app_dir['fmm'] = 'apps/fmm'
+splash_app_dir['ocean'] = 'apps/ocean/contiguous_partitions'
+splash_app_dir['raytrace'] = 'apps/raytrace'
+splash_app_dir['radiosity'] = 'apps/radiosity'
+#splash_app_dir['volrend'] = 'apps/volrend'
+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
+
+
+
+def gen_hard_config(x, y, hard_config):
+   header = '''
+/* Generated from run_simus.py */
+
+#ifndef _HD_CONFIG_H
+#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   IRQ_PER_PROCESSOR   1
+
+#endif //_HD_CONFIG_H
+''' % dict(x = x, y = y, nb_clus = x * y)
+   file = open(hard_config, 'w')
+   file.write(header)
+   file.close()
+
+
+def gen_arch_info(x, y, arch_info, arch_info_bib):
+   old_path = os.getcwd()
+   print "cd", scripts_path
+   os.chdir(scripts_path)
+   print "./gen_arch_info_large.sh", str(x), str(y), ">", arch_info
+   output = subprocess.Popen([ './gen_arch_info_large.sh', str(x), str(y) ], stdout = subprocess.PIPE).communicate()[0]
+   os.chdir(almos_path)
+   file = open(arch_info, 'w')
+   file.write(output)
+   file.close()
+   print "./info2bib -i", arch_info, "-o", arch_info_bib
+   subprocess.call([ './info2bib', '-i', arch_info, '-o', arch_info_bib ])
+   print "cd", old_path
+   os.chdir(old_path)
+   
+
+def gen_sym_links():
+   old_path = os.getcwd()
+   print "cd", almos_path
+   os.chdir(almos_path)
+
+   target = os.path.join(almos_src_dir, 'tools/soclib-bootloader/bootloader-tsar-mipsel.bin')
+   link_name = 'bootloader-tsar-mipsel.bin'
+   if not os.path.isfile(link_name):
+      print "ln -s", target, link_name
+      os.symlink(target, link_name)
+
+   target = os.path.join(almos_src_dir, 'kernel/obj.tsar/almix-tsar-mipsel.bin')
+   link_name = 'kernel-soclib.bin'
+   if not os.path.isfile(link_name):
+      print "ln -s", target, link_name
+      os.symlink(target, link_name)
+
+   target = hdd_img_name
+   link_name = 'hdd-img.bin'
+   if not os.path.isfile(link_name):
+      print "ln -s", target, link_name
+      os.symlink(target, link_name)
+
+   os.chdir(old_path)
+
+
+
+def compile_app(app_name, nprocs):
+
+   if app_name in splash2:
+      app_dir_name = os.path.join(splash2_dir, splash_app_dir[app_name])
+   elif app_name in splash2_ga:
+      app_dir_name = os.path.join(splash2_ga_dir, splash_ga_app_dir[app_name])
+   else:
+      app_dir_name = os.path.join(apps_dir, app_name)
+
+   old_path = os.getcwd()
+   print "cd", app_dir_name
+   os.chdir(app_dir_name)
+
+   # Compilation process is different in splash and other apps
+   if app_name in splash2:
+      print "make clean"
+      subprocess.call([ 'make', 'clean' ])
+
+      print "rm Makefile"
+      subprocess.call([ 'rm', 'Makefile' ])
+
+      print "ln -s Makefile.soclib Makefile"
+      subprocess.call([ 'ln', '-s', 'Makefile.soclib', 'Makefile' ])
+
+      print "make"
+      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"
+      subprocess.call([ 'make', 'clean' ])
+ 
+      print "make TARGET=tsar"
+      subprocess.call([ 'make', 'TARGET=tsar' ])
+   
+   # Creation/Modification du shrc de almos
+   if (app_name == "boot_only"):
+      shrc = "exec -p 0 /bin/boot_onl\n"
+   elif (app_name == "mandel"):
+      shrc = "exec -p 0 /bin/mandel -n%(nproc)d\n" % dict(nproc = nprocs)
+   elif (app_name == "filter"):
+      #shrc = "exec -p 0 /bin/filter /etc/imgs.raw 512 512\n"
+      shrc = "exec -p 0 /bin/filter -l1024 -c1024 -n%(nproc)d /etc/img.raw\n" % dict(nproc = nprocs)
+   elif (app_name == "filt_ga"):
+      shrc = "exec -p 0 /bin/filt_ga -n%(nproc)d -i /etc/img.raw\n" % dict(nproc = nprocs)
+   elif (app_name == "histogram"):
+      shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
+   elif (app_name == "kmeans"):
+      shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
+   elif (app_name == "showimg"):
+      shrc = "exec -p 0 /bin/showimg -p1 -i /etc/lena.sgi -o /dev/fb0\n"
+   elif (app_name == "barnes"):
+      shrc = "exec -p 0 /bin/barnes -n%(nproc)d -b%(nbody)d\n" % dict(nproc = nprocs, nbody = 1024)
+   elif (app_name == "fmm"):
+      shrc = "exec -p 0 /bin/fmm -n%(nproc)d -p%(nparticles)d\n" % dict(nproc = nprocs, nparticles = 1024)
+   elif (app_name == "ocean"):
+      shrc = "exec -p 0 /bin/ocean -n%(nproc)d -m%(gridsize)d\n" % dict(nproc = nprocs, gridsize = 66)
+   elif (app_name == "radiosity"):
+      shrc = "exec -p 0 /bin/radiosit -n %(nproc)d -batch\n" % dict(nproc = nprocs)
+   elif (app_name == "raytrace"):
+      shrc = "exec -p 0 /bin/raytrace -n%(nproc)d /etc/tea.env\n" % dict(nproc = nprocs)
+   elif (app_name == "watern"):
+      shrc = "exec -p 0 /bin/watern -n%(nproc)d -m512\n" % dict(nproc = nprocs)
+   elif (app_name == "waters"):
+      shrc = "exec -p 0 /bin/waters -n%(nproc)d -m512\n" % dict(nproc = nprocs)
+   elif (app_name == "cholesky"):
+      shrc = "exec -p 0 /bin/cholesky -n%(nproc)d /etc/tk14.O\n" % dict(nproc = nprocs)
+   elif (app_name == "fft"):
+      shrc = "exec -p 0 /bin/fft -n%(nproc)d -m10\n" % dict(nproc = nprocs)
+   elif (app_name == "lu"):
+      shrc = "exec -p 0 /bin/lu -n%(nproc)d -m512\n" % dict(nproc = nprocs)
+   elif (app_name == "radix"):
+      shrc = "exec -p 0 /bin/radix -n%(nproc)d -k1024\n" % dict(nproc = nprocs) # test : 1024 ; simu : 65536
+   elif (app_name == "radix_ga"):
+      shrc = "exec -p 0 /bin/radix_ga -p%(nproc)d -n262144\n" % dict(nproc = nprocs) # p = proc, n = num_keys
+   elif (app_name == "fft_ga"):
+      shrc = "exec -p 0 /bin/fft_ga -P%(nproc)d -M16\n" % dict(nproc = nprocs)
+   else:
+      assert(False)
+   
+   file = open(shrc_file_name, 'w')
+   file.write(shrc)
+   file.close()
+
+   # Copie du binaire et du shrc dans l'image disque
+   print "mcopy -o -i", hdd_img_file_name, shrc_file_name, "::/etc/"
+   subprocess.call([ 'mcopy', '-o', '-i', hdd_img_file_name, shrc_file_name, '::/etc/' ])
+   print "mcopy -o -i", hdd_img_file_name, app_name, "::/bin/"
+   subprocess.call([ 'mcopy', '-o', '-i', hdd_img_file_name, app_name, '::/bin/' ])
+
+   print "cd", old_path
+   os.chdir(old_path)
+# end of compile_app
+
+
+print "mkdir -p", os.path.join(scripts_path, data_dir)
+subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, data_dir) ])
+
+gen_sym_links()
+
+for i in nb_procs:
+   x, y = get_x_y(i)
+   nthreads = min(4, x * y)
+   gen_hard_config(x, y, hard_config_name)
+   gen_arch_info(x, y, arch_info_name, arch_info_bib_name)
+
+   print "cd", top_path
+   os.chdir(top_path)
+   print "touch", topcell_name
+   subprocess.call([ 'touch', topcell_name ])
+   print "make"
+   subprocess.call([ 'make' ])
+   
+   for app in apps:
+      print "cd", top_path
+      os.chdir(top_path)
+
+      compile_app(app, i)
+
+      # Launch simulation
+      if use_omp:
+         print "./simul.x -THREADS", nthreads, ">", os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
+         output = subprocess.Popen([ './simul.x', '-THREADS', str(nthreads) ], stdout = subprocess.PIPE).communicate()[0]
+      else:
+         print "./simul.x >", os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
+         output = subprocess.Popen([ './simul.x' ], stdout = subprocess.PIPE).communicate()[0]
+
+
+      # Write simulation results to data directory
+      print "cd", scripts_path
+      os.chdir(scripts_path)
+      filename = os.path.join(data_dir, app + '_' + log_init_name + str(i))
+      file = open(filename, 'w')
+      file.write(output)
+      file.close()
+
+      filename = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
+      print "mv", os.path.join(top_path, 'term1'), filename
+      subprocess.call([ 'mv', os.path.join(top_path, 'term1'), filename ])
+
+      if rerun_stats:
+         start2_found = False
+         end_found = False
+         for line in open(filename):
+            if "[START2]" in line:
+               start2 = line.split()[-1]
+               start2_found = True
+            if "[END]" in line:
+               end = line.split()[-1]
+               end_found = True
+         assert(start2_found and end_found)
+         
+         print "cd", top_path
+         os.chdir(top_path)
+
+         # Relauching simulation with reset and dump of counters
+         if use_omp:
+            print "./simul.x -THREADS", nthreads, "--reset-counters %s --dump-counters %s >" % (start2, end), os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
+            output = subprocess.Popen([ './simul.x', '-THREADS', str(nthreads), '--reset-counters', start2, '--dump-counters', end ], stdout = subprocess.PIPE).communicate()[0]
+         else:
+            print "./simul.x --reset-counters %s --dump-counters %s >" % (start2, end), os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
+            output = subprocess.Popen([ './simul.x', '--reset-counters', start2, '--dump-counters', end ], stdout = subprocess.PIPE).communicate()[0]
+         
+         # Write simulation results (counters) to data directory
+         print "cd", scripts_path
+         os.chdir(scripts_path)
+         filename = os.path.join(data_dir, app + '_' + log_init_name + str(i))
+         file = open(filename, 'w')
+         file.write(output)
+         file.close()
+ 
+
+## End of simulations
+
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/templates/coherence_template.gp
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/templates/coherence_template.gp	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/templates/coherence_template.gp	(revision 706)
@@ -0,0 +1,24 @@
+
+set terminal svg size 500 400 fixed
+set output "%(svg_name)s.svg"
+
+set ylabel "Coherence Cost for Application %(app_name)s\nNormalized w.r.t. the Number of Cycles (x 1000)" font "Times,12"
+set xlabel "Number of Cores" font "Times,12"
+
+set grid noxtics
+set grid nomxtics
+set grid nomx2tics
+set grid ytics
+set grid mytics
+
+#set logscale x 2
+#set logscale y 2
+set xrange [8:256]
+#set yrange [0:30]
+
+set key inside left top Left reverse
+
+
+plot %(plot_str)s
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/templates/metric_template.gp
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/templates/metric_template.gp	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/templates/metric_template.gp	(revision 706)
@@ -0,0 +1,34 @@
+
+set terminal svg size 1000 400 fixed
+set output "%(svg_name)s.svg"
+
+set xtics nomirror out scale 0,0 rotate by 0 font "Times,10"
+
+set xtics %(xtics_str)s
+# Creates something like:
+#set xtics ("1" 1, "4" 2, "8" 3, "16" 4, "32" 5, "64" 6, "128" 7, "256" 8, "1" 9.5, "4" 10.5, "8" 11.5, "16" 12.5, "32" 13.5, "64" 14.5, "128" 15.5, "256" 16.5, "1" 18, ...)
+
+set ylabel "%(ylabel_str)s %(norm_factor_str)s" font "Times,12"
+set xlabel " "
+
+%(app_labels)s
+
+set xrange [0:%(xmax_val)d]
+
+#set mytics 0.1
+
+set grid noxtics
+set grid nomxtics
+set grid nomx2tics
+set grid ytics
+set grid mytics
+
+
+set key inside left top Left reverse
+
+set boxwidth 1
+set style fill solid border -1
+
+plot %(plot_str)s
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/templates/speedup_template.gp
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/templates/speedup_template.gp	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/templates/speedup_template.gp	(revision 706)
@@ -0,0 +1,24 @@
+
+set terminal svg size 500 400 fixed
+set output "%(svg_name)s.svg"
+
+set ylabel "Speedup for %(appli)s" font "Times,12"
+set xlabel "Number of Cores" font "Times,12"
+
+set xrange [1:%(nb_procs)d]
+set yrange [1:130]
+
+set grid noxtics
+set grid nomxtics
+set grid nomx2tics
+set grid ytics
+set grid mytics
+
+set logscale x 2
+set logscale y 2
+
+set key inside left top Left reverse
+
+plot %(plot_str)s
+
+
Index: trunk/platforms/tsar_generic_xbar/scripts/templates/stacked_template.gp
===================================================================
--- trunk/platforms/tsar_generic_xbar/scripts/templates/stacked_template.gp	(revision 706)
+++ trunk/platforms/tsar_generic_xbar/scripts/templates/stacked_template.gp	(revision 706)
@@ -0,0 +1,37 @@
+
+set terminal svg size 1500 500 fixed
+set output "%(svg_name)s.svg"
+
+# border 3 -> bords en bas et a gauche (2 derniers bits à 1)
+set border 3 front linetype -1 linewidth 1.000
+set boxwidth 1 absolute
+set style fill solid 1.00 border -1
+
+# front : devant les autres objets (courbes) ; fc : fillcolor
+#set style rectangle front fc lt -3 fillstyle solid 1.00 border -1
+set style rectangle front fc lt 2 fillstyle solid 1.00 border -1
+set grid noxtics nomxtics ytics mytics noztics nomztics nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
+
+# Lignes derriere le graphique. 2e type de ligne pour les lignes verticales ?
+set grid layerdefault linetype 0 linewidth 1.000, linetype 0 linewidth 1.000
+
+# Legende des traits ou batons
+set key outside right Left reverse invert center
+#set key inside vertical left Left reverse invert enhanced autotitles columnhead nobox
+set style histogram rowstacked title offset character 2, 0.25, 0
+set datafile missing '-'
+set style data histograms
+
+# border : ne croise pas l'axe ; in : a l'interieur ; scale : taille (major,minor) ; offset : offset du texte
+set xtics border in scale 0.0,0.0 nomirror rotate by 0 offset character 0,0 font "Times,10"
+set ytics border out scale 1,0.5 nomirror norotate offset character 0,0
+
+set xtics %(xtics_str)s
+
+set xlabel " "
+set ylabel "%(ylabel_str)s" font "Times,14" 
+
+%(app_labels)s
+
+plot %(plot_str)s
+
Index: trunk/platforms/tsar_generic_xbar/top.cpp
===================================================================
--- trunk/platforms/tsar_generic_xbar/top.cpp	(revision 693)
+++ trunk/platforms/tsar_generic_xbar/top.cpp	(revision 706)
@@ -295,35 +295,37 @@
    // (Almos supports 32 bits physical addresses)
 
-   #define CLUSTER_IO_INC  (cluster_io_id * (0x80000000ULL / (X_SIZE * Y_SIZE) * 2))
-   #define MEMC_MAX_SIZE (0x40000000 / (X_SIZE * Y_SIZE))
+   #define CLUSTER_INC (0x80000000ULL / (X_SIZE * Y_SIZE) * 2)
+
+   #define CLUSTER_IO_INC (cluster_io_id * CLUSTER_INC)
+   #define MEMC_MAX_SIZE (0x40000000 / (X_SIZE * Y_SIZE)) // 0x40000000 : valeur totale souhaitÃ©e (ici : 1Go)
 
    #define BROM_BASE    0x00BFC00000
-   #define BROM_SIZE    0x0000100000   // 1 Mbytes
+   #define BROM_SIZE    0x0000100000 // 1 Mbytes
 
    #define MEMC_BASE    0x0000000000
    #define MEMC_SIZE    min(0x04000000, MEMC_MAX_SIZE)
 
-   #define XICU_BASE    MEMC_MAX_SIZE + (XICU_TGTID << 19)
-   #define XICU_SIZE    0x0000001000   // 4 Kbytes
+   #define XICU_BASE    (CLUSTER_INC >> 1) + (XICU_TGTID << 19)
+   #define XICU_SIZE    0x0000001000 // 4 Kbytes
    
-   #define MDMA_BASE    MEMC_MAX_SIZE + (MDMA_TGTID << 19)
-   #define MDMA_SIZE    (0x0000001000 * NB_DMA_CHANNELS)  // 4 Kbytes per channel  
-
-   #define BDEV_BASE    MEMC_MAX_SIZE + (BDEV_TGTID << 19) + (CLUSTER_IO_INC)
-   #define BDEV_SIZE    0x0000001000   // 4 Kbytes
-
-   #define MTTY_BASE    MEMC_MAX_SIZE + (MTTY_TGTID << 19) + (CLUSTER_IO_INC)
-   #define MTTY_SIZE    0x0000001000   // 4 Kbytes
-
-   #define FBUF_BASE    MEMC_MAX_SIZE + (FBUF_TGTID << 19) + (CLUSTER_IO_INC)
+   #define MDMA_BASE    (CLUSTER_INC >> 1) + (MDMA_TGTID << 19)
+   #define MDMA_SIZE    (0x0000001000 * NB_DMA_CHANNELS) // 4 Kbytes per channel  
+
+   #define BDEV_BASE    (CLUSTER_INC >> 1) + (BDEV_TGTID << 19) + (CLUSTER_IO_INC)
+   #define BDEV_SIZE    0x0000001000 // 4 Kbytes
+
+   #define MTTY_BASE    (CLUSTER_INC >> 1) + (MTTY_TGTID << 19) + (CLUSTER_IO_INC)
+   #define MTTY_SIZE    0x0000001000 // 4 Kbytes
+
+   #define FBUF_BASE    (CLUSTER_INC >> 1) + (FBUF_TGTID << 19) + (CLUSTER_IO_INC)
    #define FBUF_SIZE    (FBUF_X_SIZE * FBUF_Y_SIZE * 2) // Should be 0x80000
 
-   #define MNIC_BASE    MEMC_MAX_SIZE + (MNIC_TGTID << 19) + (CLUSTER_IO_INC)
+   #define MNIC_BASE    (CLUSTER_INC >> 1) + (MNIC_TGTID << 19) + (CLUSTER_IO_INC)
    #define MNIC_SIZE    0x0000080000
 
-   #define CDMA_BASE    MEMC_MAX_SIZE + (CDMA_TGTID << 19) + (CLUSTER_IO_INC)
+   #define CDMA_BASE    (CLUSTER_INC >> 1) + (CDMA_TGTID << 19) + (CLUSTER_IO_INC)
    #define CDMA_SIZE    (0x0000004000 * NB_CMA_CHANNELS)
 
-   #define SIMH_BASE    MEMC_MAX_SIZE + (SIMH_TGTID << 19) + (CLUSTER_IO_INC)
+   #define SIMH_BASE    (CLUSTER_INC >> 1) + (SIMH_TGTID << 19) + (CLUSTER_IO_INC)
    #define SIMH_SIZE    0x0000001000
 #endif
@@ -754,4 +756,5 @@
                 L1_DWAYS,
                 L1_DSETS,
+                IRQ_PER_PROCESSOR,
                 XRAM_LATENCY,
                 (cluster(x,y) == cluster_io_id),
@@ -979,18 +982,9 @@
             std::ostringstream m2p_signame;
             m2p_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " M2P" ;
-            std::ostringstream p_cmd_signame;
-            p_cmd_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " CMD" ;
-            std::ostringstream p_rsp_signame;
-            p_rsp_signame << "[SIG]PROC_" << x << "_" << y << "_" << l << " RSP" ;
-
-            //clusters[x][y]->wi_proc[l]->print_trace();
+
             //clusters[x][y]->signal_vci_ini_proc[l].print_trace(proc_signame.str());
             //clusters[x][y]->signal_dspin_p2m_proc[l].print_trace(p2m_signame.str());
             //clusters[x][y]->signal_dspin_m2p_proc[l].print_trace(m2p_signame.str());
-            //clusters[x][y]->signal_dspin_cmd_proc_i[l].print_trace(p_cmd_signame.str());
-            //clusters[x][y]->signal_dspin_rsp_proc_i[l].print_trace(p_rsp_signame.str());
-
-            //clusters[x][y]->xbar_rsp_d->print_trace();
-            //clusters[x][y]->xbar_cmd_d->print_trace();
+
             //clusters[x][y]->signal_dspin_cmd_l2g_d.print_trace("[SIG]L2G CMD");
             //clusters[x][y]->signal_dspin_cmd_g2l_d.print_trace("[SIG]G2L CMD");
@@ -1010,17 +1004,10 @@
             std::ostringstream sp2m;
             sp2m << "[SIG]MEMC_" << x << "_" << y << " P2M" ;
-            std::ostringstream m_cmd_signame;
-            m_cmd_signame << "[SIG]MEMC_" << x << "_" << y <<  " CMD" ;
-            std::ostringstream m_rsp_signame;
-            m_rsp_signame << "[SIG]MEMC_" << x << "_" << y <<  " RSP" ;
 
             //clusters[x][y]->memc->print_trace();
-            //clusters[x][y]->wt_memc->print_trace();
             //clusters[x][y]->signal_vci_tgt_memc.print_trace(smemc.str());
             //clusters[x][y]->signal_vci_xram.print_trace(sxram.str());
             //clusters[x][y]->signal_dspin_p2m_memc.print_trace(sp2m.str());
             //clusters[x][y]->signal_dspin_m2p_memc.print_trace(sm2p.str());
-            //clusters[x][y]->signal_dspin_cmd_memc_t.print_trace(m_cmd_signame.str());
-            //clusters[x][y]->signal_dspin_rsp_memc_t.print_trace(m_rsp_signame.str());
 
             // trace replicated peripherals
@@ -1035,8 +1022,5 @@
 
             //clusters[io_x][io_y]->brom->print_trace();
-            //clusters[io_x][io_y]->wt_brom->print_trace();
             //clusters[io_x][io_y]->signal_vci_tgt_brom.print_trace("[SIG]BROM");
-            //clusters[io_x][io_y]->signal_dspin_cmd_brom_t.print_trace("[SIG]BROM CMD");
-            //clusters[io_x][io_y]->signal_dspin_rsp_brom_t.print_trace("[SIG]BROM RSP");
 
             //clusters[io_x][io_y]->bdev->print_trace();
@@ -1093,5 +1077,5 @@
          ms1 = (uint64_t) t1.tv_sec * 1000ULL + (uint64_t) t1.tv_usec / 1000;
          ms2 = (uint64_t) t2.tv_sec * 1000ULL + (uint64_t) t2.tv_usec / 1000;
-         std::cerr << "cycle " << n << " platform clock frequency " << (double) nb_cycles / (double) (ms2 - ms1) << "Khz" << std::endl;
+         std::cerr << std::dec << "cycle " << n << " platform clock frequency " << (double) nb_cycles / (double) (ms2 - ms1) << "Khz" << std::endl;
       }
    }
Index: trunk/platforms/tsar_generic_xbar/top.desc
===================================================================
--- trunk/platforms/tsar_generic_xbar/top.desc	(revision 693)
+++ trunk/platforms/tsar_generic_xbar/top.desc	(revision 706)
@@ -7,5 +7,5 @@
 
 vci_plen_size       = 8
-vci_addr_size       = 40
+vci_addr_size       = 32
 vci_rerror_size     = 1
 vci_clen_size       = 1
@@ -22,5 +22,5 @@
 todo = Platform('caba', 'top.cpp',
 
-	uses = [
+    uses = [
             Uses('caba:tsar_xbar_cluster', 
                   vci_data_width_int = vci_cell_size_int,
@@ -29,5 +29,5 @@
                   dspin_rsp_width    = dspin_rsp_flit_size),
 
-	        Uses('common:elf_file_loader'),
+            Uses('common:elf_file_loader'),
             Uses('common:plain_file_loader'),
            ],
@@ -35,12 +35,12 @@
     # default VCI parameters (global variables)
     cell_size   = vci_cell_size_int,  
-	plen_size   = vci_plen_size,
-	addr_size   = vci_addr_size,
-	rerror_size = vci_rerror_size,
-	clen_size   = vci_clen_size,
-	rflag_size  = vci_rflag_size,
-	srcid_size  = vci_srcid_size,
-	pktid_size  = vci_pktid_size,
-	trdid_size  = vci_trdid_size,
-	wrplen_size = vci_wrplen_size,
+    plen_size   = vci_plen_size,
+    addr_size   = vci_addr_size,
+    rerror_size = vci_rerror_size,
+    clen_size   = vci_clen_size,
+    rflag_size  = vci_rflag_size,
+    srcid_size  = vci_srcid_size,
+    pktid_size  = vci_pktid_size,
+    trdid_size  = vci_trdid_size,
+    wrplen_size = vci_wrplen_size,
 )
Index: trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/metadata/tsar_xbar_cluster.sd
===================================================================
--- trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/metadata/tsar_xbar_cluster.sd	(revision 693)
+++ trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/metadata/tsar_xbar_cluster.sd	(revision 706)
@@ -3,5 +3,5 @@
 
 Module('caba:tsar_xbar_cluster', 
-    classname = 'soclib::caba::TsarXbarCluster',
+   classname = 'soclib::caba::TsarXbarCluster',
    tmpl_parameters = [
       parameter.Int('dspin_cmd_width'),
@@ -47,4 +47,7 @@
 
       Uses('caba:vci_xicu',
+              cell_size       = parameter.Reference('vci_data_width_int')),
+
+      Uses('caba:vci_local_crossbar', 
               cell_size       = parameter.Reference('vci_data_width_int')),
 
Index: trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/include/tsar_xbar_cluster.h
===================================================================
--- trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/include/tsar_xbar_cluster.h	(revision 693)
+++ trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/include/tsar_xbar_cluster.h	(revision 706)
@@ -24,4 +24,5 @@
 #include "vci_xicu.h"
 #include "dspin_local_crossbar.h"
+#include "vci_local_crossbar.h"
 #include "vci_dspin_initiator_wrapper.h"
 #include "vci_dspin_target_wrapper.h"
@@ -36,5 +37,4 @@
 #include "vci_cc_vcache_wrapper.h"
 #include "vci_simhelper.h"
-#include "../../../../giet_vm/hard_config.h"
 
 namespace soclib { namespace caba {
@@ -63,5 +63,5 @@
     // interrupt signals
     sc_signal<bool>         signal_false;
-    sc_signal<bool>         signal_proc_it[8*IRQ_PER_PROCESSOR];
+    sc_signal<bool>         signal_proc_it[8 * 6]; // 6 = Number of IRQs in the MIPS
     sc_signal<bool>         signal_irq_mdma[8];
     sc_signal<bool>         signal_irq_mtty[23];
@@ -85,4 +85,7 @@
 
     // Direct VCI signals to VCI/DSPIN wrappers
+    VciSignals<vci_param_int>       signal_vci_g2l_d;
+    VciSignals<vci_param_int>       signal_vci_l2g_d;
+
     VciSignals<vci_param_int>       signal_vci_ini_proc[8];
     VciSignals<vci_param_int>       signal_vci_ini_mdma;
@@ -101,34 +104,4 @@
     VciSignals<vci_param_int>       signal_vci_tgt_simh;
 
-    // Direct DSPIN signals to local crossbars
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_proc_i[8];
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_proc_i[8];
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mdma_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mdma_i;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_bdev_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_bdev_i;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_chbuf_i;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_chbuf_i;
-
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_memc_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_memc_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_xicu_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_xicu_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mdma_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mdma_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mtty_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mtty_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_bdev_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_bdev_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_brom_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_brom_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_fbuf_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_fbuf_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_mnic_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_mnic_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_chbuf_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_chbuf_t;
-    DspinSignals<dspin_cmd_width>     signal_dspin_cmd_simh_t;
-    DspinSignals<dspin_rsp_width>     signal_dspin_rsp_simh_t;
 
     // Coherence DSPIN signals to local crossbar
@@ -150,7 +123,4 @@
                        GdbServer<Mips32ElIss> >*  proc[8];
 
-    VciDspinInitiatorWrapper<vci_param_int,
-                             dspin_cmd_width,
-                             dspin_rsp_width>*    wi_proc[8];
 
     VciMemCache<vci_param_int,
@@ -159,79 +129,32 @@
                 dspin_cmd_width>*                 memc;
 
+    VciXicu<vci_param_int>*                       xicu;
+
+    VciMultiDma<vci_param_int>*                   mdma;
+
+    VciSimpleRam<vci_param_ext>*                  xram;
+
+    VciSimpleRom<vci_param_int>*                  brom;
+
+    VciMultiTty<vci_param_int>*                   mtty;
+
+    VciSimhelper<vci_param_int>*                  simhelper;
+
+    VciFrameBuffer<vci_param_int>*                fbuf;
+
+    VciMultiNic<vci_param_int>*                  mnic;
+
+    VciChbufDma<vci_param_int>*                   chbuf;
+
+    VciBlockDeviceTsar<vci_param_int>*            bdev;
+
+    VciLocalCrossbar<vci_param_int>*              xbar_d;
+    VciDspinInitiatorWrapper<vci_param_int,
+                             dspin_cmd_width,
+                             dspin_rsp_width>*    wi_xbar_d;
     VciDspinTargetWrapper<vci_param_int,
                           dspin_cmd_width,
-                          dspin_rsp_width>*       wt_memc;
-
-    VciXicu<vci_param_int>*                       xicu;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_xicu;
-
-    VciMultiDma<vci_param_int>*                   mdma;
-
-    VciDspinInitiatorWrapper<vci_param_int,
-                             dspin_cmd_width,
-                             dspin_rsp_width>*    wi_mdma;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_mdma;
-
-    VciSimpleRam<vci_param_ext>*                  xram;
-
-    VciSimpleRom<vci_param_int>*                  brom;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_brom;
-
-    VciMultiTty<vci_param_int>*                   mtty;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_mtty;
-
-    VciSimhelper<vci_param_int>*                  simhelper;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_simhelper;
-
-
-    VciFrameBuffer<vci_param_int>*                fbuf;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_fbuf;
-
-    VciMultiNic<vci_param_int>*                   mnic;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_mnic;
-
-    VciChbufDma<vci_param_int>*                   chbuf;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_chbuf;
-
-    VciDspinInitiatorWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wi_chbuf;
-
-    VciBlockDeviceTsar<vci_param_int>*            bdev;
-
-    VciDspinInitiatorWrapper<vci_param_int,
-                             dspin_cmd_width,
-                             dspin_rsp_width>*    wi_bdev;
-
-    VciDspinTargetWrapper<vci_param_int,
-                          dspin_cmd_width,
-                          dspin_rsp_width>*       wt_bdev;
-
-    DspinLocalCrossbar<dspin_cmd_width>*          xbar_cmd_d;
-    DspinLocalCrossbar<dspin_rsp_width>*          xbar_rsp_d;
+                          dspin_rsp_width>*       wt_xbar_d;
+
     DspinLocalCrossbar<dspin_cmd_width>*          xbar_m2p_c;
     DspinLocalCrossbar<dspin_rsp_width>*          xbar_p2m_c;
@@ -269,4 +192,5 @@
                      size_t                             l1_d_ways,
                      size_t                             l1_d_sets,
+                     size_t                             irq_per_processor,
                      size_t                             xram_latency,  // external ram
                      bool                               io,            // I/O cluster
Index: trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/src/tsar_xbar_cluster.cpp
===================================================================
--- trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/src/tsar_xbar_cluster.cpp	(revision 693)
+++ trunk/platforms/tsar_generic_xbar/tsar_xbar_cluster/caba/source/src/tsar_xbar_cluster.cpp	(revision 706)
@@ -66,4 +66,5 @@
          size_t                             l1_d_ways,
          size_t                             l1_d_sets,
+         size_t                             irq_per_processor,
          size_t                             xram_latency,
          bool                               io,
@@ -77,5 +78,5 @@
          uint32_t                           nic_timeout,
          size_t                             chbufdma_channels,
-         const Loader                      &loader,
+         const Loader &                     loader,
          uint32_t                           frozen_cycles,
          uint32_t                           debug_start_cycle,
@@ -127,11 +128,4 @@
                       proc_debug_ok);
 
-        std::ostringstream swip;
-        swip << "wi_proc_" << x_id << "_" << y_id << "_" << p;
-        wi_proc[p] = new VciDspinInitiatorWrapper<vci_param_int,
-                                                  dspin_cmd_width,
-                                                  dspin_rsp_width>(
-                     swip.str().c_str(),
-                     x_width + y_width + l_width);
     }
 
@@ -148,4 +142,5 @@
                      IntTab(cluster_id),                 // SRCID external space
                      IntTab(cluster_id, tgtid_memc),     // TGTID direct space
+                     //(cluster_id << l_width) + nb_procs, // CC_GLOBAL_ID
                      x_width,                            // Number of x bits in platform
                      y_width,                            // Number of y bits in platform
@@ -159,9 +154,4 @@
                      memc_debug_ok);
 
-    wt_memc = new VciDspinTargetWrapper<vci_param_int,
-                                        dspin_cmd_width,
-                                        dspin_rsp_width>(
-                     "wt_memc",
-                     x_width + y_width + l_width);
 
     /////////////////////////////////////////////////////////////////////////////
@@ -182,14 +172,9 @@
                      mtd,                               // mapping table
                      IntTab(cluster_id, tgtid_xicu),    // TGTID_D
-                     32,                                // number of timer IRQs
+                     nb_procs,                          // number of timer IRQs
                      32,                                // number of hard IRQs
                      32,                                // number of soft IRQs
-                     nb_procs*IRQ_PER_PROCESSOR);       // number of output IRQs
-
-    wt_xicu = new VciDspinTargetWrapper<vci_param_int,
-                                        dspin_cmd_width,
-                                        dspin_rsp_width>(
-                     "wt_xicu",
-                     x_width + y_width + l_width);
+                     nb_procs*irq_per_processor);                         // number of output IRQs
+
 
     /////////////////////////////////////////////////////////////////////////////
@@ -204,15 +189,4 @@
                      nb_dmas);                            // number of IRQs
 
-    wt_mdma = new VciDspinTargetWrapper<vci_param_int,
-                                        dspin_cmd_width,
-                                        dspin_rsp_width>(
-                     "wt_mdma",
-                     x_width + y_width + l_width);
-
-    wi_mdma = new VciDspinInitiatorWrapper<vci_param_int,
-                                           dspin_cmd_width,
-                                           dspin_rsp_width>(
-                     "wi_mdma",
-                     x_width + y_width + l_width);
 
     /////////////////////////////////////////////////////////////////////////////
@@ -225,28 +199,27 @@
     }
 
-    xbar_cmd_d = new DspinLocalCrossbar<dspin_cmd_width>(
-                     "xbar_cmd_d",
-                     mtd,                          // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, l_width,
-                     nb_direct_initiators,         // number of local of sources
-                     nb_direct_targets,            // number of local dests 
-                     2, 2,                         // fifo depths  
-                     true,                         // CMD
-                     true,                         // use local routing table 
-                     false );                      // no broadcast
-
-    /////////////////////////////////////////////////////////////////////////////
-    xbar_rsp_d = new DspinLocalCrossbar<dspin_rsp_width>(
-                     "xbar_rsp_d",
-                     mtd,                          // mapping table
-                     x_id, y_id,                   // cluster coordinates
-                     x_width, y_width, l_width,
-                     nb_direct_targets,            // number of local sources
-                     nb_direct_initiators,         // number of local dests
-                     2, 2,                         // fifo depths  
-                     false,                        // RSP
-                     false,                        // don't use local routing table 
-                     false );                      // no broadcast
+    std::ostringstream sxbar;
+    sxbar << "xbar_" << x_id << "_" << y_id;
+    xbar_d = new VciLocalCrossbar<vci_param_int>(
+                     sxbar.str().c_str(),
+                     mtd,                             // mapping table
+                     //x_id, y_id,                    // cluster coordinates
+                     cluster_id,
+                     nb_direct_initiators,            // number of local of sources
+                     nb_direct_targets,               // number of local dests 
+                     tgtid_memc);                     // Default target
+
+    ////////////// vci_dspin wrappers 
+    std::ostringstream swtxbar;
+    swtxbar << "wt_xbar_" << x_id << "_" << y_id;
+    wt_xbar_d = new VciDspinTargetWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>(
+                swtxbar.str().c_str(),
+                x_width + y_width + l_width );
+
+    std::ostringstream swixbar;
+    swixbar << "wi_xbar_" << x_id << "_" << y_id;
+    wi_xbar_d = new VciDspinInitiatorWrapper<vci_param_int, dspin_cmd_width, dspin_rsp_width>(
+                swixbar.str().c_str(),
+                x_width + y_width + l_width );
 
     /////////////////////////////////////////////////////////////////////////////
@@ -315,10 +288,4 @@
                      loader);
 
-        wt_brom = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_brom",
-                     x_width + y_width + l_width);
-
         /////////////////////////////////////////////
         fbuf = new VciFrameBuffer<vci_param_int>(
@@ -327,10 +294,4 @@
                      mtd,
                      xfb, yfb);
-
-        wt_fbuf = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_fbuf",
-                     x_width + y_width + l_width);
 
         /////////////////////////////////////////////
@@ -343,16 +304,4 @@
                      block_size,
                      64);            // burst size
-
-        wt_bdev = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_bdev",
-                     x_width + y_width + l_width);
-
-        wi_bdev = new VciDspinInitiatorWrapper<vci_param_int,
-                                               dspin_cmd_width,
-                                               dspin_rsp_width>(
-                     "wi_bdev",
-                     x_width + y_width + l_width);
 
         int mac = 0xBEEF0000;
@@ -367,9 +316,5 @@
                      nic_tx_name);
 
-        wt_mnic = new VciDspinTargetWrapper<vci_param_int,
-                                           dspin_cmd_width,
-                                           dspin_rsp_width>(
-                    "wt_mnic",
-                    x_width + y_width + l_width);
+
 
         /////////////////////////////////////////////
@@ -382,16 +327,4 @@
                      chbufdma_channels); 
 
-        wt_chbuf = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_chbuf",
-                     x_width + y_width + l_width);
-
-        wi_chbuf = new VciDspinInitiatorWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wi_chbuf",
-                     x_width + y_width + l_width);
-
         /////////////////////////////////////////////
         std::vector<std::string> vect_names;
@@ -408,20 +341,8 @@
                      vect_names);
 
-        wt_mtty = new VciDspinTargetWrapper<vci_param_int,
-                                            dspin_cmd_width,
-                                            dspin_rsp_width>(
-                     "wt_mtty",
-                     x_width + y_width + l_width);
-
         simhelper = new VciSimhelper<vci_param_int>(
                      "sim_helper",
                      IntTab(cluster_id, tgtid_simh),
                      mtd);
-
-        wt_simhelper = new VciDspinTargetWrapper<vci_param_int,
-                                                 dspin_cmd_width,
-                                                 dspin_rsp_width>(
-                     "wt_simhelper",
-                     x_width + y_width + l_width);
     }
 
@@ -466,65 +387,50 @@
     std::cout << "  - CMD & RSP routers connected" << std::endl;
 
-    ///////////////////// CMD DSPIN  local crossbar direct
-    xbar_cmd_d->p_clk                            (this->p_clk);
-    xbar_cmd_d->p_resetn                         (this->p_resetn);
-    xbar_cmd_d->p_global_out                     (signal_dspin_cmd_l2g_d);
-    xbar_cmd_d->p_global_in                      (signal_dspin_cmd_g2l_d);
-
-    xbar_cmd_d->p_local_out[tgtid_memc]          (signal_dspin_cmd_memc_t);
-    xbar_cmd_d->p_local_out[tgtid_xicu]          (signal_dspin_cmd_xicu_t);
-    xbar_cmd_d->p_local_out[tgtid_mdma]          (signal_dspin_cmd_mdma_t);
-
-    xbar_cmd_d->p_local_in[nb_procs]             (signal_dspin_cmd_mdma_i);
+    wi_xbar_d->p_clk                         (this->p_clk);
+    wi_xbar_d->p_resetn                      (this->p_resetn);
+    wi_xbar_d->p_vci                         (signal_vci_l2g_d);
+    wi_xbar_d->p_dspin_cmd                   (signal_dspin_cmd_l2g_d);
+    wi_xbar_d->p_dspin_rsp                   (signal_dspin_rsp_g2l_d);
+
+    std::cout << "  - Wrapper Ini VCI2DSPIN Direct connected" << std::endl;
+
+    wt_xbar_d->p_clk                         (this->p_clk);
+    wt_xbar_d->p_resetn                      (this->p_resetn);
+    wt_xbar_d->p_vci                         (signal_vci_g2l_d);
+    wt_xbar_d->p_dspin_cmd                   (signal_dspin_cmd_g2l_d);
+    wt_xbar_d->p_dspin_rsp                   (signal_dspin_rsp_l2g_d);
+
+    std::cout << "  - Wrapper Tgt VCI2DSPIN Direct connected" << std::endl;
+
+    ///////////////////// CMD VCI  local crossbar direct
+    xbar_d->p_clk                            (this->p_clk);
+    xbar_d->p_resetn                         (this->p_resetn);
+    xbar_d->p_target_to_up                   (signal_vci_g2l_d);
+    xbar_d->p_initiator_to_up                (signal_vci_l2g_d);
+
+    xbar_d->p_to_target[tgtid_memc]          (signal_vci_tgt_memc);
+    xbar_d->p_to_target[tgtid_xicu]          (signal_vci_tgt_xicu);
+    xbar_d->p_to_target[tgtid_mdma]          (signal_vci_tgt_mdma);
+
+    xbar_d->p_to_initiator[nb_procs]         (signal_vci_ini_mdma);
 
     for (size_t p = 0; p < nb_procs; p++)
-        xbar_cmd_d->p_local_in[p]                (signal_dspin_cmd_proc_i[p]);
+        xbar_d->p_to_initiator[p]            (signal_vci_ini_proc[p]);
 
     if (io)
     {
-        xbar_cmd_d->p_local_out[tgtid_mtty]      (signal_dspin_cmd_mtty_t);
-        xbar_cmd_d->p_local_out[tgtid_brom]      (signal_dspin_cmd_brom_t);
-        xbar_cmd_d->p_local_out[tgtid_bdev]      (signal_dspin_cmd_bdev_t);
-        xbar_cmd_d->p_local_out[tgtid_fbuf]      (signal_dspin_cmd_fbuf_t);
-        xbar_cmd_d->p_local_out[tgtid_mnic]      (signal_dspin_cmd_mnic_t);
-        xbar_cmd_d->p_local_out[tgtid_chbuf]     (signal_dspin_cmd_chbuf_t);
-        xbar_cmd_d->p_local_out[tgtid_simh]      (signal_dspin_cmd_simh_t);
-
-        xbar_cmd_d->p_local_in[nb_procs + 1]     (signal_dspin_cmd_bdev_i);
-        xbar_cmd_d->p_local_in[nb_procs + 2]     (signal_dspin_cmd_chbuf_i);
-    }
-
-    std::cout << "  - Command Direct crossbar connected" << std::endl;
-
-    //////////////////////// RSP DSPIN  local crossbar direct
-    xbar_rsp_d->p_clk                            (this->p_clk);
-    xbar_rsp_d->p_resetn                         (this->p_resetn);
-    xbar_rsp_d->p_global_out                     (signal_dspin_rsp_l2g_d);
-    xbar_rsp_d->p_global_in                      (signal_dspin_rsp_g2l_d);
-
-    xbar_rsp_d->p_local_in[tgtid_memc]           (signal_dspin_rsp_memc_t);
-    xbar_rsp_d->p_local_in[tgtid_xicu]           (signal_dspin_rsp_xicu_t);
-    xbar_rsp_d->p_local_in[tgtid_mdma]           (signal_dspin_rsp_mdma_t);
-
-    xbar_rsp_d->p_local_out[nb_procs]            (signal_dspin_rsp_mdma_i);
-
-    for (size_t p = 0; p < nb_procs; p++)
-        xbar_rsp_d->p_local_out[p]               (signal_dspin_rsp_proc_i[p]);
-
-    if (io)
-    {
-        xbar_rsp_d->p_local_in[tgtid_mtty]       (signal_dspin_rsp_mtty_t);
-        xbar_rsp_d->p_local_in[tgtid_brom]       (signal_dspin_rsp_brom_t);
-        xbar_rsp_d->p_local_in[tgtid_bdev]       (signal_dspin_rsp_bdev_t);
-        xbar_rsp_d->p_local_in[tgtid_fbuf]       (signal_dspin_rsp_fbuf_t);
-        xbar_rsp_d->p_local_in[tgtid_mnic]       (signal_dspin_rsp_mnic_t);
-        xbar_rsp_d->p_local_in[tgtid_chbuf]      (signal_dspin_rsp_chbuf_t);
-        xbar_rsp_d->p_local_in[tgtid_simh]       (signal_dspin_rsp_simh_t);
-
-        xbar_rsp_d->p_local_out[nb_procs + 1]    (signal_dspin_rsp_bdev_i);
-        xbar_rsp_d->p_local_out[nb_procs + 2]    (signal_dspin_rsp_chbuf_i);
-    }
-
-    std::cout << "  - Response Direct crossbar connected" << std::endl;
+        xbar_d->p_to_target[tgtid_mtty]      (signal_vci_tgt_mtty);
+        xbar_d->p_to_target[tgtid_brom]      (signal_vci_tgt_brom);
+        xbar_d->p_to_target[tgtid_bdev]      (signal_vci_tgt_bdev);
+        xbar_d->p_to_target[tgtid_fbuf]      (signal_vci_tgt_fbuf);
+        xbar_d->p_to_target[tgtid_mnic]      (signal_vci_tgt_mnic);
+        xbar_d->p_to_target[tgtid_chbuf]     (signal_vci_tgt_chbuf);
+        xbar_d->p_to_target[tgtid_simh]      (signal_vci_tgt_simh);
+
+        xbar_d->p_to_initiator[nb_procs + 1] (signal_vci_ini_bdev);
+        xbar_d->p_to_initiator[nb_procs + 2] (signal_vci_ini_chbuf);
+    }
+
+    std::cout << "  - Direct crossbar connected" << std::endl;
 
     ////////////////////// M2P DSPIN local crossbar coherence
@@ -572,18 +478,13 @@
         proc[p]->p_dspin_clack              (signal_dspin_clack_proc[p]);
 
-        for ( size_t i = 0 ; i < IRQ_PER_PROCESSOR ; i++)
-        {
-            proc[p]->p_irq[i]               (signal_proc_it[p*IRQ_PER_PROCESSOR+i]);
-        }
-        for ( size_t j = IRQ_PER_PROCESSOR ; j < 6 ; j++)
+        for ( size_t i = 0; i < irq_per_processor; i++)
+        {
+            proc[p]->p_irq[i]               (signal_proc_it[p*irq_per_processor + i]);
+        }
+        for ( size_t j = irq_per_processor; j < 6; j++) // 6 = number of irqs in the MIPS
         {
             proc[p]->p_irq[j]               (signal_false);
         }
 
-        wi_proc[p]->p_clk                   (this->p_clk);
-        wi_proc[p]->p_resetn                (this->p_resetn);
-        wi_proc[p]->p_dspin_cmd             (signal_dspin_cmd_proc_i[p]);
-        wi_proc[p]->p_dspin_rsp             (signal_dspin_rsp_proc_i[p]);
-        wi_proc[p]->p_vci                   (signal_vci_ini_proc[p]);
     }
 
@@ -594,8 +495,7 @@
     xicu->p_resetn                     (this->p_resetn);
     xicu->p_vci                        (signal_vci_tgt_xicu);
-
-    for (size_t i = 0; i < nb_procs*IRQ_PER_PROCESSOR; i++)
-    {
-        xicu->p_irq[i]                       (signal_proc_it[i]);
+    for (size_t p = 0; p < nb_procs * irq_per_processor; p++)
+    {
+        xicu->p_irq[p]                 (signal_proc_it[p]);
     }
     for (size_t i = 0; i < 32; i++)
@@ -620,11 +520,4 @@
         }
     }
-
-    // wrapper XICU
-    wt_xicu->p_clk                     (this->p_clk);
-    wt_xicu->p_resetn                  (this->p_resetn);
-    wt_xicu->p_dspin_cmd               (signal_dspin_cmd_xicu_t);
-    wt_xicu->p_dspin_rsp               (signal_dspin_rsp_xicu_t);
-    wt_xicu->p_vci                     (signal_vci_tgt_xicu);
 
     std::cout << "  - XICU connected" << std::endl;
@@ -640,11 +533,4 @@
     memc->p_dspin_clack                (signal_dspin_clack_memc);
 
-    // wrapper MEMC
-    wt_memc->p_clk                     (this->p_clk);
-    wt_memc->p_resetn                  (this->p_resetn);
-    wt_memc->p_dspin_cmd               (signal_dspin_cmd_memc_t);
-    wt_memc->p_dspin_rsp               (signal_dspin_rsp_memc_t);
-    wt_memc->p_vci                     (signal_vci_tgt_memc);
-
     std::cout << "  - MEMC connected" << std::endl;
 
@@ -664,18 +550,4 @@
         mdma->p_irq[i]                 (signal_irq_mdma[i]);
 
-    // wrapper tgt MDMA
-    wt_mdma->p_clk                     (this->p_clk);
-    wt_mdma->p_resetn                  (this->p_resetn);
-    wt_mdma->p_dspin_cmd               (signal_dspin_cmd_mdma_t);
-    wt_mdma->p_dspin_rsp               (signal_dspin_rsp_mdma_t);
-    wt_mdma->p_vci                     (signal_vci_tgt_mdma);
-
-    // wrapper ini MDMA
-    wi_mdma->p_clk                     (this->p_clk);
-    wi_mdma->p_resetn                  (this->p_resetn);
-    wi_mdma->p_dspin_cmd               (signal_dspin_cmd_mdma_i);
-    wi_mdma->p_dspin_rsp               (signal_dspin_rsp_mdma_i);
-    wi_mdma->p_vci                     (signal_vci_ini_mdma);
-
     std::cout << "  - MDMA connected" << std::endl;
 
@@ -691,18 +563,4 @@
         bdev->p_vci_initiator          (signal_vci_ini_bdev);
 
-        // wrapper tgt BDEV
-        wt_bdev->p_clk                 (this->p_clk);
-        wt_bdev->p_resetn              (this->p_resetn);
-        wt_bdev->p_dspin_cmd           (signal_dspin_cmd_bdev_t);
-        wt_bdev->p_dspin_rsp           (signal_dspin_rsp_bdev_t);
-        wt_bdev->p_vci                 (signal_vci_tgt_bdev);
-
-        // wrapper ini BDEV
-        wi_bdev->p_clk                 (this->p_clk);
-        wi_bdev->p_resetn              (this->p_resetn);
-        wi_bdev->p_dspin_cmd           (signal_dspin_cmd_bdev_i);
-        wi_bdev->p_dspin_rsp           (signal_dspin_rsp_bdev_i);
-        wi_bdev->p_vci                 (signal_vci_ini_bdev);
-
         std::cout << "  - BDEV connected" << std::endl;
 
@@ -711,11 +569,4 @@
         fbuf->p_resetn                 (this->p_resetn);
         fbuf->p_vci                    (signal_vci_tgt_fbuf);
-
-        // wrapper tgt FBUF
-        wt_fbuf->p_clk                 (this->p_clk);
-        wt_fbuf->p_resetn              (this->p_resetn);
-        wt_fbuf->p_dspin_cmd           (signal_dspin_cmd_fbuf_t);
-        wt_fbuf->p_dspin_rsp           (signal_dspin_rsp_fbuf_t);
-        wt_fbuf->p_vci                 (signal_vci_tgt_fbuf);
 
         std::cout << "  - FBUF connected" << std::endl;
@@ -730,11 +581,4 @@
             mnic->p_tx_irq[i]          (signal_irq_mnic_tx[i]);
         }
-
-        // wrapper tgt MNIC
-        wt_mnic->p_clk                 (this->p_clk);
-        wt_mnic->p_resetn              (this->p_resetn);
-        wt_mnic->p_dspin_cmd           (signal_dspin_cmd_mnic_t);
-        wt_mnic->p_dspin_rsp           (signal_dspin_rsp_mnic_t);
-        wt_mnic->p_vci                 (signal_vci_tgt_mnic);
 
         std::cout << "  - MNIC connected" << std::endl;
@@ -750,18 +594,4 @@
         }
 
-        // wrapper tgt CHBUF
-        wt_chbuf->p_clk                 (this->p_clk);
-        wt_chbuf->p_resetn              (this->p_resetn);
-        wt_chbuf->p_dspin_cmd           (signal_dspin_cmd_chbuf_t);
-        wt_chbuf->p_dspin_rsp           (signal_dspin_rsp_chbuf_t);
-        wt_chbuf->p_vci                 (signal_vci_tgt_chbuf);
-
-        // wrapper ini CHBUF
-        wi_chbuf->p_clk                 (this->p_clk);
-        wi_chbuf->p_resetn              (this->p_resetn);
-        wi_chbuf->p_dspin_cmd           (signal_dspin_cmd_chbuf_i);
-        wi_chbuf->p_dspin_rsp           (signal_dspin_rsp_chbuf_i);
-        wi_chbuf->p_vci                 (signal_vci_ini_chbuf);
-
         std::cout << "  - CHBUF connected" << std::endl;
 
@@ -770,11 +600,4 @@
         brom->p_resetn                 (this->p_resetn);
         brom->p_vci                    (signal_vci_tgt_brom);
-
-        // wrapper tgt BROM
-        wt_brom->p_clk                 (this->p_clk);
-        wt_brom->p_resetn              (this->p_resetn);
-        wt_brom->p_dspin_cmd           (signal_dspin_cmd_brom_t);
-        wt_brom->p_dspin_rsp           (signal_dspin_rsp_brom_t);
-        wt_brom->p_vci                 (signal_vci_tgt_brom);
 
         std::cout << "  - BROM connected" << std::endl;
@@ -789,10 +612,5 @@
         }
 
-        // wrapper tgt MTTY
-        wt_mtty->p_clk                 (this->p_clk);
-        wt_mtty->p_resetn              (this->p_resetn);
-        wt_mtty->p_dspin_cmd           (signal_dspin_cmd_mtty_t);
-        wt_mtty->p_dspin_rsp           (signal_dspin_rsp_mtty_t);
-        wt_mtty->p_vci                 (signal_vci_tgt_mtty);
+        std::cout << "  - MTTY connected" << std::endl;
 
 
@@ -802,12 +620,5 @@
         simhelper->p_vci               (signal_vci_tgt_simh);
         
-        // wrapper tgt Sim Helper
-        wt_simhelper->p_clk            (this->p_clk);
-        wt_simhelper->p_resetn         (this->p_resetn);
-        wt_simhelper->p_dspin_cmd      (signal_dspin_cmd_simh_t);
-        wt_simhelper->p_dspin_rsp      (signal_dspin_rsp_simh_t);
-        wt_simhelper->p_vci            (signal_vci_tgt_simh);
-
-        std::cout << "  - MTTY connected" << std::endl;
+        std::cout << "  - SIMH connected" << std::endl;
    }
 } // end constructor
@@ -831,17 +642,13 @@
     {
         delete proc[p];
-        delete wi_proc[p];
     }
 
     delete memc;
-    delete wt_memc;
     delete xram;
     delete xicu;
-    delete wt_xicu;
     delete mdma;
-    delete wt_mdma;
-    delete wi_mdma;
-    delete xbar_cmd_d;
-    delete xbar_rsp_d;
+    delete xbar_d;
+    delete wt_xbar_d;
+    delete wi_xbar_d;
     delete xbar_m2p_c;
     delete xbar_p2m_c;
@@ -852,19 +659,10 @@
     {
         delete brom;
-        delete wt_brom;
         delete fbuf;
-        delete wt_fbuf;
         delete bdev;
-        delete wt_bdev;
-        delete wi_bdev;
         delete mnic;
-        delete wt_mnic;
         delete chbuf;
-        delete wt_chbuf;
-        delete wi_chbuf;
         delete mtty;
-        delete wt_mtty;
         delete simhelper;
-        delete wt_simhelper;
     }
 }
