VHDL表达式不是常量

时间:2012-11-29 14:21:12

标签: 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);

但我仍然得到同样的错误。它来自哪里?????

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:-1)

使用正确的测试可能更容易

if nb_word < X"F0" then

而不是

if(nb_word<=X"F0") then

并单独留下“odata”流程。

但是我不确定为什么你的解决方案无法编译,只要你在你需要的所有三个地方改变了nb_word的初始值(你只提到了两个)。

布尔表达式周围无意义圆括号的时尚来自哪里?似乎有很多关于......