30 typedef std::list<Clock::Handle> ClockList;
35 any_clock_with_explicit_freq_(
false),
42 croot_->enterTeardown_();
61 "Cannot makeRoot on a ClockManager which already has a root");
62 croot_ = Clock::Handle(
new Clock(parent, name, scheduler_));
63 clist_.push_back(croot_);
67 Clock::Handle getRoot()
const
75 Clock::Handle
makeClock(
const std::string& name,
const Clock::Handle &parent,
76 const uint32_t &p_rat,
const uint32_t &c_rat)
78 Clock::Handle c = Clock::Handle(
new Clock(name, parent, p_rat, c_rat));
86 Clock::Handle
makeClock(
const std::string& name,
const Clock::Handle &parent)
95 const Clock::Handle &parent,
double frequency_mhz)
97 any_clock_with_explicit_freq_ =
true;
98 Clock::Handle c = Clock::Handle(
new Clock(name, parent, frequency_mhz));
107 if (any_clock_with_explicit_freq_) {
108 normalize_frequencies_();
113 uint32_t norm_ = croot_->calcNorm();
116 for (
auto i = clist_.begin(); i != clist_.end(); ++i) {
117 (*i)->setPeriod(norm_);
121 croot_->enterConfig_();
122 croot_->enterFinalizing_();
123 croot_->finalizeTree_();
124 croot_->enterFinalized_();
129 void print(std::ostream &os)
const
131 for (
auto i = clist_.begin(); i != clist_.end(); ++i) {
145 return static_cast<uint64_t
>(((1.0 / frequency_mhz) * 1000. * 1000.0));
152 void normalize_frequencies_() {
154 for (
auto i = clist_.begin(); i != clist_.end(); ++i) {
155 double frequency_mhz = (*i)->getFrequencyMhz();
157 if (frequency_mhz == 0.0) {
162 (*i)->setPeriod(period);
166 Clock::Handle croot_;
168 bool any_clock_with_explicit_freq_;
169 Scheduler* scheduler_ =
nullptr;
172 std::ostream &
operator<<(std::ostream &os,
const ClockManager &m);
File that defines the Clock class.
A simple time-based, event precedence based scheduler.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Manages building a clock tree.
Clock::Handle makeClock(const std::string &name, const Clock::Handle &parent, double frequency_mhz)
Create a new clock with a given frequency.
Clock::Handle makeClock(const std::string &name, const Clock::Handle &parent)
Create a new clock with a 1:1 ratio to a parent clock.
static uint64_t getClockPeriodFromFrequencyMhz(double frequency_mhz)
Clock::Handle makeRoot(RootTreeNode *parent=nullptr, const std::string &name="Root")
Construct a root clock.
Clock::Handle makeClock(const std::string &name, const Clock::Handle &parent, const uint32_t &p_rat, const uint32_t &c_rat)
Create a new clock with a given ratio to a parent clock.
A representation of simulated time.
TreeNode which represents the root ("top") of a device tree.
A class that lets you schedule events now and in the future.
Macros for handling exponential backoff.
std::ostream & operator<<(std::ostream &o, const SimulationInfo &info)
ostream insertion operator for SimulationInfo