第1个回答 2010-12-12
module led(rst,clk_50M,clk_4,clk_1M);
input rst,clk_50M;
output clk_4,clk_1M;
reg clk_4,clk_1M;
integer count_4,count_1M;
always @(posedge clk_50M or posedge rst)
begin
if (rst)
begin
clk_4 <= 0;
clk_1M <= 0;
count_4 <= 1;
count_1M <= 1;
end
else
begin
if (count_1M == 25)
begin
count_1M <= 1;
clk_1M <= !clk_1M;
end
else
count_1M <= count_1M + 1;
if (count_4 == 6_250_000)
begin
count_4 <= 1;
clk_4 <= !clk_4;
end
else
count_4 <= count_4 + 1;
end
end
endmodule