2024-04-15 14:32:48 +00:00
|
|
|
module downclocker #(
|
|
|
|
parameter DC_BITS = 21
|
|
|
|
) (
|
|
|
|
input wire clk_in,
|
2024-04-08 04:39:15 +00:00
|
|
|
output logic clk_out
|
|
|
|
);
|
|
|
|
|
2024-04-15 14:32:48 +00:00
|
|
|
logic [DC_BITS-1:0] counter;
|
2024-04-08 04:39:15 +00:00
|
|
|
|
2024-04-15 14:32:48 +00:00
|
|
|
initial begin
|
|
|
|
counter = 0;
|
|
|
|
clk_out = 0;
|
|
|
|
end
|
2024-04-08 04:39:15 +00:00
|
|
|
|
2024-04-15 14:32:48 +00:00
|
|
|
always_ff @(posedge clk_in) begin
|
|
|
|
if (counter[DC_BITS-1] == 1) begin
|
|
|
|
clk_out <= !clk_out;
|
|
|
|
counter <= 0;
|
|
|
|
end else begin
|
|
|
|
counter <= counter + 1;
|
2024-04-08 04:39:15 +00:00
|
|
|
end
|
2024-04-15 14:32:48 +00:00
|
|
|
end
|
2024-04-08 04:39:15 +00:00
|
|
|
endmodule
|