diff options
author | Christian Menard <Christian.Menard@tu-dresden.de> | 2017-02-09 19:15:38 -0500 |
---|---|---|
committer | Christian Menard <Christian.Menard@tu-dresden.de> | 2017-02-09 19:15:38 -0500 |
commit | ccd9210e1a1bdce828a13a4ffdf84548ffe61592 (patch) | |
tree | 0965a2bb032668a53bdb2d93ec215d808e934a6a /util/tlm/examples/master_port/main.cc | |
parent | d2b19d2732e99b53a31bb967ffccbd44d6619fa3 (diff) | |
download | gem5-ccd9210e1a1bdce828a13a4ffdf84548ffe61592.tar.xz |
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 <jason@lowepower.com>
Diffstat (limited to 'util/tlm/examples/master_port/main.cc')
-rw-r--r-- | util/tlm/examples/master_port/main.cc | 39 |
1 files changed, 11 insertions, 28 deletions
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 <systemc> #include <tlm> +#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<tlm::tlm_target_socket<>*>( @@ -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 |