Remove deprecated and unused timescale override defines

These have been 'deprecated' for 2 years and are otherwise unused except
for using a temporary placeholder value, which I have inlined with the
default value.

Also remove the now VL_TIME_STR_CONVERT utility function (and
corresponding unit tests), which have no references in any project on
GitHub.
This commit is contained in:
Geza Lore 2022-07-20 13:15:19 +01:00
parent 542e324869
commit 30e3edb81d
5 changed files with 3 additions and 124 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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 <verilated.h>
#include "TestCheck.h"
#include VM_PREFIX_INCLUDE
unsigned long long main_time = 0;
double sc_time_stamp() { return (double)main_time; }
#include <iostream>
#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;
}

View File

@ -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;

View File

@ -1,3 +0,0 @@
module t;
endmodule