modelsim仿真计数器的问题

[复制链接]
 楼主| wangjun403 发表于 2010-12-29 22:09 | 显示全部楼层 |阅读模式
为什么在时钟的下降沿,计数值才变化呢?
时钟周期100us
下面是代码
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_arith.all;
  4. --use ieee.std_logic_unsigned.all;

  5. entity cnt6 is
  6. port
  7. (clr,en,clk :in std_logic;
  8. q :out std_logic_vector(2 downto 0)
  9. );
  10. end entity;

  11. architecture rtl of cnt6 is
  12. signal tmp :std_logic_vector(2 downto 0);
  13. begin
  14. process(clk)
  15. -- variable q6:integer;
  16. begin
  17. if(clk'event and clk='1') then
  18. if(clr='0')then
  19. tmp<="000";
  20. elsif(en='1') then
  21. if(tmp="101")then
  22. tmp<="000";
  23. else
  24. tmp<=unsigned(tmp)+'1';
  25. end if;
  26. end if;
  27. end if;
  28. q<=tmp;
  29. -- qa<=q(0);
  30. -- qb<=q(1);
  31. -- qc<=q(2);
  32. end process;
  33. end rtl;

处女贴,恳请大家帮忙下,肯定会及时结贴的
byeyear 发表于 2011-1-2 21:42 | 显示全部楼层
你可以单步跟踪一下看看
lelee007 发表于 2011-1-5 13:16 | 显示全部楼层
路过,VHDL不会
sxhhhjicbb 发表于 2011-1-10 22:29 | 显示全部楼层
例如,tmp<=unsigned(tmp)+'1';
标准中,tmp时序上是要在下一个if(clk'event and clk='1') then才变成新值,modelsim仿真的时候,半个时钟就有效,以满足建立时间的要求,即下一个时钟来时,此值一定是稳定的,LZ的看到的是对的。。。。。
岚369 发表于 2011-5-14 19:43 | 显示全部楼层
刚在学
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

629

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

0

主题

629

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部