Skip to content

Commit

Permalink
Split the CCI mechanism from the rest of remote.h
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Burton <[email protected]>
  • Loading branch information
markfoodyburton committed Mar 21, 2024
1 parent 81b30b7 commit 179b764
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 216 deletions.
67 changes: 7 additions & 60 deletions examples/smoke_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ int sc_main(int argc, char** argv) {

std::string logfile = "/tmp/scp_smoke_report_test." +
std::to_string(getpid());
scp::init_logging(
scp::LogConfig()
.logLevel(scp::log::DEBUG) // set log level to debug
.msgTypeFieldWidth(20)
.fileInfoFrom(5)
.logAsync(false)
.printSimTime(false)
.logFileName(logfile)); // make the msg type column a bit tighter
scp::init_logging(scp::LogConfig()
.logLevel(scp::log::DEBUG) // set log level to debug
.msgTypeFieldWidth(20)
.fileInfoFrom(5)
.logAsync(false)
.printSimTime(false));
SCP_INFO() << "Constructing design";
test toptest("top");
test1 t1("t1");
Expand All @@ -160,56 +158,5 @@ int sc_main(int argc, char** argv) {
sc_core::sc_start();
SCP_WARN() << "Ending simulation";

#ifdef FMT_SHARED
std::string fmtstr = "FMT String : Cached version default";
#else
std::string fmtstr = "Please add FMT library for FMT support.";
#endif

std::string expected =
R"([ info] [ 0 s ]SystemC : Constructing design
[ info] [ 0 s ]out.class : constructor
[ warning] [ 0 s ]out.class : constructor
[ debug] [ 0 s ]top : First part
[ info] [ 0 s ]top : top
[ info] [ 0 s ]top : top->top->top
[ debug] [ 0 s ]top : Second part
[ info] [ 0 s ]ext test : Success
[ info] [ 0 s ]SystemC : Uncached version empty
[ info] [ 0 s ]top : )" +
fmtstr + R"(
[ info] [ 0 s ]top : UnCached version feature using SCMOD macro
[ info] [ 0 s ]top : Cached version using (m_my_logger)
[ info] [ 0 s ]top : Cached version with D
[ info] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
[ info] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
[ info] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 Logger ()
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
[ warning] [ 0 s ]t1.t2 : T2 Logger()
[ warning] [ 0 s ]My.Name : T1 My.Name typed log
[ warning] [ 0 s ]t1 : T1 Logger()
[ info] [ 0 s ]t1 : Thing1?
[ warning] [ 0 s ]t1 : Thing1?
[ warning] [ 0 s ]t1 : Thing2?
[ info] [ 0 s ]SystemC : Starting simulation
[ warning] [ 0 s ]SystemC : Ending simulation
)";

std::ifstream lf(logfile);
std::string out((std::istreambuf_iterator<char>(lf)),
std::istreambuf_iterator<char>());

std::cout << "out file\n" << out << "\n";
std::cout << "expected\n" << expected << "\n";
std::cout << "Number of difference: " << out.compare(expected) << "\n";

std::remove(logfile.c_str());
return out.compare(expected);
return 0;
}
10 changes: 4 additions & 6 deletions report/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ endif()

target_include_directories(${PROJECT_NAME} PRIVATE ${spdlog_git_SRC_DIR}/include)
if(TARGET SystemC::cci)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_CCI)
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::cci)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::systemc)
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)

#No tests yet. WIP.
#if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
# enable_testing()
# add_subdirectory(tests)
#endif()
if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
enable_testing()
add_subdirectory(tests)
endif()

add_library("scp::report::lib${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
packageproject(
Expand Down
29 changes: 28 additions & 1 deletion report/include/scp/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,26 @@
#if defined(_MSC_VER) && defined(ERROR)
#undef ERROR
#endif

static const std::array<sc_core::sc_severity, 8> severity = {
sc_core::SC_FATAL, // scp::log::NONE
sc_core::SC_FATAL, // scp::log::FATAL
sc_core::SC_ERROR, // scp::log::ERROR
sc_core::SC_WARNING, // scp::log::WARNING
sc_core::SC_INFO, // scp::log::INFO
sc_core::SC_INFO, // scp::log::DEBUG
sc_core::SC_INFO, // scp::log::TRACE
sc_core::SC_INFO // scp::log::TRACEALL
};
static const std::array<sc_core::sc_verbosity, 8> verbosity = {
sc_core::SC_NONE, // scp::log::NONE
sc_core::SC_LOW, // scp::log::FATAL
sc_core::SC_LOW, // scp::log::ERROR
sc_core::SC_LOW, // scp::log::WARNING
sc_core::SC_MEDIUM, // scp::log::INFO
sc_core::SC_HIGH, // scp::log::DEBUG
sc_core::SC_FULL, // scp::log::TRACE
sc_core::SC_DEBUG // scp::log::TRACEALL
};
namespace sc_core {
const sc_core::sc_verbosity SC_UNSET = (sc_core::sc_verbosity)INT_MAX;
}
Expand Down Expand Up @@ -168,6 +187,10 @@ struct LogConfig {
bool report_only_first_error{ false };
int file_info_from{ sc_core::SC_INFO };

std::function<sc_core::sc_verbosity(struct scp_logger_cache&, const char*,
const char*)>
log_level_lookup_fn;

//! set the logging level
LogConfig& logLevel(log);
//! define the width of the message field, 0 to disable,
Expand Down Expand Up @@ -197,6 +220,10 @@ struct LogConfig {
LogConfig& fileInfoFrom(int);
//! disable/enable the supression of all error messages after the first
LogConfig& reportOnlyFirstError(bool = true);
//! register log level function
LogConfig& registerLogLevelFn(
std::function<sc_core::sc_verbosity(struct scp_logger_cache&,
const char*, const char*)>);
};

/**
Expand Down
Loading

0 comments on commit 179b764

Please sign in to comment.