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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [clock/] [clock_mult.v] - Blame information for rev 48

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

Line No. Rev Author Line
1 34 qaztronic
//
2
//
3
//
4
 
5
`timescale 1ps/1ps
6
 
7
 
8
module clock_mult
9
#(
10
  parameter MULT = 7
11
)
12
(
13
  input       clock_in,
14
  output reg  clock_out,
15
  output reg  clock_good,
16
 
17
  input  reset
18
);
19
 
20
  // --------------------------------------------------------------------
21
  //
22
  time  clock_in_time_buffer;
23
  time  clock_out_period;
24
 
25
  wire enable = (reset === 1'b0) & ((clock_in === 1'b0) | (clock_in === 1'b1));
26
 
27
  reg [(MULT - 1):0] delayed_clock_in = 0;
28
 
29
  initial
30
    begin
31
      clock_out             <= 0;
32
      clock_out_period      <= 0;
33
      clock_good            <= 0;
34
 
35
      wait( ~enable );
36
 
37
      @(posedge clock_in);
38
      clock_in_time_buffer  = $time;
39
 
40
      @(posedge clock_in);
41
      clock_out_period      = ($time - clock_in_time_buffer) / MULT;
42
 
43
      @(posedge clock_in);
44
      clock_good            = 1;
45
 
46
    end
47
 
48
 
49
  // --------------------------------------------------------------------
50
  //
51
  integer i;
52
 
53
  always @( * )
54
    for( i = 0; i < MULT; i = i + 1 )
55
      delayed_clock_in[i] <= #(i * clock_out_period) clock_in;
56
 
57
 
58
  // --------------------------------------------------------------------
59
  //
60
  integer j;
61
 
62
  always @(posedge clock_in)
63
    begin
64
      if(clock_good)
65
        begin
66
          clock_out = 1'b1;
67
          #(clock_out_period/2);
68
          clock_out = 1'b0;
69
          for( j = 1; j < MULT; j = j + 1 )
70
            begin
71
              @(posedge delayed_clock_in[j]);
72
              clock_out = 1'b1;
73
              #(clock_out_period/2);
74
              clock_out = 1'b0;
75
            end
76
        end
77
    end
78
 
79
 
80
endmodule
81
 
82
 
83
 

powered by: WebSVN 2.1.0

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