如何用verilog将50MHz分频到50kHz?
1个回答
展开全部
module cutclk( input clk,reset,
output reg clk_divide);
reg [9:0] clk_cnt;
always @(posedge clk or posedge reset)
if(reset)
begin
clk_cnt <= 10'd0;
clk_divide <= 0;
end
else if (clk_cnt == 10'd0)
begin
clk_cnt <= 10'd1;
clk_divide <= ~ clk_divide;
end
else if (clk_cnt == 10'd500)
begin
clk_cnt <=10'd1;
clk_divide <= ~ clk_divide;
end
else clk_cnt <= clk_cnt + 10'd1;
endmodule
output reg clk_divide);
reg [9:0] clk_cnt;
always @(posedge clk or posedge reset)
if(reset)
begin
clk_cnt <= 10'd0;
clk_divide <= 0;
end
else if (clk_cnt == 10'd0)
begin
clk_cnt <= 10'd1;
clk_divide <= ~ clk_divide;
end
else if (clk_cnt == 10'd500)
begin
clk_cnt <=10'd1;
clk_divide <= ~ clk_divide;
end
else clk_cnt <= clk_cnt + 10'd1;
endmodule
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询