Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nents into develop
  • Loading branch information
eyck committed Jul 7, 2022
2 parents 7ac241a + 526f6c6 commit 63bee18
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/common/util/lz4_streambuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
******************************************************************************/

#include "lz4_streambuf.h"
#include <stdexcept>

namespace util {

Expand All @@ -29,7 +30,7 @@ lz4c_steambuf::~lz4c_steambuf() {
void lz4c_steambuf::close() {
if (closed)
return;
sync();
lz4c_steambuf::sync();
auto sz = LZ4F_compressEnd(ctx, dest_buf.data(), dest_buf.capacity(), nullptr);
if (LZ4F_isError(sz) != 0)
throw std::runtime_error(std::string("Failed to finish LZ4 compression: ") + LZ4F_getErrorName(sz));
Expand Down
4 changes: 3 additions & 1 deletion src/sysc/scc/configurer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,9 @@ struct configurer::ConfigHolder {
Document document;
};

configurer::configurer(const std::string& filename)
configurer::configurer(const std::string& filename, unsigned config_phases)
: base_type(sc_core::sc_module_name("configurer"))
, config_phases(config_phases)
#ifdef HAS_CCI
, cci_originator("configurer")
, cci_broker(cci::cci_get_global_broker(cci_originator))
Expand Down Expand Up @@ -421,6 +422,7 @@ void init_cci(std::string name) {
}

void configurer::start_of_simulation() {
if(config_phases & START_OF_SIMULATION) configure();
config_check();
if(dump_file_name.size()) {
std::ofstream of{dump_file_name};
Expand Down
14 changes: 11 additions & 3 deletions src/sysc/scc/configurer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ class configurer : public sc_core::sc_module {
#else
using broker_t = void*;
#endif
enum {
BEFORE_END_OF_ELABORATION=1, END_OF_ELABORATION=2, START_OF_SIMULATION=4
};
/**
* create a configurer using an input file
* @param filename
*/
configurer(const std::string& filename);
configurer(const std::string& filename, unsigned config_phases = BEFORE_END_OF_ELABORATION);

configurer() = delete;

Expand Down Expand Up @@ -138,11 +141,16 @@ class configurer : public sc_core::sc_module {

protected:
bool config_valid{false};
unsigned const config_phases;
std::unique_ptr<ConfigHolder> root;
std::string dump_file_name{""};
void config_check();
void before_end_of_elaboration() override { configure(); }
void end_of_elaboration() override { configure(); }
void before_end_of_elaboration() override {
if(config_phases & BEFORE_END_OF_ELABORATION) configure();
}
void end_of_elaboration() override {
if(config_phases & END_OF_ELABORATION) configure();
}
void start_of_simulation() override;

#ifdef HAS_CCI
Expand Down
1 change: 0 additions & 1 deletion src/sysc/scc/fst_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ template <> void fst_trace_t<sc_dt::sc_fxval_fast, sc_dt::sc_fxval_fast>::record
fstWriterEmitValueChange(m_fst, fst_hndl, &val);
}
template <> void fst_trace_t<sc_dt::sc_fxnum, sc_dt::sc_fxval>::record(void* m_fst) {
auto val = old_val.to_double();
fstWriterEmitValueChange32(m_fst, fst_hndl, 64, *reinterpret_cast<uint64_t*>(&old_val));
}
template <> void fst_trace_t<sc_dt::sc_fxnum_fast, sc_dt::sc_fxval_fast>::record(void* m_fst) {
Expand Down
8 changes: 6 additions & 2 deletions src/sysc/scc/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ auto compose_message(const sc_report& rep, const scc::LogConfig& cfg) -> const s
if(unlikely(rep.get_id() >= 0))
os << "("
<< "IWEF"[rep.get_severity()] << rep.get_id() << ") " << rep.get_msg_type() << ": ";
else if(cfg.msg_type_field_width)
os << util::padded(rep.get_msg_type(), cfg.msg_type_field_width) << ": ";
else if(cfg.msg_type_field_width) {
if(cfg.msg_type_field_width==std::numeric_limits<unsigned>::max())
os << rep.get_msg_type() << ": ";
else
os << util::padded(rep.get_msg_type(), cfg.msg_type_field_width) << ": ";
}
if(*rep.get_msg())
os << rep.get_msg();
if(rep.get_severity() > SC_INFO) {
Expand Down
14 changes: 14 additions & 0 deletions src/sysc/scc/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,33 @@ struct LogConfig {
bool dont_create_broker{false};
bool report_only_first_error{false};

//! set the logging level
LogConfig& logLevel(log);
//! define the width of the message field, 0 to disable, std::numeric_limits<unsigned>::max() for arbitrary width
LogConfig& msgTypeFieldWidth(unsigned);
//! enable/disable printing of system time
LogConfig& printSysTime(bool = true);
//! enable/disable printing of simulation time
LogConfig& printSimTime(bool = true);
//! enable/disable printing delta cycles
LogConfig& printDelta(bool = true);
//! enable/disable printing of severity level
LogConfig& printSeverity(bool = true);
//! enable/disable colored output
LogConfig& coloredOutput(bool = true);
//! set the file name for the log output file
LogConfig& logFileName(std::string&&);
//! set the file name for the log output file
LogConfig& logFileName(const std::string&);
//! set the regular expression to filter the output
LogConfig& logFilterRegex(std::string&&);
//! set the regular expression to filter the output
LogConfig& logFilterRegex(const std::string&);
//! enable/disable asynchronous output (write to file in separate thread
LogConfig& logAsync(bool = true);
//! disable/enable the automatic creation of a CCI broker
LogConfig& dontCreateBroker(bool = true);
//! disable/enable the supression of all error messages after the first error
LogConfig& reportOnlyFirstError(bool = true);
};
/**
Expand Down
26 changes: 25 additions & 1 deletion src/sysc/scc/sc_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@ template <typename T> struct sc_variable : public sc_variable_b {
* @return
*/
bool operator!=(T other) const { return value != other; }
/**
* greater than comparison
* @param other
* @return
*/
bool operator>(T other) const { return value > other; }
/**
* less than comparison
* @param other
* @return
*/
bool operator<(T other) const { return value < other; }
/**
* greater than or equal comparison
* @param other
* @return
*/
bool operator>=(T other) const { return value >= other; }
/**
* less than or equal comparison
* @param other
* @return
*/
bool operator<=(T other) const { return value <= other; }
//! overloaded prefix ++ operator
sc_variable& operator++() {
++value; // increment this object
Expand Down Expand Up @@ -347,7 +371,7 @@ template <typename T> struct sc_variable_vector {
}
}

bool is_valid(size_t idx) const { return values.at(idx) != nullptr; }
bool is_valid(size_t idx) const { return values.size()> idx && values.at(idx) != nullptr; }

sc_variable<T>& operator[](size_t idx) {
auto ret = values.at(idx);
Expand Down
1 change: 1 addition & 0 deletions src/sysc/tlm/scc/pe/parallel_pe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void parallel_pe::transport(tlm::tlm_generic_payload& payload, bool lt_transport
tu.gp = nullptr;
waiting_ids.push_back(id);
wait(tu.evt);
assert(tu.gp);
}
},
sc_core::sc_gen_unique_name("execute"));
Expand Down
2 changes: 1 addition & 1 deletion src/sysc/tlm/scc/tlm_id.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2021, 2020 MINRES Technologies GmbH
* Copyright 2021 - 2022 MINRES Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ add_subdirectory(fst)
project(RapidJSON VERSION "1.1.0" LANGUAGES CXX)
set( ${PROJECT_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/rapidjson-1.1/include)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR}/rapidjson-1.1/include)
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR}/rapidjson-1.1/include)
if(CMAKE_CXX_CPPCHECK)
target_compile_definitions(${PROJECT_NAME} INTERFACE RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN)
endif()

0 comments on commit 63bee18

Please sign in to comment.