1 | /* |
---|
2 | * $Id: main.cpp 108 2009-02-12 11:55:06Z 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 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_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 | err (_(" * size_nb_inst_decod (uint32_t)\n")); |
---|
25 | |
---|
26 | exit (1); |
---|
27 | } |
---|
28 | |
---|
29 | #ifndef SYSTEMC |
---|
30 | int main (int argc, char * argv[]) |
---|
31 | #else |
---|
32 | int sc_main (int argc, char * argv[]) |
---|
33 | #endif |
---|
34 | { |
---|
35 | for (int32_t i=0; i<argc; ++i) |
---|
36 | msg("%s ",argv[i]); |
---|
37 | msg("\n"); |
---|
38 | |
---|
39 | if (argc <= static_cast<int>(2+NB_PARAMS)) |
---|
40 | usage (argc, argv); |
---|
41 | |
---|
42 | uint32_t x = 1; |
---|
43 | |
---|
44 | string name = argv[x++]; |
---|
45 | |
---|
46 | uint32_t _nb_context = fromString<uint32_t>(argv[x++]); |
---|
47 | uint32_t _nb_decod_unit = fromString<uint32_t>(argv[x++]); |
---|
48 | |
---|
49 | if (argc != static_cast<int>(2+NB_PARAMS+3*_nb_context+1*_nb_decod_unit)) |
---|
50 | usage (argc, argv); |
---|
51 | |
---|
52 | uint32_t * _nb_inst_decod = new uint32_t [_nb_decod_unit]; |
---|
53 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
54 | _nb_inst_decod [i] = fromString<uint32_t>(argv[x++]); |
---|
55 | |
---|
56 | uint32_t _nb_inst_branch_complete = fromString<uint32_t>(argv[x++]); |
---|
57 | |
---|
58 | uint32_t * _link_context_to_decod_unit = new uint32_t [_nb_context]; |
---|
59 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
60 | _link_context_to_decod_unit [i] = fromString<uint32_t>(argv[x++]); |
---|
61 | |
---|
62 | uint32_t _size_address = fromString<uint32_t>(argv[x++]); |
---|
63 | |
---|
64 | uint32_t * _size_depth = new uint32_t [_nb_context]; |
---|
65 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
66 | _size_depth [i] = fromString<uint32_t>(argv[x++]); |
---|
67 | |
---|
68 | uint32_t * _nb_branch_speculated = new uint32_t [_nb_context]; |
---|
69 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
70 | _nb_branch_speculated [i] = fromString<uint32_t>(argv[x++]); |
---|
71 | |
---|
72 | uint32_t _size_nb_inst_decod = fromString<uint32_t>(argv[x++]); |
---|
73 | |
---|
74 | std::vector<uint32_t> * _translate_context_id_from_decod_unit = new std::vector<uint32_t> [_nb_decod_unit]; |
---|
75 | |
---|
76 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
77 | _translate_context_id_from_decod_unit [_link_context_to_decod_unit[i]].push_back(i); |
---|
78 | |
---|
79 | int _return = EXIT_SUCCESS; |
---|
80 | try |
---|
81 | { |
---|
82 | 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 |
---|
83 | (_nb_context , |
---|
84 | _nb_decod_unit , |
---|
85 | _nb_inst_decod , |
---|
86 | _nb_inst_branch_complete , |
---|
87 | _link_context_to_decod_unit , |
---|
88 | _translate_context_id_from_decod_unit , |
---|
89 | _size_address , |
---|
90 | _size_depth , |
---|
91 | _nb_branch_speculated , |
---|
92 | _size_nb_inst_decod , |
---|
93 | true // is_toplevel |
---|
94 | ); |
---|
95 | |
---|
96 | test (name,param); |
---|
97 | } |
---|
98 | catch (morpheo::ErrorMorpheo & error) |
---|
99 | { |
---|
100 | msg (_("%s"),error.what ()); |
---|
101 | _return = EXIT_FAILURE; |
---|
102 | } |
---|
103 | |
---|
104 | try |
---|
105 | { |
---|
106 | if (_return == EXIT_SUCCESS) |
---|
107 | TEST_OK("Front_end_Glue : no error"); |
---|
108 | else |
---|
109 | TEST_KO("Front_end_Glue : a lot of error"); |
---|
110 | } |
---|
111 | catch (morpheo::ErrorMorpheo & error) |
---|
112 | { |
---|
113 | // msg (_("<%s> :\n%s"),name.c_str(), error.what ()); |
---|
114 | _return = EXIT_FAILURE; |
---|
115 | } |
---|
116 | |
---|
117 | delete [] _translate_context_id_from_decod_unit; |
---|
118 | delete [] _nb_branch_speculated ; |
---|
119 | delete [] _size_depth ; |
---|
120 | delete [] _link_context_to_decod_unit ; |
---|
121 | delete [] _nb_inst_decod ; |
---|
122 | |
---|
123 | return (_return); |
---|
124 | } |
---|