๐Ÿ“ฆ furkan / fakequidditch

๐Ÿ“„ clock_divider.v ยท 26 lines
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
26module clock_divider (clk_in, division, clk_out);

input clk_in;
output reg clk_out = 0;

input wire [25:0] division;

integer counter_clk;

initial begin
	clk_out = 0;
	counter_clk = 0;
end

always @(posedge clk_in) begin

	if (counter_clk == division - 'd1) begin
	   counter_clk <= 'd0;
		clk_out <= 1;
	end else begin
		counter_clk <= counter_clk + 'd1;
		clk_out <= 0;
	end
end

endmodule