数组类型VHDL代码

时间:2016-11-04 10:58:49

标签: arrays vhdl

我已经为MIPS架构中的ROM内存编写了这段代码:

library IEEE; 
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all; 

entity ROM is -- instruction memory
  port(a:  in  STD_LOGIC_VECTOR(5 downto 0);
       rd: out STD_LOGIC_VECTOR(31 downto 0));
end;
-- Memory is organized in 2^6=64 words by 32bits
-- Memory is NOT byte addressable!!
-- port a is connected to: pc(7 downto 2)

architecture synt of ROM is
type ramtype is array (63 downto 0) of STD_LOGIC_VECTOR(31 downto 0);
-- Test code from Harris book
constant mem: ramtype := ( 
0 => X"20020005",
1 => X"2003000c",
2 => X"2067fff7",
3 => X"00e22025",
4 => X"00642824",
5 => X"00a42820",
6 => X"10a7000a",
7 => X"0064202a",
8 => X"10800001",
9 => X"20050000",
10 => X"00e2202a",
11 => X"00853820",
12 => X"00e23822",
13 => X"ac670044",
14 => X"8c020050",
15 => X"08000011",
16 => X"20020001",
17 => X"ac020054",
others => X"00000000")

begin
      rd <= mem(to_integer( unsigned(a)));
end;

编译程序时,cadence向我显示此行错误: 期望ramtype类型的表达式(这发生在常量mem的声明的每一行。 我不明白为什么......有人可以帮助我吗?

0 个答案:

没有答案