一個(gè)比較實(shí)用的小程序灵莲,在很多地方可以用到,實(shí)測可用帚呼。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity reseter is
port(clk:in std_logic; --輸入時(shí)鐘100Mhz
reset_out:buffer std_logic:='1'); --初始設(shè)為高電平
end reseter;
architecture behav of reseter is
signal COUNT1 :INTEGER RANGE 0 TO 300000000:=0;
signal count2 :integer range 0 to 300000000:=0;
begin
PROCESS(clk,reset_out)
BEGIN
IF RISING_EDGE(clk) THEN
IF reset_out='1' THEN --1S高電平
IF COUNT1=1000000 THEN
--IF COUNT1=40 THEN
reset_out<='0'; COUNT1<=0;
ELSE COUNT1<=count1+1;
END IF;
ELSE
if count2=200000000 then --2S低電平
-- if count2=300 then
reset_out<='1'; count2<=0;
else count2<=count2+1;
END IF;
end if;
end if;
END PROCESS ;
end behav;