Browse Source

Made configurer independend of CCI

master
Eyck Jentzsch 8 months ago
parent
commit
e27a296d3d
4 changed files with 28 additions and 4 deletions
  1. +2
    -2
      CMakeLists.txt
  2. +8
    -0
      incl/scc/configurer.h
  3. +6
    -0
      incl/scc/report.h
  4. +12
    -2
      src/configurer.cpp

+ 2
- 2
CMakeLists.txt View File

@@ -37,6 +37,8 @@ set(LIB_SOURCES
src/perf_estimator.cpp
src/io-redirector.cpp
src/ordered_semaphore.cpp
src/configurer.cpp
src/jsoncpp.cpp
)

if(CCI_FOUND)
@@ -44,8 +46,6 @@ if(CCI_FOUND)
src/tracer_base.cpp
src/tracer.cpp
src/configurable_tracer.cpp
src/configurer.cpp
src/jsoncpp.cpp
src/value_registry.cpp
)
endif()


+ 8
- 0
incl/scc/configurer.h View File

@@ -19,7 +19,9 @@

#include "report.h"
#include "utilities.h"
#ifdef WITH_CCI
#include <cci_configuration>
#endif
#include <json/json.h>

namespace scc {
@@ -91,10 +93,12 @@ public:
* @param value the value to put
*/
template <typename T> void set_value(const std::string &hier_name, T value) {
#ifdef WITH_CCI
cci::cci_param_handle param_handle = cci_broker.get_param_handle(hier_name);
if (param_handle.is_valid()) {
param_handle.set_cci_value(cci::cci_value(value));
} else {
#endif
size_t pos = hier_name.find_last_of('.');
sc_core::sc_module *mod =
dynamic_cast<sc_core::sc_module *>(sc_core::sc_find_object(hier_name.substr(0, pos).c_str()));
@@ -106,7 +110,9 @@ public:
else
SCERR() << "Could not set attribute value " << hier_name;
}
#ifdef WITH_CCI
}
#endif
}
/**
* set a value of an sc_attribute from given configuration
@@ -143,8 +149,10 @@ protected:

Json::Value root;

#ifdef WITH_CCI
cci::cci_originator cci_originator;
cci::cci_broker_handle cci_broker;
#endif
};
}



+ 6
- 0
incl/scc/report.h View File

@@ -183,6 +183,12 @@ protected:
//! macro for fatal message output
#define SCCFATAL(...) ::scc::ScLogger<::sc_core::SC_FATAL>(__FILE__, __LINE__, sc_core::SC_MEDIUM).type(__VA_ARGS__).get()

#ifdef NDEBUG
#define SCC_ASSERT(expr) ((void) 0)
#else
#define SCC_ASSERT(expr) ((void)((expr) ? 0 : (SC_REPORT_FATAL( ::sc_core::SC_ID_ASSERTION_FAILED_, #expr ), 0)))
#endif

#define SCMOD this->name()

/**


+ 12
- 2
src/configurer.cpp View File

@@ -22,15 +22,19 @@

#include "scc/configurer.h"
#include "scc/report.h"
#ifdef WITH_CCI
#include <cci_configuration>
#include <cci_utils/broker.h>
#endif
#include <fstream>

scc::configurer::configurer(const std::string &filename)
: base_type("configurer")
#ifdef WITH_CCI
, cci_originator("configurer")
, cci_broker(cci::cci_get_global_broker(cci_originator)) {
, cci_broker(cci::cci_get_global_broker(cci_originator))
#endif
{
if (filename.length() > 0) {
std::ifstream is(filename);
if (is.is_open()) {
@@ -101,6 +105,7 @@ void scc::configurer::dump_configuration(sc_core::sc_object *obj, Json::Value &p
CHECK_N_ASSIGN_VAL(std::string, attr_base);
CHECK_N_ASSIGN_VAL(char *, attr_base);
}
#ifdef WITH_CCI
const std::string hier_name{obj->name()};
cci::cci_param_predicate pred{[hier_name](cci::cci_param_untyped_handle h) -> bool {
std::string h_name {h.name()};
@@ -129,6 +134,7 @@ void scc::configurer::dump_configuration(sc_core::sc_object *obj, Json::Value &p
else if (value.is_string())
node[basename] = value.get_string().c_str();
}
#endif
for (auto *o : get_sc_objects(obj)) dump_configuration(o, node);
if (!node.empty()) parent[obj->basename()] = node;
}
@@ -207,6 +213,7 @@ void scc::configurer::configure_cci_hierarchical(const Json::Value &node, std::s
return;
else if (val.isObject())
configure_cci_hierarchical(*itr, hier_name);
#ifdef WITH_CCI
else {
cci::cci_param_handle param_handle = cci_broker.get_param_handle(hier_name);
if (param_handle.is_valid()) {
@@ -243,10 +250,13 @@ void scc::configurer::configure_cci_hierarchical(const Json::Value &node, std::s
}
}
}
#endif
}
}
}

void scc::init_cci(std::string name) {
#ifdef WITH_CCI
cci::cci_register_broker(new cci_utils::broker("Global Broker"));
#endif
}

Loading…
Cancel
Save