110152Satgutier@umich.edu/***************************************************************************** 210152Satgutier@umich.edu * McPAT 310152Satgutier@umich.edu * SOFTWARE LICENSE AGREEMENT 410152Satgutier@umich.edu * Copyright 2012 Hewlett-Packard Development Company, L.P. 510234Syasuko.eckert@amd.com * Copyright (c) 2010-2013 Advanced Micro Devices, Inc. 610152Satgutier@umich.edu * All Rights Reserved 710152Satgutier@umich.edu * 810152Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without 910152Satgutier@umich.edu * modification, are permitted provided that the following conditions are 1010152Satgutier@umich.edu * met: redistributions of source code must retain the above copyright 1110152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer; 1210152Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright 1310152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the 1410152Satgutier@umich.edu * documentation and/or other materials provided with the distribution; 1510152Satgutier@umich.edu * neither the name of the copyright holders nor the names of its 1610152Satgutier@umich.edu * contributors may be used to endorse or promote products derived from 1710152Satgutier@umich.edu * this software without specific prior written permission. 1810152Satgutier@umich.edu 1910152Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2010152Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2110152Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2210152Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2310152Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2410152Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2510152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2610152Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2710152Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2810152Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2910234Syasuko.eckert@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3010152Satgutier@umich.edu * 3110152Satgutier@umich.edu ***************************************************************************/ 3210152Satgutier@umich.edu#ifndef LOGIC_H_ 3310152Satgutier@umich.edu#define LOGIC_H_ 3410152Satgutier@umich.edu 3510152Satgutier@umich.edu#include <cmath> 3610152Satgutier@umich.edu#include <cstring> 3710152Satgutier@umich.edu#include <iostream> 3810152Satgutier@umich.edu 3910152Satgutier@umich.edu#include "arch_const.h" 4010152Satgutier@umich.edu#include "basic_circuit.h" 4110152Satgutier@umich.edu#include "basic_components.h" 4210152Satgutier@umich.edu#include "cacti_interface.h" 4310152Satgutier@umich.edu#include "component.h" 4410152Satgutier@umich.edu#include "const.h" 4510152Satgutier@umich.edu#include "decoder.h" 4610152Satgutier@umich.edu#include "parameter.h" 4710152Satgutier@umich.edu#include "xmlParser.h" 4810152Satgutier@umich.edu 4910152Satgutier@umich.eduusing namespace std; 5010152Satgutier@umich.edu 5110234Syasuko.eckert@amd.comclass selection_logic : public McPATComponent { 5210152Satgutier@umich.edupublic: 5310234Syasuko.eckert@amd.com bool is_default; 5410234Syasuko.eckert@amd.com InputParameter l_ip; 5510234Syasuko.eckert@amd.com uca_org_t local_result; 5610234Syasuko.eckert@amd.com int win_entries; 5710234Syasuko.eckert@amd.com int issue_width; 5810234Syasuko.eckert@amd.com double accesses; 5910234Syasuko.eckert@amd.com int num_threads; 6010234Syasuko.eckert@amd.com enum Device_ty device_ty; 6110234Syasuko.eckert@amd.com enum Core_type core_ty; 6210152Satgutier@umich.edu 6310234Syasuko.eckert@amd.com selection_logic(XMLNode* _xml_data, bool _is_default, int _win_entries, 6410234Syasuko.eckert@amd.com int issue_width_, const InputParameter* configure_interface, 6510234Syasuko.eckert@amd.com string _name, double _accesses, 6610234Syasuko.eckert@amd.com double clockRate_ = 0.0f, 6710234Syasuko.eckert@amd.com enum Device_ty device_ty_ = Core_device, 6810234Syasuko.eckert@amd.com enum Core_type core_ty_ = Inorder); 6910234Syasuko.eckert@amd.com void computeArea(); 7010234Syasuko.eckert@amd.com void computeEnergy(); 7110152Satgutier@umich.edu void leakage_feedback(double temperature); // TODO 7210234Syasuko.eckert@amd.com // TODO: Add a deconstructor 7310152Satgutier@umich.edu}; 7410152Satgutier@umich.edu 7510234Syasuko.eckert@amd.comclass dep_resource_conflict_check : public McPATComponent { 7610152Satgutier@umich.edupublic: 7710234Syasuko.eckert@amd.com InputParameter l_ip; 7810234Syasuko.eckert@amd.com uca_org_t local_result; 7910234Syasuko.eckert@amd.com double WNORn, WNORp, Wevalinvp, Wevalinvn, Wcompn, Wcompp, Wcomppreequ; 8010234Syasuko.eckert@amd.com CoreParameters coredynp; 8110234Syasuko.eckert@amd.com int compare_bits; 8210234Syasuko.eckert@amd.com bool is_default; 8310234Syasuko.eckert@amd.com statsDef stats_t; 8410152Satgutier@umich.edu 8510234Syasuko.eckert@amd.com dep_resource_conflict_check(XMLNode* _xml_data, const string _name, 8610234Syasuko.eckert@amd.com const InputParameter *configure_interface, 8710234Syasuko.eckert@amd.com const CoreParameters & dyn_p_, int compare_bits_, 8810234Syasuko.eckert@amd.com double clockRate_ = 0.0f, 8910234Syasuko.eckert@amd.com bool _is_default = true); 9010234Syasuko.eckert@amd.com void conflict_check_power(); 9110234Syasuko.eckert@amd.com double compare_cap(); 9210234Syasuko.eckert@amd.com void computeEnergy() {}; 9310234Syasuko.eckert@amd.com ~dep_resource_conflict_check() { 9410234Syasuko.eckert@amd.com local_result.cleanup(); 9510234Syasuko.eckert@amd.com } 9610152Satgutier@umich.edu 9710152Satgutier@umich.edu void leakage_feedback(double temperature); 9810152Satgutier@umich.edu}; 9910152Satgutier@umich.edu 10010234Syasuko.eckert@amd.comclass InstructionDecoder: public McPATComponent { 10110152Satgutier@umich.edupublic: 10210234Syasuko.eckert@amd.com Decoder* final_dec; 10310234Syasuko.eckert@amd.com Predec* pre_dec; 10410152Satgutier@umich.edu 10510234Syasuko.eckert@amd.com bool is_default; 10610234Syasuko.eckert@amd.com int opcode_length; 10710234Syasuko.eckert@amd.com int num_decoders; 10810234Syasuko.eckert@amd.com bool x86; 10910234Syasuko.eckert@amd.com int num_decoder_segments; 11010234Syasuko.eckert@amd.com int num_decoded_signals; 11110234Syasuko.eckert@amd.com InputParameter l_ip; 11210234Syasuko.eckert@amd.com uca_org_t local_result; 11310234Syasuko.eckert@amd.com enum Device_ty device_ty; 11410234Syasuko.eckert@amd.com enum Core_type core_ty; 11510234Syasuko.eckert@amd.com statsDef stats_t; 11610152Satgutier@umich.edu 11710234Syasuko.eckert@amd.com InstructionDecoder(XMLNode* _xml_data, const string _name, bool _is_default, 11810234Syasuko.eckert@amd.com const InputParameter *configure_interface, 11910234Syasuko.eckert@amd.com int opcode_length_, int num_decoders_, bool x86_, 12010234Syasuko.eckert@amd.com double clockRate_ = 0.0f, 12110234Syasuko.eckert@amd.com enum Device_ty device_ty_ = Core_device, 12210234Syasuko.eckert@amd.com enum Core_type core_ty_ = Inorder); 12310234Syasuko.eckert@amd.com InstructionDecoder(); 12410234Syasuko.eckert@amd.com void computeEnergy() {}; 12510234Syasuko.eckert@amd.com void inst_decoder_delay_power(); 12610234Syasuko.eckert@amd.com ~InstructionDecoder(); 12710152Satgutier@umich.edu void leakage_feedback(double temperature); 12810152Satgutier@umich.edu}; 12910152Satgutier@umich.edu 13010234Syasuko.eckert@amd.com// TODO: This should be defined elsewhere? This isn't a true McPATComponent 13110152Satgutier@umich.educlass DFFCell : public Component { 13210152Satgutier@umich.edupublic: 13310234Syasuko.eckert@amd.com InputParameter l_ip; 13410234Syasuko.eckert@amd.com bool is_dram; 13510234Syasuko.eckert@amd.com double cell_load; 13610234Syasuko.eckert@amd.com double WdecNANDn; 13710234Syasuko.eckert@amd.com double WdecNANDp; 13810234Syasuko.eckert@amd.com double clock_cap; 13910234Syasuko.eckert@amd.com int model; 14010234Syasuko.eckert@amd.com int n_switch; 14110234Syasuko.eckert@amd.com int n_keep_1; 14210234Syasuko.eckert@amd.com int n_keep_0; 14310234Syasuko.eckert@amd.com int n_clock; 14410234Syasuko.eckert@amd.com powerDef e_switch; 14510234Syasuko.eckert@amd.com powerDef e_keep_1; 14610234Syasuko.eckert@amd.com powerDef e_keep_0; 14710234Syasuko.eckert@amd.com powerDef e_clock; 14810152Satgutier@umich.edu 14910234Syasuko.eckert@amd.com DFFCell(bool _is_dram, double _WdecNANDn, double _WdecNANDp, double _cell_load, 15010234Syasuko.eckert@amd.com const InputParameter *configure_interface); 15110234Syasuko.eckert@amd.com double fpfp_node_cap(unsigned int fan_in, unsigned int fan_out); 15210234Syasuko.eckert@amd.com void compute_DFF_cell(void); 15310234Syasuko.eckert@amd.com ~DFFCell() {}; 15410234Syasuko.eckert@amd.com}; 15510152Satgutier@umich.edu 15610234Syasuko.eckert@amd.com// TODO: This is a very ambiguous component. Try to refactor it. 15710234Syasuko.eckert@amd.comclass Pipeline : public McPATComponent { 15810152Satgutier@umich.edupublic: 15910234Syasuko.eckert@amd.com InputParameter l_ip; 16010234Syasuko.eckert@amd.com uca_org_t local_result; 16110234Syasuko.eckert@amd.com CoreParameters coredynp; 16210234Syasuko.eckert@amd.com enum Device_ty device_ty; 16310234Syasuko.eckert@amd.com bool is_core_pipeline, is_default; 16410234Syasuko.eckert@amd.com double num_piperegs; 16510234Syasuko.eckert@amd.com bool process_ind; 16610234Syasuko.eckert@amd.com double WNANDn; 16710234Syasuko.eckert@amd.com double WNANDp; 16810234Syasuko.eckert@amd.com double load_per_pipeline_stage; 16910234Syasuko.eckert@amd.com 17010234Syasuko.eckert@amd.com Pipeline(XMLNode* _xml_data, const InputParameter *configure_interface, 17110234Syasuko.eckert@amd.com const CoreParameters & dyn_p_, 17210234Syasuko.eckert@amd.com enum Device_ty device_ty_ = Core_device, 17310234Syasuko.eckert@amd.com bool _is_core_pipeline = true, bool _is_default = true); 17410234Syasuko.eckert@amd.com void compute_stage_vector(); 17510234Syasuko.eckert@amd.com /** 17610234Syasuko.eckert@amd.com * TODO: compute() completes work that should be completed in computeArea() 17710234Syasuko.eckert@amd.com * and computeEnergy() recursively. Consider shifting these calculations 17810234Syasuko.eckert@amd.com * around to be consistent with rest of hierarchy 17910234Syasuko.eckert@amd.com */ 18010234Syasuko.eckert@amd.com void compute(); 18110234Syasuko.eckert@amd.com void computeArea() {}; 18210234Syasuko.eckert@amd.com // TODO: Move energy computation to this function to unify hierarchy 18310234Syasuko.eckert@amd.com void computeEnergy() {}; 18410234Syasuko.eckert@amd.com ~Pipeline() { 18510234Syasuko.eckert@amd.com local_result.cleanup(); 18610234Syasuko.eckert@amd.com }; 18710152Satgutier@umich.edu 18810152Satgutier@umich.edu}; 18910152Satgutier@umich.edu 19010234Syasuko.eckert@amd.comclass FunctionalUnit : public McPATComponent { 19110234Syasuko.eckert@amd.compublic: 19210234Syasuko.eckert@amd.com InputParameter interface_ip; 19310234Syasuko.eckert@amd.com CoreParameters core_params; 19410234Syasuko.eckert@amd.com CoreStatistics core_stats; 19510234Syasuko.eckert@amd.com double FU_height; 19610234Syasuko.eckert@amd.com double num_fu; 19710234Syasuko.eckert@amd.com double energy; 19810234Syasuko.eckert@amd.com double base_energy; 19910234Syasuko.eckert@amd.com double per_access_energy; 20010234Syasuko.eckert@amd.com bool is_default; 20110234Syasuko.eckert@amd.com enum FU_type fu_type; 20210234Syasuko.eckert@amd.com statsDef stats_t; 20310152Satgutier@umich.edu 20410234Syasuko.eckert@amd.com FunctionalUnit(XMLNode* _xml_data, InputParameter* interface_ip_, 20510234Syasuko.eckert@amd.com const CoreParameters & _core_params, 20610234Syasuko.eckert@amd.com const CoreStatistics & _core_stats, enum FU_type fu_type); 20710234Syasuko.eckert@amd.com void computeEnergy(); 20810152Satgutier@umich.edu void leakage_feedback(double temperature); 20910234Syasuko.eckert@amd.com ~FunctionalUnit() {}; 21010152Satgutier@umich.edu}; 21110152Satgutier@umich.edu 21210234Syasuko.eckert@amd.com// TODO: This is a very ambiguous component. Try to refactor it. 21310234Syasuko.eckert@amd.comclass UndiffCore : public McPATComponent { 21410152Satgutier@umich.edupublic: 21510234Syasuko.eckert@amd.com InputParameter interface_ip; 21610234Syasuko.eckert@amd.com CoreParameters coredynp; 21710234Syasuko.eckert@amd.com double scktRatio; 21810234Syasuko.eckert@amd.com double chip_PR_overhead; 21910234Syasuko.eckert@amd.com double macro_PR_overhead; 22010234Syasuko.eckert@amd.com enum Core_type core_ty; 22110234Syasuko.eckert@amd.com bool opt_performance; 22210234Syasuko.eckert@amd.com bool embedded; 22310234Syasuko.eckert@amd.com double pipeline_stage; 22410234Syasuko.eckert@amd.com double num_hthreads; 22510234Syasuko.eckert@amd.com double issue_width; 22610234Syasuko.eckert@amd.com bool is_default; 22710234Syasuko.eckert@amd.com bool exist; 22810152Satgutier@umich.edu 22910234Syasuko.eckert@amd.com UndiffCore(XMLNode* _xml_data, InputParameter* interface_ip_, 23010234Syasuko.eckert@amd.com const CoreParameters & dyn_p_, 23110234Syasuko.eckert@amd.com bool exist_ = true); 23210234Syasuko.eckert@amd.com void computeArea() {}; 23310234Syasuko.eckert@amd.com // TODO: Move energy computation to this function to unify hierarchy 23410234Syasuko.eckert@amd.com void computeEnergy() {}; 23510234Syasuko.eckert@amd.com ~UndiffCore() {}; 23610152Satgutier@umich.edu}; 23710152Satgutier@umich.edu#endif /* LOGIC_H_ */ 238