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 -> 正のアドレス: OK。0x20 -> 負のアドレス: エラー ...

signedto (ieee.numeric_std から) を変更するunsignedと問題が解決すると思います。

于 2013-02-19T16:14:06.833 に答える