aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vhdl/translate/trans-chap2.adb32
-rw-r--r--src/vhdl/translate/trans-chap4.adb4
-rw-r--r--testsuite/gna/issue202/ScoreboardGenericPkg.vhd124
-rw-r--r--testsuite/gna/issue202/repro.vhdl48
-rwxr-xr-xtestsuite/gna/issue202/testsuite.sh14
5 files changed, 194 insertions, 28 deletions
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb
index 9dd992be3..4f729ddc1 100644
--- a/src/vhdl/translate/trans-chap2.adb
+++ b/src/vhdl/translate/trans-chap2.adb
@@ -850,7 +850,7 @@ package body Trans.Chap2 is
Rtis.Generate_Unit (Decl);
end if;
- if Global_Storage = O_Storage_Public then
+ if Global_Storage /= O_Storage_External then
-- Create elaboration procedure for the spec
Elab_Package (Decl, Header);
end if;
@@ -876,10 +876,7 @@ package body Trans.Chap2 is
end if;
end Translate_Package;
- procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration)
- is
- El : Iir;
- Bod : Iir;
+ procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration) is
begin
-- Skip uninstantiated package that have to be macro-expanded.
if Get_Macro_Expanded_Flag (Decl) then
@@ -887,24 +884,6 @@ package body Trans.Chap2 is
end if;
Translate_Package (Decl, Get_Package_Header (Decl));
-
- if Global_Storage = O_Storage_Public then
- -- If there are package instances declared that were macro-expanded,
- -- translate the bodies of the instances.
- if Get_Need_Instance_Bodies (Decl) then
- El := Get_Declaration_Chain (Decl);
- while Is_Valid (El) loop
- if Get_Kind (El) = Iir_Kind_Package_Instantiation_Declaration
- then
- Bod := Get_Package_Body (El);
- if Is_Valid (Bod) then
- Translate_Package_Body (Bod);
- end if;
- end if;
- El := Get_Chain (El);
- end loop;
- end if;
- end if;
end Translate_Package_Declaration;
procedure Translate_Package_Body (Bod : Iir_Package_Body)
@@ -1387,9 +1366,8 @@ package body Trans.Chap2 is
-- Macro-expanded instantiations are translated like a package.
Translate_Package (Inst, Inst);
- -- For top-level package or nested package not within a package,
- -- generate code for the body.
- if Global_Storage = O_Storage_Public then
+ -- Generate code for the body.
+ if Global_Storage /= O_Storage_External then
declare
Bod : constant Iir := Get_Package_Body (Inst);
begin
@@ -1430,7 +1408,7 @@ package body Trans.Chap2 is
Finish_Subprogram_Decl
(Interface_List, Info.Package_Instance_Elab_Subprg);
- if Global_Storage /= O_Storage_Public then
+ if Global_Storage = O_Storage_External then
return;
end if;
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 8c44f7c49..e15e06db6 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -2398,7 +2398,9 @@ package body Trans.Chap4 is
begin
Push_Identifier_Prefix (Mark, Get_Identifier (El));
Translate_Declaration_Chain_Subprograms (El);
- if Is_Valid (Bod) then
+ if Is_Valid (Bod)
+ and then Global_Storage /= O_Storage_External
+ then
Translate_Declaration_Chain_Subprograms (Bod);
end if;
Pop_Identifier_Prefix (Mark);
diff --git a/testsuite/gna/issue202/ScoreboardGenericPkg.vhd b/testsuite/gna/issue202/ScoreboardGenericPkg.vhd
new file mode 100644
index 000000000..93525fe21
--- /dev/null
+++ b/testsuite/gna/issue202/ScoreboardGenericPkg.vhd
@@ -0,0 +1,124 @@
+--
+-- File Name: ScoreBoardGenericPkg.vhd
+-- Design Unit Name: ScoreBoardGenericPkg
+-- Revision: STANDARD VERSION
+--
+-- Maintainer: Jim Lewis email: jim@synthworks.com
+-- Contributor(s):
+-- Jim Lewis email: jim@synthworks.com
+--
+--
+-- Description:
+-- Defines types and methods to implement a FIFO based Scoreboard
+-- Defines type ScoreBoardPType
+-- Defines methods for putting values the scoreboard
+--
+-- Developed for:
+-- SynthWorks Design Inc.
+-- VHDL Training Classes
+-- 11898 SW 128th Ave. Tigard, Or 97223
+-- http://www.SynthWorks.com
+--
+-- Latest standard version available at:
+-- http://www.SynthWorks.com/downloads
+--
+-- Revision History:
+-- Date Version Description
+-- 12/2006: 2006.12 Initial revision
+-- 08/2010 2010.08 Added Tailpointer
+-- 05/2012 2012.05 Changed FIFO to store pointers to ExpectedType
+-- Allows usage of unconstrained arrays
+-- 08/2012 2012.08 Added Type and Subprogram Generics
+-- 08/2013 2013.08 Generics: to_string replaced write, Match replaced check
+-- Added Tags - Experimental
+-- Added Array of Scoreboards
+-- 09/2013 2013.09 Added file handling, Check Count, Finish Status
+-- Find, Flush
+-- 06/2015 2015.06 Added Alerts, SetAlertLogID, Revised LocalPush, GetDropCount,
+-- Deprecated SetFinish and ReportMode - REPORT_NONE, FileOpen
+-- Deallocate, Initialized, Function SetName
+-- 09/2016 2016.07 Released as part of OSVVM
+
+--
+--
+-- Copyright (c) 2006 - 2016 by SynthWorks Design Inc. All rights reserved.
+--
+-- Verbatim copies of this source file may be used and
+-- distributed without restriction.
+--
+-- This source file is free software; you can redistribute it
+-- and/or modify it under the terms of the ARTISTIC License
+-- as published by The Perl Foundation; either version 2.0 of
+-- the License, or (at your option) any later version.
+--
+-- This source is distributed in the hope that it will be
+-- useful, but WITHOUT ANY WARRANTY; without even the implied
+-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+-- PURPOSE. See the Artistic License for details.
+--
+-- You should have received a copy of the license with this source.
+-- If not download it from,
+-- http://www.perlfoundation.org/artistic_license_2_0
+--
+--
+
+use std.textio.all ;
+
+library ieee ;
+ use ieee.std_logic_1164.all ;
+ use ieee.numeric_std.all ;
+
+package ScoreboardGenericPkg is
+ generic (
+ type ExpectedType ;
+ type ActualType ;
+ function Match(Actual : ActualType ; -- defaults
+ Expected : ExpectedType) return boolean ; -- is "=" ;
+ function expected_to_string(A : ExpectedType) return string ; -- is to_string ;
+ function actual_to_string (A : ActualType) return string -- is to_string ;
+ ) ;
+
+-- -- For a VHDL-2002 package, comment out the generics and
+-- -- uncomment the following, it replaces a generic instance of the package.
+-- -- As a result, you will have multiple copies of the entire package.
+-- -- Inconvenient, but ok as it still works the same.
+-- subtype ExpectedType is std_logic_vector ;
+-- subtype ActualType is std_logic_vector ;
+-- alias Match is std_match [ActualType, ExpectedType return boolean] ; -- for std_logic_vector
+-- alias expected_to_string is to_hstring [ExpectedType return string]; -- VHDL-2008
+-- alias actual_to_string is to_hstring [ActualType return string]; -- VHDL-2008
+
+ -- ScoreboardReportType is deprecated
+ -- Replaced by Affirmations. ERROR is the default. ALL turns on PASSED flag
+ type ScoreboardReportType is (REPORT_ERROR, REPORT_ALL, REPORT_NONE) ; -- replaced by affirmations
+
+ type ScoreBoardPType is protected
+
+ ------------------------------------------------------------
+ ------------------------------------------------------------
+ -- Push items into the scoreboard/FIFO
+
+ -- Simple Scoreboard, no tag
+ procedure Push (Item : in ExpectedType) ;
+
+ end protected ScoreBoardPType ;
+
+end ScoreboardGenericPkg ;
+
+
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+package body ScoreboardGenericPkg is
+
+ type ScoreBoardPType is protected body
+
+ ------------------------------------------------------------
+ -- Simple Scoreboard, no tag
+ procedure Push (Item : in ExpectedType) is
+ ------------------------------------------------------------
+ begin
+ null;
+ end procedure Push ;
+
+ end protected body ScoreBoardPType ;
+end ScoreboardGenericPkg ;
diff --git a/testsuite/gna/issue202/repro.vhdl b/testsuite/gna/issue202/repro.vhdl
new file mode 100644
index 000000000..2f2e532f5
--- /dev/null
+++ b/testsuite/gna/issue202/repro.vhdl
@@ -0,0 +1,48 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library OSVVM;
+
+entity e is
+end entity;
+
+architecture a of e is
+ subtype T_DATA is std_logic_vector(31 downto 0);
+ type T_DATA_VECTOR is array(natural range <>) of T_DATA;
+
+ type T_SCOREBOARD_DATA is record
+ IsKey : std_logic;
+ Meta : std_logic_vector(31 downto 0);
+ Data : T_DATA_VECTOR(15 downto 0);
+ end record;
+
+ function match(expected : T_SCOREBOARD_DATA; actual : T_SCOREBOARD_DATA) return boolean is
+ begin
+ return TRUE;
+ end function;
+
+ function to_string(vector : T_SCOREBOARD_DATA) return string is
+ begin
+ return "to_string";
+ end function;
+
+ package P_Scoreboard is new OSVVM.ScoreboardGenericPkg
+ generic map (
+ ExpectedType => T_SCOREBOARD_DATA,
+ ActualType => T_SCOREBOARD_DATA,
+ Match => match,
+ expected_to_string => to_string,
+ actual_to_string => to_string
+ );
+ alias T_SCOREBOARD is P_Scoreboard.ScoreBoardPType
+
+ shared variable ScoreBoard : T_SCOREBOARD; -- this causes the error message
+begin
+ process
+ variable v : t_scoreboard_data;
+ begin
+ ScoreBoard.Push(v);
+ wait;
+ end process;
+end architecture;
diff --git a/testsuite/gna/issue202/testsuite.sh b/testsuite/gna/issue202/testsuite.sh
new file mode 100755
index 000000000..4d6404f90
--- /dev/null
+++ b/testsuite/gna/issue202/testsuite.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze --work=osvvm ScoreboardGenericPkg.vhd
+
+analyze repro.vhdl
+elab_simulate e
+
+clean
+clean osvvm
+
+echo "Test successful"