ICE 发表于 2010-6-28 00:07:54

分频代码 BDR是一个8位的二进制数,来实现0-256任意分频

下面的分频的代码是否有问题?
BDR是一个8位的二进制数,来实现0-256任意分频

Divi_Pro: process(areset,clk_in,BDR)
variable counter :std_logic_vector(7 downto 0);

begin
if (areset='1') then
   clk_mid<='0';
   counter:="00000000";
   elsif rising_edge( clk_in) then
if counter=(BDR-1) then
    clk_mid<='1';
    counter:="00000000";
else
    clk_mid<='0';
    counter:=counter+1;
end if;
   end if;
end process Divi_Pro;
   
Tf_Pro: process(areset,clk_mid)
begin
   if(areset='1')then
   qn<='0';

   elsif falling_edge(clk_mid) then
qn<=not qn;
   end if;
   clk_out<=qn;
end process Tf_Pro;

VVIC 发表于 2010-6-28 00:24:47

看不懂!!!

CHANG 发表于 2010-6-28 01:03:44

好像没有问题...<br>
<br>
只是我想不明白为什么要引入"CLK_MID" ,在计数达到BDR时,"qn"就取反不行么?

HDL 发表于 2010-6-28 01:39:41

奇数分频似乎有问题吧,没细看,但是不可避免要在输入时钟的两个沿变化

CCIE 发表于 2010-6-28 02:06:54

能不能加点解释

ANG 发表于 2010-6-28 03:09:06

程序好像不对喔<br>
我觉是应该是if counter=(BDR-1) /2 then <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; clk_mid&lt;='1';<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; counter:="00000000";<br>
你试一下吧

AAT 发表于 2010-6-28 04:23:22

没有问题吧,最后低沿触发没必要吧

inter 发表于 2010-6-28 05:40:49

在进程中不能定义变量的啊<br>
老兄!!!!!!!!!!!!
页: [1]
查看完整版本: 分频代码 BDR是一个8位的二进制数,来实现0-256任意分频