Skip to content

Commit 3ffea76

Browse files
committed
Add --no-std-waiver and default reading of standard lint waivers file (verilator#5607).
1 parent 09547f8 commit 3ffea76

19 files changed

+386
-269
lines changed

Changes

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Verilator 5.031 devel
1717
* Support basic constrained random for multi-dimensional dynamic array and queue (#5591). [Yilou Wang]
1818
* Support vpiDefName (#3906) (#5572). [Krzysztof Starecki]
1919
* Support `pure constraint`.
20-
* Add `--no-std-package` as subset-alias of `--no-std`.
21-
* Add `--waiver-multiline` for context-sensitive `--waiver-output`.
22-
* Add `lint_off --contents` in configuration files. (#5606)
20+
* Add `--no-std-waiver` and default reading of standard lint waivers file (#5607).
21+
* Add `--no-std-package` as subset-alias of `--no-std` (#5607).
22+
* Add `lint_off --contents` in configuration files (#5606).
23+
* Add `--waiver-multiline` for context-sensitive `--waiver-output` (#5608).
2324
* Add error on illegal enum base type (#3010). [Iztok Jeras]
2425
* Add error on `wait` with missing `.triggered` (#4457).
2526
* Add error when improperly storing to parameter (#5147). [Gökçe Aydos]

bin/verilator

+1
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ detailed descriptions of these arguments.
450450
--stats-vars Provide statistics on variables
451451
--no-std Prevent loading standard files
452452
--no-std-package Prevent parsing standard package
453+
--no-std-waiver Prevent parsing standard lint waivers
453454
--no-stop-fail Do not call $stop when assertion fails
454455
--structs-packed Convert all unpacked structures to packed structures
455456
-sv Enable SystemVerilog parsing

docs/guide/exe_verilator.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -1364,13 +1364,17 @@ Summary:
13641364
.. option:: --no-std
13651365

13661366
Prevents parsing standard input files, alias for
1367-
:opt:`--no-std-package`. This may be extended to prevent reading other
1368-
standardized files in future versions.
1367+
:opt:`--no-std-package`, :opt:`--no-std-waiver`. This may be extended
1368+
to prevent reading other standardized files in future versions.
13691369

13701370
.. option:: --no-std-package
13711371

13721372
Prevents parsing standard `std::` package file.
13731373

1374+
.. option:: --no-std-waiver
1375+
1376+
Prevents parsing standard lint waivers (`verilated_std_waiver.vlt`).
1377+
13741378
.. option:: --no-stop-fail
13751379

13761380
Don't call $stop when assertion fails. Simulation will continue.

include/verilated.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
//
1313
// DESCRIPTION: Verilator: Include in verilog files to hide verilator defines
1414

15-
`ifdef _VERILATED_V_ `else
15+
`ifndef _VERILATED_V_
1616
`define _VERILATED_V_ 1
1717

1818
// Hide verilator pragmas from other tools
19-
`ifdef VERILATOR `else
19+
`ifndef VERILATOR
2020
`define coverage_block_off
2121
`endif
2222

include/verilated_std.sv

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
/// \file
1515
/// \brief Verilated IEEE std:: header
1616
///
17-
/// This file is included automatically by Verilator when a std::mailbox or
18-
/// std::semaphore is referenced.
17+
/// This file is included automatically by Verilator, unless '--no-std-package'
18+
/// is used.
1919
///
2020
/// This file is not part of the Verilated public-facing API.
2121
/// It is only for internal use.

include/verilated_std_waiver.vlt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// DESCRIPTION: Verilator: built-in standard lint waivers
2+
//
3+
// Code available from: https://verilator.org
4+
//
5+
//*************************************************************************
6+
//
7+
// Copyright 2022-2024 by Wilson Snyder. This program is free software; you can
8+
// redistribute it and/or modify it under the terms of either the GNU Lesser
9+
// General Public License Version 3 or the Perl Artistic License Version 2.0.
10+
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
11+
//
12+
//*************************************************************************
13+
///
14+
/// \file
15+
/// \brief Verilated built-in standard lint waivers
16+
///
17+
/// This file is included automatically by Verilator, unless '--no-std-waiver'
18+
/// is used.
19+
///
20+
/// To assist in building new rules, use:
21+
/// 'verilator --waiver-multiline --waiver-output <filename>'
22+
///
23+
//*************************************************************************
24+
25+
`ifndef _VERILATED_STD_WAIVER_VLT_
26+
`define _VERILATED_STD_WAIVER_VLT_
27+
28+
`verilator_config
29+
30+
//=========================================================================
31+
// UVM
32+
33+
// Apply these rules to only UVM base files
34+
`define VLT_UVM_FILES -file "*/uvm_*.svh" -contents "*UVM_VERSION_STRING*"
35+
36+
// Whole-package file waivers
37+
lint_off -rule DECLFILENAME `VLT_UVM_FILES
38+
lint_off -rule VARHIDDEN `VLT_UVM_FILES
39+
lint_off -rule WIDTHEXPAND `VLT_UVM_FILES
40+
lint_off -rule WIDTHTRUNC `VLT_UVM_FILES
41+
42+
// Context-sensitive waivers
43+
lint_off -rule CASEINCOMPLETE `VLT_UVM_FILES -match "* case ({is_R, is_W})*"
44+
lint_off -rule CASEINCOMPLETE `VLT_UVM_FILES -match "* case(orig_severity)*"
45+
lint_off -rule CASTCONST `VLT_UVM_FILES -match "*class{}uvm_callback*"
46+
lint_off -rule CASTCONST `VLT_UVM_FILES -match "*class{}uvm_component*"
47+
lint_off -rule CASTCONST `VLT_UVM_FILES -match "*class{}uvm_event*"
48+
lint_off -rule CASTCONST `VLT_UVM_FILES -match "*class{}uvm_report_object*"
49+
lint_off -rule CASTCONST `VLT_UVM_FILES -match "*class{}uvm_sequence_item*"
50+
lint_off -rule MISINDENT `VLT_UVM_FILES -match "* foreach (abstractions[i])*"
51+
lint_off -rule MISINDENT `VLT_UVM_FILES -match "* foreach (lock_list[i])*"
52+
lint_off -rule MISINDENT `VLT_UVM_FILES -match "* rw_access.data=*"
53+
lint_off -rule MISINDENT `VLT_UVM_FILES -match "* uvm_cmdline_proc =*"
54+
lint_off -rule REALCVT `VLT_UVM_FILES -match "* m_time *"
55+
lint_off -rule REALCVT `VLT_UVM_FILES -match "*$realtime*"
56+
lint_off -rule SYMRSVDWORD `VLT_UVM_FILES -match "*'delete'*"
57+
lint_off -rule SYMRSVDWORD `VLT_UVM_FILES -match "*'list'*"
58+
lint_off -rule SYMRSVDWORD `VLT_UVM_FILES -match "*'map'*"
59+
lint_off -rule SYMRSVDWORD `VLT_UVM_FILES -match "*'override'*"
60+
lint_off -rule SYMRSVDWORD `VLT_UVM_FILES -match "*'volatile'*"
61+
62+
//=========================================================================
63+
`undef VLT_UVM_FILES
64+
`endif // Guard

src/V3FileLine.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ void FileLineSingleton::fileNameNumMapDumpJson(std::ostream& os) {
9292
std::string sep = "\n ";
9393
os << "\"files\": {";
9494
for (const auto& itr : m_namemap) {
95-
const std::string name
96-
= itr.first == V3Options::getStdPackagePath() ? "<verilated_std>" : itr.first;
97-
os << sep << '"' << filenameLetters(itr.second) << '"' << ": {\"filename\":\"" << name
95+
std::string filename = itr.first;
96+
if (filename == V3Options::getStdPackagePath()) {
97+
filename = "<verilated_std>";
98+
} else if (filename == V3Options::getStdWaiverPath()) {
99+
filename = "<verilated_std_waiver>";
100+
}
101+
os << sep << '"' << filenameLetters(itr.second) << '"' << ": {\"filename\":\"" << filename
98102
<< '"' << ", \"realpath\":\""
99103
<< V3OutFormatter::quoteNameControls(V3Os::filenameRealPath(itr.first)) << '"'
100104
<< ", \"language\":\"" << numberToLang(itr.second).ascii() << "\"}";

src/V3Global.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ void V3Global::readFiles() {
5858

5959
V3Parse parser{v3Global.rootp(), &filter, &parseSyms};
6060

61+
// Parse the std waivers
62+
if (v3Global.opt.stdWaiver()) {
63+
parser.parseFile(
64+
new FileLine{V3Options::getStdWaiverPath()}, V3Options::getStdWaiverPath(), false,
65+
"Cannot find verilated_std_waiver.vlt containing built-in lint waivers: ");
66+
}
6167
// Read .vlt files
6268
const V3StringSet& vltFiles = v3Global.opt.vltFiles();
6369
for (const string& filename : vltFiles) {

src/V3Options.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ string V3Options::filePath(FileLine* fl, const string& modname, const string& la
568568
// Return "" if not found.
569569
const string filename = V3Os::filenameCleanup(VName::dehash(modname));
570570
if (!V3Os::filenameIsRel(filename)) {
571-
// filename is an absolute path, so can find getStdPackagePath()
571+
// filename is an absolute path, so can find getStdPackagePath()/getStdWaiverPath()
572572
string exists = filePathCheckOneDir(filename, "");
573573
if (exists != "") return exists;
574574
}
@@ -631,7 +631,7 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
631631
V3LangCode V3Options::fileLanguage(const string& filename) {
632632
string ext = V3Os::filenameNonDir(filename);
633633
string::size_type pos;
634-
if (filename == V3Options::getStdPackagePath()) {
634+
if (filename == V3Options::getStdPackagePath() || filename == V3Options::getStdWaiverPath()) {
635635
return V3LangCode::mostRecent();
636636
} else if ((pos = ext.rfind('.')) != string::npos) {
637637
ext.erase(0, pos + 1);
@@ -793,6 +793,9 @@ string V3Options::getenvVERILATOR_SOLVER() {
793793
string V3Options::getStdPackagePath() {
794794
return V3Os::filenameJoin(getenvVERILATOR_ROOT(), "include", "verilated_std.sv");
795795
}
796+
string V3Options::getStdWaiverPath() {
797+
return V3Os::filenameJoin(getenvVERILATOR_ROOT(), "include", "verilated_std_waiver.vlt");
798+
}
796799

797800
string V3Options::getSupported(const string& var) {
798801
// If update below, also update V3Options::showVersion()
@@ -1258,7 +1261,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
12581261
DECL_OPTION("-json-edit-nums", OnOff, &m_jsonEditNums);
12591262
DECL_OPTION("-json-ids", OnOff, &m_jsonIds);
12601263
DECL_OPTION("-E", CbOnOff, [this](bool flag) {
1261-
if (flag) m_stdPackage = false;
1264+
if (flag) {
1265+
m_stdPackage = false;
1266+
m_stdWaiver = false;
1267+
}
12621268
m_preprocOnly = flag;
12631269
});
12641270
DECL_OPTION("-emit-accessors", OnOff, &m_emitAccessors);
@@ -1512,8 +1518,12 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
15121518
m_statsVars = flag;
15131519
m_stats |= flag;
15141520
});
1515-
DECL_OPTION("-std", CbOnOff, [this](bool flag) { m_stdPackage = flag; });
1521+
DECL_OPTION("-std", CbOnOff, [this](bool flag) {
1522+
m_stdPackage = flag;
1523+
m_stdWaiver = flag;
1524+
});
15161525
DECL_OPTION("-std-package", OnOff, &m_stdPackage);
1526+
DECL_OPTION("-std-waiver", OnOff, &m_stdWaiver);
15171527
DECL_OPTION("-stop-fail", OnOff, &m_stopFail);
15181528
DECL_OPTION("-structs-packed", OnOff, &m_structsPacked);
15191529
DECL_OPTION("-sv", CbCall, [this]() { m_defaultLanguage = V3LangCode::L1800_2023; });

src/V3Options.h

+3
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class V3Options final {
280280
bool m_reportUnoptflat = false; // main switch: --report-unoptflat
281281
bool m_savable = false; // main switch: --savable
282282
bool m_stdPackage = true; // main switch: --std-package
283+
bool m_stdWaiver = true; // main switch: --std-waiver
283284
bool m_structsPacked = false; // main switch: --structs-packed
284285
bool m_systemC = false; // main switch: --sc: System C instead of simple C++
285286
bool m_stats = false; // main switch: --stats
@@ -467,6 +468,7 @@ class V3Options final {
467468
bool stats() const { return m_stats; }
468469
bool statsVars() const { return m_statsVars; }
469470
bool stdPackage() const { return m_stdPackage; }
471+
bool stdWaiver() const { return m_stdWaiver; }
470472
bool structsPacked() const { return m_structsPacked; }
471473
bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined
472474
bool assertCaseOn() const { return m_assertCase || m_assert; }
@@ -741,6 +743,7 @@ class V3Options final {
741743
static string getenvVERILATOR_ROOT();
742744
static string getenvVERILATOR_SOLVER();
743745
static string getStdPackagePath();
746+
static string getStdWaiverPath();
744747
static string getSupported(const string& var);
745748
static bool systemCSystemWide();
746749
static bool systemCFound(); // SystemC installed, or environment points to it

src/V3ParseImp.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
332332
}
333333

334334
V3Stats::addStatSum(V3Stats::STAT_SOURCE_CHARS, m_ppBytes);
335-
if (debug() && modfilename != V3Options::getStdPackagePath()) dumpInputsFile();
335+
if (debug() && modfilename != V3Options::getStdPackagePath()
336+
&& modfilename != V3Options::getStdWaiverPath())
337+
dumpInputsFile();
336338

337339
// Parse it
338340
if (!v3Global.opt.preprocOnly()) {

src/V3Waiver.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
void V3Waiver::addEntry(V3ErrorCode errorCode, const std::string& filename, const std::string& msg)
2929
VL_MT_SAFE_EXCLUDES(s_mutex) {
3030
if (filename == V3Options::getStdPackagePath()) return;
31+
if (filename == V3Options::getStdWaiverPath()) return;
3132
const V3LockGuard lock{s_mutex};
3233

3334
string trimmsg = msg;

0 commit comments

Comments
 (0)