How to create an asynchronous Edge Detector in VHDL?


I am new to VHDL. I would like to create an Edge Detector that works asynchronously (without use of clock signal).

I am using a simple schematic for this:

edge detector

In Quartus II (Altera/Intel) I have this code:

----
signal MyInput_Change : std_logic;
----
process (MyInput)   
begin

  MyInput_Change<= not(not (MyInput)) xor MyInput;  --edge detector
  if ( MyInput_Change = '1' ) then 
       --change state of FSM
  end if;

But this code doesn't work.

What am I doing wrong?


Answers:


Declare signals:

signal I    : std_logic;         -- input
signal I_d  : std_logic := '0';  -- input delayed by 1 cycle
signal I_re : std_logic;         -- rising edge
signal I_fe : std_logic;         -- falling edge
signal I_ch : std_logic;         -- changed

Delay input signal:

I_d <= I when rising_edge(Clock);

Rising edge detection:

I_re <= not I_d and I;  -- old = 0, new = 1 => rising edge

Falling edge detection:

I_fe <= I_d and not I;  -- old = 1, new = 0 => falling edge

Edge / change detection:

I_ch <= I_d xor I;      -- old <> new       => changed