vhdl设计分频电路1

2^n分频电路的设计:
法一:
对于2^n分频电路的实现来说,可以采用逐级翻转的设计方法来实现。具体实现过程是:

首先定义一个中间信号,然后在输入的时钟信号的上升到来世进行中间信号的翻转操作,这样就可以得到2分频的信号;接下来定义个中间信号,然后在2分频信号的上升沿到来时进行这个中间信号的翻转操作,这样就可以得到4分频信号;以下依次类推,就可以一次得到8分频,16分频等2的整数次幂的分频信号。

1
library ieee; 2 use ieee.std_logic_1164.all; 3 use ieee.std_logic_arith.all; 4 use ieee.std_logic_unsigned.all; 5 6 entity clk_8div_1 is 7 port( 8 clk : in std_logic; 9 clk_div2 : out std_Logic; 10 clk_div4 : out std_logic; 11 clk_div8 : out std_logic); 12 end clk_8div_1; 13 14 architecture arc of clk_8div_1 is 15 signal clk_tmp1:std_logic; 16 signal clk_tmp2:std_logic; 17 signal clk_tmp3:std_logic; 18 begin 19 process(clk) 20 begin 21 if(clk'event and clk='1')then 22 clk_tmp1<=not clk_tmp1; 23 end if; 24 end process; 25 26 process(clk_tmp1) 27 begin 28 if(clk'event and clk='1')then 29 clk_tmp2<=not clk_tmp2; 30 end if; 31 end process; 32 33 process(clk_tmp2) 34 begin 35 if(clk'event and clk='1')then 36 clk_tmp3<=not clk_tmp3; 37 end if; 38 end process; 39 40 clk_div2<=clk_tmp1; 41 clk_div4<=clk_tmp2; 42 clk_div8<=clk_tmp3; 43 44 end arc;

 法二:
当n比较大时,采用法一的话,代码会过于冗长,效率也低。所以采用标准计数器来进行实现,是只需将计数器的相应位赋给分频电路的输出信号即可实现分频功能。
1
library ieee; 2 use ieee.std_logic_1164.all; 3 use ieee.std_logic_arith.all; 4 use ieee.std_logic_unsigned.all; 5 6 entity clk_8div_2 is 7 port( 8 clk :in std_logic; 9 clk_div2:out std_logic; 10 clk_div4:out std_logic; 11 clk_div8:out std_logic); 12 end clk_8div_2; 13 14 architecture arc of clk_8div_2 is 15 signal counter:std_logic_vector(2 downto 0); 16 begin 17 process(clk) 18 begin 19 if(clk'event and clk='1')then 20 if(counter="111")then 21 counter<=(others=>'0'); 22 else 23 counter<=counter+1; 24 end if; 25 end if; 26 end process; 27 clk_div2<=not counter(0); 28 clk_div4<=not counter(1); 29 clk_div8<=not counter(2); 30 end arc;

 

 

转载于:https://www.cnblogs.com/chenzongxiong/archive/2013/02/06/2903792.html

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值