[半整数分频器的设计(VHDL)
[半整数分频器的设计(VHDL)实现方法:首先需要设计一个计数器,计数器的模为分频系数的整数部分加1,然后设计一个扣除脉冲电路,并把它加在计数器的输出之后。(不懂什么意思,不过对照时序图比较容易理解)
VHDL程序:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity clk_div_h is
port(
clk :in std_logic;
clk_out :out std_logic;
clk_ot1,clk_ot2:out std_logic
);
end clk_div_h;
architecture rtl of clk_div_h is
constant md:std_logic_vector(3 downto 0):="0011";--计数器的模为分频系数的整数部分加1
signal count:std_logic_vector(3 downto 0);
signal clk_tmp1:std_logic;
signal clk_tmp2:std_logic;
signal clk_out_tmp:std_logic;
begin
clk_tmp1<=clk xor clk_tmp2;
modn_counter:process(clk_tmp1)
begin
if(clk_tmp1'event and clk_tmp1='1')then
if(count="0000")then
count<=md-1;
clk_out<='1';
clk_out_tmp<='1';
else
count<=count-1;
clk_out<='0';
clk_out_tmp<='0';
end if;
end if;
end process modn_counter;
half_clk:process(clk_out_tmp)
begin
if(clk_out_tmp'event and clk_out_tmp='1')then
clk_tmp2<=not clk_tmp2;
end if;
end process half_clk;
clk_ot1<=clk_tmp1;
clk_ot2<=clk_tmp2;
end rtl;
以上是一个2.5分频的半整数分频器的VHDL源程序,要得到其它分频系数的半整数分频器,只需要改变程序中常量md的值即可。
该分频器的仿真时序图:
仿真中添加了二个临时信号(clk_ot1对应clk_tmp1,clk_ot2对应clk_tmp2)的输出以便观察内部信号的跳变过程。
如时序图中所示,由于clk与clk_tmp2信号相异或,使得clk_tmp1从1回到了0快了半个时钟,也就是扣除了半个时钟。也许这就是所谓的扣除脉冲电路吧。 此东西是很有用的,多看一下吧 顶一下顶一下 很值得学习!:victory: 觉得短时间难理解的,可以用dcm模块来做时钟的分频,这样可以把后面的模块先做起来,便于仿真验证。 很值得学习!
页:
[1]