Skip to content

Commit

Permalink
fixes initialization issue in tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
eyck committed Mar 19, 2023
1 parent e510457 commit b4b551c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 53 deletions.
15 changes: 6 additions & 9 deletions src/sysc/scc/configurable_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,22 @@ using namespace scc;

#define EN_TRACING_STR "enableTracing"

configurable_tracer::configurable_tracer(std::string const&& name, bool enable_tx, bool enable_vcd, bool default_enable, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
: tracer(std::move(name), static_cast<file_type>(tx_trace_type.get_value()), static_cast<wave_type>(sig_trace_type.get_value()), top, nm)
, cci_broker(cci::cci_get_broker())
configurable_tracer::configurable_tracer(std::string const&& name, bool enable_tx, bool enable_vcd, bool default_enable, sc_core::sc_object* top)
: tracer(std::move(name), enable_tx?ENABLE:NONE, enable_vcd?ENABLE:NONE, top)
{
default_trace_enable = default_enable;
}

configurable_tracer::configurable_tracer(std::string const&& name, file_type type, bool enable_vcd, bool default_enable,
sc_core::sc_object* top, sc_core::sc_module_name const& nm)
: tracer(std::move(name), type, enable_vcd?SC_VCD:NOSIGTRC, top, nm)
, cci_broker(cci::cci_get_broker())
sc_core::sc_object* top)
: tracer(std::move(name), type, enable_vcd?ENABLE:NONE, top)
{
default_trace_enable = default_enable;
}

configurable_tracer::configurable_tracer(std::string const&& name, file_type type, sc_core::sc_trace_file* tf,
bool default_enable, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
: tracer(std::move(name), type, tf, top, nm)
, cci_broker(cci::cci_get_broker())
bool default_enable, sc_core::sc_object* top)
: tracer(std::move(name), type, tf, top)
{
default_trace_enable = default_enable;
}
Expand Down
26 changes: 3 additions & 23 deletions src/sysc/scc/configurable_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define _SCC_CONFIGURABLE_TRACER_H_

