1 | /* |
---|
2 | * $Id: test.cpp 112 2009-03-18 22:36:26Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | * Test |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/SelfTest/include/test.h" |
---|
10 | #include "Behavioural/include/Allocation.h" |
---|
11 | |
---|
12 | void test (string name, |
---|
13 | morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::Parameters * _param) |
---|
14 | { |
---|
15 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
16 | |
---|
17 | if (setlocale (LC_ALL, "") == NULL) |
---|
18 | msg(_("setlocale ko.\n")); |
---|
19 | |
---|
20 | #ifdef STATISTICS |
---|
21 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,CYCLE_MAX); |
---|
22 | #endif |
---|
23 | |
---|
24 | Tusage_t _usage = USE_ALL; |
---|
25 | |
---|
26 | // _usage = usage_unset(_usage,USE_SYSTEMC ); |
---|
27 | // _usage = usage_unset(_usage,USE_VHDL ); |
---|
28 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); |
---|
29 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); |
---|
30 | // _usage = usage_unset(_usage,USE_POSITION ); |
---|
31 | // _usage = usage_unset(_usage,USE_STATISTICS ); |
---|
32 | // _usage = usage_unset(_usage,USE_INFORMATION ); |
---|
33 | |
---|
34 | Meta_Predictor * _Meta_Predictor = new Meta_Predictor |
---|
35 | (name.c_str(), |
---|
36 | #ifdef STATISTICS |
---|
37 | _parameters_statistics, |
---|
38 | #endif |
---|
39 | _param, |
---|
40 | _usage); |
---|
41 | |
---|
42 | #ifdef SYSTEMC |
---|
43 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
44 | { |
---|
45 | /********************************************************************* |
---|
46 | * Déclarations des signaux |
---|
47 | *********************************************************************/ |
---|
48 | string rename; |
---|
49 | |
---|
50 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
51 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
52 | ALLOC1_SC_SIGNAL( in_PREDICT_VAL ," in_PREDICT_VAL ",Tcontrol_t,_param->_nb_inst_predict); |
---|
53 | ALLOC1_SC_SIGNAL(out_PREDICT_ACK ,"out_PREDICT_ACK ",Tcontrol_t,_param->_nb_inst_predict); |
---|
54 | ALLOC1_SC_SIGNAL( in_PREDICT_ADDRESS ," in_PREDICT_ADDRESS ",Taddress_t,_param->_nb_inst_predict); |
---|
55 | ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION ,"out_PREDICT_DIRECTION ",Tcontrol_t,_param->_nb_inst_predict); |
---|
56 | ALLOC1_SC_SIGNAL(out_PREDICT_HISTORY ,"out_PREDICT_HISTORY ",Thistory_t,_param->_nb_inst_predict); |
---|
57 | |
---|
58 | ALLOC1_SC_SIGNAL( in_UPDATE_VAL ," in_UPDATE_VAL ",Tcontrol_t,_param->_nb_inst_update); |
---|
59 | ALLOC1_SC_SIGNAL(out_UPDATE_ACK ,"out_UPDATE_ACK ",Tcontrol_t,_param->_nb_inst_update); |
---|
60 | ALLOC1_SC_SIGNAL( in_UPDATE_ADDRESS ," in_UPDATE_ADDRESS ",Taddress_t,_param->_nb_inst_update); |
---|
61 | ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY ," in_UPDATE_HISTORY ",Thistory_t,_param->_nb_inst_update); |
---|
62 | ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY_VAL ," in_UPDATE_HISTORY_VAL ",Tcontrol_t,_param->_nb_inst_update); |
---|
63 | ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION ," in_UPDATE_DIRECTION ",Tcontrol_t,_param->_nb_inst_update); |
---|
64 | |
---|
65 | /******************************************************** |
---|
66 | * Instanciation |
---|
67 | ********************************************************/ |
---|
68 | |
---|
69 | msg(_("<%s> : Instanciation of _Meta_Predictor.\n"),name.c_str()); |
---|
70 | |
---|
71 | (*(_Meta_Predictor->in_CLOCK)) (*(in_CLOCK)); |
---|
72 | (*(_Meta_Predictor->in_NRESET)) (*(in_NRESET)); |
---|
73 | |
---|
74 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_PREDICT_VAL ,_param->_nb_inst_predict); |
---|
75 | INSTANCE1_SC_SIGNAL(_Meta_Predictor,out_PREDICT_ACK ,_param->_nb_inst_predict); |
---|
76 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_PREDICT_ADDRESS ,_param->_nb_inst_predict); |
---|
77 | INSTANCE1_SC_SIGNAL(_Meta_Predictor,out_PREDICT_DIRECTION ,_param->_nb_inst_predict); |
---|
78 | INSTANCE1_SC_SIGNAL(_Meta_Predictor,out_PREDICT_HISTORY ,_param->_nb_inst_predict); |
---|
79 | |
---|
80 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_UPDATE_VAL ,_param->_nb_inst_update); |
---|
81 | INSTANCE1_SC_SIGNAL(_Meta_Predictor,out_UPDATE_ACK ,_param->_nb_inst_update); |
---|
82 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_UPDATE_ADDRESS ,_param->_nb_inst_update); |
---|
83 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_UPDATE_HISTORY ,_param->_nb_inst_update); |
---|
84 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_UPDATE_HISTORY_VAL ,_param->_nb_inst_update); |
---|
85 | INSTANCE1_SC_SIGNAL(_Meta_Predictor, in_UPDATE_DIRECTION ,_param->_nb_inst_update); |
---|
86 | |
---|
87 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
88 | |
---|
89 | Time * _time = new Time(); |
---|
90 | |
---|
91 | /******************************************************** |
---|
92 | * Simulation - Begin |
---|
93 | ********************************************************/ |
---|
94 | |
---|
95 | // Initialisation |
---|
96 | |
---|
97 | const uint32_t seed = 0; |
---|
98 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
99 | |
---|
100 | srand(seed); |
---|
101 | |
---|
102 | SC_START(0); |
---|
103 | LABEL("Initialisation"); |
---|
104 | |
---|
105 | LABEL("Reset"); |
---|
106 | in_NRESET->write(0); |
---|
107 | SC_START(5); |
---|
108 | in_NRESET->write(1); |
---|
109 | |
---|
110 | LABEL("Loop of Test"); |
---|
111 | |
---|
112 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
113 | { |
---|
114 | LABEL("Iteration %d",iteration); |
---|
115 | |
---|
116 | SC_START(1); |
---|
117 | } |
---|
118 | |
---|
119 | /******************************************************** |
---|
120 | * Simulation - End |
---|
121 | ********************************************************/ |
---|
122 | |
---|
123 | TEST_OK ("End of Simulation"); |
---|
124 | delete _time; |
---|
125 | |
---|
126 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
127 | |
---|
128 | delete in_CLOCK; |
---|
129 | delete in_NRESET; |
---|
130 | |
---|
131 | DELETE1_SC_SIGNAL( in_PREDICT_VAL ,_param->_nb_inst_predict); |
---|
132 | DELETE1_SC_SIGNAL(out_PREDICT_ACK ,_param->_nb_inst_predict); |
---|
133 | DELETE1_SC_SIGNAL( in_PREDICT_ADDRESS ,_param->_nb_inst_predict); |
---|
134 | DELETE1_SC_SIGNAL(out_PREDICT_DIRECTION ,_param->_nb_inst_predict); |
---|
135 | DELETE1_SC_SIGNAL(out_PREDICT_HISTORY ,_param->_nb_inst_predict); |
---|
136 | |
---|
137 | DELETE1_SC_SIGNAL( in_UPDATE_VAL ,_param->_nb_inst_update); |
---|
138 | DELETE1_SC_SIGNAL(out_UPDATE_ACK ,_param->_nb_inst_update); |
---|
139 | DELETE1_SC_SIGNAL( in_UPDATE_ADDRESS ,_param->_nb_inst_update); |
---|
140 | DELETE1_SC_SIGNAL( in_UPDATE_HISTORY ,_param->_nb_inst_update); |
---|
141 | DELETE1_SC_SIGNAL( in_UPDATE_HISTORY_VAL ,_param->_nb_inst_update); |
---|
142 | DELETE1_SC_SIGNAL( in_UPDATE_DIRECTION ,_param->_nb_inst_update); |
---|
143 | } |
---|
144 | #endif |
---|
145 | |
---|
146 | delete _Meta_Predictor; |
---|
147 | #ifdef STATISTICS |
---|
148 | delete _parameters_statistics; |
---|
149 | #endif |
---|
150 | } |
---|