2008-10-9 tianwen09
module Div_fre(Fout,CLOCK_50,KEY);
output Fout;
input CLOCK_50;
input [3:0] KEY;
reg Fout;
reg [7:0]j;
always @(posedge CLOCK_50 or negedge KEY[0])
if (!KEY[0]) //复位信号,低电平有效
begin
j<=0;
Fout<=0;
end
else
begin
if (j==9) //2N分频时,用(N-1)替换9,N<256
begin
j<=0;
Fout=~Fout;
end
else j<=j+1;
end
endmodule
module Div_fre(Fout,CLOCK_50,KEY);
output Fout;
input CLOCK_50;
input [3:0] KEY;
reg Fout;
reg [7:0]j;
always @(posedge CLOCK_50 or negedge KEY[0])
if (!KEY[0]) //复位信号,低电平有效
begin
j<=0;
Fout<=0;
end
else
begin
if (j==9) //2N分频时,用(N-1)替换9,N<256
begin
j<=0;
Fout=~Fout;
end
else j<=j+1;
end
endmodule
文章评论(0条评论)
登录后参与讨论