首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ghdl浮点异常8

ghdl浮点异常8
EN

Stack Overflow用户
提问于 2013-02-19 23:52:22
回答 1查看 862关注 0票数 0

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

代码语言:javascript
复制
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或更大的值时,它就不会编译。

EN

回答 1

Stack Overflow用户

发布于 2013-02-20 00:14:07

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

我想把signed改成unsigned (从ieee.numeric_std)可以解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14961607

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档