main.cc (11818:f12963cb9dc2) | main.cc (11821:39b0a51c9e76) |
---|---|
1/* 2 * Copyright (c) 2015, University of Kaiserslautern 3 * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: --- 29 unchanged lines hidden (view full) --- 38/** 39 * @file 40 * 41 * Example top level file for SystemC-TLM integration with C++-only 42 * instantiation. 43 * 44 */ 45 | 1/* 2 * Copyright (c) 2015, University of Kaiserslautern 3 * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: --- 29 unchanged lines hidden (view full) --- 38/** 39 * @file 40 * 41 * Example top level file for SystemC-TLM integration with C++-only 42 * instantiation. 43 * 44 */ 45 |
46#include <tlm_utils/simple_target_socket.h> 47 | |
48#include <systemc> 49#include <tlm> 50 | 46#include <systemc> 47#include <tlm> 48 |
49#include "cli_parser.hh" 50#include "report_handler.hh" |
|
51#include "sc_target.hh" 52#include "sim_control.hh" 53#include "stats.hh" 54 | 51#include "sc_target.hh" 52#include "sim_control.hh" 53#include "stats.hh" 54 |
55// Defining global string variable decalred in stats.hh 56std::string filename; 57 58void 59reportHandler(const sc_core::sc_report &report, 60 const sc_core::sc_actions &actions) 61{ 62 uint64_t systemc_time = report.get_time().value(); 63 uint64_t gem5_time = curTick(); 64 65 std::cerr << report.get_time(); 66 67 if (gem5_time < systemc_time) { 68 std::cerr << " (<) "; 69 } else if (gem5_time > systemc_time) { 70 std::cerr << " (!) "; 71 } else { 72 std::cerr << " (=) "; 73 } 74 75 std::cerr << ": " << report.get_msg_type() 76 << ' ' << report.get_msg() << '\n'; 77} 78 | |
79int 80sc_main(int argc, char **argv) 81{ | 55int 56sc_main(int argc, char **argv) 57{ |
58 CliParser parser; 59 parser.parse(argc, argv); 60 |
|
82 sc_core::sc_report_handler::set_handler(reportHandler); 83 | 61 sc_core::sc_report_handler::set_handler(reportHandler); 62 |
84 SimControl sim_control("gem5", argc, argv); | 63 Gem5SystemC::Gem5SimControl simControl("gem5", 64 parser.getConfigFile(), 65 parser.getSimulationEnd(), 66 parser.getDebugFlags()); |
85 Target *memory; 86 | 67 Target *memory; 68 |
87 filename = "m5out/stats-systemc.txt"; | 69 unsigned long long int memorySize = 512*1024*1024ULL; |
88 89 tlm::tlm_initiator_socket <> *mem_port = 90 dynamic_cast<tlm::tlm_initiator_socket<> *>( 91 sc_core::sc_find_object("gem5.memory") 92 ); 93 94 if (mem_port) { 95 SC_REPORT_INFO("sc_main", "Port Found"); | 70 71 tlm::tlm_initiator_socket <> *mem_port = 72 dynamic_cast<tlm::tlm_initiator_socket<> *>( 73 sc_core::sc_find_object("gem5.memory") 74 ); 75 76 if (mem_port) { 77 SC_REPORT_INFO("sc_main", "Port Found"); |
96 unsigned long long int size = 512*1024*1024ULL; | |
97 memory = new Target("memory", | 78 memory = new Target("memory", |
98 sim_control.getDebugFlag(), 99 size, 100 sim_control.getOffset()); | 79 parser.getVerboseFlag(), 80 memorySize, 81 parser.getMemoryOffset()); |
101 102 memory->socket.bind(*mem_port); 103 } else { 104 SC_REPORT_FATAL("sc_main", "Port Not Found"); 105 std::exit(EXIT_FAILURE); 106 } 107 | 82 83 memory->socket.bind(*mem_port); 84 } else { 85 SC_REPORT_FATAL("sc_main", "Port Not Found"); 86 std::exit(EXIT_FAILURE); 87 } 88 |
89 SC_REPORT_INFO("sc_main", "Start of Simulation"); 90 |
|
108 sc_core::sc_start(); 109 110 SC_REPORT_INFO("sc_main", "End of Simulation"); 111 112 CxxConfig::statsDump(); 113 114 return EXIT_SUCCESS; 115} | 91 sc_core::sc_start(); 92 93 SC_REPORT_INFO("sc_main", "End of Simulation"); 94 95 CxxConfig::statsDump(); 96 97 return EXIT_SUCCESS; 98} |