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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [toggle_sync.v] - Blame information for rev 25

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

Line No. Rev Author Line
1 11 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores common library Module                       ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
 
44
module toggle_sync (in_clk,
45
                    in_rst_n,
46
                    out_clk,
47
                    out_rst_n,
48
                    in,
49
                    out_req,
50
                    out_ack);
51
 
52
   output   out_req;
53
   input    in_clk, in_rst_n, out_clk, out_rst_n, in, out_ack;
54
 
55
   reg      in_flag, out_flag;
56
 
57
   always @ (posedge in_clk or negedge in_rst_n)
58
      if (~in_rst_n)
59
         in_flag <= 1'b0;
60
      else
61
         in_flag <= (in) ? ~in_flag : in_flag;
62
 
63
   always @ (posedge out_clk or negedge out_rst_n)
64
      if (~out_rst_n)
65
         out_flag <= 1'b0;
66
      else
67
         out_flag <= (out_ack & out_req) ? ~out_flag : out_flag;
68
 
69
 
70
   wire     raw_req_pend;
71
 
72
   assign raw_req_pend = in_flag ^ out_flag;
73
 
74
   reg      s1_out_req, s2_out_req;
75
 
76
   always @ (posedge out_clk or negedge out_rst_n)
77
      if (~out_rst_n) begin
78
         s1_out_req <= 1'b0;
79
         s2_out_req <= 1'b0;
80
      end // if (~out_rst_n)
81
      else begin
82
         s1_out_req <= ~out_ack & raw_req_pend;
83
         s2_out_req <= ~out_ack & s1_out_req;
84
      end // else: !if(~out_rst_n)
85
 
86
   wire out_req;
87
 
88
   assign out_req = s2_out_req;
89
 
90
endmodule // toggle_sync
91
 

powered by: WebSVN 2.1.0

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