From 3d0a2b55ce5c0a4372700b0ce32dee25cbf99cb1 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 4 Jul 2008 12:03:37 +0100 Subject: [PATCH] Avoid declaring same function multiple times If it appears in multiple places in the hierarchy --- tgt-vhdl/scope.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tgt-vhdl/scope.cc b/tgt-vhdl/scope.cc index fa3c4071a..0d6b8dd88 100644 --- a/tgt-vhdl/scope.cc +++ b/tgt-vhdl/scope.cc @@ -471,6 +471,13 @@ int draw_function(ivl_scope_t scope, ivl_scope_t parent) const char *funcname = ivl_scope_tname(scope); + // Has this function been declared already? + // (draw_function will be invoked multiple times for + // the same function if it appears multiple times in + // the design hierarchy) + if (ent->get_arch()->get_scope()->have_declared(funcname)) + return 0; + // The return type is worked out from the output port vhdl_function *func = new vhdl_function(funcname, NULL);