2 // Retime a single bit from one clock domain to another
3 // Guarantees that no matter what the relative clock rates, if the in signal is high for at least
4 // one clock cycle in the clk_in domain, then the out signal will be high for at least one
5 // clock cycle in the clk_out domain. If the in signal goes high again before the process is done
6 // the behavior is undefined. No other guarantees. Designed for passing reset into a new
16 reg sendit = 0, gotit = 0;
17 reg sendit_d = 0, gotit_d = 0;
19 always @(posedge clk_in) del_in <= in;
21 always @(posedge clk_in)
22 if(in & ~del_in) // we have a positive edge
27 always @(posedge clk_out) sendit_d <= sendit;
28 always @(posedge clk_out) out <= sendit_d;
30 always @(posedge clk_in) gotit_d <= out;
31 always @(posedge clk_in) gotit <= gotit_d;
33 endmodule // oneshot_2clk