`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 2022/03/20 16:49:31
// Design Name: 
// Module Name: frectl
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module frectl(
    output reg clk_out,
    output reg ctl,
    input clk,
    input rst_n
    );
reg [25:0] q, q_tmp;
    
always@*    
    begin
    ctl = q[17];
    if(q == 26'd50000000)      
        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'd50000000)
            clk_out = ~clk_out;
        else 
            clk_out = clk_out;
    end
    
    
endmodule
