diff options
author | Gabe Black <gabeblack@google.com> | 2018-10-05 15:55:50 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 00:57:51 +0000 |
commit | 3287171e087ecfe6d22a86703aab29a2bbd3519a (patch) | |
tree | 0e68d9b044e3041e4009aad30f1f40666f3eac12 /src | |
parent | c701d88756fa135c2016cbf968970d37ec67e26c (diff) | |
download | gem5-3287171e087ecfe6d22a86703aab29a2bbd3519a.tar.xz |
systemc: Add some error checks to sc_clock.
The Accellera version reports an error if the period, high or low
portions of the clock are zero.
Change-Id: I2cbb7c3a1b6abe4d969ef875ebf8754d2d1c489a
Reviewed-on: https://gem5-review.googlesource.com/c/13303
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/systemc/channel/sc_clock.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/systemc/channel/sc_clock.cc b/src/systemc/channel/sc_clock.cc index f67d2565d..898e7b866 100644 --- a/src/systemc/channel/sc_clock.cc +++ b/src/systemc/channel/sc_clock.cc @@ -38,6 +38,7 @@ #include "systemc/ext/channel/sc_clock.hh" #include "systemc/ext/core/sc_main.hh" #include "systemc/ext/core/sc_module.hh" // for sc_gen_unique_name +#include "systemc/ext/utils/sc_report_handler.hh" namespace sc_gem5 { @@ -108,6 +109,27 @@ sc_clock::sc_clock(const char *name, const sc_time &period, _period(period), _dutyCycle(duty_cycle), _startTime(start_time), _posedgeFirst(posedge_first) { + if (period == SC_ZERO_TIME) { + std::string msg = + "increase the period: clock '" + + std::string(name) + "'"; + SC_REPORT_ERROR("(E101) sc_clock period is zero", msg.c_str()); + } + + if (duty_cycle * period == SC_ZERO_TIME) { + std::string msg = + "increase the period or increase the duty cycle: clock '" + + std::string(name) + "'"; + SC_REPORT_ERROR("(E102) sc_clock high time is zero", msg.c_str()); + } + + if (duty_cycle * period == period) { + std::string msg = + "increase the period or decrease the duty cycle: clock '" + + std::string(name) + "'"; + SC_REPORT_ERROR("(E103) sc_clock low time is zero", msg.c_str()); + } + _gem5UpEdge = new ::sc_gem5::ClockTick(this, true, period); _gem5DownEdge = new ::sc_gem5::ClockTick(this, false, period); } |