Altera_Forum
Honored Contributor
11 years agoSimulation problem with simple edge detector
I have a very simple edge detector and I'm confused as to why I get this very small blip (pulse) on my output when it detects an edge. I ran into this in a larger design so I simplified it down to a project with only an edge detector. I have a clock, reset and an input that this the rising edge to be detected. The output should be a tick one clock period wide. I'm using the normal method/circuit to detect this, but the simulation gives me this little tiny pulse. Why is this? I've seen a simulation online with the same code that didn't have this problem. I've attached the HDL, testbench (very short files) and a pic of my simulation. Any ideas?
Simulation: http://www.alteraforum.com/forum/attachment.php?attachmentid=9571&stc=1 My detector:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity RisingeEdgeDetector is
port(
CLK : in std_logic;
RESET : in std_logic;
INPUT : in std_logic;
OUTPUT : out std_logic
);
end entity RisingeEdgeDetector;
architecture arch of RisingeEdgeDetector is
SIGNAL input_latch : std_logic;
begin
process(CLK, RESET)
begin
if(RESET = '0') then
input_latch <= '0';
elsif(rising_edge(CLK)) then
input_latch <= INPUT;
end if;
end process;
OUTPUT <= INPUT and (not input_latch);
end architecture arch;
TestBench:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY RisingeEdgeDetector_vhd_tst IS
END RisingeEdgeDetector_vhd_tst;
ARCHITECTURE RisingeEdgeDetector_arch OF RisingeEdgeDetector_vhd_tst IS
-- constants
-- signals
SIGNAL CLK : STD_LOGIC;
SIGNAL INPUT : STD_LOGIC;
SIGNAL OUTPUT : STD_LOGIC;
SIGNAL RESET : STD_LOGIC;
COMPONENT RisingeEdgeDetector
PORT (
CLK : IN STD_LOGIC;
INPUT : IN STD_LOGIC;
OUTPUT : OUT STD_LOGIC;
RESET : IN STD_LOGIC
);
END COMPONENT;
BEGIN
i1 : RisingeEdgeDetector
PORT MAP (
-- list connections between master ports and signals
CLK => CLK,
INPUT => INPUT,
OUTPUT => OUTPUT,
RESET => RESET
);
init : PROCESS
BEGIN
RESET <= '0';
wait for 100 ns;
RESET <= '1';
WAIT;
END PROCESS init;
PROCESS
BEGIN
CLK <= '0';
wait for 10 ns;
CLK <= '1';
wait for 10 ns;
END PROCESS;
PROCESS
BEGIN
INPUT <= '0';
wait for 190 ns;
INPUT <= '1';
wait for 20 ns;
INPUT <= '0';
WAIT;
END PROCESS;
END RisingeEdgeDetector_arch;
Here is the link of the simulation looks normal: http://fpgacenter.com/examples/basic/edge_detector.php