如何用verilog编写50MHZ分频到1MHZ的代码。急~~

2024-11-16 01:47:30
推荐回答(3个)
回答(1):

module hz(clk_50,clk_1);

input clk_50;
output clk_1;

reg clk_1;
reg [5:0] cnt;

always@(posedge clk_50)
begin if (cnt==6'd24)
cnt <= 6'd0;
else cnt <= cnt+1;
end

always@(posedge clk_50)
begin if (cnt==6'd0)
clk_1 <= ~clk_1;
end

endmodule

回答(2):

output oCLK;

reg[5:0] rgCnt;
always @(posedge iCLK)
begin
if(rgCnt>=6'd49) rgCnt<=6'd0;
else rgCnt<=rgCnt+1'b1;
end
assign oCLK = (rgCnt<6'd25)? 1'b0 : 1'b1;

回答(3):

50分频即可