Browse Source

Made configurer independend of CCI

Eyck Jentzsch 1 month 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
37 37
     src/perf_estimator.cpp
38 38
     src/io-redirector.cpp
39 39
     src/ordered_semaphore.cpp
40
+    src/configurer.cpp
41
+    src/jsoncpp.cpp
40 42
 )
41 43
 
42 44
 if(CCI_FOUND)
@@ -44,8 +46,6 @@ if(CCI_FOUND)
44 46
 	    src/tracer_base.cpp
45 47
 	    src/tracer.cpp
46 48
 	    src/configurable_tracer.cpp
47
-	    src/configurer.cpp
48
-    	src/jsoncpp.cpp
49 49
     	src/value_registry.cpp
50 50
     )
51 51
 endif()

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

@@ -19,7 +19,9 @@
19 19
 
20 20
 #include "report.h"
21 21
 #include "utilities.h"
22
+#ifdef WITH_CCI
22 23
 #include <cci_configuration>
24
+#endif
23 25
 #include <json/json.h>
24 26
 
25 27
 namespace scc {
@@ -91,10 +93,12 @@ public:
91 93
      * @param value the value to put
92 94
      */
93 95
     template <typename T> void set_value(const std::string &hier_name, T value) {
96
+#ifdef WITH_CCI
94 97
         cci::cci_param_handle param_handle = cci_broker.get_param_handle(hier_name);
95 98
         if (param_handle.is_valid()) {
96 99
             param_handle.set_cci_value(cci::cci_value(value));
97 100
         } else {
101
+#endif
98 102
             size_t pos = hier_name.find_last_of('.');
99 103
             sc_core::sc_module *mod =
100 104
                 dynamic_cast<sc_core::sc_module *>(sc_core::sc_find_object(hier_name.substr(0, pos).c_str()));
@@ -106,7 +110,9 @@ public:
106 110
                 else
107 111
                     SCERR() << "Could not set attribute value " << hier_name;
108 112
             }
113
+#ifdef WITH_CCI
109 114
         }
115
+#endif
110 116
     }
111 117
     /**
112 118
      * set a value of an sc_attribute from given configuration
@@ -143,8 +149,10 @@ protected:
143 149
 
144 150
     Json::Value root;
145 151
 
152
+#ifdef WITH_CCI
146 153
     cci::cci_originator cci_originator;
147 154
     cci::cci_broker_handle cci_broker;
155
+#endif
148 156
 };
149 157
 }
150 158
 

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

@@ -183,6 +183,12 @@ protected:
183 183
 //! macro for fatal message output
184 184
 #define SCCFATAL(...) ::scc::ScLogger<::sc_core::SC_FATAL>(__FILE__, __LINE__, sc_core::SC_MEDIUM).type(__VA_ARGS__).get()
185 185
 
186
+#ifdef NDEBUG
187
+#define SCC_ASSERT(expr) ((void) 0)
188
+#else
189
+#define SCC_ASSERT(expr) ((void)((expr) ? 0 : (SC_REPORT_FATAL( ::sc_core::SC_ID_ASSERTION_FAILED_, #expr ), 0)))
190
+#endif
191
+
186 192
 #define SCMOD this->name()
187 193
 
188 194
 /**

+ 12
- 2
src/configurer.cpp View File

@@ -22,15 +22,19 @@
22 22
 
23 23
 #include "scc/configurer.h"
24 24
 #include "scc/report.h"
25
+#ifdef WITH_CCI
25 26
 #include <cci_configuration>
26 27
 #include <cci_utils/broker.h>
27
-
28
+#endif
28 29
 #include <fstream>
29 30
 
30 31
 scc::configurer::configurer(const std::string &filename)
31 32
 : base_type("configurer")
33
+#ifdef WITH_CCI
32 34
 , cci_originator("configurer")
33
-, cci_broker(cci::cci_get_global_broker(cci_originator)) {
35
+, cci_broker(cci::cci_get_global_broker(cci_originator))
36
+#endif
37
+{
34 38
     if (filename.length() > 0) {
35 39
         std::ifstream is(filename);
36 40
         if (is.is_open()) {
@@ -101,6 +105,7 @@ void scc::configurer::dump_configuration(sc_core::sc_object *obj, Json::Value &p
101 105
         CHECK_N_ASSIGN_VAL(std::string, attr_base);
102 106
         CHECK_N_ASSIGN_VAL(char *, attr_base);
103 107
     }
108
+#ifdef WITH_CCI
104 109
     const std::string hier_name{obj->name()};
105 110
     cci::cci_param_predicate pred{[hier_name](cci::cci_param_untyped_handle h) -> bool {
106 111
     	std::string h_name {h.name()};
@@ -129,6 +134,7 @@ void scc::configurer::dump_configuration(sc_core::sc_object *obj, Json::Value &p
129 134
         else if (value.is_string())
130 135
             node[basename] = value.get_string().c_str();
131 136
     }
137
+#endif
132 138
     for (auto *o : get_sc_objects(obj)) dump_configuration(o, node);
133 139
     if (!node.empty()) parent[obj->basename()] = node;
134 140
 }
@@ -207,6 +213,7 @@ void scc::configurer::configure_cci_hierarchical(const Json::Value &node, std::s
207 213
                 return;
208 214
             else if (val.isObject())
209 215
                 configure_cci_hierarchical(*itr, hier_name);
216
+#ifdef WITH_CCI
210 217
             else {
211 218
                 cci::cci_param_handle param_handle = cci_broker.get_param_handle(hier_name);
212 219
                 if (param_handle.is_valid()) {
@@ -243,10 +250,13 @@ void scc::configurer::configure_cci_hierarchical(const Json::Value &node, std::s
243 250
                     }
244 251
                 }
245 252
             }
253
+#endif
246 254
         }
247 255
     }
248 256
 }
249 257
 
250 258
 void scc::init_cci(std::string name) {
259
+#ifdef WITH_CCI
251 260
     cci::cci_register_broker(new cci_utils::broker("Global Broker"));
261
+#endif
252 262
 }