用EDA怎样写频率分频器12 ,13,16分频

用EDA怎样写频率分频器12 ,13,16分频,第1张

我给你一个65536分频,如果你想要得到其他的分频,你可以通过改变65536来得到

library ieee

use ieee.std_logic_arith.all

use ieee.std_logic_1164.all

use ieee.std_logic_unsigned.all

entity fenpin is

port(clk: in std_logic

clk_div4: out std_logic)

end fenpin

architecture art of fenpin is

signal count : std_logic_vector(15 downto 0)

begin

process(clk)

begin

if(clk'event and clk='斗搜1') then

if(count = "空基历1111111111111111") then

count<=(others=>锋陪'0')

else

count<= count + 1

end if

end if

end process

clk_div4<= count(15)

end art

module clkgen(clk,cout)

input clk  镇则              --clk为频率输入,用于被分频

reg[24:0] q            --定义一个变量用于计数

output reg cout     --频率输出

always @(posedge clk)        --此进程每次在clk的上升沿被触发

begin

      if(q==20000000-1)       --q为计数器, 当clk上升沿到来的时候加一,若计数达到

 --(20000000-1)则清零再薯旅态重新计数

q=0        

      else

  数源          q=q+1

        if(q==20000000-1)     --当q计满(20000000-1)时,cout输出一个clk的高电平,

--其余时间均为低电平

cout=1

        else

cout=0

end

endmodule

相当于一个(20000000-1)分频的分频器,输出波形示意图如下:

字字手打,望楼主采纳!


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12324316.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存