From c024ff08363a416e781b58f5db452b0ed40e73b5 Mon Sep 17 00:00:00 2001 From: Mateusz Gancarz Date: Tue, 4 Mar 2025 15:29:35 +0100 Subject: [PATCH] [#74021] remove code related to SAIF file rollover --- include/verilated_saif_c.cpp | 60 ++---------------------- include/verilated_saif_c.h | 18 +++---- test_regress/t/t_trace_cat_saif.cpp | 56 ---------------------- test_regress/t/t_trace_cat_saif.py | 25 ---------- test_regress/t/t_trace_cat_saif_0000.out | 29 ------------ test_regress/t/t_trace_cat_saif_0100.out | 30 ------------ 6 files changed, 9 insertions(+), 209 deletions(-) delete mode 100644 test_regress/t/t_trace_cat_saif.cpp delete mode 100755 test_regress/t/t_trace_cat_saif.py delete mode 100644 test_regress/t/t_trace_cat_saif_0000.out delete mode 100644 test_regress/t/t_trace_cat_saif_0100.out diff --git a/include/verilated_saif_c.cpp b/include/verilated_saif_c.cpp index 96b41f291..727ba5d67 100644 --- a/include/verilated_saif_c.cpp +++ b/include/verilated_saif_c.cpp @@ -121,68 +121,15 @@ void VerilatedSaif::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) { if (isOpen()) return; // Set member variables - m_filename = filename; // "" is ok, as someone may overload open + m_filename = filename; // "" is ok, as someone may overload open - openNextImp(m_rolloverSize != 0); - if (!isOpen()) return; - - m_currentTimeOrigin = m_totalTime; initializeSaifFileContents(); Super::traceInit(); - - // When using rollover, the first chunk contains the header only. - if (m_rolloverSize) openNextImp(true); } void VerilatedSaif::openNext(bool incFilename) VL_MT_SAFE_EXCLUDES(m_mutex) { - // Open next filename in concat sequence, mangle filename if - // incFilename is true. - const VerilatedLockGuard lock{m_mutex}; - openNextImp(incFilename); -} - -void VerilatedSaif::openNextImp(bool incFilename) { - closePrev(); // Close existing - if (incFilename) { - // Find _0000.{ext} in filename - std::string name = m_filename; - const size_t pos = name.rfind('.'); - if (pos > 8 && 0 == std::strncmp("_cat", name.c_str() + pos - 8, 4) - && std::isdigit(name.c_str()[pos - 4]) && std::isdigit(name.c_str()[pos - 3]) - && std::isdigit(name.c_str()[pos - 2]) && std::isdigit(name.c_str()[pos - 1])) { - // Increment code. - if ((++(name[pos - 1])) > '9') { - name[pos - 1] = '0'; - if ((++(name[pos - 2])) > '9') { - name[pos - 2] = '0'; - if ((++(name[pos - 3])) > '9') { - name[pos - 3] = '0'; - if ((++(name[pos - 4])) > '9') { // - name[pos - 4] = '0'; - } - } - } - } - } else { - // Append _cat0000 - name.insert(pos, "_cat0000"); - } - m_filename = name; - } - if (VL_UNCOVERABLE(m_filename[0] == '|')) { - assert(0); // LCOV_EXCL_LINE // Not supported yet. - } else { - // cppcheck-suppress duplicateExpression - if (!m_filep->open(m_filename)) { - // User code can check isOpen() - m_isOpen = false; - return; - } - } - m_isOpen = true; - constDump(true); // First dump must containt the const signals - fullDump(true); // First dump must be full + // noop, SAIF only needs one file per trace } void VerilatedSaif::initializeSaifFileContents() { @@ -198,11 +145,10 @@ void VerilatedSaif::initializeSaifFileContents() { } bool VerilatedSaif::preChangeDump() { - if (VL_UNLIKELY(m_rolloverSize)) openNextImp(true); return isOpen(); } -void VerilatedSaif::emitTimeChange(uint64_t timeui) { m_totalTime = timeui; } +void VerilatedSaif::emitTimeChange(uint64_t timeui) { m_time = timeui; } VerilatedSaif::~VerilatedSaif() { close(); diff --git a/include/verilated_saif_c.h b/include/verilated_saif_c.h index 33e6be830..0e236433c 100644 --- a/include/verilated_saif_c.h +++ b/include/verilated_saif_c.h @@ -164,7 +164,6 @@ private: bool m_fileNewed; // m_filep needs destruction bool m_isOpen = false; // True indicates open file std::string m_filename; // Filename we're writing to (if open) - uint64_t m_rolloverSize = 0; // File size to rollover at int m_indent = 0; // indentation size in spaces @@ -175,15 +174,14 @@ private: std::unordered_map m_activity; // map of variables codes mapped to their activity objects std::vector> m_activityArena; // memory pool for signals bits objects - uint64_t m_totalTime{0}; // total time of the currently traced simulation - uint64_t m_currentTimeOrigin{0}; + uint64_t m_time{0}; // total time of the currently traced simulation // stack of declared scopes combined names std::vector> m_prefixStack{ {"", VerilatedTracePrefixType::SCOPE_MODULE}}; // METHODS - VL_ATTR_ALWINLINE uint64_t currentTime() const { return m_totalTime - m_currentTimeOrigin; } + VL_ATTR_ALWINLINE uint64_t currentTime() const { return m_time; } void initializeSaifFileContents(); void finalizeSaifFileContents(); @@ -204,7 +202,6 @@ private: void clearCurrentlyCollectedData(); - void openNextImp(bool incFilename); void closePrev(); void closeErr(); void declare(uint32_t code, const char* name, const char* wirep, bool array, int arraynum, @@ -241,7 +238,7 @@ public: // ACCESSORS // Set size in bytes after which new file should be created. - void rolloverSize(uint64_t size) VL_MT_SAFE { m_rolloverSize = size; } + void rolloverSize(uint64_t size) VL_MT_SAFE { /* noop */ } // METHODS - All must be thread safe // Open the file; call isOpen() to see if errors @@ -380,12 +377,9 @@ public: /// The header is only in the first file created, this allows /// "cat" to be used to combine the header plus any number of data files. void openNext(bool incFilename = true) VL_MT_SAFE { m_sptrace.openNext(incFilename); } - /// Set size in bytes after which new file should be created - /// This will create a header file, followed by each separate file - /// which might be larger than the given size (due to chunking and - /// alignment to a start of a given time's dump). Any file but the - /// first may be removed. Cat files together to create viewable saif. - void rolloverSize(size_t size) VL_MT_SAFE { m_sptrace.rolloverSize(size); } + + void rolloverSize(size_t size) VL_MT_SAFE { /* noop */ } + /// Close dump void close() VL_MT_SAFE { m_sptrace.close(); diff --git a/test_regress/t/t_trace_cat_saif.cpp b/test_regress/t/t_trace_cat_saif.cpp deleted file mode 100644 index 779f5cfb7..000000000 --- a/test_regress/t/t_trace_cat_saif.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -// -// DESCRIPTION: Verilator: Verilog Test module -// -// This file ONLY is placed under the Creative Commons Public Domain, for -// any use, without warranty, 2008 by Wilson Snyder. -// SPDX-License-Identifier: CC0-1.0 - -#include -#include - -#include - -#include VM_PREFIX_INCLUDE - -unsigned long long main_time = 0; -double sc_time_stamp() { return (double)main_time; } - -const char* trace_name() { - static char name[1000]; - VL_SNPRINTF(name, 1000, VL_STRINGIFY(TEST_OBJ_DIR) "/simpart_%04d.saif", (int)main_time); - return name; -} - -int main(int argc, char** argv) { - Verilated::debug(0); - Verilated::traceEverOn(true); - Verilated::commandArgs(argc, argv); - - std::unique_ptr top{new VM_PREFIX{"top"}}; - - std::unique_ptr tfp{new VerilatedSaifC}; - top->trace(tfp.get(), 99); - - tfp->open(trace_name()); - - top->clk = 0; - - while (main_time < 190) { // Creates 2 files - top->clk = !top->clk; - top->eval(); - - if ((main_time % 100) == 0) { - tfp->close(); - tfp->open(trace_name()); - } - tfp->dump((unsigned int)(main_time)); - ++main_time; - } - tfp->close(); - top->final(); - tfp.reset(); - top.reset(); - printf("*-* All Finished *-*\n"); - return 0; -} diff --git a/test_regress/t/t_trace_cat_saif.py b/test_regress/t/t_trace_cat_saif.py deleted file mode 100755 index e23910857..000000000 --- a/test_regress/t/t_trace_cat_saif.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -# DESCRIPTION: Verilator: Verilog Test driver/expect definition -# -# Copyright 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 - -import vltest_bootstrap - -test.scenarios('vlt_all') - -test.top_filename = "t/t_trace_cat_fst.v" - -test.compile(make_top_shell=False, - make_main=False, - v_flags2=["--trace-saif --exe", test.pli_filename]) - -test.execute() - -test.saif_identical(test.obj_dir + "/simpart_0000.saif", "t/" + test.name + "_0000.out") -test.saif_identical(test.obj_dir + "/simpart_0100.saif", "t/" + test.name + "_0100.out") - -test.passes() diff --git a/test_regress/t/t_trace_cat_saif_0000.out b/test_regress/t/t_trace_cat_saif_0000.out deleted file mode 100644 index c9acdd616..000000000 --- a/test_regress/t/t_trace_cat_saif_0000.out +++ /dev/null @@ -1,29 +0,0 @@ -(SAIFILE -(SAIFVERSION "2.0") -(DIRECTION "backward") -(DESIGN "foo") -(PROGRAM_NAME "Verilator") -(VERSION "5.032") -(DIVIDER / ) -(TIMESCALE 1ps) -(DURATION 99) - (INSTANCE top - (NET - (clk (T0 49) (T1 50) (TZ 0) (TX 0) (TB 0) (TC 100)) - ) - (INSTANCE t - (NET - (clk (T0 49) (T1 50) (TZ 0) (TX 0) (TB 0) (TC 100)) - (cyc\[0\] (T0 50) (T1 49) (TZ 0) (TX 0) (TB 0) (TC 49)) - (cyc\[1\] (T0 51) (T1 48) (TZ 0) (TX 0) (TB 0) (TC 24)) - (cyc\[2\] (T0 51) (T1 48) (TZ 0) (TX 0) (TB 0) (TC 12)) - (cyc\[3\] (T0 51) (T1 48) (TZ 0) (TX 0) (TB 0) (TC 6)) - (cyc\[4\] (T0 64) (T1 35) (TZ 0) (TX 0) (TB 0) (TC 3)) - (cyc\[5\] (T0 64) (T1 35) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[1\] (T0 0) (T1 99) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[3\] (T0 0) (T1 99) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[5\] (T0 0) (T1 99) (TZ 0) (TX 0) (TB 0) (TC 1)) - ) - ) - ) -) diff --git a/test_regress/t/t_trace_cat_saif_0100.out b/test_regress/t/t_trace_cat_saif_0100.out deleted file mode 100644 index e1099149c..000000000 --- a/test_regress/t/t_trace_cat_saif_0100.out +++ /dev/null @@ -1,30 +0,0 @@ -(SAIFILE -(SAIFVERSION "2.0") -(DIRECTION "backward") -(DESIGN "foo") -(PROGRAM_NAME "Verilator") -(VERSION "5.032") -(DIVIDER / ) -(TIMESCALE 1ps) -(DURATION 90) - (INSTANCE top - (NET - (clk (T0 45) (T1 45) (TZ 0) (TX 0) (TB 0) (TC 90)) - ) - (INSTANCE t - (NET - (clk (T0 45) (T1 45) (TZ 0) (TX 0) (TB 0) (TC 90)) - (cyc\[0\] (T0 46) (T1 44) (TZ 0) (TX 0) (TB 0) (TC 44)) - (cyc\[1\] (T0 45) (T1 45) (TZ 0) (TX 0) (TB 0) (TC 23)) - (cyc\[2\] (T0 45) (T1 45) (TZ 0) (TX 0) (TB 0) (TC 11)) - (cyc\[3\] (T0 45) (T1 45) (TZ 0) (TX 0) (TB 0) (TC 5)) - (cyc\[4\] (T0 33) (T1 57) (TZ 0) (TX 0) (TB 0) (TC 3)) - (cyc\[5\] (T0 62) (T1 28) (TZ 0) (TX 0) (TB 0) (TC 2)) - (cyc\[6\] (T0 29) (T1 61) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[1\] (T0 1) (T1 89) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[3\] (T0 1) (T1 89) (TZ 0) (TX 0) (TB 0) (TC 1)) - (unchanged\[5\] (T0 1) (T1 89) (TZ 0) (TX 0) (TB 0) (TC 1)) - ) - ) - ) -)