-
Notifications
You must be signed in to change notification settings - Fork 379
/
clk_divider.sv
43 lines (34 loc) · 929 Bytes
/
clk_divider.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//------------------------------------------------------------------------------
// clk_divider.sv
// published as part of https://github.com/pConst/basic_verilog
// Konstantin Pavlov, pavlovconst@gmail.com
//------------------------------------------------------------------------------
// INFO ------------------------------------------------------------------------
// Divides main clock to get derivative slower synchronous clocks
//
/* --- INSTANTIATION TEMPLATE BEGIN ---
clk_divider #(
.WIDTH( 32 )
) CD1 (
.clk( clk ),
.nrst( 1'b1 ),
.ena( 1'b1 ),
.out( )
);
--- INSTANTIATION TEMPLATE END ---*/
module clk_divider #( parameter
WIDTH = 32
)(
input clk,
input nrst,
input ena,
output logic [(WIDTH-1):0] out = '0
);
always_ff @(posedge clk) begin
if ( ~nrst ) begin
out[(WIDTH-1):0] <= '0;
end else if (ena) begin
out[(WIDTH-1):0] <= out[(WIDTH-1):0] + 1'b1;
end
end
endmodule