From ccd9210e1a1bdce828a13a4ffdf84548ffe61592 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 9 Feb 2017 19:15:38 -0500 Subject: misc: Clean up and complete the gem5<->SystemC-TLM bridge [4/10] The current TLM bridge only provides a Slave Port that allows the gem5 world to send request to the SystemC world. This patch series refractors and cleans up the existing code, and adds a Master Port that allows the SystemC world to send requests to the gem5 world. This patch: * Move common code of the example to a common directory. Move the cli * parsing from the SimControl module to a separate example object. Add * comments describing the Gem5SimControl module. Testing Done: Examples compile and run. Reviewed at http://reviews.gem5.org/r/3695/ Signed-off-by: Jason Lowe-Power --- util/tlm/examples/master_port/main.cc | 39 ++++++++++------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'util/tlm/examples/master_port/main.cc') diff --git a/util/tlm/examples/master_port/main.cc b/util/tlm/examples/master_port/main.cc index 205e430ae..588d81156 100644 --- a/util/tlm/examples/master_port/main.cc +++ b/util/tlm/examples/master_port/main.cc @@ -35,44 +35,27 @@ #include #include +#include "cli_parser.hh" +#include "report_handler.hh" #include "sc_master_port.hh" #include "sim_control.hh" #include "stats.hh" #include "traffic_generator.hh" -// Defining global string variable decalred in stats.hh -std::string filename; - -void -reportHandler(const sc_core::sc_report& report, - const sc_core::sc_actions& actions) -{ - uint64_t systemc_time = report.get_time().value(); - uint64_t gem5_time = curTick(); - - std::cerr << report.get_time(); - - if (gem5_time < systemc_time) { - std::cerr << " (<) "; - } else if (gem5_time > systemc_time) { - std::cerr << " (!) "; - } else { - std::cerr << " (=) "; - } - - std::cerr << ": " << report.get_msg_type() << ' ' << report.get_msg() - << '\n'; -} - int sc_main(int argc, char** argv) { + CliParser parser; + parser.parse(argc, argv); + sc_core::sc_report_handler::set_handler(reportHandler); - SimControl simControl("gem5", argc, argv); - TrafficGenerator trafficGenerator("traffic_generator"); + Gem5SystemC::Gem5SimControl simControl("gem5", + parser.getConfigFile(), + parser.getSimulationEnd(), + parser.getDebugFlags()); - filename = "m5out/stats-systemc.txt"; + TrafficGenerator trafficGenerator("traffic_generator"); tlm::tlm_target_socket<>* mem_port = dynamic_cast*>( @@ -86,7 +69,7 @@ sc_main(int argc, char** argv) std::exit(EXIT_FAILURE); } - std::cout << "Starting sc_main" << std::endl; + SC_REPORT_INFO("sc_main", "Start of Simulation"); sc_core::sc_start(); // Run to end of simulation -- cgit v1.2.3