mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-13 00:25:26 +00:00
Ensure this can definitely never divide by 0.
This commit is contained in:
@@ -106,7 +106,7 @@ template <typename BitHandler, size_t length_of_history = 3> class DigitalPhaseL
|
|||||||
|
|
||||||
// In net: use an unweighted average of the stored offsets to compute current window size,
|
// In net: use an unweighted average of the stored offsets to compute current window size,
|
||||||
// bucketing them by rounding to the nearest multiple of the base clocks per bit
|
// bucketing them by rounding to the nearest multiple of the base clocks per bit
|
||||||
window_length_ = total_spacing_ / total_divisor_;
|
window_length_ = std::max(total_spacing_ / total_divisor_, Cycles::IntType(1));
|
||||||
|
|
||||||
// Also apply a difference to phase, use a simple spring mechanism as a lowpass filter.
|
// Also apply a difference to phase, use a simple spring mechanism as a lowpass filter.
|
||||||
const auto error = new_phase - (window_length_ >> 1);
|
const auto error = new_phase - (window_length_ >> 1);
|
||||||
|
Reference in New Issue
Block a user