偶数分频方法的VHDL代码实现

将频率为50MHz时钟分频为1Hz脉冲,需要进行50000000次分频。由于分频系数为偶数,利用偶数分频方法即可。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity five555 is
 port
 (
  clk:in std_logic;
  clkout:out std_logic
 );
 end;
architecture one of five555 is 
signal clktemp:std_logic;
constant temp:integer:=25000000;
begin
 process(clk)
		variable cnt:integer:=0;
		begin
		if(clk'event and clk='1') then
			 if cnt=temp then
				 clktemp<=not clktemp;
				 cnt:=0;
			  else
				 cnt:=cnt+1;
			 end if;
		 end if;
 end process;
 clkout<=clktemp;
 end;

猜你喜欢

转载自blog.csdn.net/m0_46808930/article/details/131178152
今日推荐