2024-08-08 14:49:44 +00:00
|
|
|
module div_clk(input clk, rstn, output reg clk_div);
|
2024-08-04 06:24:44 +00:00
|
|
|
|
|
|
|
parameter DIV = 10;
|
|
|
|
parameter COUNT_WITH = 10;
|
|
|
|
reg [COUNT_WITH-1:0] count;
|
|
|
|
|
2024-08-08 14:49:44 +00:00
|
|
|
always @(posedge clk or negedge rstn) begin
|
|
|
|
if (!rstn) begin
|
2024-08-04 06:24:44 +00:00
|
|
|
count <= 0;
|
|
|
|
clk_div <= 0;
|
|
|
|
end else begin
|
|
|
|
if (count == (DIV-1)) begin
|
|
|
|
count <= 0;
|
|
|
|
clk_div <= ~clk_div;
|
|
|
|
end else begin
|
|
|
|
count <= count + 1'd1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|