【问题标题】:Calling a Component Inside Another Component "Port Mapping" (Illegal Statement) VHDL在另一个组件“端口映射”(非法声明)VHDL 中调用组件
【发布时间】:2014-02-19 19:01:53
【问题描述】:

我在我的程序中遇到了一个令人困惑的问题。我需要在我的程序中移植映射(调用)一个组件。此外,在组件内部,我需要进行另一个端口映射(调用),这在 VHDL 中是非法的。你有这个问题的替代解决方案。这是我的意思的一个例子。

我在这里开始我的程序:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity binary1 is
port( N: in std_logic;
  d: out integer);
end binary1 ;  


Architecture Behavior1 of binary1 is

这是一个组件的例子:

component binary_integer_1 is
port ( b1: in std_logic;
   int1: out integer);
end component;

调用组件的命令: 开始 s0:binary_integer_1 端口映射(n,d); 结束行为1;

另外,这里是主程序:

library ieee;
use ieee.std_logic_1164.all;
entity binary_integer_1 is
port ( b1: in std_logic;
int1: out integer);
end binary_integer_1;
architecture Behavior4 of binary_integer_1 is 
begin
process(b1)
begin
if b1 = '1' then
   int1 <= 1; 
   else
   int1 <= 0;
 end if;
 end process;
 end Behavior4;

例如,如果我想在上层实体内部做一个端口映射。我有一个非法的声明。 请为我提供另一种方法。

【问题讨论】:

  • 你的例子不清楚,你修剪的太多了。您描述组件实例化的语言是非标准的。更多的代码会有所帮助,任何实际的错误消息也会有所帮助。 “将设计实体连续分解为组件,并将这些组件绑定到可能以类似方式分解的其他设计实体,从而产生代表完整设计的设计实体层次结构。这样的设计实体集合称为设计层次结构。 "在 LRM 中,从你认为它说它是非法的地方往下的下一段(它不是)。

标签: vhdl fpga hdl modelsim intel-fpga


【解决方案1】:

我做了一个三层设计层次结构的小例子。实体和架构对从下到上列出。

entity comp1 is
    port (
        x:      in      integer;
        y:      out     integer 
    );
end entity;

architecture foo of comp1 is
begin
    y <= x after 2 ns;
end architecture;

entity comp2 is 
    port (
        a:      in  integer;
        b:      out integer
    );
end entity;

architecture fum of comp2 is
    component comp1 is
        port (
            x:      in      integer;
            y:      out     integer 
        );
    end component;

begin
INST_COMP1:
    comp1 port map (X => A, Y => B);
end architecture;

entity top is
end entity;

architecture fum of top is
     component comp2 is 
        port (
            a:      in  integer;
            b:      out integer
        );
    end component;

    signal a:   integer := 0;
    signal b:   integer;

begin
INST_COMP2:
    comp2 port map (a => a, b => b);

TEST:
    process 
    begin
        wait for 5 ns;
        a <= 1;
        wait for 5 ns;
        a <= 2;
        wait for 5 ns;
        a <= 3;
        wait for 5 ns;
        wait;
    end process;

end architecture;

ghdl -a 组件.vhdl

ghdl -e 顶部

ghdl -r top --wave=top.ghw

(用gtkwave打开top.ghw,设置波形显示),以及:

所以我们有一个顶级实体 top,它恰好是一个测试台(无端口),它实例化组件 comp2,其中包含一个实例化组件 comp1,它提供从输入分配给输出的 2 ns 延迟。

整数b的最大负值是整数范围的左值,是默认值,就像std_logic的左值是'U';输出显示默认值,直到仿真时间提前到出现 x 被分配给 comp1 中的 y(2 ns 之后)。由于顶部 x 的默认值,发生了到 0 的转换。

我使用整数来避免上下文子句(库子句和使用子句)。我本可以使用直接实体实例化,但你展示了一个组件声明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2010-10-12
    • 1970-01-01
    相关资源
    最近更新 更多