Error: /..integrator.vhd(47): near "process": (vcom-1576) expecting IF VHDL

Error: /..integrator.vhd(47): near "process": (vcom-1576) expecting IF VHDL

我正在尝试添加两个存储有符号位的寄存器,一个是 3 位 [FRQ(2 downto 0)],另一个是 7 位 [PHS(6 downto 0)]...并且必须存储加法这两个寄存器在 7 位寄存器 [PHS(6 downto 0)] 中。提前感谢您的帮助。

我得到的错误是..>>> 错误:/..integrator.vhd(47):接近 "process":(vcom-1576) 期待 IF VHDL

这是我的代码:

    library IEEE;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;
    --use ieee.std_logic_unsigned.all;


    entity integ is
        port (
            SMP_CLK : in std_logic;
            RESET : in std_logic;
            PHS : out signed (6 downto 0);
            FRQ : in signed (2 downto 0)
              );
    end integ;

    architecture behaviour of integ is

    signal sig_FRQ   : signed(2 downto 0) := (others => '0');
    signal ext_FRQ   : signed(6 downto 0) := (others => '0');
    signal sig_PHS   : signed(6 downto 0) := (others => '0');
    signal temp_PHS   : signed(6 downto 0) := (others => '0');

    begin 

    sig_FRQ <=FRQ;
    temp_PHS <= sig_PHS;
    --PHS <=signal_PHS;
    process (SMP_CLK, RESET)
    begin

    if sig_FRQ(2)='1' then
        ext_FRQ(6 downto 3) <= b"0000";
    else 
        ext_FRQ(6 downto 3) <= b"1111";
    --end if;

    if RESET='1' then
       sig_PHS <= b"0000000";


    elsif (rising_edge(SMP_CLK) ) then
    --  temp_PHS <= sig_PHS;
           sig_PHS <= signed(ext_FRQ) + signed(temp_PHS);



end process;


sig_PHS => PHS;

end behaviour; 

你的 if-elsif-else 语句有些混乱。在带有 ext_FRQ(6 downto 3) <= b"1111"; 的行之后你已经评论了 --end if; 如果你想继续 if-elsif-else 语句下一个条件应该以 elsif 单词而不是简单的 if 开始代码。

并且最后需要关闭if-elsif-else构造。

以及你需要添加到敏感列表sig_FRQ信号因为你用它来比较,如果你不把它添加到敏感列表下面的构造

if sig_FRQ(2)='1' then
    ext_FRQ(6 downto 3) <= b"0000";
else 
    ext_FRQ(6 downto 3) <= b"1111";
end if;

会出错。

在你的情况下,我想 if-elsif-else 结构的正确版本看起来像:

process (sig_FRQ)
begin
    if sig_FRQ(2)='1' then
        ext_FRQ(6 downto 3) <= b"0000";
    else 
        ext_FRQ(6 downto 3) <= b"1111";
    end if;
end process;

process (SMP_CLK, RESET)
    if RESET='1' then
        sig_PHS <= b"0000000";
    elsif (rising_edge(SMP_CLK)) then
        --temp_PHS <= sig_PHS;
        sig_PHS <= ext_FRQ + temp_PHS;
    end if;
end process;

最后,如果你想将结果赋值给输出,你需要使用另一个运算符

PHS <= sig_PHS;.