[78] | 1 | /* |
---|
| 2 | * $Id: Parameters.cpp 81 2008-04-15 18:40:01Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/Branch_Target_Buffer_Register/include/Parameters.h" |
---|
| 9 | #include "Common/include/BitManipulation.h" |
---|
| 10 | #include "Common/include/Max.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace core { |
---|
| 15 | namespace multi_front_end { |
---|
| 16 | namespace front_end { |
---|
| 17 | namespace prediction_unit { |
---|
| 18 | namespace branch_target_buffer { |
---|
| 19 | namespace branch_target_buffer_register { |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #undef FUNCTION |
---|
| 23 | #define FUNCTION "Branch_Target_Buffer_Register::Parameters" |
---|
| 24 | Parameters::Parameters (uint32_t nb_context , |
---|
| 25 | uint32_t * nb_instruction , |
---|
| 26 | uint32_t size_buffer , |
---|
| 27 | uint32_t associativity , |
---|
| 28 | uint32_t size_address , |
---|
| 29 | uint32_t size_counter , |
---|
| 30 | uint32_t nb_inst_predict, |
---|
| 31 | uint32_t nb_inst_decod , |
---|
| 32 | uint32_t nb_inst_update ) |
---|
| 33 | { |
---|
| 34 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
| 35 | |
---|
| 36 | _nb_context = nb_context ; |
---|
| 37 | _nb_instruction = nb_instruction ; |
---|
| 38 | _size_buffer = size_buffer ; |
---|
| 39 | _associativity = associativity ; |
---|
| 40 | _size_address = size_address ; |
---|
| 41 | _size_counter = size_counter ; |
---|
| 42 | _nb_inst_predict = nb_inst_predict; |
---|
| 43 | _nb_inst_decod = nb_inst_decod ; |
---|
| 44 | _nb_inst_update = nb_inst_update ; |
---|
| 45 | |
---|
| 46 | _size_bank = size_buffer/associativity; |
---|
| 47 | _size_context_id = log2(nb_context); |
---|
| 48 | _size_victim = log2(associativity); |
---|
| 49 | |
---|
| 50 | _have_port_context_id = (_size_context_id > 0); |
---|
| 51 | _have_port_victim = (_size_victim > 0); |
---|
| 52 | |
---|
| 53 | _accurate_max = (1<<_size_counter); |
---|
| 54 | _accurate_limit = (_accurate_max*PERCENT_ACCURATE_LIMIT)/100; |
---|
| 55 | _first_accurate_if_hit = (1<<(_size_counter-1)); //b1000 |
---|
| 56 | _first_accurate_if_miss = _first_accurate_if_hit-1; //b0111 |
---|
| 57 | |
---|
| 58 | uint32_t max_inst = max<uint32_t>(nb_instruction, nb_context); |
---|
| 59 | uint32_t size_offset = log2(max_inst); |
---|
| 60 | uint32_t size_bank = log2(_size_bank); |
---|
| 61 | |
---|
| 62 | _mask_offset = gen_mask<Tgeneral_data_t> (size_offset); |
---|
| 63 | _mask_bank = gen_mask<Tgeneral_data_t> (size_bank ); |
---|
| 64 | _shift_offset = 2; |
---|
| 65 | _shift_bank = _shift_offset+size_offset; |
---|
| 66 | _shift_tag = _shift_bank +size_bank ; |
---|
| 67 | |
---|
| 68 | // std::cout << "max_inst : " << toString(max_inst ) << std::endl; |
---|
| 69 | // std::cout << "size_offset : " << toString(size_offset) << std::endl; |
---|
| 70 | // std::cout << "size_bank : " << toString(size_bank ) << std::endl; |
---|
| 71 | // std::cout << "mask_offset : " << toString(_mask_offset ) << std::endl; |
---|
| 72 | // std::cout << "mask_bank : " << toString(_mask_bank ) << std::endl; |
---|
| 73 | // std::cout << "shift_offset : " << toString(_shift_offset) << std::endl; |
---|
| 74 | // std::cout << "shift_bank : " << toString(_shift_bank ) << std::endl; |
---|
| 75 | // std::cout << "shift_tag : " << toString(_shift_tag ) << std::endl; |
---|
| 76 | // std::cout << "accurate_max : " << toString(_accurate_max ) << std::endl; |
---|
| 77 | // std::cout << "first_accurate_if_hit : " << toString(_first_accurate_if_hit ) << std::endl; |
---|
| 78 | // std::cout << "first_accurate_if_miss : " << toString(_first_accurate_if_miss) << std::endl; |
---|
| 79 | // std::cout << "accurate_limit : " << toString(_accurate_limit ) << std::endl; |
---|
| 80 | |
---|
| 81 | test(); |
---|
| 82 | |
---|
| 83 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
| 84 | }; |
---|
| 85 | |
---|
| 86 | // #undef FUNCTION |
---|
| 87 | // #define FUNCTION "Branch_Target_Buffer_Register::Parameters (copy)" |
---|
| 88 | // Parameters::Parameters (Parameters & param) |
---|
| 89 | // { |
---|
| 90 | // log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
| 91 | // test(); |
---|
| 92 | // log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
| 93 | // }; |
---|
| 94 | |
---|
| 95 | #undef FUNCTION |
---|
| 96 | #define FUNCTION "Branch_Target_Buffer_Register::~Parameters" |
---|
| 97 | Parameters::~Parameters () |
---|
| 98 | { |
---|
| 99 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
| 100 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
| 101 | }; |
---|
| 102 | |
---|
| 103 | }; // end namespace branch_target_buffer_register |
---|
| 104 | }; // end namespace branch_target_buffer |
---|
| 105 | }; // end namespace prediction_unit |
---|
| 106 | }; // end namespace front_end |
---|
| 107 | }; // end namespace multi_front_end |
---|
| 108 | }; // end namespace core |
---|
| 109 | |
---|
| 110 | }; // end namespace behavioural |
---|
| 111 | }; // end namespace morpheo |
---|