updates submodule and adds abort handling in sc_main

This commit is contained in:
2025-11-21 18:12:56 +01:00
parent deb17913f6
commit 7cf4857c38
3 changed files with 26 additions and 16 deletions

2
scc

Submodule scc updated: f626f0259f...947064144c

View File

@@ -20,9 +20,10 @@
#include "vp/tb.h" #include "vp/tb.h"
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <csetjmp>
#include <csignal>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream>
#ifdef ERROR #ifdef ERROR
#undef ERROR #undef ERROR
#endif #endif
@@ -31,14 +32,20 @@ const std::string core_path{"tb.top.core_complex"};
using namespace sysc; using namespace sysc;
using namespace sc_core; using namespace sc_core;
namespace po = boost::program_options;
namespace { namespace {
const size_t ERRORR_IN_COMMAND_LINE = 1; const size_t ERRORR_IN_COMMAND_LINE = 1;
const size_t SUCCESS = 0; const size_t SUCCESS = 0;
} // namespace } // namespace
jmp_buf abrt;
void ABRThandler(int sig) { longjmp(abrt, sig); }
int sc_main(int argc, char* argv[]) { int sc_main(int argc, char* argv[]) {
signal(SIGINT, ABRThandler);
signal(SIGABRT, ABRThandler);
signal(SIGSEGV, ABRThandler);
signal(SIGTERM, ABRThandler);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SystemC >=2.2 got picky about multiple drivers so disable check // SystemC >=2.2 got picky about multiple drivers so disable check
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -73,8 +80,7 @@ int sc_main(int argc, char* argv[]) {
if(auto trace_level = parser.get<unsigned>("trace-level")) { if(auto trace_level = parser.get<unsigned>("trace-level")) {
auto file_name = parser.get<std::string>("trace-file"); auto file_name = parser.get<std::string>("trace-file");
auto trace_default_on = parser.is_set("trace-default-on"); auto trace_default_on = parser.is_set("trace-default-on");
if(parser.is_set("trace-default-off")) cfg.set_value("scc_tracer.default_trace_enable", !parser.is_set("trace-default-off"));
cfg.set_value("scc_tracer.default_trace_enable", false);
cfg.set_value("scc_tracer.tx_trace_type", static_cast<unsigned>(scc::tracer::file_type::FTR)); cfg.set_value("scc_tracer.tx_trace_type", static_cast<unsigned>(scc::tracer::file_type::FTR));
cfg.set_value("scc_tracer.sig_trace_type", static_cast<unsigned>(scc::tracer::file_type::FST)); cfg.set_value("scc_tracer.sig_trace_type", static_cast<unsigned>(scc::tracer::file_type::FST));
tracer = scc::make_unique<scc::configurable_tracer>(file_name, static_cast<bool>(trace_level & 0x2), tracer = scc::make_unique<scc::configurable_tracer>(file_name, static_cast<bool>(trace_level & 0x2),
@@ -90,7 +96,7 @@ int sc_main(int argc, char* argv[]) {
if(tracer) if(tracer)
tracer->add_control(); tracer->add_control();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// dump configuration if requested // dump configuration if requested and/or structure
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
if(parser.get<std::string>("dump-config").size() > 0) { if(parser.get<std::string>("dump-config").size() > 0) {
std::ofstream of{parser.get<std::string>("dump-config")}; std::ofstream of{parser.get<std::string>("dump-config")};
@@ -133,15 +139,19 @@ int sc_main(int argc, char* argv[]) {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// run simulation // run simulation
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
try { if(auto res = setjmp(abrt)) {
if(parser.is_set("max_time")) { SCCERR() << "Simulation aborted with signal " << res << "!";
sc_core::sc_start(scc::parse_from_string(parser.get<std::string>("max_time"))); } else {
} else try {
sc_core::sc_start(); if(parser.is_set("max_time")) {
if(sc_core::sc_start_of_simulation_invoked() && !sc_core::sc_end_of_simulation_invoked()) sc_core::sc_start(scc::parse_from_string(parser.get<std::string>("max_time")));
sc_core::sc_stop(); } else
} catch(sc_core::sc_report& rep) { sc_core::sc_start();
sc_core::sc_report_handler::get_handler()(rep, sc_core::SC_DISPLAY | sc_core::SC_STOP); if(sc_core::sc_start_of_simulation_invoked() && !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);
}
} }
return 0; return 0;
} }