vector - VHDL表达式不是常数

标签 vector compiler-errors vhdl

我在Quartus II上为CYCLONE III EP3C25 FPGA编写了VHDL程序,但遇到了问题。

这是我程序的重要部分:

odata : out std_logic_vector(15 downto 0);

signal buf_data : std_logic_vector(255 downto 0);

signal nb_word : integer :=0;

Process(clk,RST)
begin
    if(RST='0') then
        nb_word<=0;
    elsif(clk'event and clk='0') then
        if(Current_state_w=s2) then
            if(nb_word<=X"F0") then
                nb_word<=nb_word+16;
            else
                nb_word<=0;
            end if;
        end if;
    end if;
end process;

Process(clk,RST)

begin
    if(RST='0') then
        odata<=(OTHERS=>'0');
    elsif(clk'event and clk='0') then
            odata<=buf_data(nb_word+15 downto nb_word);
    end if;
end process;

这段代码可以很好地编译,但是不执行我想要的操作,然后我只想更改:
odata<=buf_data(nb_word+15 downto nb_word);


odata<=buf_data(nb_word downto nb_word-15);

我将nb_word的初始化和重置值更改为15而不是0。

问题是,当我这样做并尝试编译时,出现此错误:
Error (10779): VHDL error at VL_control.vhd(99): expression is not constant

该线对应于odata线的变化。

我真的不明白为什么会出现此错误。为什么可以加法而不是减法?
我还试图定义另一个信号,并在像这样寻址缓冲区之前对信号进行减法运算:
nb_word1 := (nb_word-15);
odata<=buf_data(nb_word downto nb_word1);

但是我仍然遇到同样的错误。那是哪里来的?

最佳答案

您应该将nb_word限制为整数范围,这样合成工具才能确定nb_word - 15的值不能为负。

另外,为什么还要将整数与位字符串文字进行比较?为什么不只说if nb_word < 15

关于vector - VHDL表达式不是常数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13627809/

相关文章:

arrays - 在 Fortran 中使用 MATMUL 进行向量乘法

c++ - 当我们已经拥有更强大的 vector 时,为什么还需要堆栈?

c++ - 在C++容器中作为模板参数提供的分配器与作为构造函数参数提供的分配器之间的区别?

compiler-errors - 在Android Studio中编译Cocos 2d-x项目时发生错误

f# - F#树难题-找不到值或构造函数 “TreeNode”

vhdl - 在Vhdl中创建实时延迟

matlab - 为什么 sum 语句会如此奇怪地合成?

VHDL/Verilog 相关的编程论坛?

list - Clojure 函数抛出空指针异常

c++ - iperf3 的 C 编译问题