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

Subversion Repositories sd_card_controller

[/] [sd_card_controller/] [trunk/] [rtl/] [verilog/] [bistable_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
//// bistable_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 has to be at least  ////
14
//// one clk_b clock period.                                      //// 
15
////                                                              ////
16
//// Author(s):                                                   ////
17
////     - Marek Czerski, ma.czerski@gmail.com                    ////
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2013 Authors                                   ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE. See the GNU Lesser General Public License for more  ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46
module bistable_domain_cross(
47
    rst,
48
    clk_a,
49
    in,
50
    clk_b,
51
    out
52
);
53
parameter width = 1;
54
input rst;
55
input clk_a;
56
input [width-1:0] in;
57
input clk_b;
58
output [width-1:0] out;
59
 
60
// We use a two-stages shift-register to synchronize in to the clk_b clock domain
61
reg [width-1:0] sync_clk_b [1:0];
62
always @(posedge clk_b or posedge rst)
63
begin
64
    if (rst == 1) begin
65
        sync_clk_b[0] <= 0;
66
        sync_clk_b[1] <= 0;
67
    end else begin
68
        sync_clk_b[0] <= in;
69
        sync_clk_b[1] <= sync_clk_b[0];
70
    end
71
end
72
 
73
assign out = sync_clk_b[1];  // new signal synchronized to (=ready to be used in) clk_b domain
74
 
75
endmodule

powered by: WebSVN 2.1.0

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