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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [sync_module.v] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 mihad
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "sync_module.v"                                   ////
4
////                                                              ////
5
////  This file is part of the "PCI bridge" project               ////
6
////  http://www.opencores.org/cores/pci/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Tadej Markovic, tadej@opencores.org                   ////
10
////                                                              ////
11
////  All additional information is avaliable in the README.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org       ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS Revision History
43
//
44
// $Log: not supported by cvs2svn $
45
//
46
//
47
 
48
// synopsys translate_off
49
`include "timescale.v"
50
// synopsys translate_on
51
 
52
module SYNC_MODULE
53
(
54
                                        set_clk_in,
55
                                        delete_clk_in,
56
                                        reset_in,
57
                                        delete_set_out,
58
                                        block_set_out,
59
                                        delete_in
60
);
61
 
62
// system inputs from two clock domains
63
input   set_clk_in;
64
input   delete_clk_in;
65
input   reset_in;
66
// control outputs
67
output  delete_set_out;
68
output  block_set_out;
69
// control input
70
input   delete_in;
71
 
72
// internal signals
73
reg             del_bit;
74
wire    meta_del_bit;
75
reg             sync_del_bit;
76
reg             delayed_del_bit;
77
wire    meta_bckp_bit;
78
reg             sync_bckp_bit;
79
reg             delayed_bckp_bit;
80
 
81
 
82
// DELETE_IN input FF - when set must be active, until it is sinchronously cleared
83
always@(posedge delete_clk_in or posedge reset_in)
84
begin
85
        if (reset_in)
86
                del_bit <= 1'b0;
87
        else
88
        begin
89
                if (!delayed_bckp_bit && sync_bckp_bit)
90
                        del_bit <= 1'b0;
91
                else if (delete_in)
92
                        del_bit <= 1'b1;
93
        end
94
end
95
assign  block_set_out = del_bit;
96
 
97
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
98
synchronizer_flop       delete_sync
99
(
100
    .data_in        (del_bit),
101
    .clk_out        (set_clk_in),
102
    .sync_data_out  (meta_del_bit),
103
    .async_reset    (reset_in)
104
) ;
105
 
106
// Final synchronization of del_bit signal to the set clock domain
107
always@(posedge set_clk_in or posedge reset_in)
108
begin
109
        if (reset_in)
110
                sync_del_bit <= 1'b0;
111
        else
112
                sync_del_bit <= meta_del_bit;
113
end
114
 
115
// Delayed sync_del_bit signal for one clock period pulse generation
116
always@(posedge set_clk_in or posedge reset_in)
117
begin
118
        if (reset_in)
119
                delayed_del_bit <= 1'b0;
120
        else
121
                delayed_del_bit <= sync_del_bit;
122
end
123
 
124
assign  delete_set_out = !delayed_del_bit && sync_del_bit;
125
 
126
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
127
synchronizer_flop       clear_delete_sync
128
(
129
    .data_in        (sync_del_bit),
130
    .clk_out        (delete_clk_in),
131
    .sync_data_out  (meta_bckp_bit),
132
    .async_reset    (reset_in)
133
) ;
134
 
135
// Final synchronization of sync_del_bit signal to the delete clock domain
136
always@(posedge delete_clk_in or posedge reset_in)
137
begin
138
        if (reset_in)
139
                sync_bckp_bit <= 1'b0;
140
        else
141
                sync_bckp_bit <= meta_bckp_bit;
142
end
143
 
144
// Delayed sync_bckp_bit signal for one clock period pulse generation
145
always@(posedge delete_clk_in or posedge reset_in)
146
begin
147
        if (reset_in)
148
                delayed_bckp_bit <= 1'b0;
149
        else
150
                delayed_bckp_bit <= sync_bckp_bit;
151
end
152
 
153
endmodule

powered by: WebSVN 2.1.0

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