library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY DH_1 IS
PORT (
clk : IN std_logic;
TRIG : OUT std_logic;
END DH_1;
ARCHITECTURE arch OF DH_1 IS
constant N:Integer:=999;
constant RC_N:Integer:=10;
signal RC:Integer range 0 TO 100;
signal TRIG_RC:std_logic;
signal TRIG_ON:std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if counter=N THEN --N=9999
counter<=0;
TRIG_ON<= NOT TRIG_ON; --将clk分频为1ms信号TRIG_ON
else
counter<=counter+1;
end if;
end if;
end process;
PROCESS(clk)
begin
if rising_edge(TRIG_ON)then
RC<=0;
end if;
If RC<10 then
RC<=RC+1;
TRIG_RC<='1';
else
TRIG_RC<='0';
end if;