新闻| 论坛| 博客| 在线研讨会
奇数次分频器
zhchxgh| 2009-07-15 00:12:19 阅读:1318 发布文章

奇数次分频器

module count(out,clk,clr);
parameter N=5;
output out;
input clk,clr;
reg out1,out2;
reg [N/2:0] count1,count2;
always @(posedge clk or posedge clr )
if(clr) begin
count1=0;
out1=0;
end
else begin
count1 = count1 + 1;
if( count1 == ((N+1)/2))
out1 =!out1;
else if (count1==N)
begin
out1=~out1;
count1=0;
end
end
always @(negedge clk or posedge clr )
if(clr) begin
count2=0;
out2=0;
end
else begin
count2 = count2 + 1;
if( count2 == (N+1)/2 )
out2 =!out2;
else if (count2==N)
begin
out2=~out2;
count2=0;
end
end
assign out=out1|out2;
endmodule

可以在其他程序中调用,例如七分频 :
......
count #(7) counter(out,clk,clr);
......

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
推荐文章
最近访客