Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/13303 )
Change subject: systemc: Add some error checks to sc_clock.
......................................................................
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 <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/channel/sc_clock.cc
1 file changed, 22 insertions(+), 0 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/systemc/channel/sc_clock.cc
b/src/systemc/channel/sc_clock.cc
index f67d256..898e7b8 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 @@
_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);
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13303
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I2cbb7c3a1b6abe4d969ef875ebf8754d2d1c489a
Gerrit-Change-Number: 13303
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev