偶分频
直接在一半时候翻转
module divider_even(
input clk,
input rst_n,
input [7:0] div,//分频系数
output reg clk_div
);
reg [7:0] cnt;
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
cnt<=0;
else
if(cnt==div-1)
cnt<=0;
else
cnt<=cnt+1;
end
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
clk_div<=0;
else
if(cnt==((div>