[88] | 1 | /* |
---|
| 2 | * $Id: main.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Front_end_Glue/SelfTest/include/test.h" |
---|
| 9 | |
---|
| 10 | #define NB_PARAMS 4 |
---|
| 11 | |
---|
| 12 | void usage (int argc, char * argv[]) |
---|
| 13 | { |
---|
| 14 | err (_("<Usage> %s name_instance list_params.\n"),argv[0]); |
---|
| 15 | err (_("list_params is :\n")); |
---|
| 16 | err (_(" * nb_context (uint32_t)\n")); |
---|
| 17 | err (_(" * nb_decod_unit (uint32_t)\n")); |
---|
| 18 | err (_(" * nb_inst_decod [nb_decod_unit] (uint32_t)\n")); |
---|
| 19 | err (_(" * nb_inst_branch_complete (uint32_t)\n")); |
---|
| 20 | err (_(" * link_context_to_decod_unit [nb_context] (uint32_t)\n")); |
---|
| 21 | err (_(" * size_address (uint32_t)\n")); |
---|
| 22 | err (_(" * size_depth [nb_context] (uint32_t)\n")); |
---|
| 23 | err (_(" * nb_branch_speculated [nb_context] (uint32_t)\n")); |
---|
| 24 | |
---|
| 25 | exit (1); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | #ifndef SYSTEMC |
---|
| 29 | int main (int argc, char * argv[]) |
---|
| 30 | #else |
---|
| 31 | int sc_main (int argc, char * argv[]) |
---|
| 32 | #endif |
---|
| 33 | { |
---|
| 34 | for (int32_t i=0; i<argc; ++i) |
---|
| 35 | msg("%s ",argv[i]); |
---|
| 36 | msg("\n"); |
---|
| 37 | |
---|
| 38 | if (argc <= static_cast<int>(2+NB_PARAMS)) |
---|
| 39 | usage (argc, argv); |
---|
| 40 | |
---|
| 41 | uint32_t x = 1; |
---|
| 42 | |
---|
| 43 | string name = argv[x++]; |
---|
| 44 | |
---|
| 45 | uint32_t _nb_context = fromString<uint32_t>(argv[x++]); |
---|
| 46 | uint32_t _nb_decod_unit = fromString<uint32_t>(argv[x++]); |
---|
| 47 | |
---|
| 48 | if (argc != static_cast<int>(2+NB_PARAMS+3*_nb_context+1*_nb_decod_unit)) |
---|
| 49 | usage (argc, argv); |
---|
| 50 | |
---|
| 51 | uint32_t * _nb_inst_decod = new uint32_t [_nb_decod_unit]; |
---|
| 52 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 53 | _nb_inst_decod [i] = fromString<uint32_t>(argv[x++]); |
---|
| 54 | |
---|
| 55 | uint32_t _nb_inst_branch_complete = fromString<uint32_t>(argv[x++]); |
---|
| 56 | |
---|
| 57 | uint32_t * _link_context_to_decod_unit = new uint32_t [_nb_context]; |
---|
| 58 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 59 | _link_context_to_decod_unit [i] = fromString<uint32_t>(argv[x++]); |
---|
| 60 | |
---|
| 61 | uint32_t _size_address = fromString<uint32_t>(argv[x++]); |
---|
| 62 | |
---|
| 63 | uint32_t * _size_depth = new uint32_t [_nb_context]; |
---|
| 64 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 65 | _size_depth [i] = fromString<uint32_t>(argv[x++]); |
---|
| 66 | |
---|
| 67 | uint32_t * _nb_branch_speculated = new uint32_t [_nb_context]; |
---|
| 68 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 69 | _nb_branch_speculated [i] = fromString<uint32_t>(argv[x++]); |
---|
| 70 | |
---|
| 71 | std::vector<uint32_t> * _translate_context_id_from_decod_unit = new std::vector<uint32_t> [_nb_decod_unit]; |
---|
| 72 | |
---|
| 73 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 74 | _translate_context_id_from_decod_unit [_link_context_to_decod_unit[i]].push_back(i); |
---|
| 75 | |
---|
| 76 | int _return = EXIT_SUCCESS; |
---|
| 77 | try |
---|
| 78 | { |
---|
| 79 | morpheo::behavioural::core::multi_front_end::front_end::front_end_glue::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::front_end_glue::Parameters |
---|
| 80 | (_nb_context , |
---|
| 81 | _nb_decod_unit , |
---|
| 82 | _nb_inst_decod , |
---|
| 83 | _nb_inst_branch_complete , |
---|
| 84 | _link_context_to_decod_unit , |
---|
| 85 | _translate_context_id_from_decod_unit , |
---|
| 86 | _size_address , |
---|
| 87 | _size_depth , |
---|
| 88 | _nb_branch_speculated , |
---|
| 89 | true // is_toplevel |
---|
| 90 | ); |
---|
| 91 | |
---|
| 92 | test (name,param); |
---|
| 93 | } |
---|
| 94 | catch (morpheo::ErrorMorpheo & error) |
---|
| 95 | { |
---|
| 96 | msg (_("%s"),error.what ()); |
---|
| 97 | _return = EXIT_FAILURE; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | try |
---|
| 101 | { |
---|
| 102 | if (_return == EXIT_SUCCESS) |
---|
| 103 | TEST_OK("Front_end_Glue : no error"); |
---|
| 104 | else |
---|
| 105 | TEST_KO("Front_end_Glue : a lot of error"); |
---|
| 106 | } |
---|
| 107 | catch (morpheo::ErrorMorpheo & error) |
---|
| 108 | { |
---|
| 109 | // msg (_("<%s> :\n%s"),name.c_str(), error.what ()); |
---|
| 110 | _return = EXIT_FAILURE; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | delete [] _translate_context_id_from_decod_unit; |
---|
| 114 | delete [] _nb_branch_speculated ; |
---|
| 115 | delete [] _size_depth ; |
---|
| 116 | delete [] _link_context_to_decod_unit ; |
---|
| 117 | delete [] _nb_inst_decod ; |
---|
| 118 | |
---|
| 119 | return (_return); |
---|
| 120 | } |
---|