#ifdef SYSTEMC
/*
 * $Id: Simulation.cpp 88 2008-12-10 18:31:39Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Simulation.h"
#include "Common/include/ErrorMorpheo.h"

namespace morpheo              {
namespace behavioural          {

  static bool            simulation_initialized;
//   static uint32_t       _simulation_num_context_next;
  double                _simulation_nb_cycle;
//   double                _simulation_nb_instruction;
//   std::vector<double> * _simulation_nb_instruction_commited;

//   Simulation::Simulation (void):
//     _num_context (_simulation_num_context_next)
//   {
//     // Test if is first context create
//     if (_simulation_num_context_next == 0)
//       _simulation_nb_instruction_commited = new std::vector<double>;

//     _simulation_num_context_next ++;
//   }
  
//   Simulation::~Simulation (void)
//   {
//     _simulation_num_context_next --;
    
//     // Test if is last context destroy
//     if (_simulation_num_context_next == 0)
//       delete _simulation_nb_instruction_commited;
//   }

  void simulation_init (double nb_cycle,
                        double nb_instruction)
  {
    if (not simulation_initialized)
      {
//         _simulation_num_context_next = 0;
        _simulation_nb_cycle         = nb_cycle       ;
//         _simulation_nb_instruction   = nb_instruction;

        if (nb_instruction != 0)
          throw ERRORMORPHEO("simulation_init",_("Stop Condition on number instruction is not yet implemented"));
        
        simulation_initialized = true;
      }
    else
      {
        msg_printf(WARNING,_("Multi instance of Morpheo : stop condition, take the highest."));

        if (_simulation_nb_cycle < nb_cycle)
          _simulation_nb_cycle = nb_cycle;

//         if (_simulation_nb_instruction < nb_instruction)
//           _simulation_nb_instruction = nb_instruction;
      }
  }
    
}; // end namespace behavioural          
}; // end namespace morpheo              

#endif
