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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [Projects/] [digilentinc.com/] [Nexys2/] [ip/] [clock/] [rtl/] [verilog/] [syn/] [clock_sys.v] - Blame information for rev 131

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
module
2
cde_clock_sys
3
#(parameter   FREQ        = 48,
4
              PLL_MULT    =  4,
5
              PLL_DIV     =  2,
6
              PLL_SIZE    =  4,
7
              CLOCK_SRC   =  0,
8
              RESET_SENSE =  0
9
)
10
 
11
(
12
input  wire   a_clk_pad_in,
13
input  wire   b_clk_pad_in,
14
input  wire   pwron_pad_in,
15
 
16
output wire      div_clk_out,
17
 
18
 
19
output  reg   one_usec,
20
output  wire   reset
21
 
22
);
23
 
24
wire      ckIn;
25
reg       ref_reset;
26
 
27
reg [6:0] counter;
28
reg [3:0] reset_cnt;
29
 
30
wire      pwron_reset;
31
   wire      dll_reset;
32
 
33
 
34
  wire ckOut;
35
 
36
 
37
 
38
generate
39
 
40
if( CLOCK_SRC)
41
 
42
  begin
43
  assign ckIn = b_clk_pad_in;
44
  end
45
else
46
  begin
47
  assign ckIn = a_clk_pad_in;
48
  end
49
 
50
endgenerate
51
 
52
 
53
generate
54
 
55
if( RESET_SENSE)
56
 
57
  begin
58
  assign pwron_reset = !pwron_pad_in;
59
  end
60
else
61
  begin
62
  assign pwron_reset = pwron_pad_in;
63
  end
64
 
65
endgenerate
66
 
67
 
68
 
69
 
70
 
71
 
72
 
73
 
74
 
75
 
76
 
77
always@(posedge ckIn or posedge pwron_reset)
78
  if( pwron_reset)   reset_cnt     <= 4'b1111;
79
  else
80
  if(|reset_cnt)     reset_cnt     <= reset_cnt-4'b0001;
81
  else               reset_cnt     <= 4'b0000;
82
 
83
 
84
 
85
always@(posedge ckIn or posedge pwron_reset)
86
  if( pwron_reset)   ref_reset     <= 1'b1;
87
  else               ref_reset     <= |reset_cnt;
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
 
96
always@(posedge ckOut)
97
  if(dll_reset)
98
       begin
99
       one_usec  <=  1'b0;
100
       counter   <=  FREQ;
101
       end
102
  else if(counter == 7'b0000001)
103
       begin
104
       one_usec  <= !one_usec;
105
       counter   <=  FREQ;
106
       end
107
  else
108
       begin
109
       one_usec  <=  one_usec;
110
       counter   <=  counter -7'b0000001;
111
       end
112
 
113
 
114
wire    ckOut_pre;
115
 
116
DCM_SP #(
117
     .DLL_FREQUENCY_MODE   ("LOW"),
118
     .CLKIN_PERIOD         (20.0),
119
     .CLK_FEEDBACK         ("2X"),
120
     .DUTY_CYCLE_CORRECTION("TRUE"),
121
     .CLKDV_DIVIDE         (2.0),
122
     .CLKFX_MULTIPLY       (4),
123
     .CLKFX_DIVIDE         (1),
124
     .PHASE_SHIFT          (0),
125
     .CLKOUT_PHASE_SHIFT   ("NONE"),
126
     .DESKEW_ADJUST        ("SYSTEM_SYNCHRONOUS"),
127
     .DFS_FREQUENCY_MODE   ("LOW"),
128
     .STARTUP_WAIT         ("FALSE"),
129
     .CLKIN_DIVIDE_BY_2    ("FALSE")
130
) DCM_SP_inst    (
131
      .CLKFX     (),
132
      .CLKFX180  (),
133
      .PSDONE    (),
134
      .STATUS    (),
135
      .PSCLK     (1'b0),
136
      .PSEN      (1'b0),
137
      .PSINCDEC  (1'b0),
138
      .CLK0      (),
139
      .CLK180    (),
140
      .CLK270    (),
141
      .CLK2X     (ckOut_pre),
142
      .CLK2X180  (),
143
      .CLK90     (),
144
      .CLKDV     (div_clk_out),
145
      .LOCKED    (),
146
      .CLKFB     (ckOut),
147
      .CLKIN     (ckIn),
148
      .RST       (1'b0)
149
   );
150
 
151
 
152
  BUFG
153
  BUFG_inst (
154
            .I(ckOut_pre),      // Clock buffer input
155
            .O(ckOut)           // Clock buffer output
156
            );
157
 
158
 
159
 
160
cde_sync_with_reset
161
  #(.WIDTH  (1),
162
    .DEPTH  (2),
163
    .RST_VAL(1'b1)
164
   )
165
  ref_rsync(
166
    .clk                 (div_clk_out),
167
    .reset_n             (!pwron_reset),
168
    .data_in             (ref_reset),
169
    .data_out            (reset)
170
       );
171
 
172
 
173
 
174
 
175
cde_sync_with_reset
176
  #(.WIDTH  (1),
177
    .DEPTH  (2),
178
    .RST_VAL(1'b1)
179
   )
180
  dll_rsync(
181
    .clk                 (ckOut),
182
    .reset_n             (!pwron_reset),
183
    .data_in             (ref_reset),
184
    .data_out            (dll_reset)
185
       );
186
 
187
 
188
 
189
endmodule

powered by: WebSVN 2.1.0

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