summaryrefslogtreecommitdiff
path: root/util/tlm/examples/slave_port/main.cc
diff options
context:
space:
mode:
authorChristian Menard <Christian.Menard@tu-dresden.de>2017-02-09 19:15:38 -0500
committerChristian Menard <Christian.Menard@tu-dresden.de>2017-02-09 19:15:38 -0500
commitccd9210e1a1bdce828a13a4ffdf84548ffe61592 (patch)
tree0965a2bb032668a53bdb2d93ec215d808e934a6a /util/tlm/examples/slave_port/main.cc
parentd2b19d2732e99b53a31bb967ffccbd44d6619fa3 (diff)
downloadgem5-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/slave_port/main.cc')
-rw-r--r--util/tlm/examples/slave_port/main.cc47
1 files changed, 15 insertions, 32 deletions
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 <tlm_utils/simple_target_socket.h>
-
#include <systemc>
#include <tlm>
+#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<tlm::tlm_initiator_socket<> *>(
@@ -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");