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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [lib/] [toggle_sync.v] - Blame information for rev 35

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OMS 8051 cores common library Module                        ////
4
////                                                              ////
5
////  This file is part of the OMS 8051 cores project             ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OMS 8051 definitions.                                       ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
////  Revision : Nov 26, 2016                                      //// 
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
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 toggle_sync (in_clk,
47
                    in_rst_n,
48
                    out_clk,
49
                    out_rst_n,
50
                    in,
51
                    out_req,
52
                    out_ack);
53
 
54
   output   out_req;
55
   input    in_clk, in_rst_n, out_clk, out_rst_n, in, out_ack;
56
 
57
   reg      in_flag, out_flag;
58
 
59
   always @ (posedge in_clk or negedge in_rst_n)
60
      if (~in_rst_n)
61
         in_flag <= 1'b0;
62
      else
63
         in_flag <= (in) ? ~in_flag : in_flag;
64
 
65
   always @ (posedge out_clk or negedge out_rst_n)
66
      if (~out_rst_n)
67
         out_flag <= 1'b0;
68
      else
69
         out_flag <= (out_ack & out_req) ? ~out_flag : out_flag;
70
 
71
 
72
   wire     raw_req_pend;
73
 
74
   assign raw_req_pend = in_flag ^ out_flag;
75
 
76
   reg      s1_out_req, s2_out_req;
77
 
78
   always @ (posedge out_clk or negedge out_rst_n)
79
      if (~out_rst_n) begin
80
         s1_out_req <= 1'b0;
81
         s2_out_req <= 1'b0;
82
      end // if (~out_rst_n)
83
      else begin
84
         s1_out_req <= ~out_ack & raw_req_pend;
85
         s2_out_req <= ~out_ack & s1_out_req;
86
      end // else: !if(~out_rst_n)
87
 
88
   wire out_req;
89
 
90
   assign out_req = s2_out_req;
91
 
92
endmodule // toggle_sync
93
 

powered by: WebSVN 2.1.0

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