Re: On synchronization methods across clock domains




Is your command multi-bit? What happens when the dstclk samples some changing bits in one cycle and the rest in the next? If multiple bits change, you can never guarantee that you'll register all the changing bits in only one cycle.

A two register synchronizer is great for a single signal but will not help for multi-bit values.

If your wire foo is used to validate the data is steady for two cycles - which isn't clear since your two_reg_synchronizer module isn't obvious - then this technique actually is recommended. You effectively have a slower domain being sampled by a higher speed domain since your srcclk signal lasts 8 clocks. The transfer from a slower to faster domain is often done by verifying the value doesn't change in consecutive cycles; if the value has changed, all bits may have been sampled or not. If the sample is consistent, the read value is stable and usable.

- John_H


almkglor@xxxxxxxxx wrote:
Hello! I'm currently designing a largish multi-clock digital core in
Verilog. I have a source clock, srcclk, which can be as slow as 1000
times slower than dstclk, or up to 2x faster than dstclk.

I need to synchronize a control from the srcclk to the dstclk. This
control is assuredly signalled every 8 srcclk cycles (as long as the
part is enabled, anyway). My design for synchronization uses an
either-edge detector, so that I can handle crossing clock domains from
faster to slower or slower to faster, like so:

always @(posedge srcclk, negedge reset_n) if(!reset_n) foo_command <=
0 else begin
if(en && every8thcycle) begin
foo_command <= ~foo_command; end end

two_reg_synchronizer a(
.in(foo_command),
.out(foo_sync),
.clk(dstclk),
.reset_n(reset_n));

always @(posedge dstclk) begin
d_foo_sync <= foo_sync; end
wire foo = (d_foo_sync != foo_sync);

I have a piece of data that is generated every 8 srcclk cycles and the
foo command is intended to tell the destination that the data for that
8-cycle set is ready. Basically, I have no control over srcclk.
dstclk is constant.

My question is, why isn't such a structure recommended by any of the
sites I've seen? Most of them just recommend the sync + rising-edge/
falling-edge detector for slow-to-fast clock domain crossings, or else
the handshaking request-acknowledge (which still uses an edge
detector, but the signal is deasserted only on ackowledgement).

I can't use the plain edge detector (because my source clock can be
faster than the destination clock) and using a handshaking request-
acknowledge won't deassert the signal fast enough for cases when the
source clock reaches 2x my destination clock (the synchronization on
both directions takes too much time).

This is the reason I developed the above synchronization style, but
I'm concerned that no one recommends it (or do I need to improve my
google-trawling skillz?). Is there any particular reason why it
isn't?

Granted, this is a digital design question not specific to Verilog -
should it be asked elsewhere?

Sincerely,
AmkG
.



Relevant Pages

  • Re: On synchronization methods across clock domains
    ... If your wire foo is used to validate the data is steady for two cycles - ... The transfer from a slower to faster domain is ... I have a source clock, srcclk, which can be as slow as 1000 ...
    (comp.lang.verilog)
  • On synchronization methods across clock domains
    ... I have a source clock, srcclk, which can be as slow as 1000 ... times slower than dstclk, or up to 2x faster than dstclk. ... I need to synchronize a control from the srcclk to the dstclk. ...
    (comp.lang.verilog)
  • Re: Accurate(ish) frequency measurement
    ... The simple method - counting cycles - would sort of work. ... clock to measure things more accurately isn't too feasable. ... an interpolator will find Delta_T1 = the time from the active ... edge of the gate to the next active edge of the unknown clock. ...
    (sci.electronics.design)
  • Re: Division by Zero in Nature, and Decomposition of Time.
    ... It *starts* with cycles, historically, but is not ... "the whole universe" to build a clock, ... > they would be either zero or very near zero relative to everything ... > that they simply do not exist relative to an observer such as us. ...
    (sci.math)
  • Re: 8051 architecture
    ... design philosophies from traditional to soft cores fro ASICs. ... Some do run in 2 clock cycles per machine state. ...
    (comp.arch.embedded)

Loading