Statistics
| Branch: | Tag: | Revision:

root / usrp2 / control_lib / oneshot_2clk.v @ a9d30712

History | View | Annotate | Download (1.7 KB)

1 bfaa5d14 Josh Blum
//
2
// Copyright 2011 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17
18 61f2f021 jcorgan
19
// Retime a single bit from one clock domain to another
20
// Guarantees that no matter what the relative clock rates, if the in signal is high for at least
21
//   one clock cycle in the clk_in domain, then the out signal will be high for at least one
22
//   clock cycle in the clk_out domain.  If the in signal goes high again before the process is done
23
//   the behavior is undefined.  No other guarantees.  Designed for passing reset into a new
24
//   clock domain.
25
26
module oneshot_2clk
27
  (input clk_in,
28
   input in,
29
   input clk_out,
30
   output reg out);
31
32
   reg 	  del_in = 0;
33
   reg 	  sendit = 0, gotit = 0;
34
   reg 	  sendit_d = 0, gotit_d = 0;
35
   
36
   always @(posedge clk_in) del_in <= in;
37
38
   always @(posedge clk_in)
39
     if(in & ~del_in)  // we have a positive edge
40
       sendit <= 1;
41
     else if(gotit)
42
       sendit <= 0;
43
44
   always @(posedge clk_out) sendit_d <= sendit;
45
   always @(posedge clk_out) out <= sendit_d;
46
47
   always @(posedge clk_in) gotit_d <= out;
48
   always @(posedge clk_in) gotit <= gotit_d;
49
50
endmodule // oneshot_2clk
51
52