Guest
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
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