logic.h revision 10152
110152Satgutier@umich.edu/*****************************************************************************
210152Satgutier@umich.edu *                                McPAT
310152Satgutier@umich.edu *                      SOFTWARE LICENSE AGREEMENT
410152Satgutier@umich.edu *            Copyright 2012 Hewlett-Packard Development Company, L.P.
510152Satgutier@umich.edu *                          All Rights Reserved
610152Satgutier@umich.edu *
710152Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without
810152Satgutier@umich.edu * modification, are permitted provided that the following conditions are
910152Satgutier@umich.edu * met: redistributions of source code must retain the above copyright
1010152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer;
1110152Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright
1210152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the
1310152Satgutier@umich.edu * documentation and/or other materials provided with the distribution;
1410152Satgutier@umich.edu * neither the name of the copyright holders nor the names of its
1510152Satgutier@umich.edu * contributors may be used to endorse or promote products derived from
1610152Satgutier@umich.edu * this software without specific prior written permission.
1710152Satgutier@umich.edu
1810152Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1910152Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2010152Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2110152Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2210152Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2310152Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2410152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2510152Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2610152Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2710152Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2810152Satgutier@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
2910152Satgutier@umich.edu *
3010152Satgutier@umich.edu ***************************************************************************/
3110152Satgutier@umich.edu#ifndef LOGIC_H_
3210152Satgutier@umich.edu#define LOGIC_H_
3310152Satgutier@umich.edu
3410152Satgutier@umich.edu#include <cassert>
3510152Satgutier@umich.edu#include <cmath>
3610152Satgutier@umich.edu#include <cstring>
3710152Satgutier@umich.edu#include <iostream>
3810152Satgutier@umich.edu
3910152Satgutier@umich.edu#include "XML_Parse.h"
4010152Satgutier@umich.edu#include "arch_const.h"
4110152Satgutier@umich.edu#include "basic_circuit.h"
4210152Satgutier@umich.edu#include "basic_components.h"
4310152Satgutier@umich.edu#include "cacti_interface.h"
4410152Satgutier@umich.edu#include "component.h"
4510152Satgutier@umich.edu#include "const.h"
4610152Satgutier@umich.edu#include "decoder.h"
4710152Satgutier@umich.edu#include "parameter.h"
4810152Satgutier@umich.edu#include "xmlParser.h"
4910152Satgutier@umich.edu
5010152Satgutier@umich.eduusing namespace std;
5110152Satgutier@umich.edu
5210152Satgutier@umich.educlass selection_logic : public Component{
5310152Satgutier@umich.edupublic:
5410152Satgutier@umich.edu        selection_logic(bool _is_default, int    win_entries_,
5510152Satgutier@umich.edu                            int  issue_width_, const InputParameter *configure_interface,
5610152Satgutier@umich.edu                            enum Device_ty device_ty_=Core_device,
5710152Satgutier@umich.edu                            enum Core_type core_ty_=Inorder);//, const ParseXML *_XML_interface);
5810152Satgutier@umich.edu        bool is_default;
5910152Satgutier@umich.edu        InputParameter l_ip;
6010152Satgutier@umich.edu        uca_org_t local_result;
6110152Satgutier@umich.edu        const ParseXML *XML_interface;
6210152Satgutier@umich.edu        int win_entries;
6310152Satgutier@umich.edu        int issue_width;
6410152Satgutier@umich.edu        int num_threads;
6510152Satgutier@umich.edu        enum Device_ty device_ty;
6610152Satgutier@umich.edu        enum Core_type core_ty;
6710152Satgutier@umich.edu
6810152Satgutier@umich.edu        void selection_power();
6910152Satgutier@umich.edu        void leakage_feedback(double temperature); // TODO
7010152Satgutier@umich.edu};
7110152Satgutier@umich.edu
7210152Satgutier@umich.educlass dep_resource_conflict_check : public Component{
7310152Satgutier@umich.edupublic:
7410152Satgutier@umich.edu        dep_resource_conflict_check(const InputParameter *configure_interface, const CoreDynParam & dyn_p_, int compare_bits_, bool _is_default=true);
7510152Satgutier@umich.edu        InputParameter l_ip;
7610152Satgutier@umich.edu        uca_org_t local_result;
7710152Satgutier@umich.edu        double WNORn, WNORp, Wevalinvp, Wevalinvn, Wcompn, Wcompp, Wcomppreequ;
7810152Satgutier@umich.edu        CoreDynParam  coredynp;
7910152Satgutier@umich.edu        int compare_bits;
8010152Satgutier@umich.edu        bool is_default;
8110152Satgutier@umich.edu        statsDef       tdp_stats;
8210152Satgutier@umich.edu        statsDef       rtp_stats;
8310152Satgutier@umich.edu        statsDef       stats_t;
8410152Satgutier@umich.edu        powerDef       power_t;
8510152Satgutier@umich.edu
8610152Satgutier@umich.edu        void conflict_check_power();
8710152Satgutier@umich.edu        double compare_cap();
8810152Satgutier@umich.edu        ~dep_resource_conflict_check(){
8910152Satgutier@umich.edu                local_result.cleanup();
9010152Satgutier@umich.edu        }
9110152Satgutier@umich.edu
9210152Satgutier@umich.edu        void leakage_feedback(double temperature);
9310152Satgutier@umich.edu};
9410152Satgutier@umich.edu
9510152Satgutier@umich.educlass inst_decoder: public Component{
9610152Satgutier@umich.edupublic:
9710152Satgutier@umich.edu        inst_decoder(bool _is_default, const InputParameter *configure_interface,
9810152Satgutier@umich.edu                        int opcode_length_,
9910152Satgutier@umich.edu                        int num_decoders_,
10010152Satgutier@umich.edu                        bool x86_,
10110152Satgutier@umich.edu                        enum Device_ty device_ty_=Core_device,
10210152Satgutier@umich.edu                        enum Core_type core_ty_=Inorder);
10310152Satgutier@umich.edu        inst_decoder();
10410152Satgutier@umich.edu        bool is_default;
10510152Satgutier@umich.edu        int  opcode_length;
10610152Satgutier@umich.edu        int  num_decoders;
10710152Satgutier@umich.edu        bool x86;
10810152Satgutier@umich.edu        int  num_decoder_segments;
10910152Satgutier@umich.edu        int  num_decoded_signals;
11010152Satgutier@umich.edu        InputParameter l_ip;
11110152Satgutier@umich.edu        uca_org_t local_result;
11210152Satgutier@umich.edu        enum Device_ty device_ty;
11310152Satgutier@umich.edu        enum Core_type core_ty;
11410152Satgutier@umich.edu
11510152Satgutier@umich.edu        Decoder * final_dec;
11610152Satgutier@umich.edu        Predec *  pre_dec;
11710152Satgutier@umich.edu
11810152Satgutier@umich.edu        statsDef       tdp_stats;
11910152Satgutier@umich.edu        statsDef       rtp_stats;
12010152Satgutier@umich.edu        statsDef       stats_t;
12110152Satgutier@umich.edu        powerDef       power_t;
12210152Satgutier@umich.edu        void inst_decoder_delay_power();
12310152Satgutier@umich.edu        ~inst_decoder();
12410152Satgutier@umich.edu        void leakage_feedback(double temperature);
12510152Satgutier@umich.edu};
12610152Satgutier@umich.edu
12710152Satgutier@umich.educlass DFFCell : public Component {
12810152Satgutier@umich.edupublic:
12910152Satgutier@umich.edu        DFFCell(bool _is_dram, double _WdecNANDn, double _WdecNANDp,double _cell_load,
13010152Satgutier@umich.edu                          const InputParameter *configure_interface);
13110152Satgutier@umich.edu        InputParameter l_ip;
13210152Satgutier@umich.edu        bool is_dram;
13310152Satgutier@umich.edu        double cell_load;
13410152Satgutier@umich.edu        double WdecNANDn;
13510152Satgutier@umich.edu        double WdecNANDp;
13610152Satgutier@umich.edu        double clock_cap;
13710152Satgutier@umich.edu        int    model;
13810152Satgutier@umich.edu        int    n_switch;
13910152Satgutier@umich.edu        int    n_keep_1;
14010152Satgutier@umich.edu        int    n_keep_0;
14110152Satgutier@umich.edu        int    n_clock;
14210152Satgutier@umich.edu        powerDef e_switch;
14310152Satgutier@umich.edu        powerDef e_keep_1;
14410152Satgutier@umich.edu        powerDef e_keep_0;
14510152Satgutier@umich.edu        powerDef e_clock;
14610152Satgutier@umich.edu
14710152Satgutier@umich.edu        double fpfp_node_cap(unsigned int fan_in, unsigned int fan_out);
14810152Satgutier@umich.edu        void compute_DFF_cell(void);
14910152Satgutier@umich.edu        };
15010152Satgutier@umich.edu
15110152Satgutier@umich.educlass Pipeline : public Component{
15210152Satgutier@umich.edupublic:
15310152Satgutier@umich.edu        Pipeline(const InputParameter *configure_interface, const CoreDynParam & dyn_p_, enum Device_ty device_ty_=Core_device, bool _is_core_pipeline=true, bool _is_default=true);
15410152Satgutier@umich.edu        InputParameter l_ip;
15510152Satgutier@umich.edu        uca_org_t local_result;
15610152Satgutier@umich.edu        CoreDynParam  coredynp;
15710152Satgutier@umich.edu        enum Device_ty device_ty;
15810152Satgutier@umich.edu        bool is_core_pipeline, is_default;
15910152Satgutier@umich.edu        double num_piperegs;
16010152Satgutier@umich.edu//	int pipeline_stages;
16110152Satgutier@umich.edu//	int tot_stage_vector, per_stage_vector;
16210152Satgutier@umich.edu        bool process_ind;
16310152Satgutier@umich.edu        double WNANDn ;
16410152Satgutier@umich.edu        double WNANDp;
16510152Satgutier@umich.edu        double load_per_pipeline_stage;
16610152Satgutier@umich.edu//	int  Hthread,  num_thread, fetchWidth, decodeWidth, issueWidth, commitWidth, instruction_length;
16710152Satgutier@umich.edu//	int  PC_width, opcode_length, num_arch_reg_tag, data_width,num_phsical_reg_tag, address_width;
16810152Satgutier@umich.edu//	bool thread_clock_gated;
16910152Satgutier@umich.edu//	bool in_order, multithreaded;
17010152Satgutier@umich.edu        void compute_stage_vector();
17110152Satgutier@umich.edu        void compute();
17210152Satgutier@umich.edu        ~Pipeline(){
17310152Satgutier@umich.edu                local_result.cleanup();
17410152Satgutier@umich.edu        };
17510152Satgutier@umich.edu
17610152Satgutier@umich.edu};
17710152Satgutier@umich.edu
17810152Satgutier@umich.edu//class core_pipeline :public pipeline{
17910152Satgutier@umich.edu//public:
18010152Satgutier@umich.edu//	int  Hthread,  num_thread, fetchWidth, decodeWidth, issueWidth, commitWidth, instruction_length;
18110152Satgutier@umich.edu//	int  PC_width, opcode_length, num_arch_reg_tag, data_width,num_phsical_reg_tag, address_width;
18210152Satgutier@umich.edu//	bool thread_clock_gated;
18310152Satgutier@umich.edu//	bool in_order, multithreaded;
18410152Satgutier@umich.edu//	core_pipeline(bool _is_default, const InputParameter *configure_interface);
18510152Satgutier@umich.edu//	virtual void compute_stage_vector();
18610152Satgutier@umich.edu//
18710152Satgutier@umich.edu//};
18810152Satgutier@umich.edu
18910152Satgutier@umich.educlass FunctionalUnit :public Component{
19010152Satgutier@umich.edupublic:
19110152Satgutier@umich.edu        ParseXML *XML;
19210152Satgutier@umich.edu        int  ithCore;
19310152Satgutier@umich.edu        InputParameter interface_ip;
19410152Satgutier@umich.edu        CoreDynParam  coredynp;
19510152Satgutier@umich.edu        double FU_height;
19610152Satgutier@umich.edu        double clockRate,executionTime;
19710152Satgutier@umich.edu        double num_fu;
19810152Satgutier@umich.edu        double energy, base_energy,per_access_energy, leakage, gate_leakage;
19910152Satgutier@umich.edu        bool  is_default;
20010152Satgutier@umich.edu        enum FU_type fu_type;
20110152Satgutier@umich.edu        statsDef       tdp_stats;
20210152Satgutier@umich.edu        statsDef       rtp_stats;
20310152Satgutier@umich.edu        statsDef       stats_t;
20410152Satgutier@umich.edu        powerDef       power_t;
20510152Satgutier@umich.edu
20610152Satgutier@umich.edu        FunctionalUnit(ParseXML *XML_interface, int ithCore_, InputParameter* interface_ip_,const CoreDynParam & dyn_p_, enum FU_type fu_type);
20710152Satgutier@umich.edu    void computeEnergy(bool is_tdp=true);
20810152Satgutier@umich.edu        void displayEnergy(uint32_t indent = 0,int plevel = 100, bool is_tdp=true);
20910152Satgutier@umich.edu    void leakage_feedback(double temperature);
21010152Satgutier@umich.edu
21110152Satgutier@umich.edu};
21210152Satgutier@umich.edu
21310152Satgutier@umich.educlass UndiffCore :public Component{
21410152Satgutier@umich.edupublic:
21510152Satgutier@umich.edu        UndiffCore(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_=true, bool embedded_=false);
21610152Satgutier@umich.edu        ParseXML *XML;
21710152Satgutier@umich.edu        int  ithCore;
21810152Satgutier@umich.edu        InputParameter interface_ip;
21910152Satgutier@umich.edu        CoreDynParam  coredynp;
22010152Satgutier@umich.edu        double clockRate,executionTime;
22110152Satgutier@umich.edu        double scktRatio, chip_PR_overhead, macro_PR_overhead;
22210152Satgutier@umich.edu        enum  Core_type core_ty;
22310152Satgutier@umich.edu        bool   opt_performance, embedded;
22410152Satgutier@umich.edu        double pipeline_stage,num_hthreads,issue_width;
22510152Satgutier@umich.edu        bool   is_default;
22610152Satgutier@umich.edu
22710152Satgutier@umich.edu    void displayEnergy(uint32_t indent = 0,int plevel = 100, bool is_tdp=true);
22810152Satgutier@umich.edu        ~UndiffCore(){};
22910152Satgutier@umich.edu        bool exist;
23010152Satgutier@umich.edu
23110152Satgutier@umich.edu
23210152Satgutier@umich.edu};
23310152Satgutier@umich.edu#endif /* LOGIC_H_ */
234