sychronize outside signal

A

Arron

In my project, the main clock is 10MHz and the input signal is a 1kHz
square wave. I hope to detect the rising edge of the input signal and
output a high level voltage for one clock when it were detected. I use
finite state machine to realize the design in Altera Quartus II, the
simulation is OK. But the hardware (Cyclone) gives unexpected results:
no output or several clock signals after the rising edge of input
signal. Does anybody know other method to my project? Thank you in
advance.
 
A

ALuPin

In my project, the main clock is 10MHz and the input signal is a 1kHz
square wave. I hope to detect the rising edge of the input signal and
output a high level voltage for one clock when it were detected. I use
finite state machine to realize the design in Altera Quartus II, the
simulation is OK. But the hardware (Cyclone) gives unexpected results:
no output or several clock signals after the rising edge of input
signal. Does anybody know other method to my project? Thank you in
advance.

Hi,

can you give some essential parts of your code to see what
could go wrong?

Rgds
André
 
N

Niv

Arron said:
In my project, the main clock is 10MHz and the input signal is a 1kHz
square wave. I hope to detect the rising edge of the input signal and
output a high level voltage for one clock when it were detected. I use
finite state machine to realize the design in Altera Quartus II, the
simulation is OK. But the hardware (Cyclone) gives unexpected results:
no output or several clock signals after the rising edge of input
signal. Does anybody know other method to my project? Thank you in
advance.

As already stated, you may have metastability issues.
Try this:

SIGNAL reg1: STD_LOGIC;
SIGNAL reg2: STD_LOGIC;
SIGNAL reg3: STD_LOGIC;

sync_1khz: PROCESS (reset_n, clk_1mhz)
BEGIN
IF reset_n = '0' THEN
reg1 <= '0';
reg2 <= '0';
ELSIF rising_edge(clk_1mhz) THEN

-- Insert metastability regs;

reg1 <= in_1khz;
reg2 <= reg1;
reg3 <= reg2;

-- Now detect the edge.

IF reg2 = '1' AND reg3 = '0' THEN -- This is the 1KHz rising edge,
delayed by a few 1MHz clock cycles.

-- Do whatever with edge.

END IF;
END IF;

END PROCESS sync_1khz;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top