electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

How to Synch. two Diff clock.


Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> How to Synch. two Diff clock.
Author Message
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post27 Feb 2008 13:15   

How to Synch. two Diff clock.


hi,
In a design i am having two clock.clk1 is of 100khz and clk2 is off 50khz and we are talking data at posedge of clk1 and using this data at posedge of clk2,so how to syn. these clks so that data at posedge of clk2 is not lost.give me some hint. how to tackle clock sync. problem B/w clocks,

Regards,
Dinesh
Back to top
banjo



Joined: 24 Dec 2005
Posts: 644
Helped: 118


Post27 Feb 2008 14:41   

How to Synch. two Diff clock.


Are the two clocks locked in phase? Or are they independently generated? Moving from a higher speed clock to a slower speed clock can be a problem. The absolute best case is that you can update data on the higher speed clock at only the lower clock's rate. Therefore, the higher speed clock can only update the data only every other cycle. In practise, you could still lose data at this rate, if you just miss the setup time on the lower speed clock.

For single bit-wide transfers, you can be assured of capturing the data if you hold the high speed data for three or more clocks. When transferring a wide bus, this still works, however you are not guaranteed that all bits of the bus will transition on the same clock cycle.

If the clock edges are fairly well aligned, I have had good success with moving the data from the positive edge to the negative edge of the higher speed clock before crossing the clock domain. This increases the setup time of the transfer and holding the data for two cycles should insure that the data makes it across the clock domains.

--- Steve
Back to top
roydmiles



Joined: 27 Feb 2008
Posts: 1


Post27 Feb 2008 17:56   

Re: How to Synch. two Diff clock.


I expect the clocks are asynchronous or it wouldn't be a problem. In this case, I would use a FIFO to transfer the data between clock domains.
Back to top
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post28 Feb 2008 6:38   

Re: How to Synch. two Diff clock.


Hi,
What is the specific reason behind to Hold the data for three or more clock pulse??
Why not Two clock???
What I get is that in a code of Synch. of clks I have to give dealy of three or more clk pulse (faster clk) and then data is Captured at slow clk so that no data loss is their during grabing of data at slower clk.Am I right or not??
If the edge of two clocks are not aligned then how to tackle this situation??

----
Dinesh


Last edited by dinesh.4126 on 28 Feb 2008 12:48; edited 1 time in total
Back to top
shawndaking



Joined: 20 Jun 2001
Posts: 235
Helped: 6


Post28 Feb 2008 10:53   

Re: How to Synch. two Diff clock.


the best thing is to up sample the 100khz.

you can use pll to multiply the 50khz .

then recover the signal and dff it with the 50khz which should be phase alligned to the upsampling clock.
Back to top
ashokjain



Joined: 28 Feb 2008
Posts: 8


Post28 Feb 2008 12:16   

Re: How to Synch. two Diff clock.


You need to provide more information so as to get further details on the answer.

1) Is the data on the 100khz always changing at every clock? Is there a new data at every clock rise edge?

2) If not what is the duration for which there is valid data on the 100khz line.

Think of an asynchronous FIFO design.
Back to top
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post28 Feb 2008 12:47   

Re: How to Synch. two Diff clock.


Hi,
1)Data is changing at every rising of clk(100khz).
2)We have to use this data to another Design which is operating at lower rate(50khz).
Interviewer asked me how you will tackle this problem so that no loss of data is occur at lower Freq. in our design without using PLL,DCM.
Back to top
banjo



Joined: 24 Dec 2005
Posts: 644
Helped: 118


Post28 Feb 2008 13:51   

How to Synch. two Diff clock.


If the data is changing at every rising edge of 100KHZ clock, then you must widen the bus when going to a 50KHZ domain! Otherwise data is arriving twice as fast as its leaving.

For the clock, I think they were looking for a answer of "the 50kHZ clock must be generated from the 100KHZ by a divider. " This insures that the 50KHZ is always later in phase than the 100KHZ and allows you to predict setup and hold times.
Back to top
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post12 Mar 2008 7:51   

Re: How to Synch. two Diff clock.


Hi,
Interviewer ask me this question by showing these waveform and expecting from me what you will do when you take same Data at CLK2(50khz).
Because at CLK2 Data will lost.
what I think is that we have to generate some intermediate signal from clk,so that that data at clk2 not be lost.
Am I thinking in right way?
and also CLK1(100KHZ).



Sorry, but you need login in to view this attachment

Back to top
shawndaking



Joined: 20 Jun 2001
Posts: 235
Helped: 6


Post12 Mar 2008 10:42   

Re: How to Synch. two Diff clock.


if ignoring the skew isues :

i think what he really wanted you to say is that you will use 2 bit bus as output with the 50khz clock, i.e to demux the data1 input !

so you use the clock2 as selector to 1:2 demux device that select the data1 input !!!


best regards !
Back to top
xtcx



Joined: 22 Dec 2007
Posts: 160
Helped: 5
Location: India


Post12 Mar 2008 11:08   

Re: How to Synch. two Diff clock.


This is getting nothing....See even though you sync your two clocks,the data is based upon the clk1 which is twice as fast as clk2(at)50MHz, so for every +ve edge of clk2 you lose one data bit..I am not so exact but maybe a way close to this could be like taking a complement of this clk2 and checking for rising edge of clk2 and clk2_inv. With respect to these 2 clks(at)50MHz, you get two data bits for one clk2 period or 1 data bit for 1 clk1 period....Thus
If rising_edge(clk2) THEN
data_buff1 <= DATA;
endif;
If rising_edge(clk2_inv) then
data_buff2 <= DATA;
end if;
Upto this point, you are reading 100MHz data rate with two 50MHz clock(invt and non-invt). For 1 single 50MHz clock cycle period, you will get two 100MHz data bits in this case.One data in data_buff1 and another in data_buff2. I once used this technique to recover the clock for Manchester coding where the recieved coded data will have twice the total bandwidth of our data rate....But I'm not sure how you could proceed from this point onward!....
Back to top
jackywang



