Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Synchronize incoming singal to clock

 
Thread Tools Search this Thread
Old 06-11-2007, 06:51 PM   #1
Default Synchronize incoming singal to clock


Hello @ all,

i have a small problem with synchronizing an incoming singal to the
Clock of my VIRTEX4.
At the moment i use this code to synchronize the incoming asynchronous
signal Pulse:

Sync_Pulse : process ( Internal_Clock )
begin

temp_pulse <= Pulse;
sync_pulse <= temp_pulse;

end process;

My question is if there is a more elegant or easier way to synchronize
an incoming signal.
thank you
Marc



TheThunder
  Reply With Quote
Old 06-11-2007, 06:56 PM   #2
ast
 
Posts: n/a
Default Re: Synchronize incoming singal to clock

"TheThunder" <> a écrit dans le message de news: m...
> Hello @ all,
>
> i have a small problem with synchronizing an incoming singal to the
> Clock of my VIRTEX4.
> At the moment i use this code to synchronize the incoming asynchronous
> signal Pulse:
>
> Sync_Pulse : process ( Internal_Clock )
> begin
>
> temp_pulse <= Pulse;
> sync_pulse <= temp_pulse;
>
> end process;
>
> My question is if there is a more elegant or easier way to synchronize
> an incoming signal.
> thank you
> Marc
>


Yes, use 2 Flip Flop, thats is correct.

but

do you really want these Flip Flop be trigerred by both edge of the clocks ?



ast
  Reply With Quote
Old 06-11-2007, 07:08 PM   #3
Dave Pollum
 
Posts: n/a
Default Re: Synchronize incoming singal to clock

TheThunder wrote:
> Hello @ all,
>
> i have a small problem with synchronizing an incoming singal to the
> Clock of my VIRTEX4.
> At the moment i use this code to synchronize the incoming asynchronous
> signal Pulse:
>
> Sync_Pulse : process ( Internal_Clock )
> begin
>
> temp_pulse <= Pulse;
> sync_pulse <= temp_pulse;
>
> end process;
>
> My question is if there is a more elegant or easier way to synchronize
> an incoming signal.
> thank you
> Marc


Except for leaving out the clock in your process, that's a standard 2-
stage synchronizer.
In other words:
process ( Internal_Clock )
begin
if rising_edge( Internal_Clock ) then
temp_pulse <= Pulse;
sync_pulse <= temp_pulse;
end if;
end;

-Dave Pollum



Dave Pollum
  Reply With Quote
Old 06-11-2007, 07:14 PM   #4
TheThunder
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
oh sorry i forgot to post the

"if rising_edge()"

thank you very much so i don't have to search anymore for a better
way!
1000 thanks!



TheThunder
  Reply With Quote
Old 06-11-2007, 07:46 PM   #5
Mike Treseler
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
TheThunder wrote:

> At the moment i use this code to synchronize the incoming asynchronous
> signal Pulse:
>
> Sync_Pulse : process ( Internal_Clock )
> begin
>
> temp_pulse <= Pulse;
> sync_pulse <= temp_pulse;
>
> end process;
>
> My question is if there is a more elegant or easier way to synchronize
> an incoming signal.


I use a procedure call from a synchronous process like this:

retime(
arg_in => Pulse, -- entity port value
update => retime_v -- UPDATE the variable retime_v
);


See the "Rising Level Counter" example here
http://home.comcast.net/~mike_treseler/
for details.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 06-16-2007, 04:06 PM   #6
Pinhas
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
There is a lot which you can see on the web regarding metastability.
In general if it is one signal, which comes across another clock
domain, than it is fine. If there are bigger buses involved, you may
need another solution.
Also there are many asynchronous serial communications standards
today. I have started to document a USB full speed project on
http://bknpk.no-ip.biz. In this case host and slave uses asynchronous
clocks.
Mike Treseler :
> TheThunder wrote:
>
> > At the moment i use this code to synchronize the incoming asynchronous
> > signal Pulse:
> >
> > Sync_Pulse : process ( Internal_Clock )
> > begin
> >
> > temp_pulse <= Pulse;
> > sync_pulse <= temp_pulse;
> >
> > end process;
> >
> > My question is if there is a more elegant or easier way to synchronize
> > an incoming signal.

