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

期末裸考系列之 例化语句实现计数器

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

1.十进制(count10)

library ieee;
use ieee.std_logic_1164.all;
entity count10 is
	port(clock,enable:in std_logic;
						q:out integer range 0 to 9;
						tc:out std_logic);
end count10;
architecture one of count10 is
begin
	process (clock )
		variable count :integer range 0 to 9;
	begin
		if clock'event and clock='1' then
			if enable='1' then
				if count<9 then count :=count+1;
					else count:=0;
				end if;
			end if;
	end if;
	if(count=9) and ( enable='1')then tc<='1';
		else tc<='0';
	end if;
	q<=count;
end process;
end one;

2.六进制

library ieee;
use ieee.std_logic_1164.all;
entity count6 is
	port(clock,enable:in std_logic;
	q:out integer range 0 to 5;
	tc:out std_logic);
end count6;
architecture two of count6 is
begin
	process (clock )
		variable count :integer range 0 to 5;
	begin
	if clock'event and clock='1' then
		if enable='1' then 
			if count<5 then count :=count+1;
				else count:=0;
			end if;
		end if;
	end if;
		if(count=5) and (enable='1')
			then tc<='1';
		else tc<='0';
		end if;
		q<=count;
	end process;
end two;

3.实现60进制

library ieee;
use ieee.std_logic_1164.all;
entity count60 is
port(clk,ena : in std_logic; 
	tens: out integer range 0 to 5;
	ones: out integer range 0 to 9;
	tc  : out std_logic);
end count60;
architecture three of count60 is
	signal cascade_wire : std_logic;
component count6
	port(clock,enable:in std_logic;
	q:out integer range 0 to 5;
	tc:out std_logic);
end component;
component count10
	port(clock,enable:in std_logic;
						q:out integer range 0 to 9;
						tc:out std_logic);
end component;
begin
	mod10:count10 port map(clock=>clk,enable=>ena, q=>ones,tc=>cascade_wire);
	mod6: count6 port map(clock=>clk,enable=>cascade_wire,q=>tens, tc=>tc);
	
end;

  • 11
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值