Joined: 14 Mar 2008
Posts: 2


Post14 Mar 2008 10:40   

Re: How to Synch. two Diff clock.


I think u need an asynchronous fifo.
Back to top
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post14 Mar 2008 11:52   

Re: How to Synch. two Diff clock.


Asynchronous FIFO I am not fully assure will it be right Answer because if we use clk1(100Khz) for writing operation and clk2(50khz) for reading operation and clk1 is faster so I think their might be problem of Data over written.

Am I right or wrong??
Back to top
banjo



Joined: 24 Dec 2005
Posts: 644
Helped: 118


Post14 Mar 2008 13:07   

How to Synch. two Diff clock.


Yes, in theory you can lose data. However, if the data stream is not continuous and the FIFO is deep enough, it will not wrap around.
If you want continuous data AND fully async clocks, then the solution is to use a FIFO with different bus widths on the input and output. This allows you to extract the data at the same rate as you put it in. Data would come out at 1/2 speed, but be twice as wide.
---- Steve
Back to top
dinesh.4126



Joined: 27 Feb 2008
Posts: 63


Post14 Mar 2008 13:30   

Re: How to Synch. two Diff clock.


I have one more doubt in Asynchronous FIFO in this case clk1(100khz) is twice of clk2(50khz),therefore Data width is Double in read case,suppose if clk1 is of 150 khz and clk2 will be of 40 khz(when two clk is not multple),then in that case asyn. FIFO will work or not???
Back to top
teteamigo



Joined: 05 Mar 2005
Posts: 132
Helped: 14
Location: Portugal


Post14 Mar 2008 14:17   

Re: How to Synch. two Diff clock.


shawndaking wrote:
if ignoring the skew isues :

i think what he really wanted you to say is that you will use 2 bit bus as output with the 50khz clock, i.e to demux the data1 input !

so you use the clock2 as selector to 1:2 demux device that select the data1 input !!!


best regards !


http://en.wikipedia.org/wiki/SerDes
Back to top
banjo



Joined: 24 Dec 2005
Posts: 644
Helped: 118


Post14 Mar 2008 18:52   

How to Synch. two Diff clock.


Within programmable logic like FPGAs, you have lots of options for bus widths. Lets say that I make the slower clock's bus 10 times as wide as the faster clock. It will still work because the FIFO has an empty flag. The slower clock with the very wide bus would then need to poll the empty flag and only attempt to extract data when the FIFO is not empty. HereI am able to extract data much faster than it can be written into the FIFO from the front-end. Therefore, I have to monitor the FIFO status and only extract data when there is something to get!
Back to top
xtcx



Joined: 22 Dec 2007
Posts: 160
Helped: 5
Location: India


Post15 Mar 2008 12:41   

Re: How to Synch. two Diff clock.


Hello friends!
I think I have a solution to this question!.....
Step 1: Let the clk of 50KHz be CLK_50KHZ and it's complement be CLK_INV50KHZ.
Step 2: Now shift the CLK_INV50KHZ by a delay of 1/4 of the ON time of CLK_50KHZ.
Step 3: Now that you have obtained 2 50KHz sqrs with one wave, 180Deg out of phase along with a shift of 1/8 of CLK_50KHZ.
Step 4: Take XOR between these two clks.
Step 5: Now what you get is a train of trigger pulse for both ON and OFF time of your CLK_50KHZ!....Use this new XORed clk to fed your device to read the data from the 100KHz data bus...The data you read is at 100Kbps rate can now be sampled at time of 1\8th of it's 100KHz clk.So no need to worry about data skipping!.....Also this makes no need for any other logic and it's a simple.! I once used this logic for recovering data from Manchester coding which has frequency exactly double of the data rate!....There you go!...If there is mistake or flaws, please correct me!..
Back to top
ecikin



Joined: 14 Jul 2007
Posts: 26


Post24 Mar 2008 4:03   

How to Synch. two Diff clock.


shift the CLK_INV50KHZ by a delay of 1/4 of the ON time of CLK_50KHZ?
Back to top
xtcx



Joined: 22 Dec 2007
Posts: 160
Helped: 5
Location: India


Post24 Mar 2008 12:34   

Re: How to Synch. two Diff clock.


The time period for 50KHz clk is 20us, therefore desing a delay of 5us and then invert the signal and use that for xoring.IS it clear now?
Back to top
Google
AdSense
Google Adsense




Post24 Mar 2008 12:34   

Ads




Back to top
EDA_hg81



Joined: 25 Nov 2005
Posts: 395


Post10 Apr 2008 16:31   

Re: How to Synch. two Diff clock.


If the data are continuous and we want to keep data bus width are same at both sides.

Can we use two FIFOs one side running at 100KHZ and other side running at 50KHZ?

I think is the same idea as using fifo with double data bus.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design -> How to Synch. two Diff clock.
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
How CDMA2000 Cell Phone Synch (1)
How to delay the input by two clock cycles? (3)
two clock, how to find out which frequency is higher? (7)
single to diff clock (1)
sycronizing of two clock? (2)
two phase clock (7)
layout question -- diff. b/w material of n-well and n-diff (1)
two clock frequency operation (4)
how to use two lmgrds to start two licenses in a linux sever (2)
Reg. Interfacing two clock domain (5)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS