您好,欢迎访问三七文档
三分频器的设计时钟输入端(clkin)首先反向和不反向分别接到两个D触发器的时钟输入端,两个D触发器的输出接到一个二输入或非门的输入端,或非门的输出反馈到前面两个D触发器的D输入端,并且或非门的输出后面接一二分频器,得到占空比为50%的三分频波形。图1:图形设计VHDL程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityfen3isport(clkin:instd_logic;--时钟输入qout1:bufferstd_logic;qout2:bufferstd_logic;qout3:bufferstd_logic;clkout:outstd_logic--占空比为1/2的三分频输出);endfen3;architecturebehaveoffen3isbeginqout3=qout1norqout2;process(clkin)beginifclkin'eventandclkin='1'then--在上升沿触发qout1=qout3;endif;endprocess;process(clkin)beginifclkin'eventandclkin='0'then--在下降沿触发qout2=qout3;endif;endprocess;process(qout3)variabletem:std_logic;beginifqout3'eventandqout3='1'then--二分频tem:=nottem;endif;clkout=tem;endprocess;endbehave;图3:仿真结果方法二:设计两个占空比为1/3的三分频器,分别在时钟输入端的上升沿和下降沿触发,然后两个分频器的输出接一个或门,得到占空比为50%的三分频波形。图4:图形设计VHDL程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityfen3isport(clkin:instd_logic;--时钟输入qout1:bufferstd_logic;qout2:bufferstd_logic;clkout:outstd_logic--占空比为1/2的三分频输出);endfen3;architecturebehaveoffen3isbeginclkout=qout1orqout2;process(clkin)--占空比为1/3的三分频variablecnt:integerrange0to2;beginifclkin'eventandclkin='1'then--在上升沿触发ifcnt=2thencnt:=0;qout1='1';elsecnt:=cnt+1;qout1='0';endif;endif;endprocess;process(clkin)variablecnt:integerrange0to2;--占空比为1/3的三分频beginifclkin'eventandclkin='0'then--在下降沿触发ifcnt=2thencnt:=0;qout2='1';elsecnt:=cnt+1;qout2='0';endif;endif;endprocess;endbehave;图5:编译结果图6:仿真结果方法三:设计一个占空比为50%的四分频器,四分频器的时钟输入端是由四分频器的输出端和时钟输入相异或后驱动的,四分频器的时钟输出端就是占空比为50%的三分频波形输出。图:图形设计VHDL程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entityfen3isport(clkin:instd_logic;--时钟输入qout1:bufferstd_logic;clkout:outstd_logic--占空比为1/2的三分频输出);endfen3;architecturebehaveoffen3isconstantcounter_len:integer:=3;--设置计数器的模signalclk_tem:std_logic;beginqout1=clkinxorclk_tem;--反馈process(qout1)--四分频variablecnt:integerrange0tocounter_len;beginifqout1'eventandqout1='1'then--在上升沿触发ifcnt=counter_lenthencnt:=0;elsecnt:=cnt+1;endif;ifcnt=1thenclk_tem='0';clkout='0';elseclk_tem='1';clkout='1';endif;endif;endprocess;endbehave;编译结果以上介绍了三种设计50%占空比三分频器的方法,由以上看出,第三种设计方法,程序最简洁,占用宏单元最少,而且可以举一反三,很容易设计出其他奇数分频占空比为50%的分频器
本文标题:3分频器的设计
链接地址:https://www.777doc.com/doc-2928899 .html