M=60的计数器

--具有异步复位、同步置数和使能的递增BCD码计数器

--module=60

library   ieee;

use   ieee.std_logic_1164.all;

use   ieee.std_logic_unsigned.all;

entity cntm60 is

port (ci         :in  std_logic;

        nrest    :in  std_logic;

        load      :in  std_logic;

        d          :in  std_logic_vector(7 downto 0);

        clk        :in  std_logic;

        co        :out  std_logic; 

        qh        :buffer  std_logic_vector(3 downto 0);

        ql        :buffer  std_logic_vector(3 downto 0));

end cntm60;

 

architecture behave of cntm60 is

 begin

 co<='1'  when  (qh="0101" and al="1001" and ci='1')  else '0';

 process(clk,nrest)

 begin

   if(nrest='0')  then

      qh<="0000";

      ql<="0000";

  elsif (clk'event and clk='1')  then

  if  (load='1')  then

      qh<=d(7 downto 4);

      ql<=d(3 downto 0);

  elsif (ci='1') then

      if(ql=9)  then

          ql<="0000"

            if(qh=5) then

             qh<="0000";

            else 

              qh<=qh+1;

            end if;

        else 

           ql<=ql+1;

        end if;

   end if;

end if;

   end process;

 end behave;

转载于:https://www.cnblogs.com/sunnytracy/archive/2009/10/21/1587395.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值