Skip to content

Commit d77580c

Browse files
authored
Update BHG_FP_clk_divider.v
1 parent ed58090 commit d77580c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hdl/BHG_FP_clk_divider.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Floating point clock divider/synthesizer.
55
// 24.16 (m.n) bit floating point clock divider. (Actually it is a fixed point fractional divider.)
66
//
7+
// 1.3 - Corrected the PPM calculation + added 1 bit to the M divider counter for the occasional requirement. (Thanks to 'dennowiggle' for catching the error)
78
// 1.2 - Added a protection for when the integer divider has less than 2 bits.
89
// - Added a compilation $error and $stop with instructions if the user supplies inoperable CLK_HZ parameters.
910
// 1.1 - Fixed a bug with some Modelsim versions where its 'Compile / Compile Options / Language Syntax' is set to 'Use Verilog 2001' instead of 'Default'.
@@ -87,7 +88,7 @@ localparam [15:0] clk_per_f = USE_FLOATING_DIVIDE ? clk_per_x65k[15:0]
8788

8889
localparam [63:0] clk_tru_hzX100 = INPUT_CLK_HZ * 6553600 / (clk_per_int*65536+clk_per_f) ; // Calculate the true output clock X 100.
8990
localparam signed clk_dif_hzX100 = (clk_tru_hzX100 - (OUTPUT_CLK_HZ*100)) ;
90-
localparam signed clk_ppm_x100 = clk_dif_hzX100 * OUTPUT_CLK_HZ / 1000000 ; // Calculate the PPM offset error X 100.
91+
localparam signed clk_ppm_x100 = clk_dif_hzX100 * 1000000 / OUTPUT_CLK_HZ ; // Calculate the PPM offset error X 100.
9192
localparam [63:0] clk_jitterx100 = (clk_per_f==0) ? 0 : (100000*1000000/INPUT_CLK_HZ) /2 ; // Calculate the occasional jitter X 100 generated by the floating point clock correction clock step.
9293

9394
localparam real f_tru = clk_tru_hzX100 ; // Necessary for being able to display the decimal point
@@ -126,7 +127,7 @@ endgenerate
126127
// Floating point clock divider logic.
127128
// ****************************************************************************
128129

129-
localparam pmb = $clog2(clk_per_int);
130+
localparam pmb = $clog2(clk_per_int) + 1;
130131
localparam mb = (pmb<2) ? 2 : pmb ; // Protection for when the integer divider has less than 2 bits.
131132

132133
reg [mb-1:0] clk_cnt_m = (mb)'(0) ; // This integer counts up 1 by 1 requiring manual bit reduction 'mb' for minimum logic cells.

0 commit comments

Comments
 (0)