17#include "configurable_tracer.h"
20#include <fmt/format.h>
21using namespace sc_core;
24#define EN_TRACING_STR "enableTracing"
27: tracer(std::move(name), enable_tx ? ENABLE : NONE, enable_vcd ? ENABLE : NONE, top) {}
30: tracer(std::move(name), type, enable_vcd ? ENABLE : NONE, top) {}
33: tracer(std::move(name), tx_type, sig_type, top) {}
36: tracer(std::move(name), type, tf, top) {}
47 const std::string kind = obj->kind();
52 }
else if(kind ==
"sc_vector") {
54 for(
auto o : obj->get_child_objects())
57 }
else if(kind ==
"sc_module") {
58 auto module_name = obj->name();
62 for(
auto o : obj->get_child_objects())
64 }
else if(kind ==
"sc_variable") {
67 }
else if(kind ==
"sc_signal" || kind ==
"sc_clock" || kind ==
"sc_buffer" || kind ==
"sc_signal_rv") {
69 try_trace(trf, obj, types_to_trace);
70 }
else if(kind ==
"sc_in" || kind ==
"sc_out" || kind ==
"sc_inout") {
72 try_trace(trf, obj, types_to_trace);
73 }
else if(
const auto* tr =
dynamic_cast<const scc::traceable*
>(obj)) {
74 if(tr->is_trace_enabled())
76 for(
auto o : obj->get_child_objects())
77 descend(o, tr->is_trace_enabled());
84 auto* attr = obj->get_attribute(EN_TRACING_STR);
85 if(attr !=
nullptr &&
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr) !=
nullptr) {
86 const auto* a =
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr);
89 std::string hier_name{obj->name()};
90 auto h =
cci_broker.get_param_handle(hier_name.append(
"." EN_TRACING_STR));
92 return h.get_cci_value().get_bool();
98 if(
dynamic_cast<sc_core::sc_module*
>(obj) !=
nullptr ||
dynamic_cast<scc::traceable*
>(obj) !=
nullptr) {
99 auto* attr = obj->get_attribute(EN_TRACING_STR);
100 if(attr ==
nullptr ||
dynamic_cast<const sc_core::sc_attribute<bool>*
>(attr) ==
nullptr) {
101 std::string hier_name{obj->name()};
102 if(hier_name.substr(0, 3) !=
"$$$") {
103 hier_name +=
"." EN_TRACING_STR;
104 auto h =
cci_broker.get_param_handle(hier_name);
106 params.push_back(
new cci::cci_param<bool>(hier_name, trace_enable,
cci_broker,
107 "Enables the signal tracing of this module", cci::CCI_ABSOLUTE_NAME,
112 }
else if(
auto battr =
dynamic_cast<sc_core::sc_attribute<bool>*
>(attr)) {
115 for(
auto* o : obj->get_child_objects())
120void configurable_tracer::end_of_elaboration() {
122 tracer::end_of_elaboration();
configurable_tracer(std::string const &&name, bool enable_tx=true, bool enable_vcd=true, sc_core::sc_object *top=nullptr)
bool get_trace_enabled(const sc_core::sc_object *, bool=false)
check for existence of 'enableTracing' attribute and return value of default otherwise
void augment_object_hierarchical(sc_core::sc_object *, bool)
add the 'enableTracing' attribute to sc_module
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
file_type
defines the transaction trace output type
SCC SystemC tracing utilities.
interface defining a traceable component
cci::cci_param_handle default_trace_enable_handle