From 907665e2e8268fb1208585cccefe5963a7df2e09 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 2 Nov 2012 20:30:47 -0400 Subject: [PATCH] Fix name collision on unnamed blocks, bug567. --- Changes | 4 +++- src/V3LinkDot.cpp | 6 ++++++ test_regress/t/t_hierarchy_unnamed.pl | 18 ++++++++++++++++++ test_regress/t/t_hierarchy_unnamed.v | 24 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_hierarchy_unnamed.pl create mode 100644 test_regress/t/t_hierarchy_unnamed.v diff --git a/Changes b/Changes index b71ce4471..3f62906b0 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,8 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.84** devel +**** Add -x-initial-edge, bug570. [Jeremy Bennett] + **** Fix parameter pins interspersed with cells broke in 3.840. [Bernard Deadman] **** Fix large shift error on large shift constants. [David Welch] @@ -13,7 +15,7 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix missing var access functions when no DPI, bug572. [Amir Gonnen] -**** Add -x-initial-edge, bug570. [Jeremy Bennett] +**** Fix name collision on unnamed blocks, bug567. [Chandan Egbert] * Verilator 3.841 2012/09/03 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index e72fdf829..220b433f2 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -451,6 +451,9 @@ private: string oldscope = m_scope; VSymEnt* oldModSymp = m_modSymp; VSymEnt* oldCurSymp = m_curSymp; + int oldParamNum = m_paramNum; + int oldBeginNum = m_beginNum; + int oldModBeginNum = m_modBeginNum; if (doit) { UINFO(2," Link Module: "<dead()) nodep->v3fatalSrc("Module in cell tree mislabeled as dead?"); @@ -482,6 +485,9 @@ private: m_scope = oldscope; m_modSymp = oldModSymp; m_curSymp = oldCurSymp; + m_paramNum = oldParamNum; + m_beginNum = oldBeginNum; + m_modBeginNum = oldModBeginNum; // Prep for next m_packagep = NULL; } diff --git a/test_regress/t/t_hierarchy_unnamed.pl b/test_regress/t/t_hierarchy_unnamed.pl new file mode 100755 index 000000000..514f638f2 --- /dev/null +++ b/test_regress/t/t_hierarchy_unnamed.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 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. + +compile ( + v_flags2 => ["--lint-only"], + make_top_shell => 0, + make_main => 0, + verilator_make_gcc => 0, + ); + +ok(1); +1; diff --git a/test_regress/t/t_hierarchy_unnamed.v b/test_regress/t/t_hierarchy_unnamed.v new file mode 100644 index 000000000..ca1b78251 --- /dev/null +++ b/test_regress/t/t_hierarchy_unnamed.v @@ -0,0 +1,24 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2012 by Chandan Egbert. + +module sub(); +endmodule + +module t(input logic a, input logic b, + output logic x, output logic y); + + always_comb begin + integer i; + x = a; + end + + sub u0(); + + always_comb begin + integer j; + y = b; + end + +endmodule