| 1 |
111 |
olivier.gi |
//----------------------------------------------------------------------------
|
| 2 |
|
|
// Copyright (C) 2001 Authors
|
| 3 |
|
|
//
|
| 4 |
|
|
// This source file may be used and distributed without restriction provided
|
| 5 |
|
|
// that this copyright statement is not removed from the file and that any
|
| 6 |
|
|
// derivative work contains the original copyright notice and the associated
|
| 7 |
|
|
// disclaimer.
|
| 8 |
|
|
//
|
| 9 |
|
|
// This source file is free software; you can redistribute it and/or modify
|
| 10 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
| 11 |
|
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
| 12 |
|
|
// (at your option) any later version.
|
| 13 |
|
|
//
|
| 14 |
|
|
// This source is distributed in the hope that it will be useful, but WITHOUT
|
| 15 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 16 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
| 17 |
|
|
// License for more details.
|
| 18 |
|
|
//
|
| 19 |
|
|
// You should have received a copy of the GNU Lesser General Public License
|
| 20 |
|
|
// along with this source; if not, write to the Free Software Foundation,
|
| 21 |
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 22 |
|
|
//
|
| 23 |
|
|
//----------------------------------------------------------------------------
|
| 24 |
|
|
//
|
| 25 |
|
|
// *File Name: omsp_sync_cell.v
|
| 26 |
|
|
//
|
| 27 |
|
|
// *Module Description:
|
| 28 |
|
|
// Generic synchronizer for the openMSP430
|
| 29 |
|
|
//
|
| 30 |
|
|
// *Author(s):
|
| 31 |
|
|
// - Olivier Girard, olgirard@gmail.com
|
| 32 |
|
|
//
|
| 33 |
|
|
//----------------------------------------------------------------------------
|
| 34 |
|
|
// $Rev: 103 $
|
| 35 |
|
|
// $LastChangedBy: olivier.girard $
|
| 36 |
|
|
// $LastChangedDate: 2011-03-05 15:44:48 +0100 (Sat, 05 Mar 2011) $
|
| 37 |
|
|
//----------------------------------------------------------------------------
|
| 38 |
|
|
|
| 39 |
|
|
module omsp_sync_cell (
|
| 40 |
|
|
|
| 41 |
|
|
// OUTPUTs
|
| 42 |
|
|
data_out, // Synchronized data output
|
| 43 |
|
|
|
| 44 |
|
|
// INPUTs
|
| 45 |
|
|
clk, // Receiving clock
|
| 46 |
|
|
data_in, // Asynchronous data input
|
| 47 |
|
|
rst // Receiving reset (active high)
|
| 48 |
|
|
);
|
| 49 |
|
|
|
| 50 |
|
|
// OUTPUTs
|
| 51 |
|
|
//=========
|
| 52 |
|
|
output data_out; // Synchronized data output
|
| 53 |
|
|
|
| 54 |
|
|
// INPUTs
|
| 55 |
|
|
//=========
|
| 56 |
|
|
input clk; // Receiving clock
|
| 57 |
|
|
input data_in; // Asynchronous data input
|
| 58 |
|
|
input rst; // Receiving reset (active high)
|
| 59 |
|
|
|
| 60 |
|
|
|
| 61 |
|
|
//=============================================================================
|
| 62 |
|
|
// 1) SYNCHRONIZER
|
| 63 |
|
|
//=============================================================================
|
| 64 |
|
|
|
| 65 |
|
|
reg [1:0] data_sync;
|
| 66 |
|
|
|
| 67 |
|
|
always @(posedge clk or posedge rst)
|
| 68 |
|
|
if (rst) data_sync <= 2'b00;
|
| 69 |
|
|
else data_sync <= {data_sync[0], data_in};
|
| 70 |
|
|
|
| 71 |
|
|
assign data_out = data_sync[1];
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
endmodule // omsp_sync_cell
|
| 75 |
|
|
|