develop #2
|
@ -1,10 +1,14 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||||
|
|
||||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">pysysc-env</pydev_property>
|
||||||
|
|
||||||
|
|
||||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||||
|
|
||||||
|
|
||||||
<pydev_property name="org.python.pydev.PYTHON_ADDITIONAL_GRAMMAR_VALIDATION">3.6</pydev_property>
|
<pydev_property name="org.python.pydev.PYTHON_ADDITIONAL_GRAMMAR_VALIDATION">3.6</pydev_property>
|
||||||
|
|
||||||
|
|
||||||
</pydev_project>
|
</pydev_project>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
set(LIB_SOURCES
|
set(LIB_SOURCES
|
||||||
initiator.cpp
|
initiator.cpp
|
||||||
logging.cpp
|
|
||||||
target.cpp
|
target.cpp
|
||||||
clkgen.cpp
|
clkgen.cpp
|
||||||
resetgen.cpp
|
resetgen.cpp
|
||||||
|
|
|
@ -55,7 +55,7 @@ void Initiator::thread_process() {
|
||||||
wait( dmi_data.get_write_latency() );
|
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();
|
<< " } , data = " << hex << data << " at time " << sc_time_stamp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -101,7 +101,7 @@ void Initiator::thread_process() {
|
||||||
dmi_ptr_valid = socket->get_direct_mem_ptr( *trans, dmi_data );
|
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();
|
<< " } , 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)
|
for (unsigned int i = 0; i < n_bytes; i += 4)
|
||||||
{
|
{
|
||||||
SCCINFO() << "mem[" << (A + i) << "] = "
|
SCCTRACE() << "mem[" << (A + i) << "] = "
|
||||||
<< *(reinterpret_cast<unsigned int*>( &data[i] ));
|
<< *(reinterpret_cast<unsigned int*>( &data[i] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ void Initiator::thread_process() {
|
||||||
|
|
||||||
for (unsigned int i = 0; i < n_bytes; i += 4)
|
for (unsigned int i = 0; i < n_bytes; i += 4)
|
||||||
{
|
{
|
||||||
SCCINFO() << "mem[" << (A + i) << "] = "
|
SCCTRACE() << "mem[" << (A + i) << "] = "
|
||||||
<< *(reinterpret_cast<unsigned int*>( &data[i] ));
|
<< *(reinterpret_cast<unsigned int*>( &data[i] ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
/*
|
|
||||||
* logging.cpp
|
|
||||||
*
|
|
||||||
* Created on: 24.12.2018
|
|
||||||
* Author: eyck
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <systemc>
|
|
||||||
#include <deque>
|
|
||||||
#include <array>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include "logging_.h"
|
|
||||||
|
|
||||||
using namespace sc_core;
|
|
||||||
|
|
||||||
enum log_level {NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE};
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
static std::deque<std::string> 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<const char *, 6> time_units{"fs", "ps", "ns", "us", "ms", "s "};
|
|
||||||
const std::array<uint64_t, 6> 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<char, 16> 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<const log_level, 4> 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<int, 8> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* logging.h
|
|
||||||
*
|
|
||||||
* Created on: 24.12.2018
|
|
||||||
* Author: eyck
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LOGGING_H_
|
|
||||||
#define LOGGING_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <systemc.h>
|
|
||||||
|
|
||||||
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_ */
|
|
|
@ -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.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.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
|
# instantiate
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
Loading…
Reference in New Issue