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/slave_port/main.cc | 47 ++++++++++++------------------------ 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'util/tlm/examples/slave_port/main.cc') diff --git a/util/tlm/examples/slave_port/main.cc b/util/tlm/examples/slave_port/main.cc index 256a99d1b..9f1cadc8d 100644 --- a/util/tlm/examples/slave_port/main.cc +++ b/util/tlm/examples/slave_port/main.cc @@ -43,48 +43,30 @@ * */ -#include - #include #include +#include "cli_parser.hh" +#include "report_handler.hh" #include "sc_target.hh" #include "sim_control.hh" #include "stats.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 sim_control("gem5", argc, argv); + Gem5SystemC::Gem5SimControl simControl("gem5", + parser.getConfigFile(), + parser.getSimulationEnd(), + parser.getDebugFlags()); Target *memory; - filename = "m5out/stats-systemc.txt"; + unsigned long long int memorySize = 512*1024*1024ULL; tlm::tlm_initiator_socket <> *mem_port = dynamic_cast *>( @@ -93,11 +75,10 @@ sc_main(int argc, char **argv) if (mem_port) { SC_REPORT_INFO("sc_main", "Port Found"); - unsigned long long int size = 512*1024*1024ULL; memory = new Target("memory", - sim_control.getDebugFlag(), - size, - sim_control.getOffset()); + parser.getVerboseFlag(), + memorySize, + parser.getMemoryOffset()); memory->socket.bind(*mem_port); } else { @@ -105,6 +86,8 @@ sc_main(int argc, char **argv) std::exit(EXIT_FAILURE); } + SC_REPORT_INFO("sc_main", "Start of Simulation"); + sc_core::sc_start(); SC_REPORT_INFO("sc_main", "End of Simulation"); -- cgit v1.2.3