#include "tracer.h"
#include <cci_configuration>
/** \ingroup scc-sysc
* @{
*/
Expand All @@ -35,14 +34,6 @@ namespace scc {
*/
class configurable_tracer : public tracer {
public:
/**
* cci parameter to determine the file type being used to trace transaction if not specified explicitly
*/
cci::cci_param<unsigned> tx_trace_type{"tx_trace_type", CFTR, "Type of TX trace file used for recording. See also scc::tracer::file_type"};
/**
* cci parameter to determine the file type being used to trace signals if not specified explicitly
*/
cci::cci_param<unsigned> sig_trace_type{"sig_trace_type", FST, "Type of signal trace file used for recording. See also scc::tracer::wave_type"};
/**
* constructs a tracer object
*
Expand All @@ -52,8 +43,7 @@ class configurable_tracer : public tracer {
* @param default_enable value of parameter enableTracing if not defined by module or CCIs
*/
configurable_tracer(std::string const&& name, bool enable_tx = true, bool enable_vcd = true, bool default_enable = false,
sc_core::sc_object* top = nullptr)
: configurable_tracer(std::move(name), enable_tx, enable_vcd, default_enable, top, tracer_base::get_name().c_str()) {}
sc_core::sc_object* top = nullptr);
/**
* constructs a tracer object
*
Expand All @@ -74,8 +64,7 @@ class configurable_tracer : public tracer {
* @param default_enable value of parameter enableTracing if not defined by module or CCIs
*/
configurable_tracer(std::string const&& name, file_type type, bool enable_vcd = true, bool default_enable = false,
sc_core::sc_object* top = nullptr)
: configurable_tracer(std::move(name), type, enable_vcd, default_enable, top, tracer_base::get_name().c_str()) {}
sc_core::sc_object* top = nullptr);
/**
* constructs a tracer object
*
Expand All @@ -96,8 +85,7 @@ class configurable_tracer : public tracer {
* @param default_enable value of parameter enableTracing if not defined by module or CCIs
*/
configurable_tracer(std::string const&& name, file_type type, sc_core::sc_trace_file* tf = nullptr,
bool default_enable = false, sc_core::sc_object* top = nullptr)
: configurable_tracer(std::move(name), type, tf, default_enable, top, tracer_base::get_name().c_str()) {}
bool default_enable = false, sc_core::sc_object* top = nullptr);
/**
* constructs a tracer object
*
Expand Down Expand Up @@ -125,12 +113,6 @@ class configurable_tracer : public tracer {
}

protected:
configurable_tracer(std::string const&& name, bool enable_tx, bool enable_vcd, bool default_enable,
sc_core::sc_object* top, sc_core::sc_module_name const&);
configurable_tracer(std::string const&& name, file_type type, bool enable_vcd, bool default_enable,
sc_core::sc_object* top, sc_core::sc_module_name const&);
configurable_tracer(std::string const&& name, file_type type, sc_core::sc_trace_file* tf,
bool default_enable, sc_core::sc_object* top, sc_core::sc_module_name const&);
//! depth-first walk thru the design hierarchy and trace signals resp. call trace() function
void descend(const sc_core::sc_object*, bool trace_all = false) override;
//! check for existence of 'enableTracing' attribute and return value of default otherwise
Expand All @@ -139,8 +121,6 @@ class configurable_tracer : public tracer {
void augment_object_hierarchical(sc_core::sc_object*);

void end_of_elaboration() override;
//! the cci broker
cci::cci_broker_handle cci_broker;
//! array of created cci parameter
std::vector<cci::cci_param_untyped*> params;
bool control_added{false};
Expand Down
21 changes: 12 additions & 9 deletions src/sysc/scc/tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@
using namespace sc_core;
using namespace scc;

tracer::tracer(std::string const&& name, file_type tx_type, wave_type sig_type, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
tracer::tracer(std::string const&& name, file_type tx_type, file_type sig_type, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
: tracer_base(nm)
, cci_broker(cci::cci_get_broker())
, txdb(nullptr)
, lwtr_db(nullptr)
, owned{sig_type!=NOSIGTRC} {
if(sig_type!=NOSIGTRC) {
, owned{sig_type!=NONE} {
if(sig_type==ENABLE) sig_type = static_cast<file_type>(sig_trace_type.get_value());
if(sig_type!=NONE) {
switch(sig_type) {
default:
trf = sc_create_vcd_trace_file(name.c_str());
Expand All @@ -67,17 +69,18 @@ tracer::tracer(std::string const&& name, file_type tx_type, wave_type sig_type,
break;
}
}
trf->set_time_unit(1, SC_PS);
init_scv_db(tx_type, std::move(name));
if(trf) trf->set_time_unit(1, SC_PS);
init_tx_db(tx_type==ENABLE?static_cast<file_type>(tx_trace_type.get_value()):tx_type, std::move(name));
}

tracer::tracer(std::string const&& name, file_type type, sc_core::sc_trace_file* tf, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
tracer::tracer(std::string const&& name, file_type tx_type, sc_core::sc_trace_file* tf, sc_core::sc_object* top, sc_core::sc_module_name const& nm)
: tracer_base(nm)
, cci_broker(cci::cci_get_broker())
, txdb(nullptr)
, lwtr_db(nullptr)
, owned{false} {
trf = tf;
init_scv_db(type, std::move(name));
init_tx_db(tx_type==ENABLE?static_cast<file_type>(tx_trace_type.get_value()):tx_type, std::move(name));
}

tracer::~tracer() {
Expand All @@ -87,8 +90,8 @@ tracer::~tracer() {
scc_close_vcd_trace_file(trf);
}

void tracer::init_scv_db(file_type type, std::string const&& name) {
if(type != NOTXTRC) {
void tracer::init_tx_db(file_type type, std::string const&& name) {
if(type != NONE) {
std::stringstream ss;
ss << name;
switch(type) {
Expand Down
37 changes: 25 additions & 12 deletions src/sysc/scc/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _SCC_TRACER_H_

#include "tracer_base.h"
#include <cci_configuration>
#include <string>
#include <vector>

Expand Down Expand Up @@ -55,9 +56,20 @@ class tracer : public tracer_base {
*
* CUSTOM means the caller needs to initialize the database driver (scv_tr_text_init() or alike)
*/
enum file_type { NOTXTRC, NONE=NOTXTRC, TEXT, COMPRESSED, SQLITE, FTR, CFTR, LWFTR, LWCFTR, CUSTOM };

