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