请教一个FPGA的问题。

代码:主要功能是把a1,a2,a3加起来。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
use ieee.std_logic_unsigned.all;
entity test1 is
port(
  clk : in std_logic;
  a1, a2, a3 : in std_logic_vector(7 downto 0);
  result : out std_logic_vector(7 downto 0));
end test1;
architecture behavior of test1 is
begin
process(clk)
  variable sum1 : std_logic_vector(7 downto 0);
begin
  if(clk'event and clk = '1') then
   sum1 := a1 + a2;
   sum1 := sum1 + a3;
   result <= sum1;
  end if;
end process;
end behavior;
时序仿真图是:


时序仿真图.JPG



我想问一下:a1+a2+a3输出的结果result为什么延时两个周期才输出来?result输出中的夹杂的不是计算结果的数字是怎么来的,是不是毛刺引起的?能不能把他们消除掉。

本人刚学,请高手解答一下,谢谢。
我也来说两句 查看全部回复

最新回复

  • wu.weihai (2008-7-26 14:24:25)

    if(clk'event and clk = '1') then
       sum1 := a1 + a2;
       sum1 := sum1 + a3;
       result <= sum1;
      end if;

    是要两个周期

    中间不是毛刺,是中间状态。是由于走线路径不同,延时不同引起的
  • xxwenhua (2008-7-26 19:23:23)

    谢谢2楼的解答。
    我还是有些疑问,输出result被综合成一个D触发器,触发器应该跟路径的延时没关系吧,每到一个时钟上升沿就打入计算好的数据,只要满足触发器的建立和保持时间,应该不会有中间的那些中间态吧,我还是不理解为什么中间夹杂了一些中间态,是不是亚稳态??
    请高手解答一下,谢谢。
  • fallrain (2008-7-26 22:25:05)

    你查看一下rtl viewer就明白了