diff --git a/.pydevproject b/.pydevproject index 9708187..a16af72 100644 --- a/.pydevproject +++ b/.pydevproject @@ -1,10 +1,14 @@ + - Default + pysysc-env + python interpreter + 3.6 - + + diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index b60cdb3..1acfabe 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -1,6 +1,5 @@ set(LIB_SOURCES initiator.cpp - logging.cpp target.cpp clkgen.cpp resetgen.cpp diff --git a/components/initiator.cpp b/components/initiator.cpp index a13c127..c246c0e 100644 --- a/components/initiator.cpp +++ b/components/initiator.cpp @@ -55,7 +55,7 @@ void Initiator::thread_process() { wait( dmi_data.get_write_latency() ); } - SCCINFO() << "DMI = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCDEBUG() << "DMI = { " << (cmd ? 'W' : 'R') << ", " << hex << i << " } , data = " << hex << data << " at time " << sc_time_stamp(); } else @@ -101,7 +101,7 @@ void Initiator::thread_process() { dmi_ptr_valid = socket->get_direct_mem_ptr( *trans, dmi_data ); } - SCCINFO() << "trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCDEBUG() << "trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i << " } , data = " << hex << data << " at time " << sc_time_stamp(); } } @@ -119,7 +119,7 @@ void Initiator::thread_process() { for (unsigned int i = 0; i < n_bytes; i += 4) { - SCCINFO() << "mem[" << (A + i) << "] = " + SCCTRACE() << "mem[" << (A + i) << "] = " << *(reinterpret_cast( &data[i] )); } @@ -131,7 +131,7 @@ void Initiator::thread_process() { for (unsigned int i = 0; i < n_bytes; i += 4) { - SCCINFO() << "mem[" << (A + i) << "] = " + SCCTRACE() << "mem[" << (A + i) << "] = " << *(reinterpret_cast( &data[i] )); } } diff --git a/components/logging.cpp b/components/logging.cpp deleted file mode 100644 index 76ca550..0000000 --- a/components/logging.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * logging.cpp - * - * Created on: 24.12.2018 - * Author: eyck - */ - - -#include -#include -#include -#include -#include -#include "logging_.h" - -using namespace sc_core; - -enum log_level {NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE}; - -namespace { - -static std::deque msg_buf; - -inline log_level verbosity2log(int verb) { - if (verb >= sc_core::SC_FULL) return TRACE; - if (verb >= sc_core::SC_HIGH) return DEBUG; - return INFO; -} - -std::string time2string(const sc_core::sc_time &t) { - const std::array time_units{"fs", "ps", "ns", "us", "ms", "s "}; - const std::array multiplier{1ULL, - 1000ULL, - 1000ULL * 1000, - 1000ULL * 1000 * 1000, - 1000ULL * 1000 * 1000 * 1000, - 1000ULL * 1000 * 1000 * 1000 * 1000}; - std::ostringstream oss; - const sc_core::sc_time_tuple tt{t}; - const auto val = tt.value(); - if (!val) { - oss << "0 s"; - } else { - const unsigned scale = tt.unit(); - const auto fs_val = val * multiplier[scale]; - for (int j = multiplier.size() - 1; j >= scale; --j) { - if (fs_val > multiplier[j]) { - const auto i = val / multiplier[j - scale]; - const auto f = val % multiplier[j - scale]; - oss << i << '.' << std::setw(3 * (j - scale)) << std::setfill('0') << std::left << f << ' ' - << time_units[j]; - break; - } - } - } - return oss.str(); -} - -const std::string compose_message(const sc_report &rep) { - std::stringstream os; - os << "[" << std::setw(20) << time2string(sc_core::sc_time_stamp()) << "] "; - if (rep.get_id() >= 0) - os << "(" - << "IWEF"[rep.get_severity()] << rep.get_id() << ") "; - os << rep.get_msg_type(); - if (*rep.get_msg()) os << ": " << rep.get_msg(); - if (rep.get_severity() > SC_INFO) { - std::array line_number_str; - os << " [FILE:" << rep.get_file_name() << ":" << rep.get_line_number() << "]"; - sc_simcontext *simc = sc_get_curr_simcontext(); - if (simc && sc_is_running()) { - const char *proc_name = rep.get_process_name(); - if (proc_name) os << "[PROCESS:" << proc_name << "]"; - } - } - return os.str(); -} - -void report_handler(const sc_report &rep, const sc_actions &actions) { - std::array map = {{INFO, WARNING, ERROR, FATAL}}; - if (actions & SC_DISPLAY) { - auto level = rep.get_severity() > sc_core::SC_INFO ? map[rep.get_severity()] : verbosity2log(rep.get_verbosity()); - msg_buf.push_back(compose_message(rep)); - } - if (actions & SC_STOP) sc_stop(); - if (actions & SC_ABORT) abort(); - if (actions & SC_THROW) throw rep; -} -} - -bool has_output(){ - return !msg_buf.empty(); -} - -std::string get_output(){ - std::string ret = msg_buf.front(); - msg_buf.pop_front(); - return ret; -} - -void init_logging(unsigned level) { - const std::array verbosity = {SC_NONE, // Logging::NONE - SC_LOW, // Logging::FATAL - SC_LOW, // Logging::ERROR - SC_LOW, // Logging::WARNING - SC_MEDIUM, // Logging::INFO - SC_HIGH, // logging::DEBUG - SC_FULL, // logging::TRACE - SC_DEBUG}; // logging::TRACE+1 - sc_report_handler::set_verbosity_level(verbosity[level]); - sc_report_handler::set_handler(report_handler); -} - - - diff --git a/components/logging_.h b/components/logging_.h deleted file mode 100644 index 20defd8..0000000 --- a/components/logging_.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * logging.h - * - * Created on: 24.12.2018 - * Author: eyck - */ - -#ifndef LOGGING_H_ -#define LOGGING_H_ - -#include -#include -#include - -bool has_output(); -std::string get_output(); -void init_logging(unsigned level); - -class Log { -public: - Log(const char* file, int line):messageLevel(sc_core::SC_INFO), file(file), line(line){}; - Log(const Log&) = delete; - Log& operator =(const Log&) = delete; - virtual ~Log(){ - ::sc_core::sc_report_handler::report(messageLevel, "", os.str().c_str(), file, line ); - } - std::ostringstream& Get(sc_core::sc_severity level = sc_core::SC_INFO){ - messageLevel = level; - return os; - } -protected: - std::ostringstream os; - sc_core::sc_severity messageLevel; - const char* file; - int line; -}; - -#define LOG(level) Log(__FILE__, __LINE__).Get(level) -#define LOG_INFO Log(__FILE__, __LINE__).Get(sc_core::SC_INFO) -#define LOG_WARN Log(__FILE__, __LINE__).Get(sc_core::SC_WARNING) -#define LOG_ERR Log(__FILE__, __LINE__).Get(sc_core::SC_ERROR) -#endif /* LOGGING_H_ */ diff --git a/router_example.py b/router_example.py index 1005e37..4e139cf 100644 --- a/router_example.py +++ b/router_example.py @@ -24,7 +24,6 @@ pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponen ############################################################################### cpp.scc.init_logging(cpp.scc.log.INFO, 24, False); cpp.sc_core.sc_report_handler.set_actions(cpp.sc_core.SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, cpp.sc_core.SC_DO_NOTHING); -cpp.scc.init_cci("GlobalBroker") ############################################################################### # instantiate ###############################################################################