always @(posedge clk_in) begin if(!rst_n) begin
cnt <= 0;
clk_p <= 0;
end else begin if(cnt < M) begin
clk_p <= 1;
cnt <= cnt + 1;
end elseif(cnt >=M && cnt < N-1) begin
clk_p <= 0;
cnt = cnt + 1;
end else cnt = 0;
end
end
always @(negedge clk_in) begin if(!rst_n) begin
cnt1 <= 0;
clk_n <= 0;
end else begin if(cnt1 < M) begin
clk_n <= 1;
cnt1 <= cnt1 + 1;
end elseif(cnt1 >=M && cnt1 < N-1) begin
clk_n <= 0;
cnt1 = cnt1 + 1;
end else cnt1 = 0;
end
end