1/*
2 * Copyright (c) 2015, University of Kaiserslautern
3 * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 *    this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the copyright holder nor the names of its
18 *    contributors may be used to endorse or promote products derived from
19 *    this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Authors: Matthias Jung
34 *          Christian Menard
35 *          Abdul Mutaal Ahmad
36 */
37
38/**
39 * @file
40 *
41 *  Example top level file for SystemC-TLM integration with C++-only
42 *  instantiation.
43 *
44 */
45
46#include <systemc>
47#include <tlm>
48
49#include "cli_parser.hh"
50#include "report_handler.hh"
51#include "sc_target.hh"
52#include "sim_control.hh"
53#include "slave_transactor.hh"
54#include "stats.hh"
55
56int
57sc_main(int argc, char **argv)
58{
59    CliParser parser;
60    parser.parse(argc, argv);
61
62    sc_core::sc_report_handler::set_handler(reportHandler);
63
64    Gem5SystemC::Gem5SimControl sim_control("gem5",
65                                           parser.getConfigFile(),
66                                           parser.getSimulationEnd(),
67                                           parser.getDebugFlags());
68
69    unsigned long long int memorySize = 512*1024*1024ULL;
70
71    Gem5SystemC::Gem5SlaveTransactor transactor("transactor", "transactor");
72    Target memory("memory",
73                  parser.getVerboseFlag(),
74                  memorySize,
75                  parser.getMemoryOffset());
76
77    memory.socket.bind(transactor.socket);
78    transactor.sim_control.bind(sim_control);
79
80    SC_REPORT_INFO("sc_main", "Start of Simulation");
81
82    sc_core::sc_start();
83
84    SC_REPORT_INFO("sc_main", "End of Simulation");
85
86    CxxConfig::statsDump();
87
88    return EXIT_SUCCESS;
89}
90