mark RFX boards as i_and_q_swapped
[debian/gnuradio] / usrp2 / fpga / control_lib / oneshot_2clk.v
1
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
7 //   clock domain.
8
9 module oneshot_2clk
10   (input clk_in,
11    input in,
12    input clk_out,
13    output reg out);
14
15    reg    del_in = 0;
16    reg    sendit = 0, gotit = 0;
17    reg    sendit_d = 0, gotit_d = 0;
18    
19    always @(posedge clk_in) del_in <= in;
20
21    always @(posedge clk_in)
22      if(in & ~del_in)  // we have a positive edge
23        sendit <= 1;
24      else if(gotit)
25        sendit <= 0;
26
27    always @(posedge clk_out) sendit_d <= sendit;
28    always @(posedge clk_out) out <= sendit_d;
29
30    always @(posedge clk_in) gotit_d <= out;
31    always @(posedge clk_in) gotit <= gotit_d;
32
33 endmodule // oneshot_2clk
34
35