vhdl - 使用自定义包会导致循环依赖

标签 vhdl circular-dependency xilinx xilinx-ise

我试图在包中声明一个无符号数组,以便我可以在所有组件中使用相同类型的数组。我先在顶级组件中声明了它,然后使用了工作库和 use命令调用包中的每个组件。我收到一条警告,内容为

WARNING:ProjectMgmt:454 - File circular dependency detected using rule: define-before-use.

我还收到一条错误消息

Line 27: Cannot find <test2> in library <work>. Please ensure that the library was compiled, and that a library and a use clause are present in the VHDL file.

为什么存在循环依赖,我是否正确创建和使用了包?

顶级组件

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

package pkg is
  type array_unsigned is array (99 downto 0) of UNSIGNED(7 downto 0);
end package;

package body pkg is
end package body;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
library work;
use work.pkg.ALL;

entity test1 is
end test1;

architecture Behavioral of test1 is
    signal input : array_unsigned;
begin
sub: entity work.test2(Behavioral)
    port map(input=>input);
end Behavioral;

底层组件

library IEEE;
library work;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.pkg.ALL;

entity test2 is
    Port (input : in array_unsigned);
end test2;

architecture Behavioral of test2 is

begin


end Behavioral;

最佳答案

问题不在于第一个文件同时包含 pkg 包和 test1 实体。这很好,而且不是循环依赖。不过,包括我自己在内的许多人可能认为这是一种不好的做法。真正的问题是 test1 从一个也使用 pkg 的单独文件实例化 test2 实体。因此,循环依赖其中 test2 依赖于 pkg 但包含 pkgtest1 的文件依赖于 test2 因为它是在那里实例化的。

Modelsim 支持仅编译文件中的特定设计单元,因此它可能能够处理这种情况。

关于vhdl - 使用自定义包会导致循环依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32613512/

相关文章:

vhdl - VHDL 的 IEEE 库中的可合成定点/浮点

python - Flask 循环依赖

python - 循环导入 hell

c - 为什么xilinx使用指针将数据存储为数组?

vhdl - 如何在 VHDL 测试平台中轻松分组和驱动信号

vhdl - 将 Chisel 转换为 Vhdl 和 SystemC?

vhdl - VHDL有三元运算符吗?

javascript - 文件夹作为模块,文件夹内作为模块 NodeJS

fpga - 将数据写入sdcard zedboard

linux - 添加软件包后 Yocto 启动失败