main.cc revision 11821
111819SChristian.Menard@tu-dresden.de/* 211819SChristian.Menard@tu-dresden.de * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 311819SChristian.Menard@tu-dresden.de * All rights reserved. 411819SChristian.Menard@tu-dresden.de * 511819SChristian.Menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 611819SChristian.Menard@tu-dresden.de * modification, are permitted provided that the following conditions are 711819SChristian.Menard@tu-dresden.de * met: 811819SChristian.Menard@tu-dresden.de * 911819SChristian.Menard@tu-dresden.de * 1. Redistributions of source code must retain the above copyright notice, 1011819SChristian.Menard@tu-dresden.de * this list of conditions and the following disclaimer. 1111819SChristian.Menard@tu-dresden.de * 1211819SChristian.Menard@tu-dresden.de * 2. Redistributions in binary form must reproduce the above copyright 1311819SChristian.Menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1411819SChristian.Menard@tu-dresden.de * documentation and/or other materials provided with the distribution. 1511819SChristian.Menard@tu-dresden.de * 1611819SChristian.Menard@tu-dresden.de * 3. Neither the name of the copyright holder nor the names of its 1711819SChristian.Menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1811819SChristian.Menard@tu-dresden.de * this software without specific prior written permission. 1911819SChristian.Menard@tu-dresden.de * 2011819SChristian.Menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2111819SChristian.Menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2211819SChristian.Menard@tu-dresden.de * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2311819SChristian.Menard@tu-dresden.de * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 2411819SChristian.Menard@tu-dresden.de * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2511819SChristian.Menard@tu-dresden.de * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2611819SChristian.Menard@tu-dresden.de * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2711819SChristian.Menard@tu-dresden.de * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2811819SChristian.Menard@tu-dresden.de * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 2911819SChristian.Menard@tu-dresden.de * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3011819SChristian.Menard@tu-dresden.de * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3111819SChristian.Menard@tu-dresden.de * 3211819SChristian.Menard@tu-dresden.de * Authors: Christian Menard 3311819SChristian.Menard@tu-dresden.de */ 3411819SChristian.Menard@tu-dresden.de 3511819SChristian.Menard@tu-dresden.de#include <systemc> 3611819SChristian.Menard@tu-dresden.de#include <tlm> 3711819SChristian.Menard@tu-dresden.de 3811821SChristian.Menard@tu-dresden.de#include "cli_parser.hh" 3911821SChristian.Menard@tu-dresden.de#include "report_handler.hh" 4011819SChristian.Menard@tu-dresden.de#include "sc_master_port.hh" 4111819SChristian.Menard@tu-dresden.de#include "sim_control.hh" 4211819SChristian.Menard@tu-dresden.de#include "stats.hh" 4311819SChristian.Menard@tu-dresden.de#include "traffic_generator.hh" 4411819SChristian.Menard@tu-dresden.de 4511819SChristian.Menard@tu-dresden.deint 4611819SChristian.Menard@tu-dresden.desc_main(int argc, char** argv) 4711819SChristian.Menard@tu-dresden.de{ 4811821SChristian.Menard@tu-dresden.de CliParser parser; 4911821SChristian.Menard@tu-dresden.de parser.parse(argc, argv); 5011821SChristian.Menard@tu-dresden.de 5111819SChristian.Menard@tu-dresden.de sc_core::sc_report_handler::set_handler(reportHandler); 5211819SChristian.Menard@tu-dresden.de 5311821SChristian.Menard@tu-dresden.de Gem5SystemC::Gem5SimControl simControl("gem5", 5411821SChristian.Menard@tu-dresden.de parser.getConfigFile(), 5511821SChristian.Menard@tu-dresden.de parser.getSimulationEnd(), 5611821SChristian.Menard@tu-dresden.de parser.getDebugFlags()); 5711821SChristian.Menard@tu-dresden.de 5811819SChristian.Menard@tu-dresden.de TrafficGenerator trafficGenerator("traffic_generator"); 5911819SChristian.Menard@tu-dresden.de 6011819SChristian.Menard@tu-dresden.de tlm::tlm_target_socket<>* mem_port = 6111819SChristian.Menard@tu-dresden.de dynamic_cast<tlm::tlm_target_socket<>*>( 6211819SChristian.Menard@tu-dresden.de sc_core::sc_find_object("gem5.memory")); 6311819SChristian.Menard@tu-dresden.de 6411819SChristian.Menard@tu-dresden.de if (mem_port) { 6511819SChristian.Menard@tu-dresden.de SC_REPORT_INFO("sc_main", "Port Found"); 6611819SChristian.Menard@tu-dresden.de trafficGenerator.socket.bind(*mem_port); 6711819SChristian.Menard@tu-dresden.de } else { 6811819SChristian.Menard@tu-dresden.de SC_REPORT_FATAL("sc_main", "Port Not Found"); 6911819SChristian.Menard@tu-dresden.de std::exit(EXIT_FAILURE); 7011819SChristian.Menard@tu-dresden.de } 7111819SChristian.Menard@tu-dresden.de 7211821SChristian.Menard@tu-dresden.de SC_REPORT_INFO("sc_main", "Start of Simulation"); 7311819SChristian.Menard@tu-dresden.de 7411819SChristian.Menard@tu-dresden.de sc_core::sc_start(); // Run to end of simulation 7511819SChristian.Menard@tu-dresden.de 7611819SChristian.Menard@tu-dresden.de SC_REPORT_INFO("sc_main", "End of Simulation"); 7711819SChristian.Menard@tu-dresden.de 7811819SChristian.Menard@tu-dresden.de CxxConfig::statsDump(); 7911819SChristian.Menard@tu-dresden.de 8011819SChristian.Menard@tu-dresden.de return EXIT_SUCCESS; 8111819SChristian.Menard@tu-dresden.de} 82