>
> I use a procedure call from a synchronous process like this:
>
> retime(
> arg_in => Pulse, -- entity port value
> update => retime_v -- UPDATE the variable retime_v
> );
>
>
> See the "Rising Level Counter" example here
> http://home.comcast.net/~mike_treseler/
> for details.
>
> -- Mike Treseler




Pinhas
  Reply With Quote
Old 06-16-2007, 09:32 PM   #7
David R Brooks
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
Pinhas wrote:
> There is a lot which you can see on the web regarding metastability.
> In general if it is one signal, which comes across another clock
> domain, than it is fine. If there are bigger buses involved, you may
> need another solution.
> Also there are many asynchronous serial communications standards
> today. I have started to document a USB full speed project on
> http://bknpk.no-ip.biz. In this case host and slave uses asynchronous
> clocks.

You shouldn't ever try to synchronise the signals of a multi-bit bus
(assuming you have no prior knowledge of exactly how they behave).
Given there is always some finite skew between the bits on the bus, it's
a cert that sometime you will synchronise the early & late values of
different bits, resulting in a broken value.
The proper way is to set the bus value, then assert a strobe.
Synchronise the strobe, then latch the bus (which is known to be stable)
into the new domain.


David R Brooks
  Reply With Quote
Old 06-18-2007, 08:53 AM   #8
ast
 
Posts: n/a
Default Re: Synchronize incoming singal to clock

"David R Brooks" <> a écrit dans le message de news:
4674495e$0$22421$...
> Pinhas wrote:
>> There is a lot which you can see on the web regarding metastability.
>> In general if it is one signal, which comes across another clock
>> domain, than it is fine. If there are bigger buses involved, you may
>> need another solution.
>> Also there are many asynchronous serial communications standards
>> today. I have started to document a USB full speed project on
>> http://bknpk.no-ip.biz. In this case host and slave uses asynchronous
>> clocks.


> You shouldn't ever try to synchronise the signals of a multi-bit bus (assuming you have no prior knowledge of exactly how they
> behave).
> Given there is always some finite skew between the bits on the bus, it's a cert that sometime you will synchronise the early &
> late values of different bits, resulting in a broken value.
> The proper way is to set the bus value, then assert a strobe. Synchronise the strobe, then latch the bus (which is known to be
> stable) into the new domain.


You can strobe asynchronously a bus only if one bit is changing at a time.

ie, generating a "half full" signal for an asynchronous FIFO by strobing
the write and read address pointer if there are gray encoded.



ast
  Reply With Quote
Old 06-20-2007, 12:23 PM   #9
Eli Bendersky
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
On Jun 11, 7:56 pm, "ast" <a...@ast.com> wrote:
> "TheThunder" <marcal...@gmx.de> a écrit dans le message de news: 1181584299.313031.41...@w5g2000hsg.googlegroups.co m...
>
>
>
>
>
> > Hello @ all,

>
> > i have a small problem with synchronizing an incoming singal to the
> > Clock of my VIRTEX4.
> > At the moment i use this code to synchronize the incoming asynchronous
> > signal Pulse:

>
> > Sync_Pulse : process ( Internal_Clock )
> > begin

>
> > temp_pulse <= Pulse;
> > sync_pulse <= temp_pulse;

>
> > end process;

>
> > My question is if there is a more elegant or easier way to synchronize
> > an incoming signal.
> > thank you
> > Marc

>
> Yes, use 2 Flip Flop, thats is correct.
>
> but
>
> do you really want these Flip Flop be trigerred by both edge of the clocks ?- Hide quoted text -
>
> - Show quoted text -


