Skip to content

Commit 62601be

Browse files
update dependencies and cleanup
Signed-off-by: Mark Burton <[email protected]>
1 parent 8c0d292 commit 62601be

File tree

18 files changed

+598
-499
lines changed

18 files changed

+598
-499
lines changed

.clang-format

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Language: Cpp
33
BasedOnStyle: Google
44

5-
ColumnLimit: 79
5+
ColumnLimit: 120
66
UseTab: Never
77
IndentWidth: 4
88
IndentCaseLabels: false
@@ -17,19 +17,23 @@ AlignConsecutiveMacros: true
1717
AlignConsecutiveAssignments: false
1818

1919
AllowAllArgumentsOnNextLine: false
20-
AllowShortFunctionsOnASingleLine: InlineOnly
21-
AllowShortIfStatementsOnASingleLine: Never
22-
AllowShortLoopsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: true
21+
AllowShortIfStatementsOnASingleLine: WithoutElse
22+
AllowShortLoopsOnASingleLine: true
23+
AllowShortLambdasOnASingleLine: true
2324

24-
BreakConstructorInitializers: AfterColon
25+
BreakConstructorInitializers: BeforeComma
2526
BreakBeforeBinaryOperators: None
2627
BreakStringLiterals: true
2728
BreakBeforeBraces: Custom
2829
BraceWrapping:
2930
AfterClass: true
31+
AfterFunction: true
32+
# PackConstructorInitializers: Never # When we have clang14
3033

3134
SpaceBeforeCtorInitializerColon: false
3235
SpacesBeforeTrailingComments: 1
36+
AlignTrailingComments: true
3337

3438
SortIncludes: false
3539
SortUsingDeclarations: false

examples/smoke.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ SC_MODULE (test) {
4848
}
4949
};
5050

