detector1.vhd

来自「很多仪器都输出同步时钟」· VHDL 代码 · 共 41 行

VHD
41
字号
-- 库声明
library IEEE;
use IEEE.STD_LOGIC_1164.all; 
use WORK.SEND_PACKAGE.ALL;
-- 实体声明
entity detector1 is
	port (
	clk : in std_logic;
	reset_n : in std_logic;
	RxD : in std_logic;          --输入信号
	new_data : out std_logic );  --指示信号,当监测到新的数据传输时置高
end detector1;

-- 结构体
architecture detector1 of detector1 is

-- 信号监测器状态机
signal state : dt_state;

begin
	-- enter your statements here --
	-- 主过程
	main : process(reset_n, clk)
	begin
		-- 复位信号
		if reset_n = '0' then
			state <= dt_unlock;
			new_data <= '0';
		elsif rising_edge(clk) then
			-- 检查输入信号和状态,当输入为低并且不在锁定状态时,输出new_data信号 
			if state = dt_unlock and RxD = '0' then
				new_data <= '1';
				state <= dt_lock;
			else
				new_data <= '0';
			end if;
		end if;
			
	end process;

end detector1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?