【问题标题】:VHDL Syntax error with if then process如果然后处理的VHDL语法错误
【发布时间】:2017-01-10 11:16:15
【问题描述】:
library ieee;
use ieee.std_logic_1164.all;

entity basic_shift_register_with_multiple_taps is

    generic
    (
        DATA_WIDTH : natural := 8
    
    );

    port 
    (
        clk          : in std_logic;
        enable       : in std_logic;
        sr_one       : in std_logic_vector((DATA_WIDTH-1) downto 0);
        sr_two       : in std_logic_vector((DATA_WIDTH-1) downto 0);
        sr_out       : out std_logic_vector(2*(DATA_WIDTH-1) downto 0)
    );

end entity ;

architecture rtl of basic_shift_register_with_multiple_taps is

    
    signal sig_out  :std_logic_vector(2*(DATA_WIDTH-1) downto 0);
    variable count  : integer := 0;
    variable count1 : integer := 0;
    
begin
    
    process (clk,enable,sr_one,sr_two,sig_out)
    
    begin
    
        if(enable = '0' or count = 16) then 
            count := 0;
            count1 := 0;
        else if (clk'event and clk='1') then
            sig_out(count) <= sr_one(count1);
            
            count := count + 1;
        
        else --if (clk'event and clk='0') then--
            sig_out(count) <= sr_two(count1);
            count := count + 1;
            
        end if;
        
        count1 := count1 + 1;   
        
        
(54)    end process;

    sr_out <= sig_out;

(58) end rtl;

错误:

错误 (10500):teste.vhd(54) 靠近文本“进程”的 VHDL 语法错误;期待“如果”

错误 (10500):在 teste.vhd(58) 文本“rtl”附近出现 VHDL 语法错误;期待“如果”

【问题讨论】:

  • 它抱怨缺少“end if”。我的猜测是你手边没有 VHDL 语法指南,所以你猜到了如何拼写“elsif”而错过了。

标签: vhdl


【解决方案1】:

你的问题是你的第二个 if 语句

if (clk'event and clk='1') then

没有与之关联的end if。因此,当编译器到达第 54 行时,它会在预期的 end if 之前遇到 end process。而不是这个

if(enable = '0' or count = 16) then 
    count := 0;
    count1 := 0;
else if (clk'event and clk='1') then
    sig_out(count) <= sr_one(count1);

    count := count + 1;

else --if (clk'event and clk='0') then--
    sig_out(count) <= sr_two(count1);
    count := count + 1;

end if;

这样做:

if(enable = '0' or count = 16) then 
    count := 0;
    count1 := 0;
else
    if (clk'event and clk='1') then
        sig_out(count) <= sr_one(count1);
        count := count + 1;
    else --if (clk'event and clk='0') then--
        sig_out(count) <= sr_two(count1);
        count := count + 1;
    end if;
end if;

但是,如果您打算对此进行综合,那么您最不用担心语法错误。见this answer

【讨论】:

  • @MatheusSasso 正如我所说,您需要查看this answer。您已经描述了不可综合的行为。逻辑合成器的工作是想出一个表现得像你的代码的电路。它不能这样做。我也不能。您已经描述了使用组合逻辑和 D 型触发器无法实现的行为。您其他问题中的错误消息会告诉您这种行为是什么。因此,您需要按照我发布的链接更改您的代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多