1 | /* |
---|
2 | * $Id: Parameters.cpp 98 2008-12-31 10:18:08Z 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 | bool is_toplevel) |
---|
34 | { |
---|
35 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
36 | |
---|
37 | _nb_context = nb_context ; |
---|
38 | _nb_instruction = nb_instruction ; |
---|
39 | _size_buffer = size_buffer ; |
---|
40 | _associativity = associativity ; |
---|
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_victim = log2(associativity); |
---|
48 | |
---|
49 | _have_port_victim = (_size_victim > 0); |
---|
50 | |
---|
51 | _accurate_max = (1<<_size_counter); |
---|
52 | _accurate_limit = (_accurate_max*PERCENT_ACCURATE_LIMIT)/100; |
---|
53 | _first_accurate_if_hit = (1<<(_size_counter-1)); //b1000 |
---|
54 | _first_accurate_if_miss = _first_accurate_if_hit-1; //b0111 |
---|
55 | |
---|
56 | uint32_t max_inst = max<uint32_t>(nb_instruction, nb_context); |
---|
57 | uint32_t size_offset = log2(max_inst); |
---|
58 | uint32_t size_bank = log2(_size_bank); |
---|
59 | |
---|
60 | _mask_offset = gen_mask<Tgeneral_data_t> (size_offset); |
---|
61 | _mask_bank = gen_mask<Tgeneral_data_t> (size_bank ); |
---|
62 | _shift_offset = 0; |
---|
63 | _shift_bank = _shift_offset+size_offset; |
---|
64 | _shift_tag = _shift_bank +size_bank ; |
---|
65 | |
---|
66 | // std::cout << "max_inst : " << toString(max_inst ) << std::endl; |
---|
67 | // std::cout << "size_offset : " << toString(size_offset) << std::endl; |
---|
68 | // std::cout << "size_bank : " << toString(size_bank ) << std::endl; |
---|
69 | // std::cout << "mask_offset : " << toString(_mask_offset ) << std::endl; |
---|
70 | // std::cout << "mask_bank : " << toString(_mask_bank ) << std::endl; |
---|
71 | // std::cout << "shift_offset : " << toString(_shift_offset) << std::endl; |
---|
72 | // std::cout << "shift_bank : " << toString(_shift_bank ) << std::endl; |
---|
73 | // std::cout << "shift_tag : " << toString(_shift_tag ) << std::endl; |
---|
74 | // std::cout << "accurate_max : " << toString(_accurate_max ) << std::endl; |
---|
75 | // std::cout << "first_accurate_if_hit : " << toString(_first_accurate_if_hit ) << std::endl; |
---|
76 | // std::cout << "first_accurate_if_miss : " << toString(_first_accurate_if_miss) << std::endl; |
---|
77 | // std::cout << "accurate_limit : " << toString(_accurate_limit ) << std::endl; |
---|
78 | |
---|
79 | test(); |
---|
80 | |
---|
81 | if (is_toplevel) |
---|
82 | { |
---|
83 | _size_instruction_address = size_address ; |
---|
84 | _size_context_id = log2(nb_context); |
---|
85 | _have_port_context_id = (_size_context_id > 0); |
---|
86 | |
---|
87 | copy (); |
---|
88 | } |
---|
89 | |
---|
90 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
91 | }; |
---|
92 | |
---|
93 | // #undef FUNCTION |
---|
94 | // #define FUNCTION "Branch_Target_Buffer_Register::Parameters (copy)" |
---|
95 | // Parameters::Parameters (Parameters & param) |
---|
96 | // { |
---|
97 | // log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
98 | // test(); |
---|
99 | // log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
100 | // }; |
---|
101 | |
---|
102 | #undef FUNCTION |
---|
103 | #define FUNCTION "Branch_Target_Buffer_Register::~Parameters" |
---|
104 | Parameters::~Parameters () |
---|
105 | { |
---|
106 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
107 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
108 | }; |
---|
109 | |
---|
110 | #undef FUNCTION |
---|
111 | #define FUNCTION "Branch_Target_Buffer_Register::copy" |
---|
112 | void Parameters::copy () |
---|
113 | { |
---|
114 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
115 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
116 | }; |
---|
117 | |
---|
118 | }; // end namespace branch_target_buffer_register |
---|
119 | }; // end namespace branch_target_buffer |
---|
120 | }; // end namespace prediction_unit |
---|
121 | }; // end namespace front_end |
---|
122 | }; // end namespace multi_front_end |
---|
123 | }; // end namespace core |
---|
124 | |
---|
125 | }; // end namespace behavioural |
---|
126 | }; // end namespace morpheo |
---|