blob: 8f46aa37bba8d7e7a79beef5cf010e865564c34c (
plain) (
blame)
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
|
module clock_divider #(
parameter integer COUNT_WIDTH = 24,
parameter [COUNT_WIDTH:0] MAX_COUNT = 6000000
) (
input clk,
input rst,
output reg div_clk
);
reg [COUNT_WIDTH:0] count = 0;
always @(posedge clk or posedge rst) begin
if (rst == 1'b1) begin
count <= 0;
div_clk <= 0;
end else if (count == MAX_COUNT - 1) begin
count <= 0;
div_clk <= ~div_clk;
end else begin
count <= count + 1;
end
end
endmodule
|