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

Subversion Repositories pwm

[/] [pwm/] [trunk/] [RTL/] [down_clocking_even.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 m99
/*Down clocking module
2 2 m99
Output clock frequency is the original frequency divided by an even number
3
*/
4
module  down_clocking_even(
5
input   i_clk,
6
input   i_rst,
7
input   [15:0]i_divisor,
8
output  o_clk
9
);
10
 
11
wire    [15:0]divisor;
12
wire    borrow;
13
 
14
minus_one       minus_one_0(
15
i_divisor,
16
divisor,
17
borrow
18
);
19
 
20
wire    go;
21
assign  go=((i_divisor!=0)&&i_rst);
22
reg     [15:0]ct;
23
reg     clk;
24 6 m99
always@(posedge i_clk or negedge i_rst)
25 2 m99
        if(!i_rst)begin
26
                ct<=0;
27
                clk<=0;
28
        end
29
        else if(go)begin
30
                if(ct>=divisor)begin
31
                        ct<=0;
32
                        clk<=~clk;
33
                end
34
                else ct<=ct+1;
35
        end
36
assign  o_clk=go?clk:i_clk;
37
endmodule

powered by: WebSVN 2.1.0

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