/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/Branch_Target_Buffer_Glue/SelfTest/include/test.h"

#define NB_PARAMS 7

void usage (int argc, char * argv[])
{
  err (_("<Usage> %s name_instance list_params.\n"),argv[0]);
  err (_("list_params is :\n"));
  err (_(" * max_nb_instruction (uint32_t)\n"));
  err (_(" * size_buffer        (uint32_t)\n"));
  err (_(" * associativity      (uint32_t)\n"));
  err (_(" * size_address       (uint32_t)\n"));
  err (_(" * nb_inst_predict    (uint32_t)\n"));
  err (_(" * nb_inst_decod      (uint32_t)\n"));
  err (_(" * nb_inst_update     (uint32_t)\n"));

  exit (1);
}

#ifndef SYSTEMC
int main    (int argc, char * argv[])
#else
int sc_main (int argc, char * argv[])
#endif
{
  if (argc != static_cast<int>(2+NB_PARAMS))
    usage (argc, argv);

  uint32_t x = 1;

  string name = argv[x++];
  uint32_t   _max_nb_instruction = fromString<uint32_t>(argv[x++]);
  uint32_t   _size_buffer        = fromString<uint32_t>(argv[x++]);
  uint32_t   _associativity      = fromString<uint32_t>(argv[x++]);
  uint32_t   _size_address       = fromString<uint32_t>(argv[x++]);
  uint32_t   _nb_inst_predict    = fromString<uint32_t>(argv[x++]);
  uint32_t   _nb_inst_decod      = fromString<uint32_t>(argv[x++]);
  uint32_t   _nb_inst_update     = fromString<uint32_t>(argv[x++]);

  int _return = EXIT_SUCCESS;
  try 
    {
      morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer::branch_target_buffer_glue::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer::branch_target_buffer_glue::Parameters
	(_max_nb_instruction ,
	 _size_buffer        ,
	 _associativity      ,
	 _size_address       ,
	 _nb_inst_predict    ,
	 _nb_inst_decod      ,
	 _nb_inst_update     );
      
      msg(_("%s"),param->print(1).c_str());
      
      test (name,param);
    }
  catch (morpheo::ErrorMorpheo & error)
    {
      msg (_("<%s> :\n%s"),name.c_str(), error.what ());
      _return = EXIT_FAILURE;
    }
  catch (...)
    {
      err (_("<%s> : This test must generate a error.\n"),name.c_str());
      _return = EXIT_FAILURE;
    }

  return (_return);
}
