mirror of
https://github.com/verilator/verilator.git
synced 2025-01-19 12:54:02 +00:00
Add warning on TOP-named modules (#4935).
This commit is contained in:
parent
01dadb0a8d
commit
a4813ec677
1
Changes
1
Changes
@ -13,6 +13,7 @@ Verilator 5.023 devel
|
|||||||
|
|
||||||
**Minor:**
|
**Minor:**
|
||||||
|
|
||||||
|
* Add warning on 'TOP'-named modules (#4935). [Yanglin Xun]
|
||||||
* Fix invalid cast on string structure creation (#4921). [esynr3z]
|
* Fix invalid cast on string structure creation (#4921). [esynr3z]
|
||||||
|
|
||||||
|
|
||||||
|
@ -642,6 +642,11 @@ class LinkParseVisitor final : public VNVisitor {
|
|||||||
if (m_lifetime.isNone()) {
|
if (m_lifetime.isNone()) {
|
||||||
m_lifetime = VN_IS(nodep, Class) ? VLifetime::AUTOMATIC : VLifetime::STATIC;
|
m_lifetime = VN_IS(nodep, Class) ? VLifetime::AUTOMATIC : VLifetime::STATIC;
|
||||||
}
|
}
|
||||||
|
if (nodep->name() == "TOP") {
|
||||||
|
// May mess up scope resolution and cause infinite loop
|
||||||
|
nodep->v3warn(E_UNSUPPORTED, "Module cannot be named 'TOP' as conflicts with "
|
||||||
|
"Verilator top-level internals");
|
||||||
|
}
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
}
|
}
|
||||||
m_valueModp = nodep;
|
m_valueModp = nodep;
|
||||||
|
5
test_regress/t/t_lint_top_bad.out
Normal file
5
test_regress/t/t_lint_top_bad.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
%Error-UNSUPPORTED: t/t_lint_top_bad.v:14:8: Module cannot be named 'TOP' as conflicts with Verilator top-level internals
|
||||||
|
14 | module TOP(
|
||||||
|
| ^~~
|
||||||
|
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||||
|
%Error: Exiting due to
|
20
test_regress/t/t_lint_top_bad.pl
Executable file
20
test_regress/t/t_lint_top_bad.pl
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# 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
|
||||||
|
|
||||||
|
scenarios(vlt => 1);
|
||||||
|
|
||||||
|
compile(
|
||||||
|
verilator_flags2 => ['-O0 --trace-fst'],
|
||||||
|
fails => 1,
|
||||||
|
expect_filename => $Self->{golden_filename},
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
33
test_regress/t/t_lint_top_bad.v
Normal file
33
test_regress/t/t_lint_top_bad.v
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2024 by Wilson Snyder.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
module sub(input wire clk, cpu_reset);
|
||||||
|
reg reset_r;
|
||||||
|
always @(posedge clk) begin
|
||||||
|
reset_r <= cpu_reset; // The problematic one
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module TOP(/*AUTOARG*/
|
||||||
|
// Inputs
|
||||||
|
clk, reset_l
|
||||||
|
);
|
||||||
|
|
||||||
|
input clk;
|
||||||
|
input reset_l;
|
||||||
|
|
||||||
|
reg sync_0, sync_1, sync_2;
|
||||||
|
wire _cpu_reset_chain_io_q = sync_0;
|
||||||
|
|
||||||
|
sub sub (.clk(clk),
|
||||||
|
.cpu_reset(_cpu_reset_chain_io_q | !reset_l));
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
sync_0 <= sync_1;
|
||||||
|
sync_1 <= sync_2;
|
||||||
|
sync_2 <= !reset_l;
|
||||||
|
end
|
||||||
|
endmodule
|
Loading…
Reference in New Issue
Block a user