-
Notifications
You must be signed in to change notification settings - Fork 16
Mburton/sc log #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
markfoodyburton
wants to merge
17
commits into
accellera-official:main
Choose a base branch
from
markfoodyburton:mburton/sc_log
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mburton/sc log #28
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fe8b52c
factor out report backend implementation into separate header
eyck 07cb8d6
changes messages in smoke_logger
eyck c0cda73
factors logger function into separate source
eyck 4e70605
applies clang-format
eyck b5985c0
Fix for upstream install on mac RPATH issue
markfoodyburton 59f3377
Split the CCI mechanism from the rest of remote.h
markfoodyburton 8a7689f
Maintain #include interface for ease of use
markfoodyburton 8c0d292
Split CCI fixes
markfoodyburton 62601be
update dependencies and cleanup
markfoodyburton fef79a1
Rename SCP_LOGGER to SCP_REPORTER
markfoodyburton 28d29a1
Mark ScLogger destructor as potentially throwing an exception
markfoodyburton 077fe80
Depricate SC_THROW, and mask it out in the ScLogger destructor.
markfoodyburton 319f643
Remove all actions and clean up
markfoodyburton 393fab8
Re-factor to create sc_log separate from SCP
markfoodyburton 6c29456
Align to SystemC/sc_log proposal
markfoodyburton 8cc36a8
Adjust cmake to be cleaner and remove conflict with AMS
markfoodyburton c7d6775
Add an Audio Example
markfoodyburton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/_build/ | ||
/.cproject | ||
/.project | ||
/.venv | ||
/.vscode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,12 @@ set(GITHUB "https://github.com/" CACHE STRING "github base url") | |
include(FetchContent) | ||
include(CTest) | ||
|
||
FetchContent_Declare( | ||
cpm-cmake | ||
GIT_REPOSITORY ${GITHUB}cpm-cmake/CPM.cmake.git | ||
GIT_SHALLOW True | ||
GIT_TAG v0.31.1 | ||
file( | ||
DOWNLOAD | ||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.5/CPM.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake | ||
) | ||
|
||
FetchContent_MakeAvailable(cpm-cmake) | ||
include(${cpm-cmake_SOURCE_DIR}/cmake/CPM.cmake) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake) | ||
|
||
cpmaddpackage("${GITHUB}TheLartians/[email protected]") | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ endmacro() | |
|
||
run_test(smoke) | ||
run_test(smoke_report) | ||
run_test(smoke_logger) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
|
||
ColumnLimit: 120 | ||
UseTab: Never | ||
IndentWidth: 4 | ||
IndentCaseLabels: false | ||
|
||
PointerAlignment: Left | ||
DerivePointerAlignment: false | ||
|
||
AccessModifierOffset: -4 | ||
|
||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveMacros: true | ||
AlignConsecutiveAssignments: false | ||
|
||
AllowAllArgumentsOnNextLine: false | ||
AllowShortFunctionsOnASingleLine: true | ||
AllowShortIfStatementsOnASingleLine: WithoutElse | ||
AllowShortLoopsOnASingleLine: true | ||
AllowShortLambdasOnASingleLine: true | ||
|
||
BreakConstructorInitializers: BeforeComma | ||
BreakBeforeBinaryOperators: None | ||
BreakStringLiterals: true | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterFunction: true | ||
# PackConstructorInitializers: Never # When we have clang14 | ||
|
||
SpaceBeforeCtorInitializerColon: false | ||
SpacesBeforeTrailingComments: 1 | ||
AlignTrailingComments: true | ||
|
||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
|
||
Cpp11BracedListStyle: false | ||
PenaltyBreakAssignment: 2000 | ||
|
||
ForEachMacros: ['SC_MODULE', 'SC_CTOR'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||
project(audioexample VERSION 1.0 LANGUAGES CXX C) | ||
|
||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to build all targets.") | ||
|
||
set(GITHUB "https://github.com/" CACHE STRING "github base url") | ||
|
||
include(FetchContent) | ||
include(CTest) | ||
|
||
# download CPM.cmake | ||
file( | ||
DOWNLOAD | ||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.2/CPM.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake | ||
) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake) | ||
|
||
cpmaddpackage("${GITHUB}TheLartians/[email protected]") | ||
|
||
cpmaddpackage( | ||
NAME SystemCLanguage | ||
GIT_REPOSITORY ${GITHUB}accellera-official/systemc.git | ||
GIT_SHALLOW True | ||
GIT_TAG 3.0.1 | ||
) | ||
|
||
set(SYSTEMC_HOME ${SystemCLanguage_SOURCE_DIR}) | ||
include_directories(${SystemCLanguage_SOURCE_DIR}/src) | ||
include_directories(${SystemCAMS_SOURCE_DIR}/src) | ||
cpmaddpackage( | ||
NAME SystemCAMS | ||
GIT_REPOSITORY ${GITHUB}/Risto97/systemc-ams.git | ||
GIT_SHALLOW True | ||
GIT_TAG master | ||
) | ||
message("including ${SystemCAMS_SOURCE_DIR}/src") | ||
target_include_directories(systemc-ams PRIVATE ${SystemCAMS_SOURCE_DIR}/src) | ||
|
||
|
||
cpmaddpackage( | ||
NAME SystemCCCI | ||
GIT_REPOSITORY ${GITHUB}accellera-official/cci.git | ||
GIT_SHALLOW True | ||
GIT_TAG main | ||
) | ||
|
||
cpmaddpackage( | ||
NAME SCP | ||
GIT_REPOSITORY https://github.com/accellera-official/systemc-common-practices.git | ||
GIT_TAG main | ||
GIT_SHALLOW TRUE | ||
) | ||
|
||
cpmaddpackage( | ||
NAME MidiParser | ||
GIT_REPOSITORY https://github.com/MStefan99/Midi-Parser.git | ||
GIT_TAG master | ||
GIT_SHALLOW TRUE | ||
) | ||
|
||
file(DOWNLOAD | ||
https://www.midiworld.com/midis/other/bach/bwv972.mid | ||
${CMAKE_CURRENT_BINARY_DIR}/bwv972.mid | ||
SHOW_PROGRESS | ||
) | ||
|
||
include_directories(${PORTAUDIO_INCLUDE_DIRS}) | ||
include_directories(include) | ||
add_executable(${PROJECT_NAME} | ||
src/main.cc | ||
) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(PORTAUDIO REQUIRED IMPORTED_TARGET GLOBAL portaudio-2.0) | ||
#include_directories(${PORTAUDIO_INCLUDE_DIRS}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove? |
||
|
||
target_link_libraries(${PROJECT_NAME} PUBLIC SystemC::systemc SystemC::cci systemc-ams scp::reporting PkgConfig::PORTAUDIO libParser) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
/* | ||
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef __ARG_PARSER_H__ | ||
#define __ARG_PARSER_H__ | ||
#include <getopt.h> | ||
#include <systemc> | ||
#include <cci_configuration> | ||
#include <scp/report.h> | ||
|
||
std::pair<std::string, std::string> get_key_val_args(const std::string& arg) | ||
{ | ||
std::stringstream ss(arg); | ||
std::string key, value; | ||
|
||
if (!std::getline(ss, key, '=')) { | ||
SCP_FATAL("Parser") << "parameter name not found!" << std::endl; | ||
} | ||
if (!std::getline(ss, value)) { | ||
SCP_FATAL("Parser") << "parameter value not found!" << std::endl; | ||
} | ||
|
||
SCP_INFO("Parser") << "Setting param " << key << " to value " << value; | ||
|
||
return std::make_pair(key, value); | ||
} | ||
void parseCommandLineWithGetOpt(const int argc, const char* const* argv) | ||
{ | ||
SCP_INFO("Parser") << "Parse command line (" << argc << " arguments)"; | ||
|
||
// getopt permutes argv array, so copy it to argv_cp | ||
std::vector<std::unique_ptr<char[]>> argv_cp; | ||
char* argv_cp_raw[argc]; | ||
for (int i = 0; i < argc; i++) { | ||
size_t len = strlen(argv[i]) + 1; // count \0 | ||
argv_cp.emplace_back(std::make_unique<char[]>(len)); | ||
strcpy(argv_cp[i].get(), argv[i]); | ||
argv_cp_raw[i] = argv_cp[i].get(); | ||
} | ||
|
||
// configure getopt | ||
optind = 0; // reset of getopt | ||
opterr = 0; // avoid error message for not recognized option | ||
|
||
// Don't add 'i' here. It must be specified as a long option. | ||
const char* optstring = "p:"; | ||
|
||
struct option long_options[] = { { "param", required_argument, 0, 'p' }, // --param foo.baa=10 | ||
{ 0, 0, 0, 0 } }; | ||
|
||
while (1) { | ||
int c = getopt_long(argc, argv_cp_raw, optstring, long_options, 0); | ||
if (c == EOF) break; | ||
|
||
switch (c) { | ||
case 'p': // -p and --param | ||
{ | ||
auto param = get_key_val_args(std::string(optarg)); | ||
cci::cci_get_global_broker(cci::cci_originator("ArgumentParser")) | ||
.set_preset_cci_value(param.first, cci::cci_value(cci::cci_value::from_json(param.second))); | ||
break; | ||
} | ||
|
||
default: | ||
/* unrecognized option */ | ||
break; | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be part of CPS base instead of the example |
||
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. | ||
* Author: GreenSocs 2022 | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef ASYNC_EVENT | ||
#define ASYNC_EVENT | ||
|
||
#include <iostream> | ||
#define SC_HAS_SUSPENDING | ||
#define SC_HAS_ASYNC_ATTACH_SUSPENDING | ||
#include <systemc> | ||
#include <tlm> | ||
#include <thread> | ||
#include <mutex> | ||
|
||
namespace gs { | ||
class async_event : public sc_core::sc_prim_channel, public sc_core::sc_event | ||
{ | ||
private: | ||
sc_core::sc_time m_delay; | ||
std::thread::id tid; | ||
std::mutex mutex; // Belt and braces | ||
bool outstanding = false; | ||
enum { none, attach, detach } attach_pending_state = none; | ||
|
||
public: | ||
async_event(bool start_attached = true): outstanding(0) | ||
{ | ||
tid = std::this_thread::get_id(); | ||
enable_attach_suspending(start_attached); | ||
} | ||
|
||
void async_notify() { notify(); } | ||
|
||
void notify() | ||
{ | ||
if (tid == std::this_thread::get_id()) { | ||
sc_core::sc_event::notify(); | ||
} else { | ||
notify(sc_core::SC_ZERO_TIME); | ||
} | ||
} | ||
void notify(double d, sc_core::sc_time_unit u) { notify(sc_core::sc_time(d, u)); } | ||
void notify(sc_core::sc_time delay) | ||
{ | ||
if (tid == std::this_thread::get_id()) { | ||
sc_core::sc_event::notify(delay); | ||
} else { | ||
mutex.lock(); | ||
m_delay = delay; | ||
outstanding = true; | ||
mutex.unlock(); | ||
async_request_update(); | ||
#ifndef SC_HAS_SUSPENDING | ||
sc_core::sc_internal_async_wakeup(); | ||
#endif | ||
} | ||
} | ||
|
||
void async_attach_suspending() | ||
{ | ||
#ifndef SC_HAS_ASYNC_ATTACH_SUSPENDING | ||
sc_core::async_attach_suspending(this); | ||
#else | ||
if (tid == std::this_thread::get_id()) { | ||
this->sc_core::sc_prim_channel::async_attach_suspending(); | ||
} else { | ||
mutex.lock(); | ||
attach_pending_state = attach; | ||
mutex.unlock(); | ||
async_request_update(); | ||
} | ||
#endif | ||
} | ||
|
||
void async_detach_suspending() | ||
{ | ||
#ifndef SC_HAS_ASYNC_ATTACH_SUSPENDING | ||
sc_core::async_detach_suspending(this); | ||
#else | ||
if (tid == std::this_thread::get_id()) { | ||
this->sc_core::sc_prim_channel::async_detach_suspending(); | ||
} else { | ||
mutex.lock(); | ||
attach_pending_state = detach; | ||
mutex.unlock(); | ||
async_request_update(); | ||
} | ||
#endif | ||
} | ||
|
||
void enable_attach_suspending(bool e) { e ? this->async_attach_suspending() : this->async_detach_suspending(); } | ||
|
||
private: | ||
void update(void) | ||
{ | ||
mutex.lock(); | ||
// we should be in SystemC thread | ||
if (outstanding) { | ||
sc_event::notify(m_delay); | ||
outstanding = false; | ||
} | ||
switch (attach_pending_state) { | ||
case attach: | ||
this->async_attach_suspending(); | ||
break; | ||
case detach: | ||
this->async_detach_suspending(); | ||
break; | ||
default: | ||
break; | ||
} | ||
attach_pending_state = none; | ||
mutex.unlock(); | ||
} | ||
void start_of_simulation() | ||
{ | ||
// we should be in SystemC thread | ||
if (outstanding) { | ||
request_update(); | ||
} | ||
} | ||
}; | ||
} // namespace gs | ||
|
||
#endif // ASYNC_EVENT |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not force global settings, rather set it for the target.