Represents a timing source for simulation.
More...
#include "timing.h"
Represents a timing source for simulation.
Definition at line 35 of file timing.h.
◆ Timing() [1/3]
Constructs a Timing object.
- Parameters
-
| name | The name of the timing source. |
| seed | The seed for the timing source's internal random number generator. |
Definition at line 24 of file timing.cpp.
24 :
27 {
28 }
static SimIdGenerator & instance()
Get the singleton instance of SimIdGenerator.
◆ ~Timing()
| timing::Timing::~Timing |
( |
| ) |
|
|
default |
◆ Timing() [2/3]
◆ Timing() [3/3]
| timing::Timing::Timing |
( |
Timing && |
| ) |
|
|
delete |
◆ clone()
| std::unique_ptr< Timing > timing::Timing::clone |
( |
| ) |
const |
Creates a new Timing instance based on the same prototype.
- Returns
- A unique_ptr to the new Timing object.
- Exceptions
-
| std::logic_error | if the timing object was not initialized from a prototype. |
Definition at line 82 of file timing.cpp.
83 {
84 if (_prototype == nullptr)
85 {
86 LOG(Level::FATAL,
"Cannot clone a Timing object that has not been initialized from a prototype.");
87 throw std::logic_error("Cannot clone a Timing object that has not been initialized from a prototype.");
88 }
89 auto new_timing = std::make_unique<Timing>(_name, _seed, _id);
92 }
References LOG, and max.
◆ getFreqOffset()
| RealType timing::Timing::getFreqOffset |
( |
| ) |
const |
|
noexcept |
Gets the frequency offset of the timing source.
- Returns
- The frequency offset.
Definition at line 103 of file timing.h.
103{ return _freq_offset; }
◆ getFrequency()
| RealType timing::Timing::getFrequency |
( |
| ) |
const |
|
noexcept |
Gets the frequency of the timing source.
- Returns
- The frequency of the timing source.
Definition at line 97 of file timing.h.
◆ getId()
| SimId timing::Timing::getId |
( |
| ) |
const |
|
noexcept |
Gets the unique ID of the timing source.
- Returns
- The timing source SimId.
Definition at line 76 of file timing.h.
◆ getName()
| std::string timing::Timing::getName |
( |
| ) |
const |
|
noexcept |
Gets the name of the timing source.
- Returns
- The name of the timing source.
Definition at line 68 of file timing.h.
◆ getNextSample()
| RealType timing::Timing::getNextSample |
( |
| ) |
const |
|
noexcept |
Gets the next sample from the timing source.
- Returns
- The next sample value or 0.0 if not enabled.
Definition at line 61 of file timing.h.
61{ return _enabled ? _model->getSample() : 0.0; }
◆ getPhaseOffset()
| RealType timing::Timing::getPhaseOffset |
( |
| ) |
const |
|
noexcept |
Gets the phase offset of the timing source.
- Returns
- The phase offset.
Definition at line 109 of file timing.h.
109{ return _phase_offset; }
◆ getSeed()
| unsigned timing::Timing::getSeed |
( |
| ) |
const |
|
noexcept |
Gets the initial seed used for the timing source's RNG.
- Returns
- The initial seed value.
Definition at line 83 of file timing.h.
◆ getSyncOnPulse()
| bool timing::Timing::getSyncOnPulse |
( |
| ) |
const |
|
noexcept |
Checks if the timing source synchronizes on pulse.
- Returns
- True if synchronized on pulse, otherwise false.
Definition at line 90 of file timing.h.
90{ return _sync_on_pulse; }
◆ initializeModel()
Initializes the timing model.
- Parameters
-
| timing | The prototype timing configuration used for initialization. |
Definition at line 39 of file timing.cpp.
40 {
41 if (_model)
42 {
43 LOG(Level::WARNING,
"Timing source '{}' already initialized. Skipping re-initialization.", _name);
44 return;
45 }
46
48 _frequency =
timing->getFrequency();
49
51
52 _freq_offset =
timing->getFreqOffset().value_or(0);
54 {
55 LOG(Level::INFO,
"Timing source '{}': applying random frequency offset with stdev {} Hz.", _name,
58 }
59
60 _phase_offset =
timing->getPhaseOffset().value_or(0);
62 {
63 LOG(Level::INFO,
"Timing source '{}': applying random phase offset with stdev {} radians.", _name,
66 }
67
68 timing->copyAlphas(_alphas, _weights);
69
70 _model = std::make_unique<noise::ClockModelGenerator>(_rng, _alphas, _weights, _frequency, _phase_offset,
71 _freq_offset, 15);
72
73 if (
timing->getFrequency() == 0.0)
74 {
75 LOG(Level::INFO,
"Timing source frequency not set, results could be incorrect.");
76 }
77
78 _sync_on_pulse =
timing->getSyncOnPulse();
79 _enabled = true;
80 }
References LOG, and max.
◆ isEnabled()
| bool timing::Timing::isEnabled |
( |
| ) |
const |
|
noexcept |
Checks if the timing source is enabled.
- Returns
- True if enabled, otherwise false.
Definition at line 116 of file timing.h.
116{ return _enabled && _model && _model->enabled(); }
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ reset()
| void timing::Timing::reset |
( |
| ) |
|
|
noexcept |
Resets the timing model.
Definition at line 136 of file timing.h.
137 {
138 if (_model)
139 {
140 _model->reset();
141 }
142 }
◆ skipSamples()
| void timing::Timing::skipSamples |
( |
std::size_t |
samples | ) |
|
|
noexcept |
Skips a number of samples in the timing model.
- Parameters
-
| samples | The number of samples to skip. |
Definition at line 31 of file timing.cpp.
32 {
33 if (_enabled && _model)
34 {
35 _model->skipSamples(samples);
36 }
37 }
The documentation for this class was generated from the following files: