From d40d9449166ecd744adabbfd948c0f0e5a49a5c5 Mon Sep 17 00:00:00 2001 From: Mateusz Gancarz Date: Wed, 26 Feb 2025 15:20:41 +0100 Subject: [PATCH] [#73220] add proper t_trace_saif_sc_unsup test --- include/verilated_saif_sc.cpp | 24 ---------- include/verilated_saif_sc.h | 57 ------------------------ src/V3Options.cpp | 6 ++- test_regress/t/t_trace_saif_sc_unsup.out | 3 ++ test_regress/t/t_trace_saif_sc_unsup.py | 8 ++-- 5 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 include/verilated_saif_sc.cpp delete mode 100644 include/verilated_saif_sc.h create mode 100644 test_regress/t/t_trace_saif_sc_unsup.out diff --git a/include/verilated_saif_sc.cpp b/include/verilated_saif_sc.cpp deleted file mode 100644 index 9ff52dcc7..000000000 --- a/include/verilated_saif_sc.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -//============================================================================= -// -// Code available from: https://verilator.org -// -// Copyright 2001-2025 by Wilson Snyder. This program is free software; you -// 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 -// -//============================================================================= -/// -/// \file -/// \brief Verilated tracing in SAIF Format implementation code -/// -/// This file is deprecated, only verilated_saif_sc.h is needed. -/// It is provided only for backward compatibility with user's linker scripts. -/// -//============================================================================= - -#ifdef VL_NO_LEGACY -#error "verilated_saif_sc.cpp is deprecated; verilated_saif_sc.h is self-sufficient" -#endif diff --git a/include/verilated_saif_sc.h b/include/verilated_saif_sc.h deleted file mode 100644 index 088bb70ac..000000000 --- a/include/verilated_saif_sc.h +++ /dev/null @@ -1,57 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -//============================================================================= -// -// Copyright 2001-2025 by Wilson Snyder. This program is free software; you 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 -// -//============================================================================= -/// -/// \file -/// \brief Verilated tracing in SAIF format for SystemC header -/// -/// User wrapper code should use this header when creating SAIF SystemC traces. -/// -/// This class is not threadsafe, as the SystemC kernel is not threadsafe. -/// -//============================================================================= - -#ifndef VERILATOR_VERILATED_SAIF_SC_H_ -#define VERILATOR_VERILATED_SAIF_SC_H_ - -#include "verilatedos.h" - -#include "verilated_sc_trace.h" -#include "verilated_saif_c.h" - -//============================================================================= -// VerilatedSaifSc -/// Trace file used to create SAIF dump for SystemC version of Verilated models. It's very similar -/// to its C version (see the class VerilatedSaifC) - -class VerilatedSaifSc final : VerilatedScTraceBase, public VerilatedSaifC { - // CONSTRUCTORS - VL_UNCOPYABLE(VerilatedSaifSc); - -public: - VerilatedSaifSc() { - spTrace()->set_time_unit(VerilatedScTraceBase::getScTimeUnit()); - spTrace()->set_time_resolution(VerilatedScTraceBase::getScTimeResolution()); - VerilatedScTraceBase::enableDeltaCycles(false); - } - - // METHODS - // Override VerilatedSaifC. Must be called after starting simulation. - void open(const char* filename) override VL_MT_SAFE { - VerilatedScTraceBase::checkScElaborationDone(); - VerilatedSaifC::open(filename); - } - - // METHODS - for SC kernel - // Called from SystemC kernel - void cycle() override { VerilatedSaifC::dump(sc_core::sc_time_stamp().to_double()); } -}; - -#endif // Guard diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 04dab7502..1b66fa91d 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1640,7 +1640,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, DECL_OPTION("-top", Set, &m_topModule); DECL_OPTION("-top-module", Set, &m_topModule); DECL_OPTION("-trace", OnOff, &m_trace); - DECL_OPTION("-trace-saif", CbCall, [this]() { + DECL_OPTION("-trace-saif", CbCall, [this, fl]() { m_trace = true; m_traceFormat = TraceFormat::SAIF; }); @@ -1824,6 +1824,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, addIncDirUser(parseFileArg(optdir, string{valp})); }); + if (m_systemC && m_traceFormat == TraceFormat::SAIF) { + fl->v3warn(E_UNSUPPORTED, "Unsupported: SAIF trace with SystemC."); + } + parser.finalize(); for (int i = 0; i < argc;) { diff --git a/test_regress/t/t_trace_saif_sc_unsup.out b/test_regress/t/t_trace_saif_sc_unsup.out new file mode 100644 index 000000000..39aa5fd81 --- /dev/null +++ b/test_regress/t/t_trace_saif_sc_unsup.out @@ -0,0 +1,3 @@ +%Error-UNSUPPORTED: Unsupported: SAIF trace with SystemC. + ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest +%Error: Exiting due to diff --git a/test_regress/t/t_trace_saif_sc_unsup.py b/test_regress/t/t_trace_saif_sc_unsup.py index 34ca93af1..dc1c163e4 100755 --- a/test_regress/t/t_trace_saif_sc_unsup.py +++ b/test_regress/t/t_trace_saif_sc_unsup.py @@ -9,15 +9,13 @@ import vltest_bootstrap -test.scenarios('vlt_all') +test.scenarios('linter') test.top_filename = "t/t_trace_fst_sc.v" if not test.have_sc: test.skip("No SystemC installed") -test.compile(verilator_flags2=["--trace-saif --sc"]) +test.lint(fails=test.vlt_all, verilator_flags2=["--sc --trace-saif --lint-only"], expect_filename=test.golden_filename) -test.execute() - -test.passes() +test.passes() \ No newline at end of file