From 5be08138935354f70ec3a80a296a9d76458106d1 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 8 Jul 2023 13:20:40 -0400 Subject: [PATCH] Explicity reference std:: in header files (#4338). No functional change intended. --- docs/guide/faq.rst | 2 +- docs/internals.rst | 2 +- include/verilated_cov.cpp | 6 +- src/V3Error.h | 6 +- src/V3OptionParser.h | 2 +- src/V3ParseSym.h | 2 +- src/V3Simulate.h | 4 +- src/V3SymTable.h | 3 +- src/V3WidthCommit.h | 8 +- src/VlcBucket.h | 8 +- src/VlcMain.cpp | 18 +-- src/VlcPoint.h | 4 +- src/VlcTest.h | 21 +-- src/VlcTop.cpp | 4 +- test_regress/t/t_dpi_accessors.cpp | 139 +++++++++--------- .../t/t_trace_open_wrong_order_bad.cpp | 2 - test_regress/t/t_vpi_get.cpp | 2 +- 17 files changed, 113 insertions(+), 120 deletions(-) diff --git a/docs/guide/faq.rst b/docs/guide/faq.rst index 621b0e3b5..d02559a7b 100644 --- a/docs/guide/faq.rst +++ b/docs/guide/faq.rst @@ -486,7 +486,7 @@ From the sc_main.cpp file, you'd then: #include "Vour.h" #include "Vour_our.h" - cout << "clock is " << top->our->clk << endl; + std::cout << "clock is " << top->our->clk << std::endl; In this example, clk is a bool you can read or set as any other variable. diff --git a/docs/internals.rst b/docs/internals.rst index ca4b626e4..136c90265 100644 --- a/docs/internals.rst +++ b/docs/internals.rst @@ -2123,7 +2123,7 @@ Or in a hand-written C++ wrapper: :: #ifdef TEST_VERBOSE - cout << "Read a=" << a << endl; + std::cout << "Read a=" << a << std::endl; #endif A filename that should be used to check the output results is given with diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index 901adada1..8fe4e99be 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -210,8 +210,8 @@ private: std::string result = prefix + "*" + suffix; - // cout << "\nch pre="<= (level))) { cout << stmsg; } \ + if (VL_UNCOVERABLE(debug() >= (level))) { std::cout << stmsg; } \ } while (false) #ifdef VL_DEBUG diff --git a/src/V3OptionParser.h b/src/V3OptionParser.h index 264d209ee..cc22b8f0a 100644 --- a/src/V3OptionParser.h +++ b/src/V3OptionParser.h @@ -43,7 +43,7 @@ class VOptionBool; // if (int consumed = parser.parse(i, argc, argv)) { // i += consumed; // } else { // error -// cerr << parser.getSuggestion(argv[i]) << endl; +// std::cerr << parser.getSuggestion(argv[i]) << std::endl; // } // } // diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index 422e86c35..c29db09d3 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -119,7 +119,7 @@ public: if (VL_UNCOVERABLE(symCurrentp()->nodep() != nodep)) { // LCOV_EXCL_START if (debug()) { showUpward(); - dumpSelf(cout, "-mism: "); + dumpSelf(std::cout, "-mism: "); } nodep->v3fatalSrc("Symbols suggest ending " << symCurrentp()->nodep()->prettyTypeName() << " but parser thinks ending " diff --git a/src/V3Simulate.h b/src/V3Simulate.h index fa28b67b8..e73f111f7 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -178,8 +178,8 @@ public: m_whyNotNodep = nodep; if (debug() >= 5) { UINFO(0, "Clear optimizable: " << why); - if (nodep) cout << ": " << nodep; - cout << endl; + if (nodep) std::cout << ": " << nodep; + std::cout << std::endl; } m_whyNotOptimizable = why; std::ostringstream stack; diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 482753a5c..534aedd3e 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -123,7 +123,8 @@ public: << " " << entp->nodep() << endl); if (name != "" && m_idNameMap.find(name) != m_idNameMap.end()) { if (!V3Error::errorCount()) { // Else may have just reported warning - if (debug() >= 9 || V3Error::debugDefault()) dumpSelf(cout, "- err-dump: ", 1); + if (debug() >= 9 || V3Error::debugDefault()) + dumpSelf(std::cout, "- err-dump: ", 1); entp->nodep()->v3fatalSrc("Inserting two symbols with same name: " << name); } } else { diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index b0d8f6662..135b559a6 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -110,10 +110,10 @@ private: AstBasicDType* const newp = nodep->findInsertSameDType(bdtypep); if (newp != bdtypep && debug() >= 9) { UINFO(9, "dtype replacement "); - nodep->dumpSmall(cout); - cout << " ----> "; - newp->dumpSmall(cout); - cout << endl; + nodep->dumpSmall(std::cout); + std::cout << " ----> "; + newp->dumpSmall(std::cout); + std::cout << std::endl; } return newp; } diff --git a/src/VlcBucket.h b/src/VlcBucket.h index 5fa253af0..cca198bde 100644 --- a/src/VlcBucket.h +++ b/src/VlcBucket.h @@ -115,11 +115,11 @@ public: } void dump() const { - cout << "# "; - for (uint64_t i = 0; i < m_dataSize; i++) { - if (hits(i)) cout << "," << i; + std::cout << "# "; + for (uint64_t i = 0; i < m_dataSize; ++i) { + if (hits(i)) std::cout << "," << i; } - cout << endl; + std::cout << std::endl; } }; diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index f6352cb03..e3b13fdee 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -98,18 +98,18 @@ void VlcOptions::parseOptsList(int argc, char** argv) { } void VlcOptions::showVersion(bool verbose) { - cout << version(); - cout << endl; + std::cout << version(); + std::cout << endl; if (!verbose) return; - cout << endl; - cout << "Copyright 2003-2023 by Wilson Snyder. Verilator is free software; you can\n"; - cout << "redistribute it and/or modify the Verilator internals under the terms of\n"; - cout << "either the GNU Lesser General Public License Version 3 or the Perl Artistic\n"; - cout << "License Version 2.0.\n"; + std::cout << endl; + std::cout << "Copyright 2003-2023 by Wilson Snyder. Verilator is free software; you can\n"; + std::cout << "redistribute it and/or modify the Verilator internals under the terms of\n"; + std::cout << "either the GNU Lesser General Public License Version 3 or the Perl Artistic\n"; + std::cout << "License Version 2.0.\n"; - cout << endl; - cout << "See https://verilator.org for documentation\n"; + std::cout << endl; + std::cout << "See https://verilator.org for documentation\n"; } //###################################################################### diff --git a/src/VlcPoint.h b/src/VlcPoint.h index f2ed5b287..81578f9b1 100644 --- a/src/VlcPoint.h +++ b/src/VlcPoint.h @@ -129,10 +129,10 @@ public: // METHODS void dump() { UINFO(2, "dumpPoints...\n"); - VlcPoint::dumpHeader(cout); + VlcPoint::dumpHeader(std::cout); for (const auto& i : *this) { const VlcPoint& point = pointNumber(i.second); - point.dump(cout); + point.dump(std::cout); } } VlcPoint& pointNumber(uint64_t num) { return m_points[num]; } diff --git a/src/VlcTest.h b/src/VlcTest.h index 3f960b9fb..0a60758ba 100644 --- a/src/VlcTest.h +++ b/src/VlcTest.h @@ -63,20 +63,21 @@ public: // METHODS static void dumpHeader() { - cout << "Tests:\n"; - // cout<<" Testrun, Computrons,"; // Currently not loaded - cout << " Covered, Rank, RankPts, Filename\n"; + std::cout << "Tests:\n"; + // std::cout<<" Testrun, Computrons,"; // Currently not loaded + std::cout << " Covered, Rank, RankPts, Filename\n"; } void dump(bool bucketsToo) { if (testrun() || computrons() != 0.0) { // currently unused // LCOV_EXCL_LINE - cout << " " << std::setw(8) << std::setfill('0') << testrun() // LCOV_EXCL_LINE - << ", " << std::setw(7) << std::setfill(' ') << computrons() // LCOV_EXCL_LINE - << ","; // LCOV_EXCL_LINE + std::cout << " " << std::setw(8) << std::setfill('0') << testrun() // LCOV_EXCL_LINE + << ", " << std::setw(7) << std::setfill(' ') + << computrons() // LCOV_EXCL_LINE + << ","; // LCOV_EXCL_LINE } - cout << " " << std::setw(7) << std::setfill(' ') << bucketsCovered(); - cout << ", " << std::setw(7) << std::setfill(' ') << rank(); - cout << ", " << std::setw(7) << std::setfill(' ') << rankPoints(); - cout << ", \"" << name() << "\"\n"; + std::cout << " " << std::setw(7) << std::setfill(' ') << bucketsCovered(); + std::cout << ", " << std::setw(7) << std::setfill(' ') << rank(); + std::cout << ", " << std::setw(7) << std::setfill(' ') << rankPoints(); + std::cout << ", \"" << name() << "\"\n"; if (bucketsToo) m_buckets.dump(); } }; diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index db60851b0..bf5038450 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -249,8 +249,8 @@ void VlcTop::annotateCalcNeeded() { } } const float pct = totCases ? (100 * totOk / totCases) : 0; - cout << "Total coverage (" << totOk << "/" << totCases << ") "; - cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%\n"; + std::cout << "Total coverage (" << totOk << "/" << totCases << ") "; + std::cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%\n"; if (totOk != totCases) cout << "See lines with '%00' in " << opt.annotateOut() << '\n'; } diff --git a/test_regress/t/t_dpi_accessors.cpp b/test_regress/t/t_dpi_accessors.cpp index cf13572d4..b5952071c 100644 --- a/test_regress/t/t_dpi_accessors.cpp +++ b/test_regress/t/t_dpi_accessors.cpp @@ -18,13 +18,6 @@ #include #include -using std::cout; -using std::dec; -using std::endl; -using std::hex; -using std::setfill; -using std::setw; - // Convenience function to check we didn't finish unexpectedly static void checkFinish(VerilatedContext* contextp, const char* msg) { if (contextp->gotFinish()) { @@ -37,7 +30,7 @@ static void checkFinish(VerilatedContext* contextp, const char* msg) { // mode. static void logReg(int clk, const char* desc, int val, const char* note) { #ifdef TEST_VERBOSE - cout << "clk = " << clk << ", " << desc << " = " << val << note << endl; + std::cout << "clk = " << clk << ", " << desc << " = " << val << note << std::endl; #endif } @@ -45,9 +38,9 @@ static void logReg(int clk, const char* desc, int val, const char* note) { // mode. static void logRegHex(int clk, const char* desc, int bitWidth, int val, const char* note) { #ifdef TEST_VERBOSE - cout << "clk = " << clk << ", " << desc << " = " << bitWidth << "\'h" << hex - << setw((bitWidth - 1) / 4 + 1) << setfill('0') << val << setfill(' ') << setw(0) << dec - << note << endl; + std::cout << "clk = " << clk << ", " << desc << " = " << bitWidth << "\'h" << std::hex + << std::setw((bitWidth - 1) / 4 + 1) << std::setfill('0') << val << std::setfill(' ') + << std::setw(0) << std::dec << note << std::endl; #endif } @@ -70,8 +63,8 @@ int main() { dut->eval(); #ifdef TEST_VERBOSE - cout << "Initial DPI values\n"; - cout << "==================\n"; + std::cout << "Initial DPI values\n"; + std::cout << "==================\n"; #endif int a = (int)a_read(); @@ -83,19 +76,19 @@ int main() { int f = (int)f_read(); #ifdef TEST_VERBOSE - cout << "Read a = " << a << endl; - cout << "Read b = 8'h" << hex << setw(2) << setfill('0') << b << setfill(' ') << setw(0) - << dec << endl; - cout << "Read mem32 = 8'h" << hex << setw(2) << setfill('0') << mem32 << setfill(' ') - << setw(0) << dec << endl; - cout << "Read c = " << c << endl; - cout << "Read d = 8'h" << hex << setw(2) << setfill('0') << d << setfill(' ') << setw(0) - << dec << endl; - cout << "Read e = 8'h" << hex << setw(2) << setfill('0') << e << setfill(' ') << setw(0) - << dec << endl; - cout << "Read f = 8'h" << hex << setw(2) << setfill('0') << f << setfill(' ') << setw(0) - << dec << endl; - cout << endl; + std::cout << "Read a = " << a << std::endl; + std::cout << "Read b = 8'h" << std::hex << std::setw(2) << std::setfill('0') << b + << std::setfill(' ') << std::setw(0) << std::dec << std::endl; + std::cout << "Read mem32 = 8'h" << std::hex << std::setw(2) << std::setfill('0') << mem32 + << std::setfill(' ') << std::setw(0) << std::dec << std::endl; + std::cout << "Read c = " << c << std::endl; + std::cout << "Read d = 8'h" << std::hex << std::setw(2) << std::setfill('0') << d + << std::setfill(' ') << std::setw(0) << std::dec << std::endl; + std::cout << "Read e = 8'h" << std::hex << std::setw(2) << std::setfill('0') << e + << std::setfill(' ') << std::setw(0) << std::dec << std::endl; + std::cout << "Read f = 8'h" << std::hex << std::setw(2) << std::setfill('0') << f + << std::setfill(' ') << std::setw(0) << std::dec << std::endl; + std::cout << std::endl; #endif checkResult((0 == a) && (0x00 == b) && (0x20 == mem32) && (1 == c) && (0xff == d) @@ -107,8 +100,8 @@ int main() { // Check we can read a scalar register. #ifdef TEST_VERBOSE - cout << "Test of scalar register reading\n"; - cout << "===============================\n"; + std::cout << "Test of scalar register reading\n"; + std::cout << "===============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -120,7 +113,7 @@ int main() { int a_after = (int)a_read(); logReg(dut->clk, "read a", a_after, " (after clk)"); #ifdef TEST_VERBOSE - cout << endl; + std::cout << std::endl; #endif // On a posedge, a should toggle, on a negedge it should stay the // same. @@ -133,8 +126,8 @@ int main() { // Check we can read a vector register. #ifdef TEST_VERBOSE - cout << "Test of vector register reading\n"; - cout << "===============================\n"; + std::cout << "Test of vector register reading\n"; + std::cout << "===============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -156,9 +149,9 @@ int main() { // Test we can read an array element #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of array element reading\n"; - cout << "=============================\n"; + std::cout << std::endl; + std::cout << "Test of array element reading\n"; + std::cout << "=============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -180,9 +173,9 @@ int main() { // Check we can read a scalar wire #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of scalar wire reading\n"; - cout << "===========================\n"; + std::cout << std::endl; + std::cout << "Test of scalar wire reading\n"; + std::cout << "===========================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -209,9 +202,9 @@ int main() { // Check we can read a vector wire #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of vector wire reading\n"; - cout << "===========================\n"; + std::cout << std::endl; + std::cout << "Test of vector wire reading\n"; + std::cout << "===========================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -239,9 +232,9 @@ int main() { // Check we can write a scalar register #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of scalar register writing\n"; - cout << "===============================\n"; + std::cout << std::endl; + std::cout << "Test of scalar register writing\n"; + std::cout << "===============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -268,9 +261,9 @@ int main() { // Check we can write a vector register #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of vector register writing\n"; - cout << "===============================\n"; + std::cout << std::endl; + std::cout << "Test of vector register writing\n"; + std::cout << "===============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -297,9 +290,9 @@ int main() { // Test we can write an array element #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of array element writing\n"; - cout << "=============================\n"; + std::cout << std::endl; + std::cout << "Test of array element writing\n"; + std::cout << "=============================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -326,9 +319,9 @@ int main() { // Check we can read a vector register slice #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of vector register slice reading\n"; - cout << "=====================================\n"; + std::cout << std::endl; + std::cout << "Test of vector register slice reading\n"; + std::cout << "=====================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -353,9 +346,9 @@ int main() { // Test we can read an array element slice #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of array element slice reading\n"; - cout << "===================================\n"; + std::cout << std::endl; + std::cout << "Test of array element slice reading\n"; + std::cout << "===================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -382,9 +375,9 @@ int main() { // Check we can read a vector wire slice #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of vector wire slice reading\n"; - cout << "=================================\n"; + std::cout << std::endl; + std::cout << "Test of vector wire slice reading\n"; + std::cout << "=================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -413,9 +406,9 @@ int main() { // Check we can write a vector register slice #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of vector register slice writing\n"; - cout << "=====================================\n"; + std::cout << std::endl; + std::cout << "Test of vector register slice writing\n"; + std::cout << "=====================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -452,9 +445,9 @@ int main() { // Test we can write an array element slice #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of array element slice writing\n"; - cout << "===================================\n"; + std::cout << std::endl; + std::cout << "Test of array element slice writing\n"; + std::cout << "===================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -497,9 +490,9 @@ int main() { // Check we can read complex registers #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of complex register reading\n"; - cout << "================================\n"; + std::cout << std::endl; + std::cout << "Test of complex register reading\n"; + std::cout << "================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -536,7 +529,7 @@ int main() { } #ifdef TEST_VERBOSE - cout << endl; + std::cout << std::endl; #endif checkFinish(contextp.get(), "t_dpi_accessors unexpected finish"); @@ -577,9 +570,9 @@ int main() { // Test we can write a complex register #ifdef TEST_VERBOSE - cout << endl; - cout << "Test of complex register writing\n"; - cout << "================================\n"; + std::cout << std::endl; + std::cout << "Test of complex register writing\n"; + std::cout << "================================\n"; #endif for (int i = 0; !contextp->gotFinish() && (i < 4); i++) { @@ -628,7 +621,7 @@ int main() { } #ifdef TEST_VERBOSE - cout << endl; + std::cout << std::endl; #endif checkFinish(contextp.get(), "t_dpi_accessors unexpected finish"); @@ -674,7 +667,7 @@ int main() { // Tidy up dut->final(); - cout << "*-* All Finished *-*\n"; + std::cout << "*-* All Finished *-*\n"; } // Local Variables: diff --git a/test_regress/t/t_trace_open_wrong_order_bad.cpp b/test_regress/t/t_trace_open_wrong_order_bad.cpp index 91945222f..9fac96261 100644 --- a/test_regress/t/t_trace_open_wrong_order_bad.cpp +++ b/test_regress/t/t_trace_open_wrong_order_bad.cpp @@ -11,8 +11,6 @@ #include "Vt_trace_open_wrong_order_bad.h" -using namespace std; - int main(int argc, char** argv) { VerilatedContext ctx; VerilatedVcdC tfp; diff --git a/test_regress/t/t_vpi_get.cpp b/test_regress/t/t_vpi_get.cpp index 132d2f39d..41f3df6b4 100644 --- a/test_regress/t/t_vpi_get.cpp +++ b/test_regress/t/t_vpi_get.cpp @@ -66,7 +66,7 @@ #define CHECK_RESULT_HEX(got, exp) \ if ((got) != (exp)) { \ std::cout << std::dec << "%Error: " << FILENM << ":" << __LINE__ << std::hex \ - << ": GOT = " << (got) << " EXP = " << (exp) << endl; \ + << ": GOT = " << (got) << " EXP = " << (exp) << std::endl; \ return __LINE__; \ }