VHDL半整数与奇数分频器设计实验


实验原理:使用数字系统中常常需要不同类型的分频,对于偶数次分频要求以50%占空比输出的电路是比较容易的额。但却难以同相同设计方式直接获得奇数分频且占空比为50%的电路。

代码如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity DIV is
	port(CLK :in std_logic;
		 K_OR,K1,K2:out std_logic);
end;
architecture BHV of DIV is
	signal C1,C2: std_logic_vector(2 downto 0);
	signal M1,M2: std_logic;
begin
process(CLK,C1)  begin
	if rising_edge(CLK)  then
		if(C1="100") then C1<="000"; 
		else C1<=C1+1; 
		end if;
		if(C1="001") then M1<=not M1;
		elsif(C1="011") then M1<=not M1;
        end if;
    end if;
end process;
process(CLK,C2)  begin
	if falling_edge(CLK)  then
		if(C2="100") then C2<="000"; 
		else C2<=C2+1; 
		end if;
		if(C2="001") then M2<=not M2;
		elsif(C2="011") then M2<=not M2;
        end if;
    end if;
end process;
	K1<=M1;  K2<=M2;  K_OR<=M1 OR M2;
end BHV;

	

1.代码分析:

这里面有两个进程,这是第一个进程

process(CLK,C1)  begin
	if rising_edge(CLK)  then
		if(C1="100") then C1<="000"; 
		else C1<=C1+1; 
		end if;
		if(C1="001") then M1<=not M1;
		elsif(C1="011") then M1<=not M1;
        end if;
    end if;
end process;

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值