2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2010-01-24 23:37:01 +00:00
|
|
|
//=============================================================================
|
|
|
|
//
|
2022-01-01 13:26:40 +00:00
|
|
|
// Copyright 2001-2022 by Wilson Snyder. This program is free software; you can
|
2020-03-21 15:24:24 +00:00
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2010-01-24 23:37:01 +00:00
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
///
|
|
|
|
/// \file
|
2021-03-20 21:46:00 +00:00
|
|
|
/// \brief Verilated tracing in VCD format for SystemC header
|
|
|
|
///
|
|
|
|
/// User wrapper code should use this header when creating VCD SystemC
|
|
|
|
/// traces.
|
2010-01-24 23:37:01 +00:00
|
|
|
///
|
2017-10-27 00:05:42 +00:00
|
|
|
/// This class is not threadsafe, as the SystemC kernel is not threadsafe.
|
|
|
|
///
|
2010-01-24 23:37:01 +00:00
|
|
|
//=============================================================================
|
|
|
|
|
2021-03-04 02:57:07 +00:00
|
|
|
#ifndef VERILATOR_VERILATED_VCD_SC_H_
|
|
|
|
#define VERILATOR_VERILATED_VCD_SC_H_
|
2010-01-24 23:37:01 +00:00
|
|
|
|
2018-10-14 17:43:24 +00:00
|
|
|
#include "verilatedos.h"
|
2010-01-24 23:37:01 +00:00
|
|
|
#include "verilated_sc.h"
|
|
|
|
#include "verilated_vcd_c.h"
|
|
|
|
|
2022-01-09 21:49:38 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-01-24 23:37:01 +00:00
|
|
|
//=============================================================================
|
|
|
|
// VerilatedVcdSc
|
|
|
|
///
|
2021-03-28 15:50:05 +00:00
|
|
|
/// Class representing a Verilator-friendly VCD trace format registered
|
|
|
|
/// with the SystemC simulation kernel, just like a SystemC-documented
|
|
|
|
/// trace format.
|
2010-01-24 23:37:01 +00:00
|
|
|
|
2020-11-19 02:32:16 +00:00
|
|
|
class VerilatedVcdSc final : sc_trace_file, public VerilatedVcdC {
|
2017-11-01 22:51:41 +00:00
|
|
|
// CONSTRUCTORS
|
|
|
|
VL_UNCOPYABLE(VerilatedVcdSc);
|
2020-04-14 02:51:35 +00:00
|
|
|
|
2010-01-24 23:37:01 +00:00
|
|
|
public:
|
2021-03-07 13:28:13 +00:00
|
|
|
/// Construct a SC trace object, and register with the SystemC kernel
|
2010-01-24 23:37:01 +00:00
|
|
|
VerilatedVcdSc() {
|
2018-08-22 23:14:06 +00:00
|
|
|
sc_get_curr_simcontext()->add_trace_file(this);
|
|
|
|
// We want to avoid a depreciated warning, but still be back compatible.
|
2019-05-15 02:49:21 +00:00
|
|
|
// Turning off the message just for this still results in an
|
|
|
|
// annoying "to turn off" message.
|
2021-07-24 12:36:11 +00:00
|
|
|
const sc_time t1sec{1, SC_SEC};
|
2020-04-14 02:51:35 +00:00
|
|
|
if (t1sec.to_default_time_units() != 0) {
|
2021-07-24 12:36:11 +00:00
|
|
|
const sc_time tunits{1.0 / t1sec.to_default_time_units(), SC_SEC};
|
2018-08-22 23:14:06 +00:00
|
|
|
spTrace()->set_time_unit(tunits.to_string());
|
|
|
|
}
|
|
|
|
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
2010-01-24 23:37:01 +00:00
|
|
|
}
|
2021-03-07 13:28:13 +00:00
|
|
|
/// Destruct, flush, and close the dump
|
2022-07-30 17:53:54 +00:00
|
|
|
virtual ~VerilatedVcdSc() /*override*/ { close(); }
|
2017-11-01 22:51:41 +00:00
|
|
|
|
2021-03-07 13:28:13 +00:00
|
|
|
// METHODS - for SC kernel
|
|
|
|
// Called by SystemC simulate()
|
2018-08-22 23:14:06 +00:00
|
|
|
virtual void cycle(bool delta_cycle) {
|
2021-02-17 01:14:13 +00:00
|
|
|
if (!delta_cycle) this->dump(sc_time_stamp().to_double());
|
2010-01-24 23:37:01 +00:00
|
|
|
}
|
|
|
|
|
2021-12-22 23:41:11 +00:00
|
|
|
// Override VerilatedVcdC. Must be called after starting simulation.
|
2022-07-30 14:01:25 +00:00
|
|
|
// cppcheck-suppress missingOverride // GCC won't accept override
|
2021-12-22 23:41:11 +00:00
|
|
|
virtual void open(const char* filename) /*override*/ VL_MT_SAFE;
|
|
|
|
|
2010-01-24 23:37:01 +00:00
|
|
|
private:
|
2021-03-07 13:28:13 +00:00
|
|
|
// METHODS - Fake outs for linker
|
2010-01-24 23:37:01 +00:00
|
|
|
|
|
|
|
#ifdef NC_SYSTEMC
|
|
|
|
// Cadence Incisive has these as abstract functions so we must create them
|
2018-08-22 23:14:06 +00:00
|
|
|
virtual void set_time_unit(int exponent10_seconds) {} // deprecated
|
2012-01-20 00:48:37 +00:00
|
|
|
#endif
|
2020-05-16 02:34:06 +00:00
|
|
|
virtual void set_time_unit(double v, sc_time_unit tu) {} // LCOV_EXCL_LINE
|
2010-01-24 23:37:01 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------
|
2020-08-29 16:56:43 +00:00
|
|
|
// SystemC 2.1.v1
|
|
|
|
#define DECL_TRACE_METHOD_A(tp) virtual void trace(const tp& object, const std::string& name);
|
|
|
|
#define DECL_TRACE_METHOD_B(tp) \
|
2018-08-22 23:14:06 +00:00
|
|
|
virtual void trace(const tp& object, const std::string& name, int width);
|
2010-01-24 23:37:01 +00:00
|
|
|
|
2019-11-10 01:35:12 +00:00
|
|
|
virtual void write_comment(const std::string&);
|
|
|
|
virtual void trace(const unsigned int&, const std::string&, const char**);
|
2010-01-24 23:37:01 +00:00
|
|
|
|
2020-08-29 14:45:47 +00:00
|
|
|
// clang-format off
|
2020-04-14 02:51:35 +00:00
|
|
|
// Formatting matches that of sc_trace.h
|
2020-08-29 14:45:47 +00:00
|
|
|
#if (SYSTEMC_VERSION >= 20171012)
|
2017-12-17 13:23:22 +00:00
|
|
|
DECL_TRACE_METHOD_A( sc_event )
|
|
|
|
DECL_TRACE_METHOD_A( sc_time )
|
2020-08-29 14:45:47 +00:00
|
|
|
#endif
|
2017-12-17 13:23:22 +00:00
|
|
|
|
2010-01-24 23:37:01 +00:00
|
|
|
DECL_TRACE_METHOD_A( bool )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_bit )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_logic )
|
|
|
|
|
|
|
|
DECL_TRACE_METHOD_B( unsigned char )
|
|
|
|
DECL_TRACE_METHOD_B( unsigned short )
|
|
|
|
DECL_TRACE_METHOD_B( unsigned int )
|
|
|
|
DECL_TRACE_METHOD_B( unsigned long )
|
|
|
|
DECL_TRACE_METHOD_B( char )
|
|
|
|
DECL_TRACE_METHOD_B( short )
|
|
|
|
DECL_TRACE_METHOD_B( int )
|
|
|
|
DECL_TRACE_METHOD_B( long )
|
|
|
|
DECL_TRACE_METHOD_B( sc_dt::int64 )
|
|
|
|
DECL_TRACE_METHOD_B( sc_dt::uint64 )
|
|
|
|
|
|
|
|
DECL_TRACE_METHOD_A( float )
|
|
|
|
DECL_TRACE_METHOD_A( double )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_int_base )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_uint_base )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_signed )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_unsigned )
|
|
|
|
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_fxval )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_fxval_fast )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_fxnum )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_fxnum_fast )
|
|
|
|
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_bv_base )
|
|
|
|
DECL_TRACE_METHOD_A( sc_dt::sc_lv_base )
|
2020-04-14 02:51:35 +00:00
|
|
|
// clang-format on
|
2010-01-24 23:37:01 +00:00
|
|
|
|
2020-04-14 02:51:35 +00:00
|
|
|
#undef DECL_TRACE_METHOD_A
|
|
|
|
#undef DECL_TRACE_METHOD_B
|
2010-01-24 23:37:01 +00:00
|
|
|
};
|
|
|
|
|
2018-08-22 23:14:06 +00:00
|
|
|
#endif // Guard
|