2017-04-17 83 views
0

我试图添加两个寄存器来存储有符号位的一个3位[FRQ(2 downto 0 )]和其他7位[PHS(6 downto 0)] ...并且必须在7位寄存器[PHS(6 downto 0)]中存储这两个寄存器。预先感谢您的有益姿态。错误:/..integrator.vhd(47):在“process”附近:(vcom-1576)期望中IF VHDL

我得到的错误是... >>> 错误:/..integrator.vhd(47):近 “过程”:(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; 

回答

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;

+0

我必须修改输出端口分配,但您的建议是很有帮助的。非常感谢。代码现在正在运行,但需要进行一些纠正才能正确添加。因为在模拟之后,我没有像我期望的那样得到结果。总之,再次感谢。 –

+0

你的代码的目标是什么? – Roman

+0

得到它按预期工作。无论如何,我正在实施用于数据通信的FSM,以用于使用数字设计的调制方案。 –