我想为 component 编写一个库C
,该组件在内部分为两个 supcomponentsc1
和c2
,它们可以由泛型配置。子模块应通过记录连接,这取决于泛型。该记录也应在组件内使用。通常我会在 a 中实例化记录package
,并在子组件的文件和组件的文件中使用包。由于它是通用的,我认为使用通用包(VHDL-2008)可能会提供解决方案。
问题是我还需要从子组件中访问记录。为此,我需要use thePackage
,但是要使用通用包,我需要传递初始值(据我所知)。
所以我尝试了(注意:我在这里没有处理记录,我只是想从通用组件访问通用包,我在其中参数化(?)带有组件参数的包):
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;
但是我从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
更新:
我尝试将其包装genericPackagePart
在一个泛型包中,并使用泛型从该包中实例化 genericPackage
,这也不起作用。
流程应该是:
- Testbench => 实例化
genericPackagePart
并genericPackage
使用通用参数 - 该记录可在测试台中从
genericPackage
- 内部
genericPackagePart
genericPackage
使用传递给的参数实例化genericPackagePart
- 记录在里面
genericPackagePart
Modelsim 给出了 Errors (test
是我给 in 的参数化实例起的名字genericPackage
,genericPackagePart
这是来自 的编译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
我查看了Passing Generics to Record Port Types但这并没有解决基于泛型的包实例化问题
为了完整起见,这里是包和测试台:
包裹:
package genericPackage is
generic(genSize : integer := 1);
constant dummy : integer := genSize;
end package;
试验台:
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;