[2] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id$ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
[48] | 9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Pattern_History_Table/include/Pattern_History_Table.h" |
---|
[2] | 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
[48] | 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | namespace prediction_unit { |
---|
| 17 | namespace direction { |
---|
| 18 | |
---|
[2] | 19 | namespace meta_predictor { |
---|
| 20 | namespace two_level_branch_predictor { |
---|
| 21 | namespace pattern_history_table { |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | void Pattern_History_Table::allocation (void) |
---|
| 25 | { |
---|
| 26 | log_printf(FUNC,Pattern_History_Table,"allocation","Begin"); |
---|
| 27 | |
---|
[42] | 28 | _component = new Component (); |
---|
[2] | 29 | |
---|
[42] | 30 | Entity * entity = _component->set_entity (_name |
---|
| 31 | ,"Pattern_History_Table" |
---|
| 32 | #ifdef POSITION |
---|
| 33 | ,MIXTE |
---|
| 34 | #endif |
---|
| 35 | ); |
---|
| 36 | |
---|
| 37 | _interfaces = entity->set_interfaces(); |
---|
| 38 | |
---|
| 39 | // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 40 | { |
---|
| 41 | Interface * interface = _interfaces->set_interface("" |
---|
| 42 | #ifdef POSITION |
---|
| 43 | , IN |
---|
| 44 | , SOUTH |
---|
| 45 | , "Generalist interface" |
---|
| 46 | #endif |
---|
| 47 | ); |
---|
| 48 | |
---|
| 49 | in_CLOCK = interface->set_signal_clk ("clock" ,1); |
---|
| 50 | in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1,RESET_VHDL_YES); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[2] | 54 | in_PREDICT_VAL = new SC_IN (Tcontrol_t) * [_param._nb_prediction]; |
---|
| 55 | out_PREDICT_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_prediction]; |
---|
| 56 | in_PREDICT_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_prediction]; |
---|
| 57 | out_PREDICT_HISTORY = new SC_OUT(Thistory_t) * [_param._nb_prediction]; |
---|
| 58 | |
---|
| 59 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 60 | { |
---|
[42] | 61 | Interface_fifo * interface = _interfaces->set_interface("predict_"+toString(i) |
---|
| 62 | #ifdef POSITION |
---|
| 63 | , IN |
---|
| 64 | , WEST |
---|
| 65 | , "Interface Predict" |
---|
| 66 | #endif |
---|
| 67 | ); |
---|
[2] | 68 | |
---|
[42] | 69 | in_PREDICT_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
| 70 | out_PREDICT_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
| 71 | in_PREDICT_ADDRESS [i] = interface->set_signal_in <Taddress_t> ("address", static_cast<uint32_t>(ceil(log2(_param._nb_counter)))); |
---|
| 72 | out_PREDICT_HISTORY [i] = interface->set_signal_out <Thistory_t> ("history", _param._size_counter); |
---|
[2] | 73 | } |
---|
[42] | 74 | |
---|
| 75 | // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[2] | 76 | |
---|
[3] | 77 | in_BRANCH_COMPLETE_VAL = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 78 | out_BRANCH_COMPLETE_ACK = new SC_OUT (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 79 | in_BRANCH_COMPLETE_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_branch_complete]; |
---|
| 80 | in_BRANCH_COMPLETE_HISTORY = new SC_IN (Thistory_t) * [_param._nb_branch_complete]; |
---|
| 81 | in_BRANCH_COMPLETE_DIRECTION = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
[2] | 82 | |
---|
| 83 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 84 | { |
---|
[42] | 85 | Interface_fifo * interface = _interfaces->set_interface("branch_complete_"+toString(i) |
---|
| 86 | #ifdef POSITION |
---|
| 87 | , IN |
---|
| 88 | , EAST |
---|
| 89 | , "Interface branch complete" |
---|
| 90 | #endif |
---|
| 91 | ); |
---|
[2] | 92 | |
---|
[42] | 93 | in_BRANCH_COMPLETE_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
| 94 | out_BRANCH_COMPLETE_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
| 95 | in_BRANCH_COMPLETE_ADDRESS [i] = interface->set_signal_in <Taddress_t> ("address" , static_cast<uint32_t>(ceil(log2(_param._nb_counter)))); |
---|
| 96 | in_BRANCH_COMPLETE_HISTORY [i] = interface->set_signal_in <Thistory_t> ("history" , _param._size_counter); |
---|
| 97 | in_BRANCH_COMPLETE_DIRECTION [i] = interface->set_signal_in <Tcontrol_t> ("direction", 1); |
---|
| 98 | } |
---|
[2] | 99 | |
---|
| 100 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 101 | string name_component; |
---|
[42] | 102 | |
---|
[2] | 103 | // =====[ component_Counter ]========================================= |
---|
| 104 | |
---|
| 105 | name_component = _name+"_Counter"; |
---|
| 106 | |
---|
[42] | 107 | component_Counter = new morpheo::behavioural::generic::counter::Counter (name_component.c_str() |
---|
[2] | 108 | #ifdef STATISTICS |
---|
[42] | 109 | ,_param_statistics |
---|
[2] | 110 | #endif |
---|
[42] | 111 | ,*(_param._param_counter)); |
---|
| 112 | |
---|
| 113 | _component->set_component (component_Counter->_component |
---|
| 114 | #ifdef POSITION |
---|
| 115 | , 25 |
---|
| 116 | , 25 |
---|
| 117 | , 10 |
---|
| 118 | , 10 |
---|
[2] | 119 | #endif |
---|
[42] | 120 | ); |
---|
[2] | 121 | |
---|
| 122 | // =====[ component_RegisterFile ]==================================== |
---|
| 123 | |
---|
| 124 | name_component = _name+"_RegisterFile"; |
---|
| 125 | |
---|
[42] | 126 | component_RegisterFile = new morpheo::behavioural::generic::registerfile::registerfile_monolithic::RegisterFile_Monolithic(name_component.c_str(), |
---|
[2] | 127 | #ifdef STATISTICS |
---|
[42] | 128 | _param_statistics , |
---|
[2] | 129 | #endif |
---|
[42] | 130 | *(_param._param_registerfile)); |
---|
| 131 | |
---|
| 132 | _component->set_component (component_RegisterFile->_component |
---|
| 133 | #ifdef POSITION |
---|
| 134 | , 75 |
---|
| 135 | , 75 |
---|
| 136 | , 10 |
---|
| 137 | , 10 |
---|
| 138 | #endif |
---|
| 139 | ); |
---|
| 140 | |
---|
| 141 | // ~~~~~[ Component - Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 142 | |
---|
| 143 | // =====[ component_RegisterFile - Instanciation ]==================== |
---|
| 144 | |
---|
| 145 | #ifdef POSITION |
---|
| 146 | _component->interface_map (_name+"_RegisterFile","", |
---|
| 147 | _name ,""); |
---|
| 148 | #endif |
---|
| 149 | |
---|
| 150 | _component->port_map(_name+"_RegisterFile", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
| 151 | _component->port_map(_name+"_RegisterFile", "in_NRESET", _name,"in_NRESET"); |
---|
[15] | 152 | |
---|
[2] | 153 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 154 | { |
---|
[42] | 155 | #ifdef POSITION |
---|
| 156 | _component->interface_map (_name+"_RegisterFile","read_" +toString(i), |
---|
| 157 | _name ,"predict_"+toString(i)); |
---|
| 158 | #endif |
---|
| 159 | |
---|
| 160 | _component->port_map(_name+"_RegisterFile", "in_READ_"+toString(i)+"_VAL" , _name, "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
| 161 | _component->port_map(_name+"_RegisterFile","out_READ_"+toString(i)+"_ACK" , _name,"out_PREDICT_"+toString(i)+"_ACK" ); |
---|
| 162 | _component->port_map(_name+"_RegisterFile", "in_READ_"+toString(i)+"_ADDRESS", _name, "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
| 163 | _component->port_map(_name+"_RegisterFile","out_READ_"+toString(i)+"_DATA" , _name,"out_PREDICT_"+toString(i)+"_HISTORY"); |
---|
[2] | 164 | } |
---|
| 165 | |
---|
| 166 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 167 | { |
---|
[42] | 168 | #ifdef POSITION |
---|
| 169 | _component->interface_map (_name+"_RegisterFile","write_" +toString(i), |
---|
| 170 | _name+"_Counter" ,"counter_"+toString(i)); |
---|
| 171 | #endif |
---|
| 172 | |
---|
| 173 | _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_VAL" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" ); |
---|
| 174 | _component->port_map(_name+"_RegisterFile","out_WRITE_"+toString(i)+"_ACK" , _name ,"out_BRANCH_COMPLETE_"+toString(i)+"_ACK" ); |
---|
| 175 | _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_ADDRESS", _name , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
| 176 | _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_DATA" , _name+"_Counter","out_COUNTER_" +toString(i)+"_DATA"); |
---|
[2] | 177 | } |
---|
| 178 | |
---|
[42] | 179 | // =====[ component_Counter - Instanciation ]========================= |
---|
| 180 | |
---|
| 181 | #if (defined(STATISTICS) || defined (VHDL_TESTBENCH)) |
---|
| 182 | |
---|
| 183 | #ifdef POSITION |
---|
| 184 | _component->interface_map (_name+"_Counter","", |
---|
| 185 | _name ,""); |
---|
| 186 | #endif |
---|
| 187 | |
---|
| 188 | _component->port_map(_name+"_Counter", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
| 189 | _component->port_map(_name+"_Counter", "in_NRESET", _name,"in_NRESET"); |
---|
| 190 | |
---|
| 191 | #endif |
---|
| 192 | |
---|
| 193 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 194 | { |
---|
| 195 | #ifdef POSITION |
---|
| 196 | _component->interface_map (_name+"_Counter","counter_"+toString(i), |
---|
| 197 | _name ,"branch_complete_"+toString(i)); |
---|
| 198 | |
---|
| 199 | #endif |
---|
| 200 | |
---|
| 201 | _component->port_map(_name+"_Counter", "in_COUNTER_" +toString(i)+"_DATA" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY"); |
---|
| 202 | _component->port_map(_name+"_Counter", "in_COUNTER_" +toString(i)+"_ADDSUB" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION"); |
---|
| 203 | _component->port_map(_name+"_Counter", "out_COUNTER_"+toString(i)+"_DATA" , _name+"_RegisterFile", "in_WRITE_"+toString(i)+"_DATA"); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | #ifdef POSITION |
---|
| 207 | _component->generate_file(); |
---|
| 208 | #endif |
---|
| 209 | |
---|
[2] | 210 | log_printf(FUNC,Pattern_History_Table,"allocation","End"); |
---|
| 211 | }; |
---|
| 212 | |
---|
| 213 | }; // end namespace pattern_history_table |
---|
| 214 | }; // end namespace two_level_branch_predictor |
---|
| 215 | }; // end namespace meta_predictor |
---|
| 216 | |
---|
[48] | 217 | }; // end namespace core |
---|
| 218 | }; // end namespace multi_front_end |
---|
| 219 | }; // end namespace front_end |
---|
| 220 | }; // end namespace prediction_unit |
---|
| 221 | }; // end namespace direction |
---|
| 222 | |
---|
| 223 | |
---|
[2] | 224 | }; // end namespace behavioural |
---|
| 225 | }; // end namespace morpheo |
---|
| 226 | #endif |
---|