0

我正在尝试编写具有 32 位地址的 SRAM,并启用字节通道写入。但是,当我尝试访问(读取或写入)大于 x1F 的地址时,在使用 GHDL 编译时出现“浮点异常 8”。以下是一些代码片段:

entity data_mem is

port(addr : in std_logic_vector(31 downto 0);
   enable : in std_logic;
   rd : in std_logic;
   wr : in std_logic;
   we : in std_logic_vector( 3 downto 0);
   din : in std_logic_vector( 31 downto 0);
   -- outputs 
   dout : out std_logic_vector(31 downto 0);
   ack : out std_logic
   );
end data_mem;

architecture structure of data_mem is

type mem_type is array (31 downto 0) of std_logic_vector(31 downto 0);
signal mem : mem_type := ((others => (others => '0'))); -- initialize to zero

begin

mem_write : process(addr,enable, wr, we, din)
begin
  if (enable = '1') then
    if (wr = '1') then
      if (we(0) = '1') then
        mem(to_integer(signed(addr)))(7 downto 0) <= din(7 downto 0) after 2 ns;
      end if; ...

因此,当我在测试台中将地址设置为 x0000_001F 或更低时,它会编译,但当我输入 x0000_0020 或更高时则不会。

4

1 回答 1

0

您正在使用signed地址转换。相当奇怪的地址类型。因为您有 32 个位置在内存中存储数据,所以您只使用 6 位 (2^5=32) 作为地址。保留 时signed,第 5 位是符号位。0x1ff -> 正地址:好的。0x20 -> 负地址:错误...

我想改变signedto unsigned(from ieee.numeric_std) 将解决问题。

于 2013-02-19T16:14:06.833 回答