[83] | 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/Context_State/SelfTest/include/test.h" |
---|
| 9 | |
---|
| 10 | #define NB_PARAMS 5 |
---|
| 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_branch_complete (uint32_t)\n")); |
---|
| 19 | err (_(" * size_depth [nb_context] (uint32_t)\n")); |
---|
| 20 | err (_(" * size_address (uint32_t)\n")); |
---|
| 21 | err (_(" * size_inst_decod [nb_decod_unit] (uint32_t)\n")); |
---|
[88] | 22 | err (_(" * size_inst_commit (uint32_t)\n")); |
---|
[83] | 23 | err (_(" * link_context_to_decod_unit [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 | if (argc <= static_cast<int>(2+NB_PARAMS)) |
---|
| 35 | usage (argc, argv); |
---|
| 36 | |
---|
| 37 | uint32_t x = 1; |
---|
| 38 | |
---|
| 39 | string name = argv[x++]; |
---|
| 40 | //const uint32_t size_data = atoi(argv[x++]); |
---|
| 41 | //const uint32_t nb_port = atoi(argv[x++]); |
---|
| 42 | |
---|
| 43 | uint32_t _nb_context = fromString<uint32_t>(argv[x++]); |
---|
| 44 | uint32_t _nb_decod_unit = fromString<uint32_t>(argv[x++]); |
---|
| 45 | uint32_t _nb_inst_branch_complete = fromString<uint32_t>(argv[x++]); |
---|
| 46 | |
---|
[88] | 47 | if (argc != static_cast<int>(2+NB_PARAMS+2*_nb_context+1*_nb_decod_unit)) |
---|
[83] | 48 | usage (argc, argv); |
---|
| 49 | |
---|
| 50 | uint32_t * _size_depth = new uint32_t [_nb_context]; |
---|
| 51 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 52 | _size_depth [i] = fromString<uint32_t>(argv[x++]); |
---|
| 53 | |
---|
| 54 | uint32_t _size_address = fromString<uint32_t>(argv[x++]); |
---|
| 55 | |
---|
| 56 | uint32_t * _size_inst_decod = new uint32_t [_nb_decod_unit]; |
---|
| 57 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 58 | _size_inst_decod [i] = fromString<uint32_t>(argv[x++]); |
---|
[88] | 59 | uint32_t _size_inst_commit = fromString<uint32_t>(argv[x++]); |
---|
[83] | 60 | uint32_t * _link_context_to_decod_unit = new uint32_t [_nb_context]; |
---|
| 61 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 62 | _link_context_to_decod_unit [i] = fromString<uint32_t>(argv[x++]); |
---|
| 63 | |
---|
| 64 | int _return = EXIT_SUCCESS; |
---|
| 65 | try |
---|
| 66 | { |
---|
| 67 | morpheo::behavioural::core::multi_front_end::front_end::context_state::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::context_state::Parameters |
---|
| 68 | (_nb_context , |
---|
| 69 | _nb_decod_unit , |
---|
| 70 | _nb_inst_branch_complete , |
---|
| 71 | _size_depth , |
---|
| 72 | _size_address , |
---|
| 73 | _size_inst_decod , |
---|
| 74 | _size_inst_commit , |
---|
| 75 | _link_context_to_decod_unit , |
---|
[88] | 76 | true |
---|
[83] | 77 | ); |
---|
| 78 | |
---|
| 79 | msg(_("%s"),param->print(1).c_str()); |
---|
| 80 | |
---|
| 81 | test (name,param); |
---|
| 82 | } |
---|
| 83 | catch (morpheo::ErrorMorpheo & error) |
---|
| 84 | { |
---|
| 85 | msg (_("<%s> :\n%s"),name.c_str(), error.what ()); |
---|
| 86 | _return = EXIT_FAILURE; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | delete [] _size_depth; |
---|
| 90 | delete [] _size_inst_decod; |
---|
| 91 | delete [] _link_context_to_decod_unit; |
---|
| 92 | |
---|
| 93 | try |
---|
| 94 | { |
---|
| 95 | if (_return == EXIT_SUCCESS) |
---|
| 96 | TEST_OK("Context_State : no error"); |
---|
| 97 | else |
---|
| 98 | TEST_KO("Context_State : a lot of error"); |
---|
| 99 | } |
---|
| 100 | catch (morpheo::ErrorMorpheo & error) |
---|
| 101 | { |
---|
| 102 | msg (_("<%s> :\n%s\n"),name.c_str(), error.what ()); |
---|
| 103 | _return = EXIT_FAILURE; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | return (_return); |
---|
| 107 | } |
---|