集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2664|回复: 7

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

[复制链接]
ICE 发表于 2010-6-28 00:07:54 | 显示全部楼层 |阅读模式
下面的分频的代码是否有问题?
  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 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-16 07:02 , Processed in 0.082175 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表