0

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

我得到的错误是..>>> 错误:/..integrator.vhd(47): near "process": (vcom-1576) Expecting 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; 
4

1 回答 1

2

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;.

于 2017-04-17T09:06:15.073 回答