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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [mp3/] [lib/] [xilinx/] [unisims/] [DCM.v] - Blame information for rev 317

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

Line No. Rev Author Line
1 266 lampret
// $Header: /home/marcus/revision_ctrl_test/oc_cvs/cvs/or1k/mp3/lib/xilinx/unisims/DCM.v,v 1.1.1.1 2001-11-04 18:59:47 lampret Exp $
2
 
3
/*
4
 
5
FUNCTION        : Digital Clock Manager
6
 
7
*/
8
 
9
`timescale  1 ps / 1 ps
10
 
11
module DCM      (CLKFB, CLKIN, DSSEN,
12
                 PSCLK, PSEN, PSINCDEC, RST,
13
                 CLK0, CLK90, CLK180, CLK270, CLK2X, CLK2X180,
14
                 CLKDV, CLKFX, CLKFX180, LOCKED, PSDONE, STATUS);
15
 
16
parameter CLK_FEEDBACK = "1X";
17
parameter CLKDV_DIVIDE = 2.0;
18
parameter CLKFX_DIVIDE = 1;
19
parameter CLKFX_MULTIPLY = 4;
20
parameter CLKOUT_PHASE_SHIFT = "NONE";
21
parameter DFS_FREQUENCY_MODE = "LOW";
22
parameter DLL_FREQUENCY_MODE = "LOW";
23
parameter DSS_MODE = "NONE";
24
parameter DUTY_CYCLE_CORRECTION = "TRUE";
25
parameter FACTORY_JF = 8'h00;
26
parameter MAXPERCLKIN = 100000;
27
parameter MAXPERPSCLK = 100000;
28
parameter PHASE_SHIFT = 0;
29
parameter STARTUP_WAIT = "FALSE";
30
 
31
input CLKFB, CLKIN, DSSEN;
32
input PSCLK, PSEN, PSINCDEC, RST;
33
 
34
output CLK0, CLK90, CLK180, CLK270, CLK2X, CLK2X180;
35
output CLKDV, CLKFX, CLKFX180, LOCKED, PSDONE;
36
output [7:0] STATUS;
37
 
38
reg    CLK0, CLK90, CLK180, CLK270, CLK2X, CLK2X180;
39
reg    CLKDV, CLKFX, CLKFX180;
40
 
41
reg    lock_period, lock_delay, lock_clkin, lock_clkfb;
42
reg    delay_found;
43
time   clkin_edge[0:1];
44
time   psclk_edge[0:1], psclk_period;
45
time   delay_edge[0:1];
46
time   period, delay, delay_fb;
47
 
48
reg    clkin_in, clkfb_in;
49
wire   psclk_in, psen_in, psincdec_in, rst_in;
50
reg    clklost_out, locked_out, psdone_out, psoverflow_out, pslock;
51
wire   clk0_int, clk4x_int, clkdv_int;
52
reg    clk2x_int;
53
wire   clk2x_2575, clk2x_5050;
54
 
55
reg    clkin_locked, clkin_period, clkin_div2_r, clkin_div2_f;
56
reg    clkin_low1, clkin_low2, clkin_high1, clkin_high2;
57
 
58
reg    clkin_window, clkfb_window;
59
reg    clk1x, clkin_5050, clk1x_5050;
60
reg    clk1x_shift125, clk1x_shift250;
61
reg    clk2x_shift;
62
 
63
reg    [7:0] count3, count4, count5, count7, count9, count11, count13, count15;
64
reg    [32:1] divider;
65
reg    [8:0] divide_type;
66
reg    [1:0] clkfb_type;
67
reg    clk1x_type;
68
reg    dll_mode_type;
69
reg    rst_1, rst_2;
70
reg    notifier;
71
 
72
reg    [11:0] numerator, denominator, gcd;
73
reg    [23:0] i, n, d;
74
reg    generate, clkfx_int;
75
time   period_fx;
76
 
77
reg    [9:0] ps_in;
78
time   clkin_delay, clkfb_delay;
79
 
80
initial begin
81
  clk1x <= 0;
82
  clk1x_5050 <= 0;
83
  clk1x_shift125 <= 0;
84
  clk1x_shift250 <= 0;
85
  clk2x_shift <= 0;
86
  clkfb_delay <= 0;
87
  clkfb_window <= 0;
88
  clkfx_int <= 0;
89
  clkin_5050 <= 0;
90
  clkin_delay <= 0;
91
  clkin_div2_f <= 0;
92
  clkin_div2_r <= 0;
93
  clkin_edge[0] <= 1'bx;
94
  clkin_edge[1] <= 1'bx;
95
  clkin_high1 <= 0;
96
  clkin_high2 <= 0;
97
  clkin_low1 <= 0;
98
  clkin_low2 <= 0;
99
  clkin_window <= 0;
100
  count11 <= 0;
101
  count13 <= 0;
102
  count15 <= 0;
103
  count3 <= 0;
104
  count4 <= 0;
105
  count5 <= 0;
106
  count7 <= 0;
107
  count9 <= 0;
108
  delay <= 0;
109
  delay_fb <= 0;
110
  delay_found <= 0;
111
  divider <= 0;
112
  generate <= 0;
113
  lock_delay <= 0;
114
  lock_period <= 0;
115
  locked_out <= 0;
116
  period <= 0;
117
  psdone_out <= 0;
118
  pslock <= 0;
119
  psoverflow_out <= 0;
120
  case (CLK_FEEDBACK)
121
    "none" : clkfb_type <= 0;
122
    "NONE" : clkfb_type <= 0;
123
    "1x" : clkfb_type <= 1;
124
    "1X" : clkfb_type <= 1;
125
    "2x"  : clkfb_type <= 2;
126
    "2X"  : clkfb_type <= 2;
127
    default : begin
128
                $display("Error : CLK_FEEDBACK = %s is neither NONE, 1X nor 2X.", CLK_FEEDBACK);
129
                $finish;
130
              end
131
  endcase
132
 
133
  case (DLL_FREQUENCY_MODE)
134
    "high" : dll_mode_type <= 1;
135
    "HIGH" : dll_mode_type <= 1;
136
    "low"  : dll_mode_type <= 0;
137
    "LOW"  : dll_mode_type <= 0;
138
    default : begin
139
                $display("Error : DLL_FREQUENCY_MODE = %s is neither HIGH nor LOW.", DLL_FREQUENCY_MODE);
140
                $finish;
141
              end
142
  endcase
143
 
144
  case (DUTY_CYCLE_CORRECTION)
145
    "false" : clk1x_type <= 0;
146
    "FALSE" : clk1x_type <= 0;
147
    "true"  : clk1x_type <= 1;
148
    "TRUE"  : clk1x_type <= 1;
149
    default : begin
150
                $display("Error : DUTY_CYCLE_CORRECTION = %s is neither TRUE nor FALSE.", DUTY_CYCLE_CORRECTION);
151
                $finish;
152
              end
153
  endcase
154
 
155
  case (CLKDV_DIVIDE)
156
    1.5   : divide_type <= 'd3;
157
    2.0   : divide_type <= 'd4;
158
    2.5   : divide_type <= 'd5;
159
    3.0   : divide_type <= 'd6;
160
    3.5   : divide_type <= 'd7;
161
    4.0   : divide_type <= 'd8;
162
    4.5   : divide_type <= 'd9;
163
    5.0   : divide_type <= 'd10;
164
    5.5   : divide_type <= 'd11;
165
    6.0   : divide_type <= 'd12;
166
    6.5   : divide_type <= 'd13;
167
    7.0   : divide_type <= 'd14;
168
    7.5   : divide_type <= 'd15;
169
    8.0   : divide_type <= 'd16;
170
    9.0   : divide_type <= 'd18;
171
    10.0  : divide_type <= 'd20;
172
    11.0  : divide_type <= 'd22;
173
    12.0  : divide_type <= 'd24;
174
    13.0  : divide_type <= 'd26;
175
    14.0  : divide_type <= 'd28;
176
    15.0  : divide_type <= 'd30;
177
    16.0  : divide_type <= 'd32;
178
    default : begin
179
                $display("Error : CLKDV_DIVIDE = %f is not 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, or 16.0.", CLKDV_DIVIDE);
180
                $finish;
181
              end
182
  endcase
183
end
184
 
185
//
186
// phase shift parameters
187
//
188
 
189
initial begin
190
  case (CLKOUT_PHASE_SHIFT)
191
    "NONE"     : ps_in <= 0;
192
    "none"     : ps_in <= 0;
193
    "FIXED"   : ps_in <= PHASE_SHIFT + 256;
194
    "fixed"   : ps_in <= PHASE_SHIFT + 256;
195
    "VARIABLE" : ps_in <= PHASE_SHIFT + 256;
196
    "variable" : ps_in <= PHASE_SHIFT + 256;
197
    default : begin
198
                $display("Error : CLKOUT_PHASE_SHIFT = %s is neither NONE, FIXED nor VARIABLE.", CLKOUT_PHASE_SHIFT);
199
                $finish;
200
              end
201
  endcase
202
end
203
 
204
always @(posedge psclk_in) begin
205
  if ((CLKOUT_PHASE_SHIFT == "VARIABLE") || (CLKOUT_PHASE_SHIFT == "variable"))
206
    if (psen_in)
207
      if (pslock)
208
        $display("Warning : Please wait for PSDONE signal before adjusting the Phase Shift.");
209
      else
210
        if (psincdec_in == 1)
211
          if (ps_in == 511)
212
            psoverflow_out <= 1;
213
          else begin
214
            ps_in <= ps_in + 1;
215
            psoverflow_out <= 0;
216
            delay_fb <= delay_fb + period * 1 / 256;
217
            pslock <= 1;
218
          end
219
        else
220
          if (ps_in == 0)
221
            psoverflow_out <= 1;
222
          else begin
223
            ps_in <= ps_in - 1;
224
            psoverflow_out <= 0;
225
            delay_fb <= delay_fb - period * 1 / 256;
226
            pslock <= 1;
227
          end
228
end
229
 
230
//
231
// determine phase shift
232
//
233
always @ (lock_period or ps_in) begin
234
  if (lock_period & (clkfb_type != 0)) begin
235
    clkin_delay <= period;
236
    clkfb_delay <= period * (512 - ps_in) / 256;
237
  end
238
end
239
 
240
always @ (posedge pslock) begin
241
  @(posedge CLKIN)
242
  @(posedge psclk_in)
243
    psdone_out <= 1;
244
  @(posedge psclk_in)
245
    psdone_out <= 0;
246
    pslock <= 0;
247
end
248
 
249
//
250
// fx parameters
251
//
252
 
253
initial begin
254
  generate = 1'b0;
255
  numerator = CLKFX_MULTIPLY;
256
  denominator = CLKFX_DIVIDE;
257
  gcd = 1;
258
  for (i = 2; i <= numerator; i = i + 1) begin
259
    if (((numerator % i) == 0) && ((denominator % i) == 0))
260
      gcd = i;
261
  end
262
  numerator = CLKFX_MULTIPLY / gcd;
263
  denominator = CLKFX_DIVIDE  / gcd;
264
end
265
 
266
//
267
// input wire delays
268
//
269
// buf b_clkin (clkin_in, CLKIN);
270
// buf b_clkfb (clkfb_in, CLKFB);
271
always @(CLKIN) begin
272
  clkin_in <= #clkin_delay CLKIN;
273
end
274
 
275
always @(CLKFB) begin
276
  clkfb_in <= #clkfb_delay CLKFB;
277
end
278
 
279
buf b_dssen (dssen_in, DSSEN);
280
buf b_psclk (psclk_in, PSCLK);
281
buf b_psen (psen_in, PSEN);
282
buf b_psincdec (psincdec_in, PSINCDEC);
283
buf b_rst (rst_in, RST);
284
buf b_locked (LOCKED, locked_out);
285
buf b_psdone (PSDONE, psdone_out);
286
buf b_psoverflow (STATUS[0], psoverflow_out);
287
buf b_clklost (STATUS[1], clklost_out);
288
 
289
//
290
// clock lost
291
//
292
 
293
always @(CLKIN) begin
294
    clkin_locked <= #period CLKIN;
295
end
296
 
297
always @(clkin_locked) begin
298
  clkin_period <= #period clkin_locked;
299
end
300
 
301
always @(posedge clkin_locked) begin
302
  clkin_div2_r <= ~clkin_div2_r;
303
end
304
 
305
always @(negedge clkin_period) begin
306
  clkin_low1 <= clkin_div2_r;
307
end
308
 
309
always @(negedge clkin_period) begin
310
  clkin_low2 <= clkin_low1;
311
end
312
 
313
always @(negedge clkin_locked) begin
314
  clkin_div2_f <= ~clkin_div2_f;
315
end
316
 
317
always @(posedge clkin_period) begin
318
  clkin_high1 <= clkin_div2_f;
319
end
320
 
321
always @(posedge clkin_period) begin
322
  clkin_high2 <= clkin_high1;
323
end
324
 
325
always @(clkin_low1 or clkin_low2 or clkin_high1 or clkin_high2) begin
326
  clklost_out <= locked_out && (!(clkin_low1 ^ clkin_low2) || !(clkin_high1 ^ clkin_high2));
327
end
328
 
329
//
330
// determine clock period
331
//
332
always @(posedge clkin_in) begin
333
  clkin_edge[0] <= $time;
334
  clkin_edge[1] <= clkin_edge[0];
335
  if (rst_2)
336
    period <= 0;
337
  else if (period < clkin_edge[0] - clkin_edge[1] - 500)
338
    period <= clkin_edge[0] - clkin_edge[1];
339
  else if (period > clkin_edge[0] - clkin_edge[1] + 500)
340
    period <= clkin_edge[0] - clkin_edge[1];
341
end
342
 
343
always @(period) begin
344
  CLK0 <= 0;                    // period changed reset everything
345
  CLK180 <= 0;
346
  clk1x <= 0;
347
  clk1x_5050 <= 0;
348
  clk1x_shift125 <= 0;
349
  clk1x_shift250 <= 0;
350
  CLK270 <= 0;
351
  CLK2X <= 0;
352
  CLK2X180 <= 0;
353
  clk2x_shift <= 0;
354
  CLK90 <= 0;
355
  CLKDV <= 0;
356
  clkfb_window <= 0;
357
  CLKFX <= 0;
358
  CLKFX180 <= 0;
359
  clkfx_int <= 0;
360
  clkin_5050 <= 0;
361
  clkin_window <= 0;
362
  clklost_out <= 0;
363
  delay <= 0;
364
  delay_fb <= 0;
365
  delay_found <= 0;
366
  divider <= 0;
367
  generate <= 0;
368
  lock_clkfb <= 0;
369
  lock_clkin <= 0;
370
  lock_delay <= 0;
371
  lock_period <= 0;
372
  locked_out <= 0;
373
  psdone_out <= 0;
374
  pslock <= 0;
375
  psoverflow_out <= 0;
376
  if (period < clkin_edge[0] - clkin_edge[1] - 500)
377
    lock_period <= 0;
378
  else if (period > clkin_edge[0] - clkin_edge[1] + 500)
379
    lock_period <= 0;
380
  else if ((clkin_edge[0] != 1'bx) && (clkin_edge[1] != 1'bx))
381
    lock_period <= 1;
382
end
383
 
384
always @(posedge lock_period) begin
385
  if (period > MAXPERCLKIN) begin
386
    $display("    \$maxperiod( posedge CLKIN:%0.3f", $time/1000, "ns,  %0d", MAXPERCLKIN, " : %0.3f", period/1000, "ns );");
387
  end
388
end
389
 
390
always @(posedge psclk_in) begin
391
  psclk_edge[0] <= $time;
392
  psclk_edge[1] <= psclk_edge[0];
393
  psclk_period <= psclk_edge[0] - psclk_edge[1];
394
  if (psclk_period > MAXPERPSCLK) begin
395
    $display("    \$maxperiod( posedge PSCLK:%0.3f", $time/1000, "ns,  %0d", MAXPERPSCLK, " : %0.3f", period/1000, "ns );");
396
  end
397
end
398
 
399
//
400
// determine clock delay
401
//
402
always @ (lock_period or delay_found) begin
403
  if (lock_period && !delay_found) begin
404
    assign CLK0 = 0; assign CLK2X = 0;
405
    #period
406
    assign CLK0 = 1; assign CLK2X = 1;
407
    delay_edge[1] = $time;
408
    @(posedge clkfb_in)
409
    delay_edge[0] = $time;
410
    #period
411
    assign CLK0 = 0; assign CLK2X = 0;
412
    deassign CLK0; deassign CLK2X;
413
    #period
414
    delay = (10 * period - (delay_edge[0] - delay_edge[1])) % period;
415
    delay_found = 1;
416
  end
417
end
418
 
419
always @ (lock_period or delay_found) begin
420
  if (lock_period && delay_found) begin
421
    for (delay_fb = 0; delay_fb < delay; delay_fb = delay_fb + 1000)
422
      @(posedge clkin_in);
423
    delay_fb <= delay + period;
424
  end
425
end
426
 
427
always @ (posedge clkin_in) begin
428
  if (rst_2) begin
429
    CLK0 <= 0;
430
    CLK180 <= 0;
431
    clk1x <= 0;
432
    clk1x_5050 <= 0;
433
    clk1x_shift125 <= 0;
434
    clk1x_shift250 <= 0;
435
    CLK270 <= 0;
436
    CLK2X <= 0;
437
    CLK2X180 <= 0;
438
    clk2x_shift <= 0;
439
    CLK90 <= 0;
440
    CLKDV <= 0;
441
    clkfb_window <= 0;
442
    CLKFX <= 0;
443
    CLKFX180 <= 0;
444
    clkfx_int <= 0;
445
    clkin_5050 <= 0;
446
    clkin_edge[0] <= 1'bx;
447
    clkin_edge[1] <= 1'bx;
448
    clkin_window <= 0;
449
    clklost_out <= 0;
450
    count11 <= 0;
451
    count13 <= 0;
452
    count15 <= 0;
453
    count3 <= 0;
454
    count4 <= 0;
455
    count5 <= 0;
456
    count7 <= 0;
457
    count9 <= 0;
458
    delay <= 0;
459
    delay_fb <= 0;
460
    delay_found <= 0;
461
    divider <= 0;
462
    generate <= 0;
463
    lock_clkfb <= 0;
464
    lock_clkin <= 0;
465
    lock_delay <= 0;
466
    lock_period <= 0;
467
    locked_out <= 0;
468
    psdone_out <= 0;
469
    pslock <= 0;
470
    psoverflow_out <= 0;
471
    case (CLKOUT_PHASE_SHIFT)
472
      "NONE"     : ps_in <= 0;
473
      "none"     : ps_in <= 0;
474
      "FIXED"   : ps_in <= PHASE_SHIFT + 256;
475
      "fixed"   : ps_in <= PHASE_SHIFT + 256;
476
      "VARIABLE" : ps_in <= PHASE_SHIFT + 256;
477
      "variable" : ps_in <= PHASE_SHIFT + 256;
478
    endcase
479
  end
480
end
481
 
482
always @ (posedge clkfb_in) begin
483
  #0   clkfb_window = 1;
484
  #100 clkfb_window = 0;
485
end
486
 
487
always @ (posedge clkin_in) begin
488
  #0   clkin_window = 1;
489
  #100 clkin_window = 0;
490
end
491
 
492
always @ (posedge clkin_in) begin
493
  #1
494
  if (clkfb_window && delay_found)
495
    lock_clkin <= 1;
496
  else
497
    lock_clkin <= 0;
498
end
499
 
500
always @ (posedge clkfb_in) begin
501
  #1
502
  if (clkin_window && delay_found)
503
    lock_clkfb <= 1;
504
  else
505
    lock_clkfb <= 0;
506
  @ (posedge clkfb_in);
507
end
508
 
509
always @ (lock_clkin or lock_clkfb) begin
510
  if (lock_clkin || lock_clkfb)
511
    lock_delay <= 1;
512
  else
513
    lock_delay <= 0;
514
end
515
 
516
//
517
// generate master reset signal
518
//
519
always @ (posedge clkin_in) begin
520
   {rst_2,rst_1} <= {rst_1,rst_in};
521
end
522
 
523
//
524
// generate lock signal
525
//
526
always @ (posedge clkin_in) begin
527
  if ((clkfb_type == 0) & lock_period)
528
    locked_out <= 1;
529
  else
530
    locked_out <= lock_delay & lock_period & ~rst_2;
531
end
532
 
533
//
534
// generate the clk0_int
535
//
536
always @ (clkin_in) begin
537
  if (delay_found)
538
    clk1x <= #delay_fb clkin_in;
539
end
540
 
541
always @ (posedge clkin_in) begin
542
    clkin_5050 <= 1;
543
    #(period/2)
544
    clkin_5050 <= 0;
545
end
546
 
547
always @ (clkin_5050) begin
548
  if (delay_found)
549
    clk1x_5050 <= #delay_fb clkin_5050;
550
end
551
 
552
assign clk0_int = (clk1x_type) ? clk1x_5050 : clk1x;
553
 
554
//
555
// generate the clk2x_int
556
//
557
always @(clk1x_5050) begin
558
  clk1x_shift125 <= #(period/8) clk1x_5050;
559
  clk1x_shift250 <= #(period/4) clk1x_5050;
560
end
561
 
562
assign clk2x_2575 = clk1x_5050 & ~clk1x_shift250;
563
assign clk2x_5050 = clk1x_5050 ^ clk1x_shift250;
564
 
565
always @(clk2x_5050 or clk2x_2575) begin
566
  if (locked_out)
567
    clk2x_int = clk2x_5050;
568
  else
569
    clk2x_int = clk2x_2575;
570
end
571
 
572
//
573
// generate the clk4x_int
574
//
575
always @(clk2x_5050) begin
576
  clk2x_shift <= #(period/8) clk2x_5050;
577
end
578
 
579
assign clk4x_int = clk2x_5050 ^ clk2x_shift;
580
 
581
//
582
// generate the clkdv_int
583
//
584
 
585
always @(posedge clk4x_int) begin
586
  if (dll_mode_type) begin
587
    if (count3 == 0)
588
      divider[3] <= 1;
589
    if (count3 == 2)
590
      divider[3] <= 0;
591
  end
592
  else
593
    if (count3 == 0 || count3 == 3)
594
      divider[3] <= divider[3] + 1;
595
  count3 <= (count3 + 1) % 6;
596
end
597
 
598
always @(posedge clk4x_int) begin
599
  if (count4 == 0)
600
    divider[4] <= divider[4] + 1;
601
  count4 <= (count4 + 1) % 4;
602
end
603
 
604
always @(posedge clk4x_int) begin
605
  if (dll_mode_type) begin
606
    if (count5 == 0)
607
      divider[5] <= 1;
608
    if (count5 == 4)
609
      divider[5] <= 0;
610
  end
611
  else
612
    if (count5 == 0 || count5 == 5)
613
      divider[5] <= divider[5] + 1;
614
  count5 <= (count5 + 1) % 10;
615
end
616
 
617
always @(posedge divider[3]) begin
618
  divider[6] <= divider[6] + 1;
619
end
620
 
621
always @(posedge clk4x_int) begin
622
  if (dll_mode_type) begin
623
    if (count7 == 0)
624
      divider[7] <= 1;
625
    if (count7 == 6)
626
      divider[7] <= 0;
627
  end
628
  else
629
    if (count7 == 0 || count7 == 7)
630
      divider[7] <= divider[7] + 1;
631
  count7 <= (count7 + 1) % 14;
632
end
633
 
634
always @(posedge divider[4]) begin
635
  divider[8] <= divider[8] + 1;
636
end
637
 
638
always @(posedge clk4x_int) begin
639
  if (dll_mode_type) begin
640
    if (count9 == 0)
641
      divider[9] <= 1;
642
    if (count9 == 8)
643
      divider[9] <= 0;
644
  end
645
  else
646
    if (count9 == 0 || count9 == 9)
647
      divider[9] <= divider[9] + 1;
648
  count9 <= (count9 + 1) % 18;
649
end
650
 
651
always @(posedge divider[5]) begin
652
  divider[10] <= divider[10] + 1;
653
end
654
 
655
always @(posedge clk4x_int) begin
656
  if (dll_mode_type) begin
657
    if (count11 == 0)
658
      divider[11] <= 1;
659
    if (count11 == 10)
660
      divider[11] <= 0;
661
  end
662
  else
663
    if (count11 == 0 || count11 == 11)
664
      divider[11] <= divider[11] + 1;
665
  count11 <= (count11 + 1) % 22;
666
end
667
 
668
always @(posedge divider[6]) begin
669
  divider[12] <= divider[12] + 1;
670
end
671
 
672
always @(posedge clk4x_int) begin
673
  if (dll_mode_type) begin
674
    if (count13 == 0)
675
      divider[13] <= 1;
676
    if (count13 == 12)
677
      divider[13] <= 0;
678
  end
679
  else
680
    if (count13 == 0 || count13 == 13)
681
      divider[13] <= divider[13] + 1;
682
  count13 <= (count13 + 1) % 26;
683
end
684
 
685
always @(posedge divider[7]) begin
686
  divider[14] <= divider[14] + 1;
687
end
688
 
689
always @(posedge clk4x_int) begin
690
  if (dll_mode_type) begin
691
    if (count15 == 0)
692
      divider[15] <= 1;
693
    if (count15 == 14)
694
      divider[15] <= 0;
695
  end
696
  else
697
    if (count15 == 0 || count15 == 15)
698
      divider[15] <= divider[15] + 1;
699
  count15 <= (count15 + 1) % 30;
700
end
701
 
702
always @(posedge divider[8]) begin
703
  divider[16] <= divider[16] + 1;
704
end
705
 
706
always @(posedge divider[9]) begin
707
  divider[18] <= divider[18] + 1;
708
end
709
 
710
always @(posedge divider[10]) begin
711
  divider[20] <= divider[20] + 1;
712
end
713
 
714
always @(posedge divider[11]) begin
715
  divider[22] <= divider[22] + 1;
716
end
717
 
718
always @(posedge divider[12]) begin
719
  divider[24] <= divider[24] + 1;
720
end
721
 
722
always @(posedge divider[13]) begin
723
  divider[26] <= divider[26] + 1;
724
end
725
 
726
always @(posedge divider[14]) begin
727
  divider[28] <= divider[28] + 1;
728
end
729
 
730
always @(posedge divider[15]) begin
731
  divider[30] <= divider[30] + 1;
732
end
733
 
734
always @(posedge divider[16]) begin
735
  divider[32] <= divider[32] + 1;
736
end
737
 
738
assign clkdv_int = divider[divide_type];
739
 
740
//
741
// generate fx output signal
742
//
743
 
744
always @(locked_out) begin
745
  if (locked_out) begin
746
    period_fx = period * denominator / numerator;
747
    while (period > 0) begin
748
      generate = !generate;
749
      for (n = 1; n <= denominator; n = n + 1) begin
750
        #(period);
751
      end
752
    end
753
  end
754
end
755
 
756
always @(generate) begin
757
  if (period_fx > 0) begin
758
    for (d = 1; d < numerator; d = d + 1) begin
759
      clkfx_int <= 1;
760
      #(period_fx/2);
761
      clkfx_int <= 0;
762
      #(period_fx/2);
763
    end
764
    clkfx_int <= 1;
765
    #(period_fx/2);
766
    clkfx_int <= 0;
767
  end
768
end
769
 
770
//
771
// generate all output signal
772
//
773
always @ (clk0_int) begin
774
    CLK0 <= clk0_int;
775
end
776
 
777
always @ (clk0_int) begin
778
    CLK90 <= #(period/4) clk0_int;
779
end
780
 
781
always @ (clk0_int) begin
782
    CLK180 <= #(period/2) clk0_int;
783
end
784
 
785
always @ (clk0_int) begin
786
    CLK270 <= #(3*period/4) clk0_int;
787
end
788
 
789
always @ (clk2x_int) begin
790
    CLK2X <= clk2x_int;
791
end
792
 
793
always @ (clk2x_int) begin
794
    CLK2X180 <= #(period/4) clk2x_int;
795
end
796
 
797
always @ (clkdv_int) begin
798
  if (locked_out)
799
    CLKDV <= #(period) clkdv_int;
800
end
801
 
802
always @ (clkfx_int) begin
803
    CLKFX <= #(delay_fb) clkfx_int;
804
end
805
 
806
always @ (clkfx_int) begin
807
    CLKFX180 <= #(delay_fb + period_fx/2) clkfx_int;
808
end
809
 
810
specify
811
        specparam CLKFBDLYLH = 0:0:0, CLKFBDLYHL = 0:0:0;
812
        specparam CLKINDLYLH = 0:0:0, CLKINDLYHL = 0:0:0;
813
        specparam DSSENDLYLH = 0:0:0, DSSENDLYHL = 0:0:0;
814
        specparam PSCLKDLYLH = 0:0:0, PSCLKDLYHL = 0:0:0;
815
        specparam PSENDLYLH = 0:0:0, PSENDLYHL = 0:0:0;
816
        specparam PSINCDECDLYLH = 0:0:0, PSINCDECDLYHL = 0:0:0;
817
        specparam RSTDLYLH = 0:0:0, RSTDLYHL = 0:0:0;
818
        specparam LOCKEDDLYLH = 0:0:0, LOCKEDDLYHL = 0:0:0;
819
        specparam PSDONEDLYLH = 0:0:0, PSDONEDLYHL = 0:0:0;
820
        specparam STATUS0DLYLH = 0:0:0, STATUS0DLYHL = 0:0:0;
821
        specparam STATUS1DLYLH = 0:0:0, STATUS1DLYHL = 0:0:0;
822
        specparam STATUS2DLYLH = 0:0:0, STATUS2DLYHL = 0:0:0;
823
        specparam STATUS3DLYLH = 0:0:0, STATUS3DLYHL = 0:0:0;
824
        specparam STATUS4DLYLH = 0:0:0, STATUS4DLYHL = 0:0:0;
825
        specparam STATUS5DLYLH = 0:0:0, STATUS5DLYHL = 0:0:0;
826
        specparam STATUS6DLYLH = 0:0:0, STATUS6DLYHL = 0:0:0;
827
        specparam STATUS7DLYLH = 0:0:0, STATUS7DLYHL = 0:0:0;
828
 
829
        specparam PWCLKINHI = 0:0:0, PWCLKINLO = 0:0:0;
830
        specparam PWPSCLKHI = 0:0:0, PWPSCLKLO = 0:0:0;
831
        specparam PWRSTHI = 0:0:0;
832
        specparam MINPERCLKIN = 10:10:10;
833
        specparam MINPERPSCLK = 10:10:10;
834
 
835
        specparam SUPSENHIPSCLK = 0:0:0, SUPSENLOPSCLK = 0:0:0;
836
        specparam HOLDPSENHIPSCLK = 0:0:0, HOLDPSENLOPSCLK = 0:0:0;
837
        specparam SUPSINCDECHIPSCLK = 0:0:0, SUPSINCDECLOPSCLK = 0:0:0;
838
        specparam HOLDPSINCDECHIPSCLK = 0:0:0, HOLDPSINCDECLOPSCLK = 0:0:0;
839
 
840
        (CLKIN => LOCKED) = (CLKINDLYLH + LOCKEDDLYLH, CLKINDLYHL + LOCKEDDLYHL);
841
 
842
        $setup (posedge PSEN, posedge PSCLK, SUPSENHIPSCLK, notifier);
843
        $setup (negedge PSEN, posedge PSCLK, SUPSENLOPSCLK, notifier);
844
        $hold (posedge PSCLK, posedge PSEN, HOLDPSENHIPSCLK, notifier);
845
        $hold (posedge PSCLK, negedge PSEN, HOLDPSENLOPSCLK, notifier);
846
        $setup (posedge PSINCDEC, posedge PSCLK, SUPSINCDECHIPSCLK, notifier);
847
        $setup (negedge PSINCDEC, posedge PSCLK, SUPSINCDECLOPSCLK, notifier);
848
        $hold (posedge PSCLK, posedge PSINCDEC, HOLDPSINCDECHIPSCLK, notifier);
849
        $hold (posedge PSCLK, negedge PSINCDEC, HOLDPSINCDECLOPSCLK, notifier);
850
 
851
        $period (posedge CLKIN, MINPERCLKIN, notifier);
852
        $period (posedge PSCLK, MINPERCLKIN, notifier);
853
        $width (posedge CLKIN, PWCLKINHI, 0, notifier);
854
        $width (negedge CLKIN, PWCLKINLO, 0, notifier);
855
        $width (posedge PSCLK, PWPSCLKHI, 0, notifier);
856
        $width (negedge PSCLK, PWPSCLKLO, 0, notifier);
857
        $width (posedge RST, PWRSTHI, 0, notifier);
858
endspecify
859
 
860
endmodule

powered by: WebSVN 2.1.0

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