OpenCores
URL https://opencores.org/ocsvn/dpll-isdn/dpll-isdn/trunk

Subversion Repositories dpll-isdn

[/] [dpll-isdn/] [trunk/] [Sources/] [freqdivider.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dmsu
 
2
/* frequency divider and phase controller */
3
 
4
module freqdivider(MainClock, Positive, Negative, FrequencyOut);
5
 input MainClock;                 // main clock
6
 input Positive, Negative;    // signals Positive, Negative are synchronous with MainClock
7
 output FrequencyOut;         // output frequency
8
 
9
/* needed counter length */
10
parameter DividerLength   = 7;
11
 
12
/*  controlled prescaler, after this prescales the "divider by 2" installed,     */
13
/*  so composite divide coefficient will be equivalent of 96 (in this example) - */
14
/*  it's necessary for work DPLL on frequency 192kHz with oscillator             */
15
/*  frequency 18432kHz                                                           */
16
/* additional divider by 2 used for getting output signal with duty factor of 2  */
17
 
18
parameter DividerMaxValue = 48;
19
 
20
reg [DividerLength-1 : 0] DividerCounter;
21
reg FrequencyOut;        // registered output
22
 
23
/* Process of freq. division according to  signals from Random  Deviations Filter:  */
24
/* if "lag" then counter will incremented by 2                                                                          */
25
/* if "lead" then counter will not changed                                                                                */
26
/* if there is no phase lead or lag then counter normally incremented by 1                          */
27
 
28
always @(posedge MainClock)
29
 begin
30
  if(DividerCounter >= (DividerMaxValue - 1))
31
    DividerCounter <= 0;
32
    else if(Negative)       DividerCounter <= DividerCounter + 2;
33
          else if(Positive) DividerCounter <= DividerCounter;
34
                else        DividerCounter <= DividerCounter + 1;
35
  if(DividerCounter == 0) FrequencyOut <= ~FrequencyOut;           // additional divider by 2 - for producing 50% duty factor of the output signal
36
 end
37
 
38
endmodule

powered by: WebSVN 2.1.0

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