VHDL语言。。如何实现50MHz分频为1Hz?
直接采用50分频即可。
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;
entity clk_div is
port(
clk : in std_logic;
clk1:out std_logic
);
end clk_div;
architecture mix of clk_div is
signal count :integer range 0 to 49999999;
严格来说是从0-49999999,刚好50000000个计数值,正好将50M的时钟分为1Hz的时钟
扩展资料:
CPU的主频,即CPU内核工作的时钟频率(CPU Clock Speed)。通常所说的某某CPU是多少GHz的,而这个多少GHz就是“CPU的主频”。很多人认为CPU的主频就是其运行速度,其实不然。CPU的主频表示在CPU内数字脉冲信号震荡的速度,与CPU实际的运算能力并没有直接关系。
主频和实际的运算速度存在一定的关系,但至今还没有一个确定的公式能够定量两者的数值关系,因为CPU的运算速度还要看CPU的流水线的各方面的性能指标。由于主频并不直接代表运算速度,所以在一定情况下,很可能会出现主频较高的CPU实际运算速度较低的现象。
参考资料来源:百度百科-时钟频率
然后时钟2在这个PROCESS里面累加器到了50M的时候改变状态
然后输出为时钟2
就可以了
额 算了 给你写个程序吧 这年头 得点分不容易啊
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
entity div_frequence is
port(
clk_in,reset : in std_logic;
clk_out : out std_logic
);
end div_frequence;
architecture rtl of div_frequence is
signal local_s : std_logic;
begin
process(reset,clk_in)
variable tmp : integer;
begin
if (reset = '0') then
tmp := 0 ;
local_s <= '0';
elsif rising_edge(clk_in) then
if (tmp < 50000000) then
tmp := tmp + 1;
else
if (local_s = '0') then
local_s <= '1';
else
local_s <= '0';
end if;
tmp := 0;
end if;
end if;
clk_out <= local_s;
end process;
end rtl;
library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity fenpin is
port(
clk_in :in std_logic;---------input clk 50MHz
clk_1Hz :out std_logic;
clk_500Hz :out std_logic;
clk_1KHz :out std_logic;
clk_4MHz :out std_logic);-------输出clk
end fenpin;
architecture behav of fenpin is
signal cnt1 :natural range from 0 to 25000000;
signal cnt500 :natural range from 0 to 50000;
signal cnt1K :natural range from 0 to 25000;
signal cnt4M :natural range from 0 to 25;
begin
process(clk_in)
begin
if clk_in'event and clk_in='1' then
if cnt1 = 24999999 then
cnt1<=0;
clk_1Hz<=not clk_1Hz; ------------50M分频 25M的高电平 ,5M的低电平
else
cnt1<=cnt1+1;
end if;
if cnt500 = 49999 then
cnt500<=0;
clk_500Hz<=not clk_500Hz; --------------100K分频 50K的高电平 ,50K的低电平
else
cnt500<=cnt500+1;
end if;
if cnt1K = 24999 then
cnt1K<=0;
clk_1KHz<=not clk_1KHz;------------------50K分频 25K的高电平 ,25K的低电平
else
cnt1K<=cnt1K+1;
end if;
if cnt4M = 24 then ---------------------25为一个周期 用13分频和12分频的混合实现12.5分频
cnt4M<=0;
clk_4MHz<='1'; --------------------13分频的高电平
elsif cnt4M = 11 then
clk_4MHz<='1'; --------------------12分频的高电平
cnt4M<=cnt4M+1;
else
clk_4MHz<='0'; --------------------其余为低电平
cnt4M<=cnt4M+1;
end if;
end if;
end if;
end process;
end behav;
2011-05-04
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;
entity clk_div is
port(
clk : in std_logic;
clk1:out std_logic
);
end clk_div;
architecture mix of clk_div is
signal count :integer range 0 to 49999999;
----严格来说是从0-49999999,刚好50000000个计数值,正好将50M的时钟分为1Hz的时钟
begin
clk_div_proc:process(clk)
begin
if rising_edge(clk) then
if count=49999999 then
count<=0;
else
count<=count+1;
end if;
if count>24999999 then---占空比50%
clk1<='1';
else clk1<='0';
end if;
end if;
end process clk_div_proc;
end mix;
仿真验证正确。