1.分频比交错法
分频比交错法,顾名思义就是在一定时间间隔T内,由不同的分频比电路交叉着对输入信号进行分频,从而在T时间内达到小数分频的目的。假设要实现8.666666分频,则可以以6次分频为一个周期,每个周期内进行2次9分频和4次8分频,这样,输出F_OUT均为F_IN的8.666666分频,该类分频器的程序结构如图所示。在这种方法中,为使分频输出信号的占空比尽可能均匀,8分频和9分频应交替进行。
module clk_div_8p6(
clk_in,rst_n,clk_out
);
input clk_in;
input rst_n;
output clk_out;
reg [3:0]cnt1;
reg [2:0]cnt2;
reg clk_out_t;
reg fs_ctl;
assign clk_out=clk_out_t;
always @( posedge clk_in )
begin
if(!rst_n)
begin
cnt1<=4'b0000;
cnt2<=3'b000;
clk_out_t<=1'b0;
end
else
begin
case(fs_ctl)
1'b1://deal the ninth frequency
begin
if(cnt1==4'b1000)
begin
cnt1<=4'b0000;
clk_out_t<=1'b1;
if(cnt2==3'b101)
cnt2<=3'b000;
else
cnt2<=cnt2+3'b001;
end
elseif(cnt1<4'b0101)
begin
cnt1<=cnt1+4'b0001;
clk_out_t<=1'b0;
end
else
begin
cnt1<=cnt1+4'b0001;
clk_out_t<=1'b1;
end
end
1'b0://deal the eigth frequency
begin
if(cnt1==4'b0111)
begin
cnt1<=4'b0000;
clk_out_t<=1'b1;
if(cnt2==3'b101)
cnt2<=3'b000;
else
cnt2<=cnt2+3'b001;
end
elseif(cnt1<4'b0100)
begin
cnt1<=cnt1+4'b0001;
clk_out_t<=1'b0;
end
else
begin
cnt1<=cnt1+4'b0001;
clk_out_t<=1'b1;
end
end
endcase
end
end
always @( posedge clk_in )
begin
if(!rst_n)
begin
fs_ctl<=1'b0;
end
else
begin
case(cnt2)
3'b000,3'b011:fs_ctl<=1'b1;
default:fs_ctl<=1'b0;
endcase
end
End
endmodule
2.累加器分频法
累加器分频法的结构如图所示,通过调整步长STEP 的值来实现不同的分频比。假设累加器位数为8,则累加器的模值N为28=256。若STEP=27,则分频比K为:
类似地,通过改变模值N 和步长STEP 就可以以任意精度逼近某个预定的分频比。
首先,假设模值为65536,计算出相应的步长:
N=[65536/8.66] = [7567.667]=7568,其中“[]”为四舍五入操作。
module clk_div_8p62(
clk_in,rst_n,clk_out
);
input clk_in;
input rst_n;
output clk_out;
reg [15:0] cnt;
always @( posedge clk_in )
begin
if(!rst_n)
begin
cnt<=16'h0;
end
else
begin
cnt<=cnt+7568;
end
end
assign clk_out=cnt[15];
Endmodule