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

#include "Behavioural/include/Simulation.h"

namespace morpheo              {
namespace behavioural          {

  bool simulation_test_end (void)
  {
    msg("##########[ cycle %d ]\n",static_cast<uint32_t>(sc_simulation_time()));

    // Test if a stop condition is activate
    if ((_simulation_nb_cycle == 0)//  and
//         (_simulation_nb_instruction == 0)
        )
      return false;

    bool end_cycle = true;
//     bool end_inst  = true;

    if (_simulation_nb_cycle != 0)
      end_cycle = (_simulation_nb_cycle <= sc_simulation_time());

//     if (_simulation_nb_instruction != 0)
//       {
//         std::vector<double>::iterator it=_simulation_nb_instruction_commited->begin();
        
//         // Scan all context and test if all can finish
//         while (end_inst and it!=_simulation_nb_instruction_commited->end())
//           {
//             end_inst &= (*it <= _simulation_nb_instruction);
//             it ++;
//           }
//       }
    
    return end_cycle // and end_inst
      ;
  }

}; // end namespace behavioural          
}; // end namespace morpheo              

#endif
