`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2022/03/29 08:47:14
// Design Name: 
// Module Name: fast_clk
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module fast_clk(
    output reg clk_out,
    input clk,
    input rst_n
    );
    reg [25:0] q, q_tmp;
    
always@*    
    begin
    if(q == 26'd500000)       
        q_tmp = 26'd0;
    else
        q_tmp = q + 1'b1;
    end
    
always@(posedge clk or negedge rst_n)
    if(~rst_n) q <= 26'd0;
    else 
    begin
        q <= q_tmp;
        if(q == 26'd500000)
            clk_out = ~clk_out;
        else 
            clk_out = clk_out;
    end

endmodule
