I am trying to use generic packages with a protected type in Modelsim 10.0a. The technote vhdl2008.note states:
a basic generic package and its instantiation with some noteworthy restrictions:
- generic lists on package can contain constant generics and package generics
- the generic package can be instantiated as a design unit, but not in any local declarative region.
- Generics cannot depend on other generics in the same generic list
It is reasonable to use this to instantiate the generic fixed and float
packages from IEEE. You can write your own generic package, instantiate it, and use it. Just keep within the restrictions.
Now I have a generic package
library ieee; use ieee.std_logic_1164.all; package test_generic_pkg is generic( WIDTH : natural := 16 ); type test_type is protected procedure set(d : std_logic_vector(WIDTH-1 downto 0)); impure function get return std_logic_vector; end protected; end package test_generic_pkg; package body test_generic_pkg is type test_type is protected body variable data : std_logic_vector(WIDTH-1 downto 0); procedure set(d : std_logic_vector(WIDTH-1 downto 0)) is begin data := d; end procedure set; impure function get return std_logic_vector is begin return data; end function get; end protected body; end package body test_generic_pkg;
An used by an entity/architecture
package test_pkg is new work.test_generic_pkg generic map( WIDTH => 16 ); library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.test_pkg.all; entity tb is end entity tb; architecture behavioural of tb is shared variable test : test_type; signal clk : std_logic := '0'; begin clk_gen: process is begin wait for 50 ns; clk <= not clk; end process; test1_p: process(clk) is variable cnt : unsigned(15 downto 0) := to_unsigned(0, 16); begin if rising_edge(clk) then test.set(std_logic_vector(cnt)); cnt := cnt + 1; end if; end process; test2_p: process(clk) is begin if falling_edge(clk) then assert false report to_string(test.get) severity note; end if; end process; end architecture behavioural;
This two files can be tested with the
vlib work vcom -work work -2008 -novopt test_generic_pkg.vhd tb.vhd vsim -novopt work.tb
When executing this do file Modelsim compiles both files and while loading the libraries for the simulation it fails with:
... # Loading work.queue_pkg(body) # Loading work.queue64 ... # ** INTERNAL ERROR: pkgref: export lookup failed for package #0 # Error loading design
I also tried to put the package instantiation in a separate file but the results stays the same. What is the solution to get generic packages with protected type working with Modelsim? Using generic packages works fine without a protected type and protected types in a normal package also.
P.S.: Modelsim 10.0a seems to not support this feature although it is not mentioned in the technote. What version of Modelsim added this feature?