-1

如何从 rom_type 读取数据?

entity my_rom is
 port(
  addr: in std_logic_vector(3 downto 0);
  data: out std_logic_vector(0 to 7)
 );
end my_rom;
architecture a of my_rom is

 type rom_type is array (0 to 7) of std_logic_vector(0 to 7);
 constant R1_ROM: rom_type :=
 (
  -- data
 );
begin
 data <= R1_rom(conv_integer(addr));
end a;
4

1 回答 1

5

您正在使用conv_integer,它不是原始 VHDL 的一部分......它在一个库中。但是,您不想使用它 - 它来自非标准库

取而代之use ieee.numeric_std.all;的是您在实体之前需要的东西。然后用于to_integer(unsigned(addr))索引 ROM。更好的是,将地址作为unsigned向量传递,甚至直接作为integer.

尝试改掉使用std_logic_vector(只是一袋比特)来表示数字的习惯,并使用定义明确的数字类型。

或者使用 Verilog,这无关紧要:)

我自己,我更喜欢 VHDL 的强类型,以防止我愚蠢的脚射击......

于 2009-12-02T16:28:11.720 回答