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

Subversion Repositories spacewire

[/] [spacewire/] [branches/] [ref/] [rtl/] [synchronizer_flop.v] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 btltz
//===========================================================================
2
// $Id: synchronizer_flop.v,v 1.1.1.1 2005-04-16 03:12:12 btltz Exp $
3
//
4
//////////////////////////////////////////////////////////////////////
5
////                                                              ////
6
//// synchronizer_flop                                            ////
7
////                                                              ////
8
//// This file is part of the general opencores effort.           ////
9
//// <http://www.opencores.org/cores/misc/>                       ////
10
////                                                              ////
11
//// Module Description:                                          ////
12
////                                                              ////
13
//// Make a rising-edge triggered flop with async reset with a    ////
14
////   distinguished name so that it can be replaced with a flop  ////
15
////   which does not make X's during simulation.                 ////
16
////                                                              ////
17
//// This flop should be used instead of a regular flop for ALL   ////
18
////   cross-clock-domain flops.  Manually instantiating this     ////
19
////   flop for all signals which must NEVER go to 1'bX during    ////
20
////   simulation will make it possible for the user to           ////
21
////   substitute a simulation model which does NOT have setup    ////
22
////   and hold checks.                                           ////
23
////                                                              ////
24
//// If a target device library has a component which is          ////
25
////   especially well suited to perform this function, it should ////
26
////   be instantiated by name in this file.  Otherwise, the      ////
27
////   behaviorial version of this module will be used.           ////
28
////                                                              ////
29
//// To Do:                                                       ////
30
////    To parameterize the reg "PulseKeep",i must keep it in a  ////
31
////    alone module due to the data_in is a array of clock      ////
32
////    signal. Who can tell me the way to merge the two in a    ////
33
////    single module?                                            ////
34
////                                                              ////
35
//// Author(s):                                                   ////
36
//// - anynomous                                                  ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
////                                                              ////
40
//// Copyright (C) 2001 Authors and OPENCORES.ORG                 ////
41
////                                                              ////
42
//// This source file may be used and distributed without         ////
43
//// restriction provided that this copyright statement is not    ////
44
//// removed from the file and that any derivative work contains  ////
45
//// the original copyright notice and the associated disclaimer. ////
46
////                                                              ////
47
//// This source file is free software; you can redistribute it   ////
48
//// and/or modify it under the terms of the GNU Lesser General   ////
49
//// Public License as published by the Free Software Foundation; ////
50
//// either version 2.1 of the License, or (at your option) any   ////
51
//// later version.                                               ////
52
////                                                              ////
53
//// This source is distributed in the hope that it will be       ////
54
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
55
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
56
//// PURPOSE. See the GNU Lesser General Public License for more  ////
57
//// details.                                                     ////
58
////                                                              ////
59
//// You should have received a copy of the GNU Lesser General    ////
60
//// Public License along with this source; if not, download it   ////
61
//// from <http://www.opencores.org/lgpl.shtml>                   ////
62
////                                                              ////
63
//////////////////////////////////////////////////////////////////////
64
//
65
// CVS Revision History
66
//
67
// $Log: not supported by cvs2svn $
68
// Revision 1.5  2005/03/26  17:49 btltz
69
// Add annother order flip-flop for FPGA usage
70
// Add annother style of synchronizer
71
// parameterized
72
// change timescale due to my own environment.You may change it.
73
//
74
// Revision 1.4  2001/09/03 13:18:30  bbeaver
75
// no message
76
//
77
// Revision 1.1  2001/09/02 11:32:03  Blue Beaver
78
// no message
79
//
80
//
81
 
82
`timescale 1ns/10ps
83
`define STYLE1     //STYLE1 for conditions that input signals are wider than clk 
84
//`define  STYLE2          //STYLE2 for conditions that input signals may be narrower than clk 
85
 
86
// If the vendor has a flop which is particularly good at settling out of
87
//   metastability, it should be used here.
88
module synchronizer_flop #(parameter WIDTH = 8*2)
89
                      ( output reg [WIDTH-1:0] sync_data_out,
90
                        input [WIDTH-1:0] data_in,
91
                        input clk, async_reset
92
                       );
93
/*
94
  input   data_in;
95
  input   clk_out;
96
  output  sync_data_out;
97
  input   async_reset;*/
98
 
99
  reg [WIDTH-1:0] sync_data_out0;
100
 
101
`ifdef STYLE2
102
 wire [WIDTH-1:0] clr_PK = (sync_data_out & !data_in) ;
103
 wire [WIDTH-1:0] KP_OUT;
104
 ////////////////////////////////////////
105
 //PulseKeep parameterized instantiation
106
 //
107
 generate
108
 begin:G1
109
   genvar i;
110
   for(i=0; i<WIDTH; i=i+1)
111
    begin:inst
112
          PulseKeep_reg  inst_KP (KP_OUT[i],data_in[i],clr_PK[i],async_reset);
113
    end
114
 end
115
 endgenerate
116
 
117
 `endif
118
//////////
119
  always @(posedge clk or posedge async_reset)
120
  begin
121
    if (async_reset == 1'b1)
122
    begin
123
      sync_data_out0 <= 0;
124
      sync_data_out <= 0;
125
    end
126
    else
127
    begin
128
// In gate-level simulation, must only go to 1'bX if the input is 1'bX or 1'bZ.
129
// This should NEVER go to 1'bX due to setup or hold violations.  
130
   `ifdef STYLE2
131
      sync_data_out0 <= KP_OUT;
132
   `else  //STYLE1
133
      sync_data_out0 <= data_in;
134
   `endif
135
      sync_data_out <= sync_data_out0;  //Added in revision 1.5
136
     end
137
    end
138
 
139
endmodule
140
 
141
`ifdef STYLE2
142
 /////////////////////////
143
 //PulseKeep assignment
144
 //
145
 module PulseKeep_reg (output reg out,
146
                       input asych_in,clr ,reset);
147
 wire rst = clr || reset;
148
   always @(posedge asych_in or posedge rst )
149
     if(rst)
150
           out <= 0;
151
     else
152
           out <= 1;
153
endmodule
154
 
155
`endif
156
 
157
 
158
`undef STYLE1
159
`undef STYLE2

powered by: WebSVN 2.1.0

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