OpenCores
URL https://opencores.org/ocsvn/sd_card_controller/sd_card_controller/trunk

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [rtl/] [verilog/] [monostable_domain_cross.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 rozpruwacz
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// WISHBONE SD Card Controller IP Core                          ////
4
////                                                              ////
5
//// monostable_domain_cross.v                                    ////
6
////                                                              ////
7
//// This file is part of the WISHBONE SD Card                    ////
8
//// Controller IP Core project                                   ////
9 8 rozpruwacz
//// http://opencores.org/project,sd_card_controller              ////
10 3 rozpruwacz
////                                                              ////
11
//// Description                                                  ////
12
//// Clock synchronisation beetween two clock domains.            ////
13
//// Assumption is that input signal duration is always           //// 
14
//// one clk_a clock period. If that is true output signal        ////
15
//// duration is always one clk_b clock period.                   ////
16
////                                                              ////
17
//// Author(s):                                                   ////
18
////     - Marek Czerski, ma.czerski@gmail.com                    ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2013 Authors                                   ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE. See the GNU Lesser General Public License for more  ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from http://www.opencores.org/lgpl.shtml                     ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
 
47
module monostable_domain_cross(
48
    input rst,
49
    input clk_a,
50
    input in,
51
    input clk_b,
52
    output out
53
);
54
 
55
// this changes level when the in is seen in clk_a
56
reg toggle_clk_a;
57
always @(posedge clk_a or posedge rst)
58
begin
59
    if (rst)
60
        toggle_clk_a <= 0;
61
    else
62
        toggle_clk_a <= toggle_clk_a ^ in;
63
end
64
 
65
// which can then be sync-ed to clk_b
66
reg [2:0] sync_clk_b;
67
always @(posedge clk_b or posedge rst)
68
begin
69
    if (rst)
70
        sync_clk_b <= 0;
71
    else
72
        sync_clk_b <= {sync_clk_b[1:0], toggle_clk_a};
73
end
74
 
75
// and recreate the flag in clk_b
76
assign out = (sync_clk_b[2] ^ sync_clk_b[1]);
77
 
78
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.