25#include "sc_vcd_trace.h"
26#include "scv/scv_tr_db.h"
28#include <scc/sc_vcd_trace.h>
38#define SCVNS ::scv_tr::
46using namespace sc_core;
49static char const*
const tx_trace_type_name =
"scc_tracer.tx_trace_type";
50static char const*
const sig_trace_type_name =
"scc_tracer.sig_trace_type";
51static char const*
const close_db_in_eos_name =
"scc_tracer.close_db_in_eos";
53tracer::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)
57, owned{sig_type != NONE} {
59 if(sig_type == ENABLE)
60 sig_type =
static_cast<file_type
>(sig_trace_type_handle.get_cci_value().get<unsigned>());
61 if(sig_type != NONE) {
64 trf = sc_create_vcd_trace_file(name.c_str());
78 trf->set_time_unit(1, SC_PS);
79 init_tx_db(tx_type == ENABLE ?
static_cast<file_type
>(tx_trace_type_handle.get_cci_value().get<
unsigned>()) : tx_type, std::move(name));
82tracer::tracer(std::string
const&& name, file_type tx_type, sc_core::sc_trace_file* tf, sc_core::sc_object* top,
83 sc_core::sc_module_name
const& nm)
90 init_tx_db(tx_type == ENABLE ?
static_cast<file_type
>(tx_trace_type_handle.get_cci_value().get<
unsigned>()) : tx_type, std::move(name));
97 scc_close_vcd_trace_file(trf);
100void tracer::init_tx_db(file_type type, std::string
const&& name) {
102 std::stringstream ss;
106 SCVNS scv_tr_text_init();
110 auto* val = getenv(
"SCC_SCV_TR_COMPRESSION_LEVEL");
111 auto level = val ? atoi(val) : std::numeric_limits<unsigned>::max();
114 SCVNS scv_tr_plain_init();
117 SCVNS scv_tr_compressed_init();
120 SCVNS scv_tr_lz4_init();
132 SCVNS scv_tr_ftr_init(
false);
135 SCVNS scv_tr_ftr_init(
true);
138 lwtr::tx_ftr_init(
false);
141 lwtr::tx_ftr_init(
true);
148 if(type == LWFTR || type == LWCFTR) {
149 lwtr_db =
new lwtr::tx_db(name.c_str());
151 txdb =
new SCVNS scv_tr_db(ss.str().c_str());
154 trf->write_comment(std::string(
"TXREC: ") + ss.str());
159void tracer::end_of_elaboration() {
161 for(
auto o : sc_get_top_level_objects())
166void tracer::end_of_simulation() {
173 scc_close_vcd_trace_file(trf);
179void tracer::init_cci_handles() {
182 tx_trace_type = scc::make_unique<cci::cci_param<unsigned>>(
183 tx_trace_type_name, CFTR,
"Type of TX trace file used for recording. See also scc::tracer::file_type", cci::CCI_ABSOLUTE_NAME);
188 sig_trace_type = scc::make_unique<cci::cci_param<unsigned>>(
189 sig_trace_type_name, FST,
"Type of signal trace file used for recording. See also scc::tracer::wave_type",
190 cci::CCI_ABSOLUTE_NAME);
196 close_db_in_eos = scc::make_unique<cci::cci_param<bool>>(
197 close_db_in_eos_name,
false,
"Close the waveform/transaction tracing databases during end_of_simulation",
198 cci::CCI_ABSOLUTE_NAME);
cci::cci_param_handle tx_trace_type_handle
virtual ~tracer() override
the destructor
cci::cci_param_handle close_db_in_eos_handle
cci::cci_param_handle sig_trace_type_handle
sc_core::sc_trace_file * create_fst_trace_file(const char *name, std::function< bool()> enable)
create FST file which uses pull mechanism
sc_core::sc_trace_file * create_vcd_pull_trace_file(const char *name, std::function< bool()> enable=std::function< bool()>())
create VCD file which uses pull mechanism
sc_core::sc_trace_file * create_vcd_push_trace_file(const char *name, std::function< bool()> enable=std::function< bool()>())
create VCD file which uses push mechanism
void scv_tr_mtc_init()
initializes the infrastructure to use a compressed text based transaction recording database with a m...
void scv_tr_sqlite_init()
initializes the infrastructure to use a SQLite based transaction recording database
base class for automatic tracer
cci::cci_param_handle default_trace_enable_handle
cci::cci_broker_handle cci_broker