分频(二)

3. 半整数分频

 N.5分频器原理图:

5.5半整数分频源代码

module clk5p5(clkin,clr,clkout);

input clkin,clr;
output reg clkout;

reg clk1;wire clk2;
integer count;
//cout为N的值

xor xor1(clk2,clkin,clk1);

always @(posedge clkout or negedge clr) //clkout2分频
begin
if(~clr)
begin
clk1
<=1'b0;
end
else
clk1
=~clk1;

end

always @(posedge clk2 or negedge clr)
begin
if(~clr)
begin
count
<=0;
clkout
<=1'b0;
end
else if(count==5)//计数到5时clkout输出1
begin
count
<=0;
clkout
<=1'b1;
end
else //计数不到5时clkout输出0
begin
count
<=count+1;
clkout
<=1'b0;
end
end

endmodule


 

4. 小数分频

原理:设计两个分频比的整数分频器,然后通过控制两种分频比出现的不同次数来获得所需的小数分频值,是一种近似值。

8.1分频系数 8.1=(8*9+9*1)/(9+1)

9.2分频系数9.2=(9*9+11*1)/(9+1)

 

posted on 2011-09-20 21:13  zerine  阅读(319)  评论(0编辑  收藏  举报

导航