发新话题
打印

元件配置

元件配置

在引用
------------------------------------------------------------------------
-- N-bit adder
-- The width of the adder is determined by generic N
------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;

entity adderN is
    generic(N : integer := 16);
    port (a    : in std_logic_vector(N downto 1);
          b    : in std_logic_vector(N downto 1);
          cin  : in std_logic;
          sum  : out std_logic_vector(N downto 1);
          cout : out std_logic);
end adderN;


-- behavioral implementation of the N-bit adder
architecture behavioral of adderN is
begin

    p1: process(a, b, cin)
    variable vsum : std_logic_vector(N downto 1);
    variable carry : std_logic;
    begin
    carry := cin;
    for i in 1 to N loop
        vsum(i) := (a(i) xor b(i)) xor carry;
        carry := (a(i) and b(i)) or (carry and (a(i) or b(i)));
    end loop;
    sum <= vsum;
    cout <= carry;
    end process p1;

end behavioral;

时使用下面的配置方式
configuration test_adder_behavioral of testbench is
    for adder8
    for all: adderN
        use entity work.adderN(behavioral);
    end for;
    end for;
end test_adder_behavioral;

提示 ** Error: D:/Program_Files/altera72/mywork/test/simulation/modelsim/testbench.vhd(137): (vcom-1002) Generic 'n' in component 'addern' does not exist in entity 'addern'.
# ** Error: D:/Program_Files/altera72/mywork/test/simulation/modelsim/testbench.vhd(139): VHDL Compiler exiting
怎么回事?现在把这个配置部分删除后,能通过编译
做永远的初学者,欢迎大家指点

TOP

提示: 作者被禁止或删除 内容自动屏蔽

TOP

太强了,我得多学习

TOP

n 的取值受到定制。是否改写一下,就可以呢
我是初学。

TOP

发新话题