Browse Source

refactor tracer API

master
Eyck Jentzsch 3 weeks ago
parent
commit
805688ca0b
3 changed files with 21 additions and 56 deletions
  1. +0
    -19
      incl/scc/tracer.h
  2. +20
    -2
      incl/scc/tracer_base.h
  3. +1
    -35
      src/tracer.cpp

+ 0
- 19
incl/scc/tracer.h View File

@ -48,32 +48,13 @@ public:
* @param enable enable VCD (signal and POD) tracing
*/
tracer(const std::string&&, file_type, bool = true);
/**
* the constructor
*
* @param name base name of the trace file(s)
* @param type type of trace file for transactions
* @param the trace file to use for signal and POD tracing
*/
tracer(const std::string&&, file_type, sc_core::sc_trace_file* = nullptr);
/**
* the destructor
*/
virtual ~tracer() override;
const sc_core::sc_trace_file* get_trace_file() const {
return trf;
}
void set_trace_file(sc_core::sc_trace_file* trf) {
if(this->trf && owned) sc_core::sc_close_vcd_trace_file(this->trf);
this->trf = trf;
owned=false;
}
protected:
void end_of_elaboration() override;
bool owned{false};
#ifdef WITH_SCV
scv_tr_db* txdb;
#endif

+ 20
- 2
incl/scc/tracer_base.h View File

@ -39,13 +39,29 @@ public:
tracer_base(const sc_core::sc_module_name& nm)
: sc_core::sc_module(nm) {}
tracer_base(const sc_core::sc_module_name& nm, sc_core::sc_trace_file* tf)
: sc_core::sc_module(nm), trf(tf) {}
tracer_base(const sc_core::sc_module_name& nm, sc_core::sc_trace_file* tf, bool owned=true)
: sc_core::sc_module(nm), trf(tf), owned(owned) {}
~tracer_base(){
if(trf && owned)
sc_close_vcd_trace_file(trf);
}
void set_trace_types(trace_types t){
types_to_trace=t;
}
const sc_core::sc_trace_file* get_trace_file() const {
return trf;
}
void set_trace_file(sc_core::sc_trace_file* trf) {
if(this->trf && owned)
sc_close_vcd_trace_file(trf);
this->trf=trf;
owned=false;
}
protected:
virtual void descend(const sc_core::sc_object*, bool trace_all = false);
@ -53,6 +69,8 @@ protected:
sc_core::sc_trace_file* trf{nullptr};
bool owned{false};
trace_types types_to_trace{trace_types::ALL};
};

+ 1
- 35
src/tracer.cpp View File

@ -34,7 +34,6 @@ using namespace scc;
tracer::tracer(const std::string&& name, file_type type, bool enable)
: tracer_base(sc_core::sc_module_name(sc_core::sc_gen_unique_name("tracer")))
, owned(true)
#ifdef WITH_SCV
, txdb(nullptr)
#endif
@ -42,6 +41,7 @@ tracer::tracer(const std::string&& name, file_type type, bool enable)
if(enable) {
trf = sc_create_vcd_trace_file(name.c_str());
trf->set_time_unit(1, SC_PS);
owned=true;
}
#ifdef WITH_SCV
if(type != NONE) {
@ -69,38 +69,6 @@ tracer::tracer(const std::string&& name, file_type type, bool enable)
#endif
}
tracer::tracer(const std::string&& name, file_type type, sc_core::sc_trace_file* tf)
: tracer_base(sc_core::sc_module_name(sc_core::sc_gen_unique_name("tracer")), tf)
#ifdef WITH_SCV
, txdb(nullptr)
#endif
{
#ifdef WITH_SCV
if(type != NONE) {
std::stringstream ss;
ss << name;
switch(type) {
case TEXT:
scv_tr_text_init();
ss << ".txlog";
break;
case COMPRESSED:
scv_tr_compressed_init();
ss << ".txlog";
break;
case SQLITE:
scv_tr_sqlite_init();
ss << ".txdb";
break;
default:
break;
}
txdb = new scv_tr_db(ss.str().c_str());
scv_tr_db::set_default_db(txdb);
}
#endif
}
void tracer::end_of_elaboration() {
if(trf)
for(auto o : sc_get_top_level_objects(sc_curr_simcontext))
@ -108,8 +76,6 @@ void tracer::end_of_elaboration() {
}
tracer::~tracer() {
if(trf && owned)
sc_close_vcd_trace_file(trf);
#ifdef WITH_SCV
delete txdb;
#endif

Loading…
Cancel
Save