diff options
author | Gabe Black <gabeblack@google.com> | 2018-09-22 06:12:16 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 00:28:06 +0000 |
commit | 0f6961d200e6334ca676f16f81280fbdec62b942 (patch) | |
tree | 90b9ba29bea021a793705931024f37a56ba279f7 | |
parent | 648b45c83072e5cb93eea804f24ca10af3ffa545 (diff) | |
download | gem5-0f6961d200e6334ca676f16f81280fbdec62b942.tar.xz |
systemc: Add an error check to sc_time.
Change-Id: Ie525a1624a6496a51277fb984cbfeec21eb79749
Reviewed-on: https://gem5-review.googlesource.com/c/12966
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
-rw-r--r-- | src/systemc/core/sc_time.cc | 8 | ||||
-rw-r--r-- | src/systemc/tests/systemc/kernel/sc_time/test16/expected_returncode | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/systemc/core/sc_time.cc b/src/systemc/core/sc_time.cc index 999fba2f9..0b8ad620b 100644 --- a/src/systemc/core/sc_time.cc +++ b/src/systemc/core/sc_time.cc @@ -494,6 +494,14 @@ sc_set_default_time_unit(double d, sc_time_unit tu) // Normalize d to seconds. defaultUnit = d * TimeUnitScale[tu]; specified = true; + + double resolution = SimClock::Float::Hz; + if (resolution == 0.0) + resolution = TimeUnitScale[SC_PS]; + if (defaultUnit < resolution) { + SC_REPORT_ERROR("(E515) set default time unit failed", + "value smaller than time resolution"); + } } sc_time diff --git a/src/systemc/tests/systemc/kernel/sc_time/test16/expected_returncode b/src/systemc/tests/systemc/kernel/sc_time/test16/expected_returncode new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/sc_time/test16/expected_returncode @@ -0,0 +1 @@ +1 |