51-
int sc_main(int argc, char** argv) {
51+
int sc_main(int argc, char** argv)
52+
{
5253
SCP_INFO() << "Constructing design";
5354
test test1("test");
5455
SCP_INFO() << "Starting simulation";

examples/smoke_logger.cc

+20-18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <scp/tlm_extensions/initiator_id.h>
1717
#include <scp/tlm_extensions/path_trace.h>
1818
#include <scp/logger.h>
19+
#include <scp/report_cci_setter.h>
1920

2021
#include <systemc>
2122
#include <tlm>
@@ -48,7 +49,8 @@ SC_MODULE (test3) {
4849
};
4950

5051
SC_MODULE (test2) {
51-
SC_CTOR (test2) : t31("t3_1"), t32("t3_2"), t4("t4") {
52+
SC_CTOR (test2) : t31("t3_1"), t32("t3_2"), t4("t4")
53+
{
5254
SCP_INFO(()) << " T2 Logger()";
5355
SCP_WARN(()) << " T2 Logger()";
5456
}
@@ -58,7 +60,8 @@ SC_MODULE (test2) {
5860
};
5961

6062
SC_MODULE (test1) {
61-
SC_CTOR (test1) : t2("t2") {
63+
SC_CTOR (test1) : t2("t2")
64+
{
6265
SCP_WARN((), "My.Name") << " T1 My.Name typed log";
6366
SCP_INFO(()) << " T1 Logger()";
6467
SCP_WARN(()) << " T1 Logger()";
@@ -81,7 +84,8 @@ class outside_class
8184
SCP_LOGGER("out.class", "thing1");
8285

8386
public:
84-
outside_class() {
87+
outside_class()
88+
{
8589
SCP_INFO(())("constructor");
8690
SCP_WARN(())("constructor");
8791
}
@@ -119,8 +123,7 @@ SC_MODULE (test) {
119123
SCP_INFO() << "Globally cached version empty";
120124
SCP_INFO(())("FMT String : Locally cached version default");
121125
SCP_INFO(SCMOD) << "Globally cached version feature using SCMOD macro";
122-
SCP_INFO((m_my_logger))
123-
<< "Locally cached version using (m_my_logger)";
126+
SCP_INFO((m_my_logger)) << "Locally cached version using (m_my_logger)";
124127
SCP_INFO((D)) << "Locally cached version with D";
125128
}
126129

@@ -130,7 +133,8 @@ SC_MODULE (test) {
130133
SCP_LOGGER((D), "other", "feature.one");
131134
};
132135

133-
int sc_main(int argc, char** argv) {
136+
int sc_main(int argc, char** argv)
137+
{
134138
cci_utils::consuming_broker broker("global_broker");
135139
cci_register_broker(broker);
136140
cci::cci_originator orig("config");
@@ -142,16 +146,15 @@ int sc_main(int argc, char** argv) {
142146
broker.set_preset_cci_value("test4.log_level", cci::cci_value(4), orig);
143147
broker.set_preset_cci_value("thing1.log_level", cci::cci_value(5), orig);
144148

145-
std::string logfile = "/tmp/scp_smoke_report_test." +
146-
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
149+
std::string logfile = "/tmp/scp_smoke_report_test." + std::to_string(getpid());
150+
scp::scp_logger_from_cci cci_logger;
151+
scp::init_logging(scp::LogConfig()
152+
.logLevel(scp::log::DEBUG) // set log level to debug
153+
.msgTypeFieldWidth(20)
154+
.fileInfoFrom(5)
155+
.logAsync(false)
156+
.printSimTime(false)
157+
.logFileName(logfile)); // make the msg type column a bit tighter
155158
SCP_INFO() << "Constructing design";
156159
test toptest("top");
157160
test1 t1("t1");
@@ -203,8 +206,7 @@ int sc_main(int argc, char** argv) {
203206
)";
204207

205208
std::ifstream lf(logfile);
206-
std::string out((std::istreambuf_iterator<char>(lf)),
207-
std::istreambuf_iterator<char>());
209+
std::string out((std::istreambuf_iterator<char>(lf)), std::istreambuf_iterator<char>());
208210

209211
std::cout << "out file\n" << out << "\n";
210212
std::cout << "expected\n" << expected << "\n";

examples/smoke_report.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ SC_MODULE (test3) {
4747
};
4848

4949
SC_MODULE (test2) {
50-
SC_CTOR (test2) : t31("t3_1"), t32("t3_2"), t4("t4") {
50+
SC_CTOR (test2) : t31("t3_1"), t32("t3_2"), t4("t4")
51+
{
5152
SCP_INFO(()) << " T2 Logger()";
5253
SCP_WARN(()) << " T2 Logger()";
5354
}
@@ -57,7 +58,8 @@ SC_MODULE (test2) {
5758
};
5859

5960
SC_MODULE (test1) {
60-
SC_CTOR (test1) : t2("t2") {
61+
SC_CTOR (test1) : t2("t2")
62+
{
6163
SCP_WARN((), "My.Name") << " T1 My.Name typed log";
6264
SCP_INFO(()) << " T1 Logger()";
6365
SCP_WARN(()) << " T1 Logger()";
@@ -80,7 +82,8 @@ class outside_class
8082
SCP_LOGGER("out.class", "thing1");
8183

8284
public:
83-
outside_class() {
85+
outside_class()
86+
{
8487
SCP_INFO(())("constructor");
8588
SCP_WARN(())("constructor");
8689
}
@@ -128,7 +131,8 @@ SC_MODULE (test) {
128131
SCP_LOGGER((D), "other", "feature.one");
129132
};
130133

131-
int sc_main(int argc, char** argv) {
134+
int sc_main(int argc, char** argv)
135+
{
132136
cci_utils::consuming_broker broker("global_broker");
133137
cci_register_broker(broker);
134138
cci::cci_originator orig("config");
@@ -140,8 +144,7 @@ int sc_main(int argc, char** argv) {
140144
broker.set_preset_cci_value("test4.log_level", cci::cci_value(4), orig);
141145
broker.set_preset_cci_value("thing1.log_level", cci::cci_value(5), orig);
142146

143-
std::string logfile = "/tmp/scp_smoke_report_test." +
144-
std::to_string(getpid());
147+
std::string logfile = "/tmp/scp_smoke_report_test." + std::to_string(getpid());
145148
SCP_INFO() << "Constructing design";
146149
test toptest("top");
147150
test1 t1("t1");

report/CMakeLists.txt

+14-17
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ set(GITHUB "https://github.com/" CACHE STRING "github base url")
88
include(FetchContent)
99
include(CTest)
1010

11-
FetchContent_Declare(
12-
cpm-cmake
13-
GIT_REPOSITORY ${GITHUB}cpm-cmake/CPM.cmake.git
14-
GIT_SHALLOW True
15-
GIT_TAG v0.31.1
11+
# download CPM.cmake
12+
file(
13+
DOWNLOAD
14+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.2/CPM.cmake
15+
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
1616
)
17-
18-
FetchContent_MakeAvailable(cpm-cmake)
19-
include(${cpm-cmake_SOURCE_DIR}/cmake/CPM.cmake)
17+
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
2018

2119
cpmaddpackage("${GITHUB}TheLartians/[email protected]")
2220

@@ -60,25 +58,25 @@ if(WITH_FMT)
6058
NAME fmt
6159
GIT_REPOSITORY ${GITHUB}fmtlib/fmt.git
6260
GIT_SHALLOW True
63-
GIT_TAG 9.1.0
61+
GIT_TAG 11.0.2
6462
OPTIONS FMT_INSTALL "" ON
6563
)
6664
endif()
6765

6866
FetchContent_Declare(
6967
spdlog_git
7068
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
71-
GIT_TAG "v1.9.2"
69+
GIT_TAG "v1.15.0"
7270
GIT_SHALLOW ON
7371
)
74-
FetchContent_Populate(spdlog_git)
72+
FetchContent_MakeAvailable(spdlog_git)
7573
FetchContent_GetProperties(
7674
spdlog_git
7775
SOURCE_DIR spdlog_git_SRC_DIR
7876
POPULATED spdlog_git_FOUND
7977
)
8078

81-
add_library(${PROJECT_NAME} src/report.cpp src/logger.cpp)
79+
add_library(${PROJECT_NAME} src/sc_report.cpp src/logger.cpp)
8280
target_include_directories(
8381
${PROJECT_NAME} PUBLIC
8482
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
@@ -92,18 +90,17 @@ endif()
9290
target_include_directories(${PROJECT_NAME} PRIVATE ${spdlog_git_SRC_DIR}/include)
9391

9492
if(TARGET SystemC::cci)
95-
target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_CCI)
9693
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::cci)
9794
endif()
9895

9996
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::systemc)
10097
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
10198

10299
# No tests yet. WIP.
103-
# if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
104-
# enable_testing()
105-
# add_subdirectory(tests)
106-
# endif()
100+
if(BUILD_TESTING AND ("${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}"))
101+
enable_testing()
102+
add_subdirectory(tests)
103+
endif()
107104
add_library("scp::report::lib${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
108105
packageproject(
109106
NAME "${PROJECT_NAME}"

report/include/scp/helpers.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#include <tlm>
2323

2424
namespace scp {
25-
static std::string scp_txn_tostring(tlm::tlm_generic_payload& trans) {
25+
static std::string scp_txn_tostring(tlm::tlm_generic_payload& trans)
26+
{
2627
std::stringstream info;
2728
const char* cmd = "UNKOWN";
2829
switch (trans.get_command()) {
@@ -42,8 +43,7 @@ static std::string scp_txn_tostring(tlm::tlm_generic_payload& trans) {
4243
unsigned char* ptr = trans.get_data_ptr();
4344
info << " data: 0x";
4445
for (int i = trans.get_data_length(); i; i--) {
45-
info << std::setw(2) << std::setfill('0') << std::hex
46-
<< (unsigned int)(ptr[i - 1]);
46+
info << std::setw(2) << std::setfill('0') << std::hex << (unsigned int)(ptr[i - 1]);
4747
}
4848
info << " status: " << trans.get_response_string() << " ";
4949
for (unsigned int i = 0; i < tlm::max_num_extensions(); i++) {

report/include/scp/logger.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ namespace scp {
3434
* @param type_field_width the with of the type field in the output
3535
* @param print_time whether to print the system time stamp
3636
*/
37-
void init_logging(log level = log::WARNING, unsigned type_field_width = 24,
38-
bool print_time = false);
37+
void init_logging(log level = log::WARNING, unsigned type_field_width = 24, bool print_time = false);
3938
/**
4039
* @fn void init_logging(log=log::WARNING, unsigned=24, bool=false)
4140
* @brief initializes the SystemC logging system with a particular logging

report/include/scp/report.h

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1-
/* this is merely a convenience */
1+
/* this is merely a convenience to maintain the old API's */
22

33
#include "scp/sc_report.h"
44
#include "scp/helpers.h"
55
#include "scp/logger.h"
6+
7+
#ifdef FMT_SHARED
8+
#ifndef _FMT_CONVENIENCE_DEFINED
9+
#define _FMT_CONVENIENCE_DEFINED
10+
#include <fmt/format.h>
11+
12+
/* Convenience for common SystemC useage */
13+
// Allows Join to be used on vectors etc.
14+
#include <fmt/ranges.h>
15+
// cover 'std' types
16+
#include <fmt/std.h>
17+
// Make all enum's behave like their underlying types by default
18+
#include <type_traits>
19+
template <typename E>
20+
struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<std::decay_t<E>>, char>> : fmt::formatter<std::string_view> {
21+
auto format(E e, format_context& ctx) const { return formatter<std::string_view, char>::format("Test", ctx); }
22+
};
23+
#endif // _FMT_CONVENIENCE_DEFINED
24+
#endif
25+
26+
#ifdef HAS_CCI
27+
#ifndef _GLOBAL_SCP_LOGGER_FROM_CCI_DEFINED
28+
#define _GLOBAL_SCP_LOGGER_FROM_CCI_DEFINED
29+
#include "scp/report_cci_setter.h"
30+
static scp::scp_logger_from_cci _global_scp_logger_from_cci;
31+
#endif // _GLOBAL_SCP_LOGGER_FROM_CCI_DEFINED
32+
#endif

0 commit comments

Comments
 (0)