我在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/