The process the OP presented has another problem, IMHO. It doesn't
take reset into account. I don't think it's a portable way to code
such a process for synchronization. It is better to have some known
reset value:

process (clk, reset_n)
begin
if (reset_n = '0') then
sync_sig_1 <= '0'; -- or '1' if that is the reset value of sig
sync_sig_2 <= '0';
elsif (rising_edge(clk)) then
sync_sig_1 <= sig;
sync_sig_2 <= sync_sig_1;
end if;
end if;

sync_sig_2 is a synchronized (double FF) sig.




Eli Bendersky
  Reply With Quote
Old 06-20-2007, 02:10 PM   #10
Laurent Pinchart
 
Posts: n/a
Default Re: Synchronize incoming singal to clock
Eli Bendersky wrote:

> On Jun 11, 7:56 pm, "ast" <a...@ast.com> wrote:
>> "TheThunder" <marcal...@gmx.de> a écrit dans le message de news:
>> 1181584299.313031.41...@w5g2000hsg.googlegroups.co m...
>>
>>
>>
>>
>>
>> > Hello @ all,

>>
>> > i have a small problem with synchronizing an incoming singal to the
>> > Clock of my VIRTEX4.
>> > At the moment i use this code to synchronize the incoming asynchronous
>> > signal Pulse:

>>
>> > Sync_Pulse : process ( Internal_Clock )
>> > begin

>>
>> > temp_pulse <= Pulse;
>> > sync_pulse <= temp_pulse;

>>
>> > end process;

>>
>> > My question is if there is a more elegant or easier way to synchronize
>> > an incoming signal.
>> > thank you
>> > Marc

>>
>> Yes, use 2 Flip Flop, thats is correct.
>>
>> but
>>
>> do you really want these Flip Flop be trigerred by both edge of the
>> clocks ?- Hide quoted text -
>>
>> - Show quoted text -

>
> The process the OP presented has another problem, IMHO. It doesn't
> take reset into account. I don't think it's a portable way to code
> such a process for synchronization. It is better to have some known
> reset value:
>
> process (clk, reset_n)
> begin
> if (reset_n = '0') then
> sync_sig_1 <= '0'; -- or '1' if that is the reset value of sig
> sync_sig_2 <= '0';
> elsif (rising_edge(clk)) then
> sync_sig_1 <= sig;
> sync_sig_2 <= sync_sig_1;
> end if;
> end if;
>
> sync_sig_2 is a synchronized (double FF) sig.


I would advice against a reset signal in input synchronization blocks. You
are trying to generate in internal signal (sync_sig_2) which follows an
external asynchronous signal (sig) and filters out most of the
metastability and other asynchronous race conditions. Adding a reset signal
will only delay the input synchronization time during reset without any
added advantage.

Beside adding complexity for no reason, an asynchronous reset will make
sync_sig_2 asynchronous. Ken Chapman published a very interesting article
about reset strategies in FPGA designs called "Get Smart About Reset (Think
Local, Not Global)". You can find it on Xilinx's website at
http://www.xilinx.com/xlnx/xweb/xil_...kc_smart_reset

Best regards,

Laurent Pinchart



Laurent Pinchart
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Synchronize heterogeneous databases using SOASYNC soalib Software 1 04-13-2009 12:14 PM
Computer Clock GoneBeforeMyTime A+ Certification 5 04-21-2007 05:31 PM
Post-Route Simulation does not give output for the first clock cycle Options velocityreviews Software 0 04-17-2007 05:47 PM
New Releases: Revelations, The Librarian & My Left Foot: Updated complete downloadable R1 DVD DB & Info lists Doug MacLean DVD Video 0 05-17-2005 06:57 AM
Hollywood Detective - The Buried Clock David Marsh DVD Video 1 09-27-2004 11:26 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46