I want to write a library for component C
, the component is split internally into two supcomponents c1
and c2
, which are configurable by generics. The submodules should be connected by a record, that depends on the generics. The record should also be used within the components. Usually I would instantiate the record in a package
, and use the package in the files for the subcomponents and in the file for the component. Since it is generic I figured using a generic Package (VHDL-2008) might offer a solution.
The Problem is I need to access the record also from within the subcomponents. To do so I need to use thePackage
, however to use a generic package I need to pass initial values (as far as I know).
So I tried (note: Iam not working with records here, I am just trying to get access to a generic package from a generic component, where I parameterize(?) the package with the parameters of the component):
entity genericPackagePart is
generic(
outputValue : integer
);
port(
result: out integer
);
end entity;
architecture behav of genericPackagePart is
package test is new work.genericPackage
generic map(
genSize => outputValue
);
use work.test.all;
begin
result <= dummy; -- dummy is a constant from genericPackage set to the value genSize (generic parameter)
end architecture;
However I get the following errors from modelsim:
** Error: (vcom-11) Could not find work.test.
** Error: genericPackagePart.vhd(17): (vcom-1195) Cannot find expanded name "work.test".
** Error: genericPackagePart.vhd(17): Unknown expanded name.
** Error: genericPackagePart.vhd(19): (vcom-1136) Unknown identifier "dummy".
** Error: genericPackagePart.vhd(20): VHDL Compiler exiting
Update:
I tried wrapping the genericPackagePart
in a generic package and to instantiate the genericPackage
from within that package with the generics, this did not work either.
The flow would have been:
- Testbench => Instantiate
genericPackagePart
andgenericPackage
with generic parameters - The record is available in the testbench from
genericPackage
- Inside
genericPackagePart
genericPackage
is instantiated with the parameters passed togenericPackagePart
- the record is available inside
genericPackagePart
Modelsim gave Errors (test
is the name I gave to the parameterizes instance of genericPackage
in genericPackagePart
, this is from the compile of genericPackagePart
):
** Error: (vcom-11) Could not find work.test.
** Error: genericPackagePart.vhd(11): (vcom-1195) Cannot find expanded name "work.test".
** Error: genericPackagePart.vhd(11): Unknown expanded name.
** Error: genericPackagePart.vhd(13): near "entity": expecting END
I looked at Passing Generics to Record Port Types but that does not solve the issue of the package instantiation based on generics
For completness here is the package and a testbench:
Package:
package genericPackage is
generic(genSize : integer := 1);
constant dummy : integer := genSize;
end package;
Testbench:
package myGenericPackage is new work.genericPackage
generic map(
genSize => 5
);
use work.myGenericPackage.all;
entity genericPackageTestbench is
end entity;
architecture testbench of genericPackageTestbench is
signal testsignal : integer;
signal testsignal2 : integer;
signal dummy : integer := 12;
component genericPackagePart is
generic(
outputValue : integer
);
port(
result: out integer
);
end component;
begin
test : process is
begin
wait for 20 ns;
testsignal <= dummy;
wait for 20 ns;
testsignal <= work.myGenericPackage.dummy;
wait;
end process;
testPart: genericPackagePart
port map(result => testsignal2)
generic map(outputValue => 128);
end architecture;