2018-10-02 22:42:53 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//=============================================================================
|
|
|
|
//
|
2021-03-20 21:46:00 +00:00
|
|
|
// Code available from: https://verilator.org
|
2018-10-02 22:42:53 +00:00
|
|
|
//
|
2024-01-01 08:19:59 +00:00
|
|
|
// Copyright 2001-2024 by Wilson Snyder. This program is free software; you
|
2020-03-21 15:24:24 +00:00
|
|
|
// can 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
|
2018-10-02 22:42:53 +00:00
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
///
|
|
|
|
/// \file
|
2021-03-20 21:46:00 +00:00
|
|
|
/// \brief Verilated C++ tracing in FST format implementation code
|
|
|
|
///
|
|
|
|
/// This file must be compiled and linked against all Verilated objects
|
|
|
|
/// that use --trace-fst.
|
|
|
|
///
|
|
|
|
/// Use "verilator --trace-fst" to add this to the Makefile for the linker.
|
2018-10-02 22:42:53 +00:00
|
|
|
///
|
|
|
|
//=============================================================================
|
|
|
|
|
2020-04-13 23:13:10 +00:00
|
|
|
// clang-format off
|
|
|
|
|
2018-10-02 22:42:53 +00:00
|
|
|
#include "verilated.h"
|
|
|
|
#include "verilated_fst_c.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
2019-05-03 00:33:05 +00:00
|
|
|
// GTKWave configuration
|
2022-11-05 12:47:34 +00:00
|
|
|
#define HAVE_LIBPTHREAD
|
|
|
|
#define FST_WRITER_PARALLEL
|
2024-01-21 18:59:54 +00:00
|
|
|
#define LZ4_DISABLE_DEPRECATE_WARNINGS
|
2019-05-03 00:33:05 +00:00
|
|
|
|
2018-10-02 22:42:53 +00:00
|
|
|
// Include the GTKWave implementation directly
|
2019-11-16 08:54:05 +00:00
|
|
|
#define FST_CONFIG_INCLUDE "fst_config.h"
|
2018-10-02 22:42:53 +00:00
|
|
|
#include "gtkwave/fastlz.c"
|
2018-10-14 17:43:24 +00:00
|
|
|
#include "gtkwave/fstapi.c"
|
2018-10-02 22:42:53 +00:00
|
|
|
#include "gtkwave/lz4.c"
|
|
|
|
|
2018-10-14 11:04:18 +00:00
|
|
|
#include <algorithm>
|
2018-10-02 22:42:53 +00:00
|
|
|
#include <iterator>
|
2018-10-14 11:04:18 +00:00
|
|
|
#include <sstream>
|
2023-10-24 15:33:29 +00:00
|
|
|
#include <type_traits>
|
2018-10-02 22:42:53 +00:00
|
|
|
|
|
|
|
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
|
|
|
# include <io.h>
|
|
|
|
#else
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2020-04-13 23:13:10 +00:00
|
|
|
// clang-format on
|
|
|
|
|
2021-04-07 13:55:11 +00:00
|
|
|
//=============================================================================
|
2023-10-24 15:33:29 +00:00
|
|
|
// Check that forward declared types matches the FST API types
|
|
|
|
|
|
|
|
static_assert(std::is_same<vlFstHandle, fstHandle>::value, "vlFstHandle mismatch");
|
|
|
|
static_assert(std::is_same<vlFstEnumHandle, fstEnumHandle>::value, "vlFstHandle mismatch");
|
2021-04-07 13:55:11 +00:00
|
|
|
|
2018-10-02 22:42:53 +00:00
|
|
|
//=============================================================================
|
2020-04-19 22:57:36 +00:00
|
|
|
// Specialization of the generics for this trace format
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2022-05-29 18:08:39 +00:00
|
|
|
#define VL_SUB_T VerilatedFst
|
|
|
|
#define VL_BUF_T VerilatedFstBuffer
|
2022-05-28 11:20:35 +00:00
|
|
|
#include "verilated_trace_imp.h"
|
2022-05-29 18:08:39 +00:00
|
|
|
#undef VL_SUB_T
|
|
|
|
#undef VL_BUF_T
|
2018-10-02 22:42:53 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// VerilatedFst
|
|
|
|
|
2022-07-30 15:52:35 +00:00
|
|
|
VerilatedFst::VerilatedFst(void* /*fst*/) {}
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2020-04-08 21:54:35 +00:00
|
|
|
VerilatedFst::~VerilatedFst() {
|
|
|
|
if (m_fst) fstWriterClose(m_fst);
|
2020-08-15 14:12:55 +00:00
|
|
|
if (m_symbolp) VL_DO_CLEAR(delete[] m_symbolp, m_symbolp = nullptr);
|
2022-11-13 22:40:50 +00:00
|
|
|
if (m_strbufp) VL_DO_CLEAR(delete[] m_strbufp, m_strbufp = nullptr);
|
2020-04-08 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-07 16:01:54 +00:00
|
|
|
void VerilatedFst::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) {
|
2021-07-24 12:36:11 +00:00
|
|
|
const VerilatedLockGuard lock{m_mutex};
|
2018-10-08 00:39:51 +00:00
|
|
|
m_fst = fstWriterCreate(filename, 1);
|
2019-05-02 23:55:16 +00:00
|
|
|
fstWriterSetPackType(m_fst, FST_WR_PT_LZ4);
|
2020-04-19 22:57:36 +00:00
|
|
|
fstWriterSetTimescaleFromString(m_fst, timeResStr().c_str()); // lintok-begin-on-ref
|
2022-07-20 10:27:10 +00:00
|
|
|
if (m_useFstWriterThread) fstWriterSetParallelMode(m_fst, 1);
|
2023-10-23 10:36:24 +00:00
|
|
|
constDump(true); // First dump must contain the const signals
|
2021-04-14 20:52:14 +00:00
|
|
|
fullDump(true); // First dump must be full for fst
|
2020-04-21 22:49:07 +00:00
|
|
|
|
2022-05-29 18:08:39 +00:00
|
|
|
Super::traceInit();
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2020-04-08 21:54:35 +00:00
|
|
|
// convert m_code2symbol into an array for fast lookup
|
|
|
|
if (!m_symbolp) {
|
2022-03-05 20:44:32 +00:00
|
|
|
m_symbolp = new fstHandle[nextCode()]{0};
|
2020-08-16 15:43:49 +00:00
|
|
|
for (const auto& i : m_code2symbol) m_symbolp[i.first] = i.second;
|
2020-04-08 21:54:35 +00:00
|
|
|
}
|
|
|
|
m_code2symbol.clear();
|
2020-04-29 23:09:09 +00:00
|
|
|
|
|
|
|
// Allocate string buffer for arrays
|
2022-11-13 22:40:50 +00:00
|
|
|
if (!m_strbufp) m_strbufp = new char[maxBits() + 32];
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-07 16:01:54 +00:00
|
|
|
void VerilatedFst::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
|
2021-07-24 12:36:11 +00:00
|
|
|
const VerilatedLockGuard lock{m_mutex};
|
2022-05-29 18:08:39 +00:00
|
|
|
Super::closeBase();
|
2020-04-21 22:49:07 +00:00
|
|
|
fstWriterClose(m_fst);
|
2020-08-15 14:12:55 +00:00
|
|
|
m_fst = nullptr;
|
2020-04-21 22:49:07 +00:00
|
|
|
}
|
|
|
|
|
2021-03-07 16:01:54 +00:00
|
|
|
void VerilatedFst::flush() VL_MT_SAFE_EXCLUDES(m_mutex) {
|
2021-07-24 12:36:11 +00:00
|
|
|
const VerilatedLockGuard lock{m_mutex};
|
2022-05-29 18:08:39 +00:00
|
|
|
Super::flushBase();
|
2020-04-21 22:49:07 +00:00
|
|
|
fstWriterFlushContext(m_fst);
|
|
|
|
}
|
|
|
|
|
2022-03-27 19:27:40 +00:00
|
|
|
void VerilatedFst::emitTimeChange(uint64_t timeui) { fstWriterEmitTimeChange(m_fst, timeui); }
|
2018-10-02 22:42:53 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// Decl
|
|
|
|
|
2022-03-27 19:27:40 +00:00
|
|
|
void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, uint32_t elements,
|
2020-04-04 17:45:24 +00:00
|
|
|
unsigned int minValbits, const char** itemNamesp,
|
|
|
|
const char** itemValuesp) {
|
2021-06-19 02:19:35 +00:00
|
|
|
const fstEnumHandle enumNum
|
2020-04-04 17:45:24 +00:00
|
|
|
= fstWriterCreateEnumTable(m_fst, name, elements, minValbits, itemNamesp, itemValuesp);
|
2018-10-08 11:21:22 +00:00
|
|
|
m_local2fstdtype[dtypenum] = enumNum;
|
|
|
|
}
|
|
|
|
|
2023-10-24 15:33:29 +00:00
|
|
|
// TODO: should return std::optional<fstScopeType>, but I can't have C++17
|
|
|
|
static std::pair<bool, fstScopeType> toFstScopeType(VerilatedTracePrefixType type) {
|
|
|
|
switch (type) {
|
2024-09-21 12:25:14 +00:00
|
|
|
case VerilatedTracePrefixType::ROOTIO_MODULE: return {true, FST_ST_VCD_MODULE};
|
2023-10-24 15:33:29 +00:00
|
|
|
case VerilatedTracePrefixType::SCOPE_MODULE: return {true, FST_ST_VCD_MODULE};
|
|
|
|
case VerilatedTracePrefixType::SCOPE_INTERFACE: return {true, FST_ST_VCD_INTERFACE};
|
|
|
|
case VerilatedTracePrefixType::STRUCT_PACKED:
|
|
|
|
case VerilatedTracePrefixType::STRUCT_UNPACKED: return {true, FST_ST_VCD_STRUCT};
|
|
|
|
case VerilatedTracePrefixType::UNION_PACKED: return {true, FST_ST_VCD_UNION};
|
|
|
|
default: return {false, /* unused so whatever, just need a value */ FST_ST_VCD_SCOPE};
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
2023-10-24 15:33:29 +00:00
|
|
|
}
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2023-10-24 15:33:29 +00:00
|
|
|
void VerilatedFst::pushPrefix(const std::string& name, VerilatedTracePrefixType type) {
|
2024-09-21 12:25:14 +00:00
|
|
|
assert(!m_prefixStack.empty()); // Constructor makes an empty entry
|
|
|
|
std::string pname = name;
|
|
|
|
// An empty name means this is the root of a model created with name()=="". The
|
|
|
|
// tools get upset if we try to pass this as empty, so we put the signals under a
|
|
|
|
// new scope, but the signals further down will be peers, not children (as usual
|
|
|
|
// for name()!="")
|
|
|
|
// Terminate earlier $root?
|
|
|
|
if (m_prefixStack.back().second == VerilatedTracePrefixType::ROOTIO_MODULE) popPrefix();
|
|
|
|
if (pname.empty()) { // Start new temporary root
|
|
|
|
pname = "$rootio"; // VCD names are not backslash escaped
|
|
|
|
m_prefixStack.emplace_back("", VerilatedTracePrefixType::ROOTIO_WRAPPER);
|
|
|
|
type = VerilatedTracePrefixType::ROOTIO_MODULE;
|
|
|
|
}
|
|
|
|
const std::string newPrefix = m_prefixStack.back().first + pname;
|
2023-10-24 15:33:29 +00:00
|
|
|
const auto pair = toFstScopeType(type);
|
|
|
|
const bool properScope = pair.first;
|
|
|
|
const fstScopeType scopeType = pair.second;
|
|
|
|
m_prefixStack.emplace_back(newPrefix + (properScope ? " " : ""), type);
|
|
|
|
if (properScope) {
|
|
|
|
const std::string scopeName = lastWord(newPrefix);
|
|
|
|
fstWriterSetScope(m_fst, scopeType, scopeName.c_str(), nullptr);
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
2023-10-24 15:33:29 +00:00
|
|
|
}
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2023-10-24 15:33:29 +00:00
|
|
|
void VerilatedFst::popPrefix() {
|
2024-09-21 12:25:14 +00:00
|
|
|
assert(!m_prefixStack.empty());
|
2023-10-24 15:33:29 +00:00
|
|
|
const bool properScope = toFstScopeType(m_prefixStack.back().second).first;
|
|
|
|
if (properScope) fstWriterSetUpscope(m_fst);
|
|
|
|
m_prefixStack.pop_back();
|
2024-09-21 12:25:14 +00:00
|
|
|
assert(!m_prefixStack.empty()); // Always one left, the constructor's initial one
|
2023-10-24 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VerilatedFst::declare(uint32_t code, const char* name, int dtypenum,
|
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum, bool bussed,
|
|
|
|
int msb, int lsb) {
|
|
|
|
const int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
|
|
|
|
|
|
|
|
const std::string hierarchicalName = m_prefixStack.back().first + name;
|
|
|
|
|
|
|
|
const bool enabled = Super::declCode(code, hierarchicalName, bits);
|
|
|
|
if (!enabled) return;
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2023-10-24 15:33:29 +00:00
|
|
|
assert(hierarchicalName.rfind(' ') != std::string::npos);
|
2018-10-02 22:42:53 +00:00
|
|
|
std::stringstream name_ss;
|
2023-10-24 15:33:29 +00:00
|
|
|
name_ss << lastWord(hierarchicalName);
|
2021-08-12 17:40:44 +00:00
|
|
|
if (array) name_ss << "[" << arraynum << "]";
|
2022-02-26 17:52:24 +00:00
|
|
|
if (bussed) name_ss << " [" << msb << ":" << lsb << "]";
|
2023-10-24 15:33:29 +00:00
|
|
|
const std::string name_str = name_ss.str();
|
|
|
|
|
|
|
|
if (dtypenum > 0) fstWriterEmitEnumTableRef(m_fst, m_local2fstdtype[dtypenum]);
|
|
|
|
|
2024-01-12 18:09:34 +00:00
|
|
|
fstVarDir varDir = FST_VD_IMPLICIT;
|
2023-10-24 15:33:29 +00:00
|
|
|
switch (direction) {
|
|
|
|
case VerilatedTraceSigDirection::INOUT: varDir = FST_VD_INOUT; break;
|
|
|
|
case VerilatedTraceSigDirection::OUTPUT: varDir = FST_VD_OUTPUT; break;
|
|
|
|
case VerilatedTraceSigDirection::INPUT: varDir = FST_VD_INPUT; break;
|
|
|
|
case VerilatedTraceSigDirection::NONE: varDir = FST_VD_IMPLICIT; break;
|
|
|
|
}
|
2018-10-02 22:42:53 +00:00
|
|
|
|
2023-10-24 15:33:29 +00:00
|
|
|
fstVarType varType;
|
|
|
|
// Doubles have special decoding properties, so must indicate if a double
|
|
|
|
if (type == VerilatedTraceSigType::DOUBLE) {
|
|
|
|
if (kind == VerilatedTraceSigKind::PARAMETER) {
|
|
|
|
varType = FST_VT_VCD_REAL_PARAMETER;
|
|
|
|
} else {
|
|
|
|
varType = FST_VT_VCD_REAL;
|
|
|
|
}
|
2018-10-08 11:21:22 +00:00
|
|
|
}
|
2023-10-24 15:33:29 +00:00
|
|
|
// clang-format off
|
|
|
|
else if (kind == VerilatedTraceSigKind::PARAMETER) varType = FST_VT_VCD_PARAMETER;
|
|
|
|
else if (kind == VerilatedTraceSigKind::SUPPLY0) varType = FST_VT_VCD_SUPPLY0;
|
|
|
|
else if (kind == VerilatedTraceSigKind::SUPPLY1) varType = FST_VT_VCD_SUPPLY1;
|
|
|
|
else if (kind == VerilatedTraceSigKind::TRI) varType = FST_VT_VCD_TRI;
|
|
|
|
else if (kind == VerilatedTraceSigKind::TRI0) varType = FST_VT_VCD_TRI0;
|
|
|
|
else if (kind == VerilatedTraceSigKind::TRI1) varType = FST_VT_VCD_TRI1;
|
|
|
|
else if (kind == VerilatedTraceSigKind::WIRE) varType = FST_VT_VCD_WIRE;
|
|
|
|
//
|
|
|
|
else if (type == VerilatedTraceSigType::INTEGER) varType = FST_VT_VCD_INTEGER;
|
|
|
|
else if (type == VerilatedTraceSigType::BIT) varType = FST_VT_SV_BIT;
|
|
|
|
else if (type == VerilatedTraceSigType::LOGIC) varType = FST_VT_SV_LOGIC;
|
|
|
|
else if (type == VerilatedTraceSigType::INT) varType = FST_VT_SV_INT;
|
|
|
|
else if (type == VerilatedTraceSigType::SHORTINT) varType = FST_VT_SV_SHORTINT;
|
|
|
|
else if (type == VerilatedTraceSigType::LONGINT) varType = FST_VT_SV_LONGINT;
|
|
|
|
else if (type == VerilatedTraceSigType::BYTE) varType = FST_VT_SV_BYTE;
|
|
|
|
else if (type == VerilatedTraceSigType::EVENT) varType = FST_VT_VCD_EVENT;
|
|
|
|
else if (type == VerilatedTraceSigType::TIME) varType = FST_VT_VCD_TIME;
|
|
|
|
else { assert(0); /* Unreachable */ }
|
|
|
|
// clang-format on
|
2020-06-04 20:08:32 +00:00
|
|
|
|
2020-08-16 15:43:49 +00:00
|
|
|
const auto it = vlstd::as_const(m_code2symbol).find(code);
|
2020-06-04 20:08:32 +00:00
|
|
|
if (it == m_code2symbol.end()) { // New
|
|
|
|
m_code2symbol[code]
|
2023-10-24 15:33:29 +00:00
|
|
|
= fstWriterCreateVar(m_fst, varType, varDir, bits, name_str.c_str(), 0);
|
2018-10-02 22:42:53 +00:00
|
|
|
} else { // Alias
|
2023-10-24 15:33:29 +00:00
|
|
|
fstWriterCreateVar(m_fst, varType, varDir, bits, name_str.c_str(), it->second);
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declEvent(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum) {
|
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, false, 0, 0);
|
2022-11-23 09:07:14 +00:00
|
|
|
}
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declBit(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum) {
|
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, false, 0, 0);
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declBus(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum, int msb,
|
2023-10-23 15:01:55 +00:00
|
|
|
int lsb) {
|
2023-10-24 15:33:29 +00:00
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, true, msb, lsb);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declQuad(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum, int msb,
|
|
|
|
int lsb) {
|
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, true, msb, lsb);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declArray(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum, int msb,
|
|
|
|
int lsb) {
|
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, true, msb, lsb);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2023-10-23 15:01:55 +00:00
|
|
|
void VerilatedFst::declDouble(uint32_t code, uint32_t fidx, const char* name, int dtypenum,
|
2023-10-24 15:33:29 +00:00
|
|
|
VerilatedTraceSigDirection direction, VerilatedTraceSigKind kind,
|
|
|
|
VerilatedTraceSigType type, bool array, int arraynum) {
|
|
|
|
declare(code, name, dtypenum, direction, kind, type, array, arraynum, false, 63, 0);
|
2018-10-02 22:42:53 +00:00
|
|
|
}
|
|
|
|
|
2022-05-29 18:08:39 +00:00
|
|
|
//=============================================================================
|
|
|
|
// Get/commit trace buffer
|
|
|
|
|
2023-10-23 15:01:55 +00:00
|
|
|
VerilatedFst::Buffer* VerilatedFst::getTraceBuffer(uint32_t fidx) {
|
2022-07-18 14:32:14 +00:00
|
|
|
if (offload()) return new OffloadBuffer{*this};
|
|
|
|
return new Buffer{*this};
|
|
|
|
}
|
2022-05-29 18:08:39 +00:00
|
|
|
|
2022-07-18 14:32:14 +00:00
|
|
|
void VerilatedFst::commitTraceBuffer(VerilatedFst::Buffer* bufp) {
|
|
|
|
if (offload()) {
|
|
|
|
OffloadBuffer* const offloadBufferp = static_cast<OffloadBuffer*>(bufp);
|
|
|
|
if (offloadBufferp->m_offloadBufferWritep) {
|
|
|
|
m_offloadBufferWritep = offloadBufferp->m_offloadBufferWritep;
|
|
|
|
return; // Buffer will be deleted by the offload thread
|
|
|
|
}
|
2022-05-29 18:08:39 +00:00
|
|
|
}
|
|
|
|
delete bufp;
|
|
|
|
}
|
|
|
|
|
2022-07-20 10:27:10 +00:00
|
|
|
//=============================================================================
|
|
|
|
// Configure
|
|
|
|
|
|
|
|
void VerilatedFst::configure(const VerilatedTraceConfig& config) {
|
|
|
|
// If at least one model requests the FST writer thread, then use it
|
|
|
|
m_useFstWriterThread |= config.m_useFstWriterThread;
|
|
|
|
}
|
|
|
|
|
2022-05-29 18:08:39 +00:00
|
|
|
//=============================================================================
|
|
|
|
// VerilatedFstBuffer implementation
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// Trace rendering primitives
|
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
// Note: emit* are only ever called from one place (full* in
|
2022-05-28 11:20:35 +00:00
|
|
|
// verilated_trace_imp.h, which is included in this file at the top),
|
2020-04-25 18:37:59 +00:00
|
|
|
// so always inline them.
|
|
|
|
|
2022-11-23 09:07:14 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2024-09-10 23:14:52 +00:00
|
|
|
void VerilatedFstBuffer::emitEvent(uint32_t code) {
|
2022-11-23 09:08:02 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], "1");
|
2022-11-23 09:07:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitBit(uint32_t code, CData newval) {
|
2022-03-05 20:44:32 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
2020-04-19 22:57:36 +00:00
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], newval ? "1" : "0");
|
|
|
|
}
|
2020-04-29 23:09:09 +00:00
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitCData(uint32_t code, CData newval, int bits) {
|
2020-04-29 23:09:09 +00:00
|
|
|
char buf[VL_BYTESIZE];
|
2022-03-05 20:44:32 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
2020-04-29 23:09:09 +00:00
|
|
|
cvtCDataToStr(buf, newval << (VL_BYTESIZE - bits));
|
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2020-04-29 23:09:09 +00:00
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitSData(uint32_t code, SData newval, int bits) {
|
2020-04-29 23:09:09 +00:00
|
|
|
char buf[VL_SHORTSIZE];
|
2022-03-05 20:44:32 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
2020-04-29 23:09:09 +00:00
|
|
|
cvtSDataToStr(buf, newval << (VL_SHORTSIZE - bits));
|
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2020-04-29 23:09:09 +00:00
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitIData(uint32_t code, IData newval, int bits) {
|
2020-04-29 23:09:09 +00:00
|
|
|
char buf[VL_IDATASIZE];
|
2022-03-05 20:44:32 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
2020-04-29 23:09:09 +00:00
|
|
|
cvtIDataToStr(buf, newval << (VL_IDATASIZE - bits));
|
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
|
2020-04-19 22:57:36 +00:00
|
|
|
}
|
2020-04-29 23:09:09 +00:00
|
|
|
|
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitQData(uint32_t code, QData newval, int bits) {
|
2020-04-29 23:09:09 +00:00
|
|
|
char buf[VL_QUADSIZE];
|
2022-03-05 20:44:32 +00:00
|
|
|
VL_DEBUG_IFDEF(assert(m_symbolp[code]););
|
2020-04-29 23:09:09 +00:00
|
|
|
cvtQDataToStr(buf, newval << (VL_QUADSIZE - bits));
|
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitWData(uint32_t code, const WData* newvalp, int bits) {
|
2020-04-29 23:09:09 +00:00
|
|
|
int words = VL_WORDS_I(bits);
|
2022-11-13 22:40:50 +00:00
|
|
|
char* wp = m_strbufp;
|
2020-04-29 23:09:09 +00:00
|
|
|
// Convert the most significant word
|
|
|
|
const int bitsInMSW = VL_BITBIT_E(bits) ? VL_BITBIT_E(bits) : VL_EDATASIZE;
|
|
|
|
cvtEDataToStr(wp, newvalp[--words] << (VL_EDATASIZE - bitsInMSW));
|
|
|
|
wp += bitsInMSW;
|
|
|
|
// Convert the remaining words
|
|
|
|
while (words > 0) {
|
|
|
|
cvtEDataToStr(wp, newvalp[--words]);
|
|
|
|
wp += VL_EDATASIZE;
|
|
|
|
}
|
2022-11-13 22:40:50 +00:00
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], m_strbufp);
|
2020-04-29 23:09:09 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 18:37:59 +00:00
|
|
|
VL_ATTR_ALWINLINE
|
2022-05-29 18:08:39 +00:00
|
|
|
void VerilatedFstBuffer::emitDouble(uint32_t code, double newval) {
|
2020-04-19 22:57:36 +00:00
|
|
|
fstWriterEmitValueChange(m_fst, m_symbolp[code], &newval);
|
|
|
|
}
|