Newbie: Synchronize a time value to another clock

Discussion in 'VHDL' started by Manfred Balik, Nov 12, 2004.

  1. I'm using an even-numbered clock to generate a time value.
    How can I synchronize this time value to a part in the code using an other
    odd-numbered clock ?
    Thanks, Manfred
    Manfred Balik, Nov 12, 2004
    #1
    1. Advertising

  2. Manfred Balik wrote:
    > I'm using an even-numbered clock to generate a time value.
    > How can I synchronize this time value to a part in the code using an other
    > odd-numbered clock ?


    What are even/odd-numbered clocks?
    What is a time value?

    Paul.
    Paul Uiterlinden, Nov 12, 2004
    #2
    1. Advertising

  3. even-numbered clock: 40 MHz
    odd-numbered clock: 27.678...MHz
    time value: like in Unix "timespec" - 16bit for ns, 16bit for s
    I can't make this time value from the 27.678...MHz-clock, because the
    duration of one clock is not equal to nanoseconds.
    So I want to make the time value by an 40MHz-clock, but I need the value in
    the 27.678...MHz-clock-domain.
    Thanks, Manfred


    "Paul Uiterlinden" <> schrieb im Newsbeitrag
    news:cn2ac9$73h$...
    > Manfred Balik wrote:
    >> I'm using an even-numbered clock to generate a time value.
    >> How can I synchronize this time value to a part in the code using an
    >> other odd-numbered clock ?

    >
    > What are even/odd-numbered clocks?
    > What is a time value?
    >
    > Paul.
    Manfred Balik, Nov 12, 2004
    #3
  4. Manfred Balik

    Hal Murray Guest

    >So I want to make the time value by an 40MHz-clock, but I need the value in
    >the 27.678...MHz-clock-domain.


    Plan 1:
    Take the 40 MHz clock and divide it down so that it is slow enough
    to process in the 27 MHz domain. Say 10 MHz for example. Send
    that across (watch metastability and such) and update the clock
    every time you see an edge.

    Plan 2:
    How much accuracy do you need? (The crystal isn't perfect.)
    Just use a big counter - lots of bits in the fraction part.
    Every time the 27 MHz clock ticks you add a magic constant.
    The fraction part will overflow occasionally and correct
    for not having simple integer values.


    --
    The suespammers.org mail server is located in California. So are all my
    other mailboxes. Please do not send unsolicited bulk e-mail or unsolicited
    commercial e-mail to my suespammers.org address or any of my other addresses.
    These are my opinions, not necessarily my employer's. I hate spam.
    Hal Murray, Nov 12, 2004
    #4
  5. Manfred Balik wrote:
    > even-numbered clock: 40 MHz
    > odd-numbered clock: 27.678...MHz
    > time value: like in Unix "timespec" - 16bit for ns, 16bit for s
    > I can't make this time value from the 27.678...MHz-clock, because the
    > duration of one clock is not equal to nanoseconds.
    > So I want to make the time value by an 40MHz-clock, but I need the value in
    > the 27.678...MHz-clock-domain.
    > Thanks, Manfred
    >
    >
    > "Paul Uiterlinden" <> schrieb im Newsbeitrag
    > news:cn2ac9$73h$...
    >
    >>Manfred Balik wrote:
    >>
    >>>I'm using an even-numbered clock to generate a time value.
    >>>How can I synchronize this time value to a part in the code using an
    >>>other odd-numbered clock ?

    >>
    >>What are even/odd-numbered clocks?
    >>What is a time value?
    >>
    >>Paul.


    Well, depends a lot on how you are going to implement it, if it is a
    FPGA that
    supports a FIFO with separate read and write clocks it should be very
    easy. Just
    divide your write clock down to 10 or 20 MHz and you will not have any
    problem.

    If your design is based on something else, we have to have another think.

    /NS
    Nils Strandberg, Nov 12, 2004
    #5
  6. Manfred Balik wrote:
    > even-numbered clock: 40 MHz
    > odd-numbered clock: 27.678...MHz
    > time value: like in Unix "timespec" - 16bit for ns, 16bit for s
    > I can't make this time value from the 27.678...MHz-clock, because the
    > duration of one clock is not equal to nanoseconds.
    > So I want to make the time value by an 40MHz-clock, but I need the value in
    > the 27.678...MHz-clock-domain.


    OK, so your main problem is to get this 16 bit value accros the clock
    boundary, from the area running on the fast clock to the area on the
    slow clock.

    Because this value is generated with a different clock, you cannot clock
    it in without further measures. The best way is to create a single
    data-valid signal and solve the meta-stability problem on that signal.
    That means that the signal must be at least two 40 MHz clock periods
    long (otherwise it can be missed, clocking it in at 27 MHz) and this
    signal must be clocked in with two cascaded flip-flops (for the
    meta-stability problem). Also make sure that the source of the
    data-valid signal is a flip-flop, so the transistion across the clock
    boundary is directly from flip-flop to flip-flop, without any logic in
    between (again: to avoid meta-stability problems).

    Perhaps you'll also need a kind of request signal (indicating "give me a
    new value") going from the 27 MHz area to the 40 MHz area. If so, the
    meta-stablity problem should be considered there as well.

    Paul.
    Paul Uiterlinden, Nov 15, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    710
    Peter Alfke
    Apr 27, 2006
  2. Replies:
    8
    Views:
    475
    Magnus Lycka
    Aug 5, 2005
  3. TheThunder
    Replies:
    13
    Views:
    1,188
    Laurent Pinchart
    Jun 21, 2007
  4. Junkone

    synchronize clock

    Junkone, Sep 22, 2008, in forum: Ruby
    Replies:
    1
    Views:
    96
    Heesob Park
    Sep 22, 2008
  5. Chuck Remes
    Replies:
    12
    Views:
    219
    Tony Arcieri
    Jul 7, 2010
Loading...

Share This Page