ROM数组的常量值

Constant value of ROM array

我正在尝试制作 64 位 ROM type ROM is array (7 downto 0, 7 downto 0) of std_logic;

那我要创建 constant R :ROM :=.

其中 R(0, 7 downto 0 ) 将是 "00010011"

的值

R(0, ) R(1, )由一个3位指针值选择,然后按公式输出:

for i in 0 to 7  loop
      Data_Out(i) <= R(conv_integer(AArray),i);
end loop;.

但是无论我尝试用哪种方式定义 ROM 的常量值,我都会得到一个错误,有人可以指出我为该数组定义常量的正确方法。

对于更复杂的初始化值,创建一个returns要分配的常量值的函数通常很有帮助,例如:

type ROM is array (7 downto 0, 7 downto 0) of std_logic;

function ROM_init return ROM is
  variable res_v : ROM;
begin
  -- Write code that assigns initial value to res_v
  return res_v;
end function;

constant R : ROM := ROM_init;

如果确实需要向量数组,您可以考虑改为:

type ROM is array (7 downto 0) of std_logic_vector(7 downto 0);
function ROM_init return ROM is
  variable res_v : ROM;
begin
  res_v(0) := "00010011";  -- Value from question
  -- Write more code that assigns initial value to res_v;
  return res_v;
end function;
constant R : ROM := ROM_init;

请注意,综合工具可能不会将其作为 ROM 存储块来实现,而只是作为简单的逻辑网络来实现。