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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [clkgen/] [clkgen.v] - Blame information for rev 803

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

Line No. Rev Author Line
1 361 julius
//////////////////////////////////////////////////////////////////////
2
//
3
// clkgen
4
//
5
// Handles clock and reset generation for rest of design
6
//
7
//
8
//////////////////////////////////////////////////////////////////////
9
////                                                              ////
10
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
11
////                                                              ////
12
//// This source file may be used and distributed without         ////
13
//// restriction provided that this copyright statement is not    ////
14
//// removed from the file and that any derivative work contains  ////
15
//// the original copyright notice and the associated disclaimer. ////
16
////                                                              ////
17
//// This source file is free software; you can redistribute it   ////
18
//// and/or modify it under the terms of the GNU Lesser General   ////
19
//// Public License as published by the Free Software Foundation; ////
20
//// either version 2.1 of the License, or (at your option) any   ////
21
//// later version.                                               ////
22
////                                                              ////
23
//// This source is distributed in the hope that it will be       ////
24
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
25
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
26
//// PURPOSE.  See the GNU Lesser General Public License for more ////
27
//// details.                                                     ////
28
////                                                              ////
29
//// You should have received a copy of the GNU Lesser General    ////
30
//// Public License along with this source; if not, download it   ////
31
//// from http://www.opencores.org/lgpl.shtml                     ////
32
////                                                              ////
33
//////////////////////////////////////////////////////////////////////
34
//
35
// A simple implementation for the main generic ORPSoC simulations
36
//
37
 
38
`include "timescale.v"
39
`include "orpsoc-defines.v"
40
 
41
module clkgen
42
  (
43
   // Main clocks in, depending on board
44
   clk_pad_i,
45 363 julius
 
46
   // Input reset - through a buffer, asynchronous
47
   async_rst_o,
48 361 julius
   // Wishbone clock and reset out  
49
   wb_clk_o,
50
   wb_rst_o,
51
 
52
   // JTAG clock
53
`ifdef JTAG_DEBUG
54
   tck_pad_i,
55
   dbg_tck_o,
56
`endif
57
 
58
   // Asynchronous, active low reset in
59
   rst_n_pad_i
60
 
61
   );
62
 
63
   input clk_pad_i;
64
 
65 363 julius
   output async_rst_o;
66
 
67 361 julius
   output wb_rst_o;
68
   output wb_clk_o;
69
 
70
`ifdef JTAG_DEBUG
71
   input  tck_pad_i;
72
   output dbg_tck_o;
73
`endif
74
 
75
   // Asynchronous, active low reset (pushbutton, typically)
76
   input  rst_n_pad_i;
77
 
78
   // First, deal with the asychronous reset
79
   wire   async_rst_n;
80
 
81
   // An input buffer is usually instantiated here
82
   assign async_rst_n = rst_n_pad_i;
83
 
84
   // Everyone likes active-high reset signals...
85 363 julius
   assign async_rst_o = ~async_rst_n;
86 361 julius
 
87
`ifdef JTAG_DEBUG
88
   assign dbg_tck_o = tck_pad_i;
89
`endif
90
 
91
   //
92
   // Declare synchronous reset wires here
93
   //
94
 
95
   // An active-low synchronous reset signal (usually a PLL lock signal)
96
   wire   sync_rst_n;
97 362 julius
   assign sync_rst_n  = async_rst_n; // Pretend it's somehow synchronous now
98 361 julius
 
99
 
100
   // Here we just assign "board" clock (really test) to wishbone clock
101
   assign wb_clk_o = clk_pad_i;
102
 
103
   //
104
   // Reset generation
105
   //
106
   //
107
 
108
   // Reset generation for wishbone
109
   reg [15:0]       wb_rst_shr;
110 363 julius
   always @(posedge wb_clk_o or posedge async_rst_o)
111
     if (async_rst_o)
112 361 julius
       wb_rst_shr <= 16'hffff;
113
     else
114
       wb_rst_shr <= {wb_rst_shr[14:0], ~(sync_rst_n)};
115
 
116
   assign wb_rst_o = wb_rst_shr[15];
117
 
118
endmodule // clkgen

powered by: WebSVN 2.1.0

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