vhdl中的时钟分频器,从100MHz到1Hz代码

问题描述 投票:0回答:1

我编写了这段代码,将时钟分频为一个nexys4 fpga,默认情况下其集成时钟为100Mhz频率,我需要将其分频为1hz。有人可以告诉我它是否正确或是否需要更改吗?

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;


entity digi_clk is
port (clk1 : in std_logic;
       clk : out std_logic
     );
end digi_clk;

architecture Behavioral of digi_clk is

signal count : integer :=0;
signal b : std_logic :='0';
begin

 --clk generation.For 100 MHz clock this generates 1 Hz clock.
process(clk1) 
begin
if(rising_edge(clk1)) then
count <=count+1;
if(count = 50000000) then
b <= not b;
count <=0;

end if;
end if;
clk<=b;
end process;
end;
vhdl fpga clock
1个回答
0
投票

代码看起来不错。但是,现有代码将产生刚好低于1 Hz的输出频率。要获得精确的100000000:1比率,您将需要从以下位置更改条件语句:

    if(count = 50000000) then

...至:

    if(count = 50000000-1) then
© www.soinside.com 2019 - 2024. All rights reserved.