小数分频器设计
设计原理:小数分频的基本原理是采用脉冲吞计数器和锁相环先设计两个不同分频比的整数分频器,然后通过控制单位时间内两种分频比出现的不同次数来获得所需要的小数分频值。由于分频器的分频值不断改变,因此分频后得到的信号抖动比较大,实际应用不常用。半数分频稳定,经常会用。
下面是一个2.5分频器的程序。
library ieee;
use
ieee.std_logic_1164.all;
use
ieee.std_logic_unsigned.all;
use
ieee.numeric_std.all;
entity fenpin is
generic(dwidth:integer:=3);
port(clkin:in
std_logic;
set:in std_logic_vector(dwidth
downto 0);
clkout:buffer
std_logic);
end;
architecture rt1 of fenpin
is
signal
clk,div2:std_logic;
signal count:integer range dwidth
downto 0;
begin
clk<=clkin xor div2;
process(clk)
begin
if(clk'event and clk='1')
then
if (count=0) then
count<=
to_integer(unsigned(set))-1;
clkout<='1';
else
count<=count-1;
clkout<='0';
end if;
end if;
end process;
process(clkout)
begin
if(clkout'event and clkout='1')
then
div2<=not div2;
end if;
end process;
end rt1
来源于九江学院电子学院,仅供参考——mksun成