port(
data_in : in std_logic;
clk : in std_logic;
data_out : out std_logic
)
signal data_temp : std_logic;
-- 将输入数据打一个节拍,用于判断上升沿
process(clk, data_in)
begin
if clk'event and clk = '1' then
data_temp <= data_in;
end if;
end process;
-- 当 当前的data_in = 为高电平,而前一个clk输入的data_in即data_temp = 0 为低电平时,表示检测到data_in的上升沿。
porcess(clk, data_in, data_temp)
begin
if clk'event and clk = '1' then
if data_in = '1' and data_temp = '0' then
data_out <= '1';
else
data_out <= '0'
end if;
end if;
end process;