enum wave_type { NOSIGTRC, SC_VCD, PULL_VCD, PUSH_VCD, FST};
enum file_type { NONE, ENABLE, TEXT, COMPRESSED, SQLITE, FTR, CFTR, LWFTR, LWCFTR, CUSTOM,
SC_VCD = TEXT,
PULL_VCD = COMPRESSED,
PUSH_VCD = SQLITE,
FST
};
/**
* cci parameter to determine the file type being used to trace transaction if not specified explicitly
*/
cci::cci_param<unsigned> tx_trace_type{"tx_trace_type", CFTR, "Type of TX trace file used for recording. See also scc::tracer::file_type"};
/**
* cci parameter to determine the file type being used to trace signals if not specified explicitly
*/
cci::cci_param<unsigned> sig_trace_type{"sig_trace_type", FST, "Type of signal trace file used for recording. See also scc::tracer::wave_type"};
/**
* @fn tracer(const std::string&&, file_type, bool=true)
* @brief the constructor
Expand All @@ -66,7 +78,7 @@ class tracer : public tracer_base {
* @param type type of trace file for transactions
* @param enable enable VCD (signal and POD) tracing
*/
tracer(std::string const&& name, file_type tx_type, wave_type sig_type, sc_core::sc_object* top = nullptr)
tracer(std::string const&& name, file_type tx_type, file_type sig_type, sc_core::sc_object* top = nullptr)
: tracer(std::move(name), tx_type, sig_type, top, tracer_base::get_name().c_str()) {}
/**
* @fn tracer(const std::string&&, file_type, bool=true)
Expand All @@ -76,7 +88,7 @@ class tracer : public tracer_base {
* @param type type of trace file for transactions
* @param enable enable VCD (signal and POD) tracing
*/
tracer(std::string const& name, file_type tx_type, wave_type sig_type, sc_core::sc_object* top = nullptr)
tracer(std::string const& name, file_type tx_type=ENABLE, file_type sig_type=ENABLE, sc_core::sc_object* top = nullptr)
: tracer(std::string(name), tx_type, sig_type, top) {}
/**
* @fn tracer(const std::string&&, file_type, bool=true)
Expand All @@ -87,7 +99,7 @@ class tracer : public tracer_base {
* @param enable enable VCD (signal and POD) tracing
*/
tracer(std::string const&& name, file_type type, bool enable = true, sc_core::sc_object* top = nullptr)
: tracer(name, type, enable?SC_VCD:NOSIGTRC, top) {}
: tracer(name, type, enable?ENABLE:NONE, top) {}
/**
* @fn tracer(const std::string&, file_type, bool=true)
* @brief the constructor
Expand All @@ -97,7 +109,7 @@ class tracer : public tracer_base {
* @param enable enable VCD (signal and POD) tracing
*/
tracer(std::string const& name, file_type type, bool enable = true, sc_core::sc_object* top = nullptr)
: tracer(name, type, enable?SC_VCD:NOSIGTRC, top) {}
: tracer(name, type, enable?ENABLE:NONE, top) {}
/**
* @fn tracer(const std::string&&, file_type, bool=true)
* @brief the constructor
Expand Down Expand Up @@ -125,18 +137,19 @@ class tracer : public tracer_base {
virtual ~tracer() override;

protected:
tracer(std::string const&& name, file_type tx_type, wave_type sig_type, sc_core::sc_object* top, sc_core::sc_module_name const& nm);
tracer(std::string const&& name, file_type tx_type, file_type sig_type, sc_core::sc_object* top, sc_core::sc_module_name const& nm);
tracer(std::string const&& name, file_type type, sc_core::sc_trace_file* tf, sc_core::sc_object* top, sc_core::sc_module_name const& nm);
void end_of_elaboration() override;
#ifdef HAS_SCV
scv_tr_db* txdb;
#else
scv_tr::scv_tr_db* txdb;
scv_tr::scv_tr_db* txdb{nullptr};
#endif
lwtr::tx_db* lwtr_db;

lwtr::tx_db* lwtr_db{nullptr};
//! the cci broker
cci::cci_broker_handle cci_broker;
private:
void init_scv_db(file_type type, std::string const&& name);
void init_tx_db(file_type type, std::string const&& name);
bool owned{false};
sc_core::sc_object* top{nullptr};
};
Expand Down

0 comments on commit b4b551c

Please sign in to comment.