17 #include "configurable_tracer.h"
18 #include "traceable.h"
19 #include <unordered_set>
21 using namespace sc_core;
24 #define EN_TRACING_STR "enableTracing"
26 configurable_tracer::configurable_tracer(std::string
const&& name,
bool enable_tx,
bool enable_vcd,
bool default_enable,
27 sc_core::sc_object* top)
28 :
tracer(std::move(name), enable_tx ? ENABLE : NONE, enable_vcd ? ENABLE : NONE, top) {
33 sc_core::sc_object* top)
34 :
tracer(std::move(name), type, enable_vcd ? ENABLE : NONE, top) {
39 sc_core::sc_object* top)
40 :
tracer(std::move(name), type, tf, top) {
45 for(
auto ptr : params)
53 const std::string kind = obj->kind();
58 }
else if(kind ==
"sc_vector") {
60 for(
auto o : obj->get_child_objects())
63 }
else if(kind ==
"sc_module") {
67 for(
auto o : obj->get_child_objects())
69 }
else if(kind ==
"sc_variable") {
72 }
else if(kind ==
"sc_signal" || kind ==
"sc_clock" || kind ==
"sc_buffer" || kind ==
"sc_signal_rv") {
74 try_trace(trf, obj, types_to_trace);
75 }
else if(kind ==
"sc_in" || kind ==
"sc_out" || kind ==
"sc_inout") {
77 try_trace(trf, obj, types_to_trace);
78 }
else if(
const auto* tr =
dynamic_cast<const scc::traceable*
>(obj)) {
79 if(tr->is_trace_enabled())
81 for(
auto o : obj->get_child_objects())
82 descend(o, tr->is_trace_enabled());
89 auto* attr = obj->get_attribute(EN_TRACING_STR);
90 if(attr !=
nullptr &&
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr) !=
nullptr) {
91 const auto* a =
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr);
94 std::string hier_name{obj->name()};
95 auto h =
cci_broker.get_param_handle(hier_name.append(
"." EN_TRACING_STR));
97 return h.get_cci_value().get_bool();
103 if(
dynamic_cast<sc_core::sc_module*
>(obj) !=
nullptr ||
dynamic_cast<scc::traceable*
>(obj) !=
nullptr) {
104 auto* attr = obj->get_attribute(EN_TRACING_STR);
105 if(attr ==
nullptr ||
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr) ==
nullptr) {
106 std::string hier_name{obj->name()};
107 if(hier_name.substr(0, 11) !=
"scc_tracer") {
108 hier_name +=
"." EN_TRACING_STR;
109 auto h =
cci_broker.get_param_handle(hier_name);
116 }
else if(
auto battr =
dynamic_cast<sc_core::sc_attribute<bool>*
>(attr)) {
119 for(
auto* o : obj->get_child_objects())
124 void configurable_tracer::end_of_elaboration() {
126 tracer::end_of_elaboration();
configurable_tracer(std::string const &&name, bool enable_tx=true, bool enable_vcd=true, bool default_enable=false, sc_core::sc_object *top=nullptr)
void augment_object_hierarchical(sc_core::sc_object *)
add the 'enableTracing' attribute to sc_module
bool get_trace_enabled(const sc_core::sc_object *, bool=false)
check for existence of 'enableTracing' attribute and return value of default otherwise
void descend(const sc_core::sc_object *, bool trace_all=false) override
depth-first walk thru the design hierarchy and trace signals resp. call trace() function
std::vector< cci::cci_param_untyped * > params
array of created cci parameter
interface defining a traceable component
bool default_trace_enable
the default for tracing if no attribute is configured
a component traversing the SystemC object hierarchy and tracing the objects
file_type
defines the transaction trace output type