diff --git a/platform/src/CLIParser.cpp b/platform/src/CLIParser.cpp index 4508c0f..ed72201 100644 --- a/platform/src/CLIParser.cpp +++ b/platform/src/CLIParser.cpp @@ -88,23 +88,27 @@ CLIParser::CLIParser(int argc, char *argv[]) auto log_file_name = vm_["log-file"].as(); scc::init_logging(scc::LogConfig() .logFileName(log_file_name) - .logLevel(static_cast(dbg_level)) + .logLevel(dbg_level) .logFilterRegex(log_regex) .coloredOutput(colored_output) ); } else { scc::init_logging(scc::LogConfig() - .logLevel(static_cast(dbg_level)) + .logLevel(dbg_level) .logFilterRegex(log_regex) .coloredOutput(colored_output) ); } + LOGGER(DEFAULT)::reporting_level()=static_cast(dbg_level); + LOGGER(DEFAULT)::print_time()=false; + LOGGER(DEFAULT)::print_severity()=false; + LOG_OUTPUT(DEFAULT)::ostream() = &std::cout; } void CLIParser::build() { // clang-format off desc.add_options() - ("help,h", "Print help message") + ("help,h", "Print help message") ("verbose,v", po::value()->implicit_value(3), "Sets logging verbosity") ("Verbose,V", po::value()->default_value(logging::INFO), "Debug output level as with --verbose but print non-colored") ("debug-level,D", po::value(), "Debug output level (textual) as with --verbose") @@ -113,13 +117,15 @@ void CLIParser::build() { ("disass,d", po::value()->implicit_value(""), "Enables disassembly") ("elf,l", po::value(), "ELF file to load") ("gdb-port,g", po::value()->default_value(0), "enable gdb server and specify port to use") - ("ir-dump", "dump the intermediate representation") + ("ir-dump", "dump the intermediate representation") ("quantum", po::value(), "SystemC quantum time in ns") ("reset,r", po::value(), "reset address") ("trace-level,t", po::value()->default_value(0), "enable tracing, or combination of 1=signals and 2=TX text, 4=TX compressed text, 6=TX in SQLite") ("trace-default-on", "enables tracing for all unspecified modules") ("trace-file", po::value()->default_value("system"), "set th ename of the trace file") ("max_time,m", po::value(), "maximum time to run") + ("backend", po::value()->default_value("tcc"), "ISS engine to use") + ("heart-beat,b", "Enable heartbeat printing") ("config-file,c", po::value()->default_value(""), "read configuration from file") ("dump-config,dc", po::value()->default_value(""), "dump configuration to file file"); // clang-format on diff --git a/platform/src/sc_main.cpp b/platform/src/sc_main.cpp index 600be7f..6e63a7e 100644 --- a/platform/src/sc_main.cpp +++ b/platform/src/sc_main.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include +using namespace sc_core; using namespace sysc; namespace po = boost::program_options; @@ -67,6 +69,8 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // CLI argument parsing & logging setup /////////////////////////////////////////////////////////////////////////// + scc::stream_redirection cout_redir(std::cout, scc::log::INFO); + scc::stream_redirection cerr_redir(std::cerr, scc::log::ERROR); CLIParser parser(argc, argv); if (!parser.is_valid()) return ERROR_IN_COMMAND_LINE; /////////////////////////////////////////////////////////////////////////// @@ -90,6 +94,7 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // instantiate top level /////////////////////////////////////////////////////////////////////////// + auto estimator = scc::make_unique(parser.is_set("heart-beat") ? 10_us : SC_ZERO_TIME); auto i_system = scc::make_unique("i_system"); /////////////////////////////////////////////////////////////////////////// // add non-implemented 'enableTracing' properties @@ -106,6 +111,7 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // overwrite config with command line settings /////////////////////////////////////////////////////////////////////////// + cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.backend", parser.get("backend")); cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.gdb_server_port", parser.get("gdb-port")); cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.dump_ir", parser.is_set("dump-ir")); if (parser.is_set("elf")) @@ -116,7 +122,7 @@ int sc_main(int argc, char *argv[]) { cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", args[0]); } if (parser.is_set("quantum")) - tlm::tlm_global_quantum::instance().set(sc_core::sc_time(parser.get("quantum"), sc_core::SC_NS)); + tlm::tlm_global_quantum::instance().set(sc_time(parser.get("quantum"), SC_NS)); if (parser.is_set("reset")) { auto str = parser.get("reset"); uint64_t start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); @@ -137,12 +143,22 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// try { if (parser.is_set("max_time")) { - sc_core::sc_start(scc::parse_from_string(parser.get("max_time"))); + sc_start(scc::parse_from_string(parser.get("max_time"))); } else - sc_core::sc_start(); - if (!sc_core::sc_end_of_simulation_invoked()) sc_core::sc_stop(); - } catch (sc_core::sc_report &rep) { - sc_core::sc_report_handler::get_handler()(rep, sc_core::SC_DISPLAY | sc_core::SC_STOP); + sc_start(); + } catch(sc_report& e) { + SCCERR() << "Caught sc_report exception during simulation: " << e.what() << ":" << e.get_msg(); + } catch(std::exception& e) { + SCCERR() << "Caught exception during simulation: " << e.what(); + } catch(...) { + SCCERR() << "Caught unspecified exception during simulation"; } - return 0; + if(sc_is_running()) { + SCCERR() << "Simulation timeout!"; // calls sc_stop + } + auto errcnt = sc_report_handler::get_count(SC_ERROR); + auto warncnt = sc_report_handler::get_count(SC_WARNING); + SCCINFO() << "Finished, there were " << errcnt << " error" << (errcnt == 1 ? "" : "s") << " and " << warncnt << " warning" + << (warncnt == 1 ? "" : "s"); + return errcnt + warncnt; } diff --git a/riscv b/riscv index edeff7a..71b9768 160000 --- a/riscv +++ b/riscv @@ -1 +1 @@ -Subproject commit edeff7add807ab0e524b5d05b16defe58be2a867 +Subproject commit 71b976811b43557fa0610aef01989d54df841a2c diff --git a/scc b/scc index 0145853..529cb29 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 01458535fa10e3bd5794d50df82ce94f214bfbe1 +Subproject commit 529cb29a483e00bc2bfc1fba25dbbf595b077235