Fix error on too many UDP port inputs

This commit is contained in:
Wilson Snyder 2025-08-27 07:48:33 -04:00
parent ac21d25d43
commit 54efa86a6c
7 changed files with 78 additions and 2 deletions

View File

@ -110,7 +110,6 @@ class UdpVisitor final : public VNVisitor {
} }
AstNode* iNodep = nodep->iFieldsp(); AstNode* iNodep = nodep->iFieldsp();
AstNode* oNodep = nodep->oFieldsp(); AstNode* oNodep = nodep->oFieldsp();
uint32_t inputvars = 0;
AstSenTree* edgetrigp = nullptr; AstSenTree* edgetrigp = nullptr;
AstLogAnd* logandp = new AstLogAnd{fl, new AstConst{fl, AstConst::BitTrue{}}, AstLogAnd* logandp = new AstLogAnd{fl, new AstConst{fl, AstConst::BitTrue{}},
@ -118,7 +117,6 @@ class UdpVisitor final : public VNVisitor {
for (AstVar* itr : m_inputVars) { for (AstVar* itr : m_inputVars) {
if (!iNodep) break; if (!iNodep) break;
inputvars++;
if (AstUdpTableLineVal* linevalp = VN_CAST(iNodep, UdpTableLineVal)) { if (AstUdpTableLineVal* linevalp = VN_CAST(iNodep, UdpTableLineVal)) {
string valName = linevalp->name(); string valName = linevalp->name();
AstVarRef* const referencep = new AstVarRef{fl, itr, VAccess::READ}; AstVarRef* const referencep = new AstVarRef{fl, itr, VAccess::READ};
@ -141,6 +139,10 @@ class UdpVisitor final : public VNVisitor {
} }
iNodep = iNodep->nextp(); iNodep = iNodep->nextp();
} }
uint32_t inputvars = 0;
for (const AstNode* icountp = nodep->iFieldsp(); icountp; icountp = icountp->nextp())
++inputvars;
if (inputvars != m_inputVars.size()) { if (inputvars != m_inputVars.size()) {
nodep->v3error("Incorrect number of input values, expected " << m_inputVars.size() nodep->v3error("Incorrect number of input values, expected " << m_inputVars.size()
<< ", got " << inputvars); << ", got " << inputvars);

View File

@ -0,0 +1,5 @@
%Error: t/t_udp_bad_line_inputs.v:9:5: Incorrect number of input values, expected 1, got 5
9 | ? 1 ? 0 0 : 0;
| ^
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: Exiting due to

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 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('linter')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,11 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
primitive udp_0(output o, input i);
table
? 1 ? 0 0 : 0; // <--- BAD too many inputs
endtable
endprimitive

View File

@ -0,0 +1,9 @@
%Error: t/t_udp_bad_line_outputs.v:9:11: syntax error, unexpected UDP table field, expecting : or UDP table line end
9 | ? : 0 0 : 0;
| ^
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: t/t_udp_bad_line_outputs.v:15:15: syntax error, unexpected UDP table field, expecting UDP table line end
15 | ? : 0 : 0 0;
| ^
%Error: Cannot continue
... This fatal error may be caused by the earlier error(s); resolve those first.

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 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('linter')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,17 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
primitive udp_1(output reg o, input i);
table
? : 0 0 : 0; // <--- BAD too many recirc
endtable
endprimitive
primitive udp_2(output reg o, input i);
table
? : 0 : 0 0; // <--- BAD too many outputs
endtable
endprimitive