Changeset 88 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/SelfTest/src/test.cpp
- Timestamp:
- Dec 10, 2008, 7:31:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/SelfTest/src/test.cpp
r82 r88 7 7 */ 8 8 9 #define NB_ITERATION 1 02410 #define CYCLE_MAX (1 28*NB_ITERATION)9 #define NB_ITERATION 1 10 #define CYCLE_MAX (10000*NB_ITERATION) 11 11 12 12 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/SelfTest/include/test.h" 13 13 #include "Common/include/Test.h" 14 14 #include "Behavioural/include/Allocation.h" 15 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/Branch_Target_Buffer_Register/SelfTest/include/test_BTB.h" 15 16 16 17 void test (string name, … … 20 21 21 22 #ifdef STATISTICS 22 morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5, 50);23 morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,CYCLE_MAX); 23 24 #endif 25 26 Tusage_t _usage = USE_ALL; 27 28 // _usage = usage_unset(_usage,USE_SYSTEMC ); 29 // _usage = usage_unset(_usage,USE_VHDL ); 30 // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); 31 // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); 32 // _usage = usage_unset(_usage,USE_POSITION ); 33 // _usage = usage_unset(_usage,USE_STATISTICS ); 34 // _usage = usage_unset(_usage,USE_INFORMATION ); 24 35 25 36 Branch_Target_Buffer * _Branch_Target_Buffer = new Branch_Target_Buffer … … 29 40 #endif 30 41 _param, 31 USE_ALL);32 42 _usage); 43 33 44 #ifdef SYSTEMC 34 45 /********************************************************************* … … 110 121 msg(_("<%s> : Start Simulation ............\n"),name.c_str()); 111 122 123 // Initialisation 124 const uint32_t seed = 0; 125 //const uint32_t seed = static_cast<uint32_t>(time(NULL)); 126 127 srand(seed); 128 129 const int32_t percent_transaction_decod = 75; 130 const int32_t percent_transaction_predict = 75; 131 132 SC_START(0); 133 112 134 Time * _time = new Time(); 113 135 … … 116 138 ********************************************************/ 117 139 118 // Initialisation 119 120 const uint32_t seed = 0; 121 //const uint32_t seed = static_cast<uint32_t>(time(NULL)); 122 123 srand(seed); 124 125 SC_START(0); 126 LABEL("Initialisation"); 127 128 LABEL("Reset"); 129 in_NRESET->write(0); 130 SC_START(5); 131 in_NRESET->write(1); 132 133 LABEL("Loop of Test"); 134 135 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 136 { 137 LABEL("Iteration %d",iteration); 138 139 SC_START(1); 140 } 140 { 141 LABEL("Reset"); 142 in_NRESET->write(0); 143 SC_START(5); 144 in_NRESET->write(1); 145 146 LABEL("Loop of Test"); 147 148 Taddress_t btb_address [_param->_associativity]; 149 Tcontext_t btb_context [_param->_associativity]; 150 151 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 152 { 153 LABEL("Iteration %d",iteration); 154 155 // FIRST STEP - Test (without sort, with concurent access, same context) 156 157 // fill a btb line 158 #define NB_REQUEST (8*_param->_associativity) 159 uint32_t nb_request; 160 uint32_t index = rand()&_param->_param_branch_target_buffer_register->_mask_bank; 161 Tcontext_t context = rand()&_param->_nb_context; 162 163 for (uint32_t j=0; j<_param->_associativity; j++) 164 // btb_val [j] = false; 165 btb_address [j] = static_cast<Taddress_t>(-1); 166 167 { 168 uint32_t associativity = 0; 169 170 while (associativity < _param->_associativity) 171 { 172 for (uint32_t j=0; j<_param->_nb_inst_decod; j++) 173 { 174 Taddress_t address = ((associativity << _param->_param_branch_target_buffer_register->_shift_tag) | 175 (index << _param->_param_branch_target_buffer_register->_shift_bank)| 176 (0)); 177 178 in_DECOD_VAL [j]->write(((rand()%100)<percent_transaction_decod) and ((associativity+j) < _param->_associativity)); 179 in_DECOD_CONTEXT_ID [j]->write(context); 180 in_DECOD_ADDRESS_SRC [j]->write( address ); 181 in_DECOD_ADDRESS_DEST [j]->write(~address ); 182 in_DECOD_CONDITION [j]->write(BRANCH_CONDITION_FLAG_SET); 183 in_DECOD_LAST_TAKE [j]->write(address&1); 184 in_DECOD_MISS_PREDICTION [j]->write(1); 185 in_DECOD_IS_ACCURATE [j]->write(1); 186 } 187 188 SC_START(0); 189 190 for (uint32_t j=0; j<_param->_nb_inst_decod; j++) 191 if (in_DECOD_VAL [j]->read() and out_DECOD_ACK [j]->read()) 192 { 193 LABEL("DECOD [%d] Transaction Accepted",j); 194 195 Taddress_t address = in_DECOD_ADDRESS_SRC [j]->read(); 196 197 btb_address[associativity] = address; 198 btb_context[associativity] = context; 199 associativity ++; 200 } 201 202 SC_START(1); 203 } 204 } 205 206 nb_request = 0; 207 208 while (nb_request < NB_REQUEST) 209 { 210 for (uint32_t i=0; i<_param->_nb_inst_predict; i++) 211 { 212 in_PREDICT_VAL [i]->write(((rand()%100)<percent_transaction_predict)); 213 in_PREDICT_CONTEXT_ID [i]->write(rand()&_param->_nb_context); 214 in_PREDICT_ADDRESS [i]->write(gen_addr(_param->_param_branch_target_buffer_register,index)); 215 } 216 217 SC_START(0); 218 219 for (uint32_t i=0; i<_param->_nb_inst_predict; i++) 220 if (in_PREDICT_VAL [i]->read() and out_PREDICT_ACK [i]->read()) 221 { 222 LABEL("PREDICT [%d] Transaction Accepted",i); 223 224 Tcontrol_t hit = out_PREDICT_HIT [i]->read(); 225 Taddress_t address = in_PREDICT_ADDRESS [i]->read(); 226 Taddress_t address_src = out_PREDICT_ADDRESS_SRC [i]->read(); 227 Taddress_t address_dest = out_PREDICT_ADDRESS_DEST [i]->read(); 228 229 Taddress_t tag = address >> _param->_param_branch_target_buffer_register->_shift_tag; 230 231 Tcontrol_t my_hit = false; 232 Tcontrol_t my_addr; 233 234 for (uint32_t i=0; i<_param->_associativity; i++) 235 { 236 Taddress_t btb_address [_param->_associativity]; 237 Tcontext_t btb_context [_param->_associativity]; 238 } 239 240 if (hit) 241 { 242 TEST(Tbranch_condition_t,out_PREDICT_CONDITION [i]->read(),BRANCH_CONDITION_FLAG_SET); 243 TEST(Tcontrol_t ,out_PREDICT_LAST_TAKE [i]->read(),address_src&1); 244 // TEST(Tcontrol_t ,out_PREDICT_IS_ACCURATE [i]->read(), ); 245 } 246 247 nb_request ++; 248 } 249 250 SC_START(1); 251 } 252 } 253 } 141 254 142 255 /********************************************************
Note: See TracChangeset
for help on using the changeset viewer.