main.cc revision 10152:52c552138ba1
1/*****************************************************************************
2 *                                McPAT
3 *                      SOFTWARE LICENSE AGREEMENT
4 *            Copyright 2012 Hewlett-Packard Development Company, L.P.
5 *                          All Rights Reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
29 *
30 ***************************************************************************/
31#include <iostream>
32
33#include "XML_Parse.h"
34#include "globalvar.h"
35#include "io.h"
36#include "processor.h"
37#include "version.h"
38#include "xmlParser.h"
39
40using namespace std;
41
42void print_usage(char * argv0);
43
44int main(int argc,char *argv[])
45{
46        char * fb ;
47        bool infile_specified     = false;
48        int  plevel               = 2;
49        opt_for_clk	=true;
50        //cout.precision(10);
51        if (argc <= 1 || argv[1] == string("-h") || argv[1] == string("--help"))
52        {
53                print_usage(argv[0]);
54        }
55
56        for (int32_t i = 0; i < argc; i++)
57        {
58                if (argv[i] == string("-infile"))
59                {
60                        infile_specified = true;
61                        i++;
62                        fb = argv[ i];
63                }
64
65                if (argv[i] == string("-print_level"))
66                {
67                        i++;
68                        plevel = atoi(argv[i]);
69                }
70
71                if (argv[i] == string("-opt_for_clk"))
72                {
73                        i++;
74                        opt_for_clk = (bool)atoi(argv[i]);
75                }
76        }
77        if (infile_specified == false)
78        {
79                print_usage(argv[0]);
80        }
81
82
83        cout<<"McPAT (version "<< VER_MAJOR <<"."<< VER_MINOR
84                << " of " << VER_UPDATE << ") is computing the target processor...\n "<<endl;
85
86        //parse XML-based interface
87        ParseXML *p1= new ParseXML();
88        p1->parse(fb);
89        Processor proc(p1);
90        proc.displayEnergy(2, plevel);
91        delete p1;
92        return 0;
93}
94
95void print_usage(char * argv0)
96{
97    cerr << "How to use McPAT:" << endl;
98    cerr << "  mcpat -infile <input file name>  -print_level < level of details 0~5 >  -opt_for_clk < 0 (optimize for ED^2P only)/1 (optimzed for target clock rate)>"<< endl;
99    //cerr << "    Note:default print level is at processor level, please increase it to see the details" << endl;
100    exit(1);
101}
102