在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
12
返回列表 发新帖
楼主: woshaogang123

[求助] 计数计数模块设计遇到的问题

[复制链接]
 楼主| 发表于 2012-6-15 10:13:01 | 显示全部楼层
回复 9# chenfengrugao


    我在Quartus II 里面建波形文件怎么仿真不出来呢?
发表于 2012-6-15 18:24:27 | 显示全部楼层
本帖最后由 chenfengrugao 于 2012-6-15 18:25 编辑

回复 10# woshaogang123

那你需要先取start和stop的上升沿。
因为逻辑简单,就根据start和stop的上升沿产生计数的状态(cnt_status)。复杂时用状态机。
QuartusII不能仿真的原因不是很清楚,应该是软件没设置好,建议再看看帮助文档。我这里没有QuartusII所以没法给你截图。

下面是参考代码。
   



  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;

  4. entity count is
  5. port(
  6. clk:in std_logic;
  7. reset : in std_logic;
  8. start: in std_logic;
  9. stop: in std_logic;
  10. cout : out std_logic_vector(7 downto 0)
  11. );
  12. end count;

  13. architecture behav of count is
  14. signal start_dly1 : std_logic;
  15. signal start_dly2 : std_logic;
  16. signal start_rising_edge : std_logic;
  17. signal stop_dly1 : std_logic;
  18. signal stop_dly2 : std_logic;
  19. signal stop_rising_edge : std_logic;
  20. signal cnt_status : std_logic;
  21. begin

  22. process(clk,reset)
  23. begin
  24. if reset='1' then
  25. start_dly1 <= '0';
  26. start_dly2 <= '0';
  27. elsif clk'event and clk='1' then
  28. start_dly1 <= start;
  29. start_dly2 <= start_dly1;
  30. end if;
  31. end process;

  32. start_rising_edge <= not(start_dly2) and start_dly1;

  33. process(clk,reset)
  34. begin
  35. if reset='1' then
  36. stop_dly1 <= '0';
  37. stop_dly2 <= '0';
  38. elsif clk'event and clk='1' then
  39. stop_dly1 <= stop;
  40. stop_dly2 <= stop_dly1;
  41. end if;
  42. end process;

  43. stop_rising_edge <= not(stop_dly2) and stop_dly1;

  44. -- status
  45. process(clk,reset)
  46. begin
  47. if reset='1' then
  48. cnt_status <= '0';
  49. elsif clk'event and clk='1' then
  50. if start_rising_edge = '1' then
  51. cnt_status <= '1';
  52. elsif stop_rising_edge = '1' then
  53. cnt_status <= '0';
  54. end if;
  55. end if;
  56. end process;

  57. process(clk,reset)
  58. variable c : std_logic_vector(7 downto 0);
  59. begin
  60. if reset='1' then
  61. c:="00000000";
  62. cout<="00000000";
  63. elsif clk'event and clk='1' then
  64. if cnt_status = '1' then
  65. c:=c+1;
  66. else
  67. cout<=c;
  68. end if;
  69. end if;
  70. end process;

  71. end behav;




复制代码

Capture1.PNG
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条


小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-12-19 15:41 , Processed in 0.017526 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表