|
SatCat5
|
Simulated clock mimics operation of "ptp_realtime.vhd".
Definition at line 18 of file ptp_simclock.h.
#include <ptp_simclock.h>
Public Member Functions | |
| SimulatedClock (double nominal_hz, double actual_hz) | |
| Constructor allows user to set nominal vs actual frequency. More... | |
| bool | ok () const |
| Confirm initial configuration is valid. | |
| unsigned | num_coarse () const |
| Report the number of coarse adjustments. More... | |
| unsigned | num_fine () const |
| Report the number of fine adjustments. More... | |
| double | mean () const |
| Mean of all inputs to clock_rate(...) | |
| satcat5::ptp::Time | clock_adjust (const satcat5::ptp::Time &amount) override |
| Make a one-time adjustment of the specified magnitude. More... | |
| satcat5::ptp::Time | clock_now () override |
| Return the current time if available, TIME_ZERO otherwise. | |
| void | clock_rate (s64 offset) override |
| Adjust rate by a normalized frequency offset. More... | |
| double | clock_offset_ppm () const |
| void | clock_set (const satcat5::ptp::Time &t) |
| void | run (const satcat5::ptp::Time &dt) |
| Run simulation for X seconds. | |
| s64 | get_rate () const |
| Read the current clock-tuning parameter. More... | |
Static Public Attributes | |
| static constexpr unsigned | TICK_SCALE_NSEC = 40 |
| Convert from internal ticks to engineering units. More... | |
| static constexpr u64 | TICKS_PER_SUBNS |
| Convert from internal ticks to engineering units. More... | |
| static constexpr double | TICKS_PER_SEC |
| Convert from internal ticks to engineering units. More... | |
Protected Attributes | |
| s64 | m_offset |
Private Attributes | |
| const satcat5::ptp::RateConversion | m_scale_nominal |
| const double | m_rate_actual |
| const s64 | m_nco_rate |
| satcat5::util::uint128_t | m_nco_accum |
| unsigned | m_count_coarse |
| unsigned | m_count_fine |
| satcat5::ptp::Time | m_rtc |
| satcat5::test::Statistics | m_stats |
| satcat5::ptp::TrackingClock * | m_next |
| SimulatedClock::SimulatedClock | ( | double | nominal_hz, |
| double | actual_hz | ||
| ) |
Constructor allows user to set nominal vs actual frequency.
For example, this allows simulations where the reference oscillator is running 10 ppm faster than its nominal rate.
Definition at line 16 of file ptp_simclock.cc.
|
overridevirtual |
Make a one-time adjustment of the specified magnitude.
Positive quantities indicate the clock should move forward. Return value is the estimated remainder or residual error.
Implements satcat5::ptp::TrackingClock.
Definition at line 32 of file ptp_simclock.cc.
|
overridevirtual |
Adjust rate by a normalized frequency offset.
Positive offsets command the clock to run faster. (See discussion above, near definition of RATE_ONE_PPB.)
Implements satcat5::ptp::TrackingClock.
Definition at line 43 of file ptp_simclock.cc.
|
inlineinherited |
Read the current clock-tuning parameter.
Definition at line 70 of file ptp_tracking.h.
|
inline |
Report the number of coarse adjustments.
(Coarse adjustments are discontinuous phase jumps of any size.)
Definition at line 42 of file ptp_simclock.h.
|
inline |
Report the number of fine adjustments.
(Fine adjustments are confined to rate changes only.)
Definition at line 46 of file ptp_simclock.h.
|
staticconstexpr |
Convert from internal ticks to engineering units.
1 Tick = 1 LSB = 2^-40 nanoseconds = 2^-24 subns. (This matches the default for ptp_counter_gen and ptp_realtime.)
Definition at line 24 of file ptp_simclock.h.
|
staticconstexpr |
Convert from internal ticks to engineering units.
1 Tick = 1 LSB = 2^-40 nanoseconds = 2^-24 subns. (This matches the default for ptp_counter_gen and ptp_realtime.)
Definition at line 27 of file ptp_simclock.h.
|
staticconstexpr |
Convert from internal ticks to engineering units.
1 Tick = 1 LSB = 2^-40 nanoseconds = 2^-24 subns. (This matches the default for ptp_counter_gen and ptp_realtime.)
Definition at line 25 of file ptp_simclock.h.