R
rekz
Guest
I have the following clock divider
// Generate a 1 kHz clock from 50 MHz clock
module LCDClkDiv(Clk, Rst, ClkOut);
input Clk, Rst;
output reg ClkOut;
parameter DivVal = 1250;
reg[24:0] DivCnt;
reg ClkInt;
always @(posedge Clk) begin
if( Rst == 1 )begin
DivCnt <= 0;
ClkOut <= 0;
ClkInt <= 0;
end
else begin
if( DivCnt == (DivVal-1) ) begin
ClkOut <= ~ClkInt;
ClkInt <= ~ClkInt;
DivCnt <= 0;
end
else begin
ClkOut <= ClkInt;
ClkInt <= ClkInt;
DivCnt <= DivCnt + 1;
end
end
end
endmodule
However I don't understand the calculation on how it can convert from
a 50MHz to a 1kHz above... what are the calculations? The 50MHz comes
from the FPGA clock
// Generate a 1 kHz clock from 50 MHz clock
module LCDClkDiv(Clk, Rst, ClkOut);
input Clk, Rst;
output reg ClkOut;
parameter DivVal = 1250;
reg[24:0] DivCnt;
reg ClkInt;
always @(posedge Clk) begin
if( Rst == 1 )begin
DivCnt <= 0;
ClkOut <= 0;
ClkInt <= 0;
end
else begin
if( DivCnt == (DivVal-1) ) begin
ClkOut <= ~ClkInt;
ClkInt <= ~ClkInt;
DivCnt <= 0;
end
else begin
ClkOut <= ClkInt;
ClkInt <= ClkInt;
DivCnt <= DivCnt + 1;
end
end
end
endmodule
However I don't understand the calculation on how it can convert from
a 50MHz to a 1kHz above... what are the calculations? The 50MHz comes
from the FPGA clock