如何修复错误"无法解析索引名称"

时间:2014-12-24 10:18:03

标签: vhdl modelsim

我在Modelsim中编写和减速此代码但在我的组件中我将收到错误"无法解析索引名称类型std_ulogic作为类型std_logic_vector"。如何解决?

library IEEE;
use ieee.std_logic_1164.all,ieee.numeric_std.all,Work.all;

entity NbitCarrySkipAdder is
generic (n: integer :=8);           
Port(A, B: in  std_logic_vector (n-1 downto 0);
    Cin:  in std_logic;
    Sum: out  std_logic_vector (n-1 downto 0);
    Cout: out std_logic);
end NbitCarrySkipAdder;

architecture behavioral of NbitCarrySkipAdder is

  component NBitBlockWithSkipAdder is 
  generic(n:integer:=4);
  port( a, b : in std_logic_vector( n-1 downto 0);
        Cin_Block : in std_logic;
        S : out std_logic_vector( n-1 downto 0);                        
        Cout_Block : out std_logic);
end component NBitBlockWithSkipAdder;
signal Carry: std_logic_vector(0 to n);
begin

g1: for i in 0 to n-1 generate

lt: if i = 0 generate
       f0: NBitBlockWithSkipAdder port map (A(i),B(i),Cin,Sum(i),Carry(i+1));
     end generate lt;

rt: if i = n-1 generate
       fn: NBitBlockWithSkipAdder port map (A(i),B(i),Carry(i),Sum(i),Cout);
     end generate rt;

md: if i > 0 and i < n-1 generate
       fm: NBitBlockWithSkipAdder port map (A(i),B(i),Carry(i),Sum(i),Carry(i+1));
     end generate md;
end generate g1;

end architecture behavioral;

我的组件减速与上述代码中的减速相同。 THX

1 个答案:

答案 0 :(得分:0)

问题是A(i)std_logic的端口映射中是NBitBlockWithSkipAdder,但a端口被声明为std_logic_vector

NBitBlockWithSkipAdder中的端口类型更改为std_logic,或使用A中的一个元素范围,以获得一个std_logic_vector一位,如A(i downto i),因此实例化如下:

f0 : NBitBlockWithSkipAdder port map (A(i downto i), B(i downto i), Cin, Sum(i downto i), Carry(i+1));