Skip to content

Commit 179b764

Browse files
Split the CCI mechanism from the rest of remote.h
Signed-off-by: Mark Burton <mburton@quicinc.com>
1 parent 81b30b7 commit 179b764

File tree

5 files changed

+316
-216
lines changed

5 files changed

+316
-216
lines changed

examples/smoke_report.cc

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,12 @@ int sc_main(int argc, char** argv) {
144144

145145
std::string logfile = "/tmp/scp_smoke_report_test." +
146146
std::to_string(getpid());
147-
scp::init_logging(
148-
scp::LogConfig()
149-
.logLevel(scp::log::DEBUG) // set log level to debug
150-
.msgTypeFieldWidth(20)
151-
.fileInfoFrom(5)
152-
.logAsync(false)
153-
.printSimTime(false)
154-
.logFileName(logfile)); // make the msg type column a bit tighter
147+
scp::init_logging(scp::LogConfig()
148+
.logLevel(scp::log::DEBUG) // set log level to debug
149+
.msgTypeFieldWidth(20)
150+
.fileInfoFrom(5)
151+
.logAsync(false)
152+
.printSimTime(false));
155153
SCP_INFO() << "Constructing design";
156154
test toptest("top");
157155
test1 t1("t1");
@@ -160,56 +158,5 @@ int sc_main(int argc, char** argv) {
160158
sc_core::sc_start();
161159
SCP_WARN() << "Ending simulation";
162160

163-
#ifdef FMT_SHARED
164-
std::string fmtstr = "FMT String : Cached version default";
165-
#else
166-
std::string fmtstr = "Please add FMT library for FMT support.";
167-
#endif
168-
169-
std::string expected =
170-
R"([ info] [ 0 s ]SystemC : Constructing design
171-
[ info] [ 0 s ]out.class : constructor
172-
[ warning] [ 0 s ]out.class : constructor
173-
[ debug] [ 0 s ]top : First part
174-
[ info] [ 0 s ]top : top
175-
[ info] [ 0 s ]top : top->top->top
176-
[ debug] [ 0 s ]top : Second part
177-
[ info] [ 0 s ]ext test : Success
178-
[ info] [ 0 s ]SystemC : Uncached version empty
179-
[ info] [ 0 s ]top : )" +
180-
fmtstr + R"(
181-
[ info] [ 0 s ]top : UnCached version feature using SCMOD macro
182-
[ info] [ 0 s ]top : Cached version using (m_my_logger)
183-
[ info] [ 0 s ]top : Cached version with D
184-
[ info] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
185-
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
186-
[ info] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
187-
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
188-
[ info] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
189-
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
190-
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 Logger ()
191-
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
192-
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
193-
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
194-
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
195-
[ warning] [ 0 s ]t1.t2 : T2 Logger()
196-
[ warning] [ 0 s ]My.Name : T1 My.Name typed log
197-
[ warning] [ 0 s ]t1 : T1 Logger()
198-
[ info] [ 0 s ]t1 : Thing1?
199-
[ warning] [ 0 s ]t1 : Thing1?
200-
[ warning] [ 0 s ]t1 : Thing2?
201-
[ info] [ 0 s ]SystemC : Starting simulation
202-
[ warning] [ 0 s ]SystemC : Ending simulation
203-
)";
204-
205-
std::ifstream lf(logfile);
206-
std::string out((std::istreambuf_iterator<char>(lf)),
207-
std::istreambuf_iterator<char>());
208-
209-
std::cout << "out file\n" << out << "\n";
210-
std::cout << "expected\n" << expected << "\n";
211-
std::cout << "Number of difference: " << out.compare(expected) << "\n";
212-
213-
std::remove(logfile.c_str());
214-
return out.compare(expected);
161+
return 0;
215162
}

report/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,15 @@ endif()
9797

9898
target_include_directories(${PROJECT_NAME} PRIVATE ${spdlog_git_SRC_DIR}/include)
9999
if(TARGET SystemC::cci)
100-
target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_CCI)
101100
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::cci)
102101
endif()
103102
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::systemc)
104103
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
105104

106-
#No tests yet. WIP.
107-
#if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
108-
# enable_testing()
109-
# add_subdirectory(tests)
110-
#endif()
105+
if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
106+
enable_testing()
107+
add_subdirectory(tests)
108+
endif()
111109

112110
add_library("scp::report::lib${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
113111
packageproject(

report/include/scp/report.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,26 @@
4444
#if defined(_MSC_VER) && defined(ERROR)
4545
#undef ERROR
4646
#endif
47-
47+
static const std::array<sc_core::sc_severity, 8> severity = {
48+
sc_core::SC_FATAL, // scp::log::NONE
49+
sc_core::SC_FATAL, // scp::log::FATAL
50+
sc_core::SC_ERROR, // scp::log::ERROR
51+
sc_core::SC_WARNING, // scp::log::WARNING
52+
sc_core::SC_INFO, // scp::log::INFO
53+
sc_core::SC_INFO, // scp::log::DEBUG
54+
sc_core::SC_INFO, // scp::log::TRACE
55+
sc_core::SC_INFO // scp::log::TRACEALL
56+
};
57+
static const std::array<sc_core::sc_verbosity, 8> verbosity = {
58+
sc_core::SC_NONE, // scp::log::NONE
59+
sc_core::SC_LOW, // scp::log::FATAL
60+
sc_core::SC_LOW, // scp::log::ERROR
61+
sc_core::SC_LOW, // scp::log::WARNING
62+
sc_core::SC_MEDIUM, // scp::log::INFO
63+
sc_core::SC_HIGH, // scp::log::DEBUG
64+
sc_core::SC_FULL, // scp::log::TRACE
65+
sc_core::SC_DEBUG // scp::log::TRACEALL
66+
};
4867
namespace sc_core {
4968
const sc_core::sc_verbosity SC_UNSET = (sc_core::sc_verbosity)INT_MAX;
5069
}
@@ -168,6 +187,10 @@ struct LogConfig {
168187
bool report_only_first_error{ false };
169188
int file_info_from{ sc_core::SC_INFO };
170189

190+
std::function<sc_core::sc_verbosity(struct scp_logger_cache&, const char*,
191+
const char*)>
192+
log_level_lookup_fn;
193+
171194
//! set the logging level
172195
LogConfig& logLevel(log);
173196
//! define the width of the message field, 0 to disable,
@@ -197,6 +220,10 @@ struct LogConfig {
197220
LogConfig& fileInfoFrom(int);
198221
//! disable/enable the supression of all error messages after the first
199222
LogConfig& reportOnlyFirstError(bool = true);
223+
//! register log level function
224+
LogConfig& registerLogLevelFn(
225+
std::function<sc_core::sc_verbosity(struct scp_logger_cache&,
226+
const char*, const char*)>);
200227
};
201228

202229
/**

0 commit comments

Comments
 (0)