0

我有一个输入信号,它是一个std_logic_vector并保存一个地址。我用它从内存中读取,我需要读取 500 位,但由于我的内存数据总线只有 256 位宽,我需要读取两个连续的 256 位块。为此,我想第一次从存储在信号中的地址读取,第二次从存储地址之后的 256 位(32 字节)地址读取。如何将常数添加到std_logic_vector

ADRESS  : in std_logic_vector (0 to 31);

--code

--read first word:
dfmc_DDR2Interface_address <= ADRESS;
dfmc_DDR2Interface_read <= '1';

-- more code

--read second word (what I want to do)
dfmc_DDR2Interface_address <= ADRESS+32;
dfmc_DDR2Interface_read <= '1';
4

2 回答 2

1

简单的方法是使用numeric_std_unsigned包:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std_unsigned.all;  -- if you add this...

entity add_integer_literal_to_slv_signal is
    port (
        address: in std_logic_vector(0 to 31);
        dfmc_DDR2Interface_address: out std_logic_vector (0 to 31);
        dfmc_DDR2Interface_read: out std_logic
    );
end;

architecture example of add_integer_literal_to_slv_signal is
begin
    --read first word:
    dfmc_DDR2Interface_address <= address;
    dfmc_DDR2Interface_read <= '1';

    -- more code

    --read second word (what I want to do)
    dfmc_DDR2Interface_address <= address + 256; -- ...this will work out of the box!
    dfmc_DDR2Interface_read <= '1';
end;

作为记录,您应该正确查看 numeric_std 包。@JimLewis 对 VHDL 2008 算术有一个很好的总结: http ://www.gstitt.ece.ufl.edu/vhdl/refs/vhdl_math_tricks_mapld_2003.pdf

于 2013-10-20T15:44:57.253 回答
0

一种解决方案是询问地址在您的设计上下文中的含义。

如果,正如我通常发现的那样,它表示一个无符号数,最简洁的答案是将地址声明为无符号类型(来自 numeric_std)库,或者有时甚至声明为 Natural 的范围子类型。

然后整数的加法将简单地工作,没有大惊小怪,而且 VHDL-2008 对脑死亡工具的支持也没有问题。

在您的测试台中,您可能必须转换为 std_logic_vector 才能连接到设计不佳的仿真模型,但这种转换可能很少。

于 2013-10-21T09:35:33.990 回答