diff --git a/src/V3AstNodeExpr.h b/src/V3AstNodeExpr.h index 8014553d1..374483b85 100644 --- a/src/V3AstNodeExpr.h +++ b/src/V3AstNodeExpr.h @@ -4872,7 +4872,7 @@ public: } ASTGEN_MEMBERS_AstCvtPackString; void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); } - string emitVerilog() override { return "%f$_CAST(%l)"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } string emitC() override { V3ERROR_NA_RETURN(""); } bool cleanOut() const override { return true; } bool cleanLhs() const override { return true; } diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index efdd2958c..f14b483e6 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -864,7 +864,7 @@ public: switch (nodep->ctlType()) { case VDumpCtlType::FILE: putns(nodep, "vlSymsp->_vm_contextp__->dumpfile("); - emitCvtPackStr(nodep->exprp()); + iterateConst(nodep->exprp()); puts(");\n"); break; case VDumpCtlType::VARS: @@ -927,7 +927,7 @@ public: puts("("); puts(cvtToStr(nodep->outp()->widthMin())); puts(", "); - emitCvtPackStr(nodep->searchp()); + iterateConst(nodep->searchp()); puts(", "); putbs(""); iterateAndNextConstNull(nodep->outp()); @@ -935,7 +935,7 @@ public: } void visit(AstTestPlusArgs* nodep) override { putns(nodep, "VL_TESTPLUSARGS_I("); - emitCvtPackStr(nodep->searchp()); + iterateConst(nodep->searchp()); puts(")"); } void visit(AstFError* nodep) override { @@ -965,16 +965,14 @@ public: } void visit(AstFOpen* nodep) override { putns(nodep, "VL_FOPEN_NN("); - emitCvtPackStr(nodep->filenamep()); + iterateConst(nodep->filenamep()); putbs(", "); - if (nodep->modep()->width() > 4 * 8) - nodep->modep()->v3error("$fopen mode should be <= 4 characters"); - emitCvtPackStr(nodep->modep()); + iterateConst(nodep->modep()); puts(");\n"); } void visit(AstFOpenMcd* nodep) override { putns(nodep, "VL_FOPEN_MCD_N("); - emitCvtPackStr(nodep->filenamep()); + iterateConst(nodep->filenamep()); puts(");\n"); } void visit(AstNodeReadWriteMem* nodep) override { @@ -1004,7 +1002,7 @@ public: } } putbs(", "); - emitCvtPackStr(nodep->filenamep()); + iterateConst(nodep->filenamep()); putbs(", "); { const bool need_ptr = !VN_IS(nodep->memp()->dtypep(), AssocArrayDType); @@ -1297,7 +1295,7 @@ public: puts(", "); if (nodep->suffixp()) { puts("true, "); - emitCvtPackStr(nodep->suffixp()); + iterateAndNextConstNull(nodep->suffixp()); } else { puts("false, \"\""); } diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 9b6f052a6..63bed1b20 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -283,6 +283,16 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public VNVisitorConst { void visit(AstCoverInc*) override {} // N/A void visit(AstCoverToggle*) override {} // N/A + void visit(AstCvtPackString* nodep) override { + putfs(nodep, ""); + if (AstConst* const lhsConstp = VN_CAST(nodep->lhsp(), Const)) { + putsQuoted(lhsConstp->num().toString()); + } else { + puts("string'("); + iterateAndNextConstNull(nodep->lhsp()); + puts(")"); + } + } void visit(AstTestPlusArgs* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); @@ -292,7 +302,9 @@ class EmitVBaseVisitorConst VL_NOT_FINAL : public VNVisitorConst { void visit(AstValuePlusArgs* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); - iterateChildrenConst(nodep); + iterateConstNull(nodep->searchp()); + putbs(", "); + iterateConstNull(nodep->outp()); puts(")"); } void visitNodeDisplay(AstNode* nodep, AstNode* fileOrStrgp, const string& text, diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 97cbbf73c..0cc6fd188 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -5893,17 +5893,16 @@ class WidthVisitor final : public VNVisitor { } void visit(AstDumpCtl* nodep) override { assertAtStatement(nodep); - // Just let all arguments seek their natural sizes - userIterateChildren(nodep, WidthVP{SELF, BOTH}.p()); + if (nodep->exprp()) iterateCheckString(nodep, "LHS", nodep->exprp(), BOTH); } void visit(AstFOpen* nodep) override { // Although a system function in IEEE, here a statement which sets the file pointer (MCD) - userIterateAndNext(nodep->filenamep(), WidthVP{SELF, BOTH}.p()); - userIterateAndNext(nodep->modep(), WidthVP{SELF, BOTH}.p()); + iterateCheckString(nodep, "filename", nodep->filenamep(), BOTH); + iterateCheckString(nodep, "mode", nodep->modep(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } void visit(AstFOpenMcd* nodep) override { - userIterateAndNext(nodep->filenamep(), WidthVP{SELF, BOTH}.p()); + iterateCheckString(nodep, "filename", nodep->filenamep(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } void visit(AstFClose* nodep) override { @@ -6005,7 +6004,7 @@ class WidthVisitor final : public VNVisitor { } void visit(AstNodeReadWriteMem* nodep) override { assertAtStatement(nodep); - userIterateAndNext(nodep->filenamep(), WidthVP{SELF, BOTH}.p()); + iterateCheckString(nodep, "filename", nodep->filenamep(), BOTH); userIterateAndNext(nodep->memp(), WidthVP{SELF, BOTH}.p()); const AstNodeDType* subp = nullptr; if (const AstAssocArrayDType* adtypep @@ -6037,13 +6036,13 @@ class WidthVisitor final : public VNVisitor { } void visit(AstTestPlusArgs* nodep) override { if (m_vup->prelim()) { - userIterateAndNext(nodep->searchp(), WidthVP{SELF, BOTH}.p()); + iterateCheckString(nodep, "LHS", nodep->searchp(), BOTH); nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return } } void visit(AstValuePlusArgs* nodep) override { if (m_vup->prelim()) { - userIterateAndNext(nodep->searchp(), WidthVP{SELF, BOTH}.p()); + iterateCheckString(nodep, "LHS", nodep->searchp(), BOTH); userIterateAndNext(nodep->outp(), WidthVP{SELF, BOTH}.p()); nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return } diff --git a/test_regress/t/t_debug_emitv.out b/test_regress/t/t_debug_emitv.out index aedb5a5ea..a5071f8e0 100644 --- a/test_regress/t/t_debug_emitv.out +++ b/test_regress/t/t_debug_emitv.out @@ -40,7 +40,7 @@ module Vt_debug_emitv_t; Iface the_ifaces[3:0] (); initial begin begin - if ($test$plusargs(40'h48454c4c4f)) begin + if ($test$plusargs("HELLO")) begin $display("Hello argument found."); end if ((Pkg::FOO == 'sh0)) begin @@ -49,7 +49,7 @@ module Vt_debug_emitv_t; if ((ZERO == 'sh0)) begin $write(""); end - if ($value$plusargs(56'h544553543d2564i1)) begin + if ($value$plusargs("TEST=%d", i1)) begin $display("value was %~", i1); end else begin @@ -185,10 +185,10 @@ module Vt_debug_emitv_t; : $c('sh1e))); $c(;); $display("%d", $c(0)); - fd = $fopen(72'h2f6465762f6e756c6c); + fd = $fopen("/dev/null"); ; $fclose(fd); - fd = $fopen(72'h2f6465762f6e756c6c, 8'h72); + fd = $fopen("/dev/null", "r"); ; $fgetc(fd); $fflush(fd); @@ -196,9 +196,9 @@ module Vt_debug_emitv_t; ; $fdisplay(32'h69203d20, "%~", sum); $fwrite(fd, "hello"); - $readmemh(fd, array); - $readmemh(fd, array, 'sh0); - $readmemh(fd, array, 'sh0, 'sh0); + $readmemh(string'(fd), array); + $readmemh(string'(fd), array, 'sh0); + $readmemh(string'(fd), array, 'sh0, 'sh0); sum = 'sh0; begin : unnamedblk3 int signed i; diff --git a/test_regress/t/t_sys_fopen_bad.out b/test_regress/t/t_sys_fopen_bad.out deleted file mode 100644 index 53525cf73..000000000 --- a/test_regress/t/t_sys_fopen_bad.out +++ /dev/null @@ -1,5 +0,0 @@ -%Error: t/t_sys_fopen_bad.v:14:34: $fopen mode should be <= 4 characters - 14 | file = $fopen("/dev/null", "somereallywidebad"); - | ^~~~~~~~~~~~~~~~~~~ - ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. -%Error: Exiting due to diff --git a/test_regress/t/t_sys_fopen_bad.py b/test_regress/t/t_sys_fopen_bad.py deleted file mode 100755 index e33e10acf..000000000 --- a/test_regress/t/t_sys_fopen_bad.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 -# DESCRIPTION: Verilator: Verilog Test driver/expect definition -# -# Copyright 2024 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') - -test.lint(fails=True, expect_filename=test.golden_filename) - -test.passes() diff --git a/test_regress/t/t_sys_fopen_bad.v b/test_regress/t/t_sys_fopen_bad.v deleted file mode 100644 index 9d633d4fe..000000000 --- a/test_regress/t/t_sys_fopen_bad.v +++ /dev/null @@ -1,17 +0,0 @@ -// DESCRIPTION: Verilator: Verilog Test module -// -// Copyright 2022 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 - -module t (); - - integer file; - - initial begin - file = $fopen("/dev/null", "somereallywidebad"); - end - -endmodule