如何解决"符号没有明显的声明错误"

时间:2015-04-08 06:12:07

标签: vhdl

我的vhdl代码如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

entity pc is
port( inp : in std_logic_vector(31 downto 0);
  oup : out std_logic_vector(31 downto 0));
end pc ;

architecture behv of pc is
signal programcounter : std_logic_vector(31 downto 0);
begin
process(inp)
begin
programcounter<=inp;
oup<=programcounter;
end process;
end behv;

library ieee;
use ieee.std_logic_1164.all;

entity ins_memory is
port( inp1 : in std_logic_vector(31 downto 0);
  oup1 : out std_logic_vector (4 downto 0));

end ins_memory;

architecture behv1 of ins_memory is
type ROM_Array is array (0 to 14)
of std_logic_vector(4 downto 0);
constant Content: ROM_Array := (
0 => "00001",
-- Suppose ROM has
1 => "00010",
-- prestored value
2 => "00011",
-- like this table
3 => "00100",
--
4 => "00101",
--
5 => "00110",
--
6 => "00111",
--
7 => "01000",
--
8 => "01001",
--
9 => "01010",
--
10 => "01011",
--
11 => "01100",
--
12 => "01101",
--
13 => "01110",
--
14 => "01111",
--
OTHERS => "11111"
--
);

component pc is
port( inp : in std_logic_vector(31 downto 0);
  oup : out std_logic_vector(31 downto 0));
end component ;

begin
D1: pc port map(inp1);
process(inp1)
begin
oup1<= Content (to_integer(inp1));
end process;
end behv1;

基本上,我试图在实体pc中实例化ins_memory这是一个ROM

我得到的错误是:

  

oup1&lt; = Content(to_integer(inp1));符号   &#39; TO_INTEGER&#39;没有明显的声明。

那么,我该如何解决这个错误?

1 个答案:

答案 0 :(得分:3)

有两个实体/体系结构声明,但只有第一个使用std_logic_arith/unsigned包,因此第二个不知道这些。所以在ins_memory实体之前添加它:

use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

接下来,to_integer来自numeric_std包。 std_logic_vector包中的integerstd_logic_unsigned转换名为conv_integer,因此将oup1分配更新为:

oup1<= Content (conv_integer(inp1));

顺便说一句,如果你直接用{{1>}实例化pc实体,你可以得到组件声明的脊。

D1 : entity work.pc port map(inp1);

另外,请考虑使用VHDL标准numeric_std包而不是专有的Synopsys std_logic_arith/unsigned包。