当前位置:   article > 正文

Quartus II 例化语句实现计数器(60进制)_用quartus2做60进制计数器

用quartus2做60进制计数器
期末裸考系列之 例化语句实现计数器

全加器用一个十进制计数器以及一个六进制计数器实现

1.十进制(count10)

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. entity count10 is
  4. port(clock,enable:in std_logic;
  5. q:out integer range 0 to 9;
  6. tc:out std_logic);
  7. end count10;
  8. architecture one of count10 is
  9. begin
  10. process (clock )
  11. variable count :integer range 0 to 9;
  12. begin
  13. if clock'event and clock='1' then
  14. if enable='1' then
  15. if count<9 then count :=count+1;
  16. else count:=0;
  17. end if;
  18. end if;
  19. end if;
  20. if(count=9) and ( enable='1')then tc<='1';
  21. else tc<='0';
  22. end if;
  23. q<=count;
  24. end process;
  25. end one;

2.六进制

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. entity count6 is
  4. port(clock,enable:in std_logic;
  5. q:out integer range 0 to 5;
  6. tc:out std_logic);
  7. end count6;
  8. architecture two of count6 is
  9. begin
  10. process (clock )
  11. variable count :integer range 0 to 5;
  12. begin
  13. if clock'event and clock='1' then
  14. if enable='1' then
  15. if count<5 then count :=count+1;
  16. else count:=0;
  17. end if;
  18. end if;
  19. end if;
  20. if(count=5) and (enable='1')
  21. then tc<='1';
  22. else tc<='0';
  23. end if;
  24. q<=count;
  25. end process;
  26. end two;

3.实现60进制

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. entity count60 is
  4. port(clk,ena : in std_logic;
  5. tens: out integer range 0 to 5;
  6. ones: out integer range 0 to 9;
  7. tc : out std_logic);
  8. end count60;
  9. architecture three of count60 is
  10. signal cascade_wire : std_logic;
  11. component count6
  12. port(clock,enable:in std_logic;
  13. q:out integer range 0 to 5;
  14. tc:out std_logic);
  15. end component;
  16. component count10
  17. port(clock,enable:in std_logic;
  18. q:out integer range 0 to 9;
  19. tc:out std_logic);
  20. end component;
  21. begin
  22. mod10:count10 port map(clock=>clk,enable=>ena, q=>ones,tc=>cascade_wire);
  23. mod6: count6 port map(clock=>clk,enable=>cascade_wire,q=>tens, tc=>tc);
  24. end;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/731334
推荐阅读
  

闽ICP备14008679号