diff --git a/include/verilated.cpp b/include/verilated.cpp index 74aaf3fbd..7b9200363 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -2164,29 +2164,6 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary //=========================================================================== // Timescale conversion -// Helper function for conversion of timescale strings -// Converts (1|10|100)(s|ms|us|ns|ps|fs) to power of then -int VL_TIME_STR_CONVERT(const char* strp) VL_PURE { - int scale = 0; - if (!strp) return 0; - if (*strp++ != '1') return 0; - while (*strp == '0') { - ++scale; - ++strp; - } - switch (*strp++) { - case 's': break; - case 'm': scale -= 3; break; - case 'u': scale -= 6; break; - case 'n': scale -= 9; break; - case 'p': scale -= 12; break; - case 'f': scale -= 15; break; - default: return 0; - } - if ((scale < 0) && (*strp++ != 's')) return 0; - if (*strp) return 0; - return scale; -} static const char* vl_time_str(int scale) VL_PURE { static const char* const names[] = {"100s", "10s", "1s", "100ms", "10ms", "1ms", "100us", "10us", "1us", @@ -2308,8 +2285,9 @@ void VerilatedContext::checkMagic(const VerilatedContext* contextp) { } VerilatedContext::Serialized::Serialized() { - m_timeunit = VL_TIME_UNIT; // Initial value until overriden by _Vconfigure - m_timeprecision = VL_TIME_PRECISION; // Initial value until overriden by _Vconfigure + constexpr int8_t picosecond = -12; + m_timeunit = picosecond; // Initial value until overriden by _Vconfigure + m_timeprecision = picosecond; // Initial value until overriden by _Vconfigure } void VerilatedContext::assertOn(bool flag) VL_MT_SAFE { diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index c8fb91d3e..a7c3fcc73 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -256,25 +256,7 @@ extern void _vl_debug_print_w(int lbits, WDataInP const iwp); //========================================================================= // Pli macros -extern int VL_TIME_STR_CONVERT(const char* strp) VL_PURE; - -// These are deprecated and used only to establish the default precision/units. -// Use Verilator timescale-override for better control. // clang-format off -#ifndef VL_TIME_PRECISION -# ifdef VL_TIME_PRECISION_STR -# define VL_TIME_PRECISION VL_TIME_STR_CONVERT(VL_STRINGIFY(VL_TIME_PRECISION_STR)) -# else -# define VL_TIME_PRECISION (-12) ///< Timescale default units if not in Verilog - picoseconds -# endif -#endif -#ifndef VL_TIME_UNIT -# ifdef VL_TIME_UNIT_STR -# define VL_TIME_UNIT VL_TIME_STR_CONVERT(VL_STRINGIFY(VL_TIME_PRECISION_STR)) -# else -# define VL_TIME_UNIT (-12) ///< Timescale default units if not in Verilog - picoseconds -# endif -#endif #if defined(SYSTEMC_VERSION) /// Return current simulation time diff --git a/test_regress/t/t_timescale.cpp b/test_regress/t/t_timescale.cpp deleted file mode 100644 index 84c53c583..000000000 --- a/test_regress/t/t_timescale.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -// This file ONLY is placed under the Creative Commons Public Domain, for -// any use, without warranty, 2020 by Wilson Snyder. -// SPDX-License-Identifier: CC0-1.0 - -#include - -#include "TestCheck.h" - -#include VM_PREFIX_INCLUDE - -unsigned long long main_time = 0; -double sc_time_stamp() { return (double)main_time; } - -#include - -#define FILENM "t_timescale.cpp" - -int errors = 0; - -int main(int argc, char** argv, char** env) { - VM_PREFIX* top = new VM_PREFIX("top"); - - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100s"), 2); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10s"), 1); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1s"), 0); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100ms"), -1); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10ms"), -2); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1ms"), -3); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100us"), -4); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10us"), -5); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1us"), -6); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100ns"), -7); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10ns"), -8); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1ns"), -9); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100ps"), -10); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10ps"), -11); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1ps"), -12); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("100fs"), -13); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("10fs"), -14); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1fs"), -15); - - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1.5s"), 0); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1s "), 0); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("1ss"), 0); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT("s"), 0); - TEST_CHECK_EQ(VL_TIME_STR_CONVERT(0), 0); - - top->final(); - VL_DO_DANGLING(delete top, top); - printf("*-* All Finished *-*\n"); - - return errors ? 10 : 0; -} diff --git a/test_regress/t/t_timescale.pl b/test_regress/t/t_timescale.pl deleted file mode 100755 index 1bab927e5..000000000 --- a/test_regress/t/t_timescale.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl -if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } -# DESCRIPTION: Verilator: Verilog Test driver/expect definition -# -# Copyright 2003-2019 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 - -scenarios(vlt_all => 1); - -compile( - make_top_shell => 0, - make_main => 0, - v_flags2 => ["--exe $Self->{t_dir}/t_timescale.cpp"], - ); - -execute( - check_finished => 1, - ); - -ok(1); -1; diff --git a/test_regress/t/t_timescale.v b/test_regress/t/t_timescale.v deleted file mode 100644 index 396bc9b35..000000000 --- a/test_regress/t/t_timescale.v +++ /dev/null @@ -1,3 +0,0 @@ -module t; - -endmodule