logic.h revision 10234:5cb711fa6176
1/***************************************************************************** 2 * McPAT 3 * SOFTWARE LICENSE AGREEMENT 4 * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 * Copyright (c) 2010-2013 Advanced Micro Devices, Inc. 6 * All Rights Reserved 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer; 12 * redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution; 15 * neither the name of the copyright holders nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 ***************************************************************************/ 32#ifndef LOGIC_H_ 33#define LOGIC_H_ 34 35#include <cmath> 36#include <cstring> 37#include <iostream> 38 39#include "arch_const.h" 40#include "basic_circuit.h" 41#include "basic_components.h" 42#include "cacti_interface.h" 43#include "component.h" 44#include "const.h" 45#include "decoder.h" 46#include "parameter.h" 47#include "xmlParser.h" 48 49using namespace std; 50 51class selection_logic : public McPATComponent { 52public: 53 bool is_default; 54 InputParameter l_ip; 55 uca_org_t local_result; 56 int win_entries; 57 int issue_width; 58 double accesses; 59 int num_threads; 60 enum Device_ty device_ty; 61 enum Core_type core_ty; 62 63 selection_logic(XMLNode* _xml_data, bool _is_default, int _win_entries, 64 int issue_width_, const InputParameter* configure_interface, 65 string _name, double _accesses, 66 double clockRate_ = 0.0f, 67 enum Device_ty device_ty_ = Core_device, 68 enum Core_type core_ty_ = Inorder); 69 void computeArea(); 70 void computeEnergy(); 71 void leakage_feedback(double temperature); // TODO 72 // TODO: Add a deconstructor 73}; 74 75class dep_resource_conflict_check : public McPATComponent { 76public: 77 InputParameter l_ip; 78 uca_org_t local_result; 79 double WNORn, WNORp, Wevalinvp, Wevalinvn, Wcompn, Wcompp, Wcomppreequ; 80 CoreParameters coredynp; 81 int compare_bits; 82 bool is_default; 83 statsDef stats_t; 84 85 dep_resource_conflict_check(XMLNode* _xml_data, const string _name, 86 const InputParameter *configure_interface, 87 const CoreParameters & dyn_p_, int compare_bits_, 88 double clockRate_ = 0.0f, 89 bool _is_default = true); 90 void conflict_check_power(); 91 double compare_cap(); 92 void computeEnergy() {}; 93 ~dep_resource_conflict_check() { 94 local_result.cleanup(); 95 } 96 97 void leakage_feedback(double temperature); 98}; 99 100class InstructionDecoder: public McPATComponent { 101public: 102 Decoder* final_dec; 103 Predec* pre_dec; 104 105 bool is_default; 106 int opcode_length; 107 int num_decoders; 108 bool x86; 109 int num_decoder_segments; 110 int num_decoded_signals; 111 InputParameter l_ip; 112 uca_org_t local_result; 113 enum Device_ty device_ty; 114 enum Core_type core_ty; 115 statsDef stats_t; 116 117 InstructionDecoder(XMLNode* _xml_data, const string _name, bool _is_default, 118 const InputParameter *configure_interface, 119 int opcode_length_, int num_decoders_, bool x86_, 120 double clockRate_ = 0.0f, 121 enum Device_ty device_ty_ = Core_device, 122 enum Core_type core_ty_ = Inorder); 123 InstructionDecoder(); 124 void computeEnergy() {}; 125 void inst_decoder_delay_power(); 126 ~InstructionDecoder(); 127 void leakage_feedback(double temperature); 128}; 129 130// TODO: This should be defined elsewhere? This isn't a true McPATComponent 131class DFFCell : public Component { 132public: 133 InputParameter l_ip; 134 bool is_dram; 135 double cell_load; 136 double WdecNANDn; 137 double WdecNANDp; 138 double clock_cap; 139 int model; 140 int n_switch; 141 int n_keep_1; 142 int n_keep_0; 143 int n_clock; 144 powerDef e_switch; 145 powerDef e_keep_1; 146 powerDef e_keep_0; 147 powerDef e_clock; 148 149 DFFCell(bool _is_dram, double _WdecNANDn, double _WdecNANDp, double _cell_load, 150 const InputParameter *configure_interface); 151 double fpfp_node_cap(unsigned int fan_in, unsigned int fan_out); 152 void compute_DFF_cell(void); 153 ~DFFCell() {}; 154}; 155 156// TODO: This is a very ambiguous component. Try to refactor it. 157class Pipeline : public McPATComponent { 158public: 159 InputParameter l_ip; 160 uca_org_t local_result; 161 CoreParameters coredynp; 162 enum Device_ty device_ty; 163 bool is_core_pipeline, is_default; 164 double num_piperegs; 165 bool process_ind; 166 double WNANDn; 167 double WNANDp; 168 double load_per_pipeline_stage; 169 170 Pipeline(XMLNode* _xml_data, const InputParameter *configure_interface, 171 const CoreParameters & dyn_p_, 172 enum Device_ty device_ty_ = Core_device, 173 bool _is_core_pipeline = true, bool _is_default = true); 174 void compute_stage_vector(); 175 /** 176 * TODO: compute() completes work that should be completed in computeArea() 177 * and computeEnergy() recursively. Consider shifting these calculations 178 * around to be consistent with rest of hierarchy 179 */ 180 void compute(); 181 void computeArea() {}; 182 // TODO: Move energy computation to this function to unify hierarchy 183 void computeEnergy() {}; 184 ~Pipeline() { 185 local_result.cleanup(); 186 }; 187 188}; 189 190class FunctionalUnit : public McPATComponent { 191public: 192 InputParameter interface_ip; 193 CoreParameters core_params; 194 CoreStatistics core_stats; 195 double FU_height; 196 double num_fu; 197 double energy; 198 double base_energy; 199 double per_access_energy; 200 bool is_default; 201 enum FU_type fu_type; 202 statsDef stats_t; 203 204 FunctionalUnit(XMLNode* _xml_data, InputParameter* interface_ip_, 205 const CoreParameters & _core_params, 206 const CoreStatistics & _core_stats, enum FU_type fu_type); 207 void computeEnergy(); 208 void leakage_feedback(double temperature); 209 ~FunctionalUnit() {}; 210}; 211 212// TODO: This is a very ambiguous component. Try to refactor it. 213class UndiffCore : public McPATComponent { 214public: 215 InputParameter interface_ip; 216 CoreParameters coredynp; 217 double scktRatio; 218 double chip_PR_overhead; 219 double macro_PR_overhead; 220 enum Core_type core_ty; 221 bool opt_performance; 222 bool embedded; 223 double pipeline_stage; 224 double num_hthreads; 225 double issue_width; 226 bool is_default; 227 bool exist; 228 229 UndiffCore(XMLNode* _xml_data, InputParameter* interface_ip_, 230 const CoreParameters & dyn_p_, 231 bool exist_ = true); 232 void computeArea() {}; 233 // TODO: Move energy computation to this function to unify hierarchy 234 void computeEnergy() {}; 235 ~UndiffCore() {}; 236}; 237#endif /* LOGIC_H_ */ 238