diff options
Diffstat (limited to 'src/systemc/tests/systemc/kernel/sc_time/test01')
4 files changed, 660 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log new file mode 100644 index 000000000..05f57cbfb --- /dev/null +++ b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log @@ -0,0 +1,115 @@ +SystemC Simulation +test_print +0 s +1230 ps +12300 ns +1230 us +12300 ms +1230 s +12300000 s +test_constructors +0 s +0 s +1235 ps +1234 ps +0 s +18446744073709550382 ps +18446744073709550383 ps +1 ns +2 ns +3 ns +4 ns +5 ns +6 ns +7 ns +8 ns +9 ns +10 ns +11 ns +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(double,bool) +1234 ps +1235 ps +18446744073709550383 ps +18446744073709550382 ps +1 ps +2 ps +0 s +18446744073709551615 ps + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(uint64,bool) +0 s +25 ns +25 ps +25 ps +test_assignment +0 s +1235 ps +18446744073709550074 ps +test_conversion +0 +0 +0 s +0 +1234500 +1.2345e+06 +1234500 ps +1.2345e-06 +18446744073709550074 +1.84467e+19 +18446744073709550074 ps +1.84467e+07 +test_relational +1 +0 +0 +1 +0 +1 +0 +1 +0 +0 +1 +1 +0 +1 +1 +1 +0 +0 +test_arithmetic +0 s +1235 ps +18446744073709550074 ps +1235 ps +2469 ps +18446744073709551309 ps +18446744073709548532 ps +0 s +18446744073709550381 ps +1542 ps +1 ps +2777 ps +0 s +0 s +1525 ps +2468 ps +0 s +617 ps +1.00081 +1235 ps +1 ps +1 ps +1 ps +test_SC_ZERO_TIME +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: You can turn off warnings about + IEEE 1666 deprecated features by placing this method call + as the first statement in your sc_main() function: + + sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated", + sc_core::SC_DO_NOTHING ); + diff --git a/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw new file mode 100644 index 000000000..c61cc7857 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw @@ -0,0 +1,115 @@ +SystemC Simulation +test_print +0 s +1230 ps +12300 ns +1230 us +12300 ms +1230 s +12300000 s +test_constructors +0 s +0 s +1235 ps +1234 ps +0 s +18446744073709550382 ps +18446744073709550383 ps +1 ns +2 ns +3 ns +4 ns +5 ns +6 ns +7 ns +8 ns +9 ns +10 ns +11 ns +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(double,bool) +1234 ps +1235 ps +18446744073709550383 ps +18446744073709550382 ps +1 ps +2 ps +0 s +18446744073709551615 ps + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(uint64,bool) +0 s +25 ns +25 ps +25 ps +test_assignment +0 s +1235 ps +18446744073709550074 ps +test_conversion +0 +0 +0 s +0 +1234500 +1.2345e+006 +1234500 ps +1.2345e-006 +18446744073709550074 +1.84467e+019 +18446744073709550074 ps +1.84467e+007 +test_relational +1 +0 +0 +1 +0 +1 +0 +1 +0 +0 +1 +1 +0 +1 +1 +1 +0 +0 +test_arithmetic +0 s +1235 ps +18446744073709550074 ps +1235 ps +2469 ps +18446744073709551309 ps +18446744073709548532 ps +0 s +18446744073709550381 ps +1542 ps +1 ps +2777 ps +0 s +0 s +1525 ps +2468 ps +0 s +617 ps +1.00081 +1235 ps +1 ps +1 ps +1 ps +test_SC_ZERO_TIME +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: You can turn off warnings about + IEEE 1666 deprecated features by placing this method call + as the first statement in your sc_main() function: + + sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated", + sc_core::SC_DO_NOTHING ); + diff --git a/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw64 b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw64 new file mode 100644 index 000000000..c61cc7857 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/sc_time/test01/golden/test01.log.mingw64 @@ -0,0 +1,115 @@ +SystemC Simulation +test_print +0 s +1230 ps +12300 ns +1230 us +12300 ms +1230 s +12300000 s +test_constructors +0 s +0 s +1235 ps +1234 ps +0 s +18446744073709550382 ps +18446744073709550383 ps +1 ns +2 ns +3 ns +4 ns +5 ns +6 ns +7 ns +8 ns +9 ns +10 ns +11 ns +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(double,bool) +1234 ps +1235 ps +18446744073709550383 ps +18446744073709550382 ps +1 ps +2 ps +0 s +18446744073709551615 ps + +Info: (I804) /IEEE_Std_1666/deprecated: deprecated constructor: sc_time(uint64,bool) +0 s +25 ns +25 ps +25 ps +test_assignment +0 s +1235 ps +18446744073709550074 ps +test_conversion +0 +0 +0 s +0 +1234500 +1.2345e+006 +1234500 ps +1.2345e-006 +18446744073709550074 +1.84467e+019 +18446744073709550074 ps +1.84467e+007 +test_relational +1 +0 +0 +1 +0 +1 +0 +1 +0 +0 +1 +1 +0 +1 +1 +1 +0 +0 +test_arithmetic +0 s +1235 ps +18446744073709550074 ps +1235 ps +2469 ps +18446744073709551309 ps +18446744073709548532 ps +0 s +18446744073709550381 ps +1542 ps +1 ps +2777 ps +0 s +0 s +1525 ps +2468 ps +0 s +617 ps +1.00081 +1235 ps +1 ps +1 ps +1 ps +test_SC_ZERO_TIME +0 s + +Info: (I804) /IEEE_Std_1666/deprecated: You can turn off warnings about + IEEE 1666 deprecated features by placing this method call + as the first statement in your sc_main() function: + + sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated", + sc_core::SC_DO_NOTHING ); + diff --git a/src/systemc/tests/systemc/kernel/sc_time/test01/test01.cpp b/src/systemc/tests/systemc/kernel/sc_time/test01/test01.cpp new file mode 100644 index 000000000..31d8e8e8f --- /dev/null +++ b/src/systemc/tests/systemc/kernel/sc_time/test01/test01.cpp @@ -0,0 +1,315 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test01.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_time's methods + +#include "systemc.h" + +void +test_print() +{ + cout << "test_print" << endl; + + sc_time t1; + cout << t1 << endl; + + uint64 v = 1230; + sc_time t2 = sc_time::from_value( v ); + cout << t2 << endl; + + v *= 10000; + sc_time t3 = sc_time::from_value( v ); + cout << t3 << endl; + + v *= 100; + sc_time t4 = sc_time::from_value( v ); + cout << t4 << endl; + + v *= 10000; + sc_time t5 = sc_time::from_value( v ); + cout << t5 << endl; + + v *= 100; + sc_time t6 = sc_time::from_value( v ); + cout << t6 << endl; + + v *= 10000; + sc_time t7 = sc_time::from_value( v ); + cout << t7 << endl; +} + +void +test_constructors() +{ + cout << "test_constructors" << endl; + + sc_time t1; + cout << t1 << endl; + + sc_time t2a( 0, SC_SEC ); + cout << t2a << endl; + + sc_time t2b( 1.2345, SC_NS ); + cout << t2b << endl; + sc_time t2c( 1.2341, SC_NS ); + cout << t2c << endl; + + sc_time t2d( 1, SC_FS ); + cout << t2d << endl; + + sc_time t2e( -1.2345, SC_NS ); + cout << t2e << endl; + sc_time t2f( -1.2341, SC_NS ); + cout << t2f << endl; + + char v1 = 1; + signed char v2 = 2; + unsigned char v3 = 3; + short v4 = 4; + unsigned short v5 = 5; + int v6 = 6; + unsigned int v7 = 7; + long v8 = 8; + unsigned long v9 = 9; + float v10 = 10; + double v11 = 11; + + sc_time t2g( v1, SC_NS ); + cout << t2g << endl; + sc_time t2h( v2, SC_NS ); + cout << t2h << endl; + sc_time t2i( v3, SC_NS ); + cout << t2i << endl; + sc_time t2j( v4, SC_NS ); + cout << t2j << endl; + sc_time t2k( v5, SC_NS ); + cout << t2k << endl; + sc_time t2l( v6, SC_NS ); + cout << t2l << endl; + sc_time t2m( v7, SC_NS ); + cout << t2m << endl; + sc_time t2n( v8, SC_NS ); + cout << t2n << endl; + sc_time t2o( v9, SC_NS ); + cout << t2o << endl; + sc_time t2p( v10, SC_NS ); + cout << t2p << endl; + sc_time t2q( v11, SC_NS ); + cout << t2q << endl; + + sc_time t3a( 0, SC_SEC ); + cout << t3a << endl; + + sc_time t3b( 1.2341, true ); + cout << t3b << endl; + sc_time t3c( 1.2345, true ); + cout << t3c << endl; + sc_time t3d( -1.2341, true ); + cout << t3d << endl; + sc_time t3e( -1.2345, true ); + cout << t3e << endl; + + sc_time t3f( 1.2345, false ); + cout << t3f << endl; + sc_time t3g( 1.5432, false ); + cout << t3g << endl; + sc_time t3h( -1.2345, false ); + cout << t3h << endl; + sc_time t3i( -1.5432, false ); + cout << t3i << endl; + +#if !defined( _MSC_VER ) + sc_time t4a( 0ull, true ); + cout << t4a << endl; + sc_time t4b( 25ull, true ); + cout << t4b << endl; + sc_time t4c( 25ull, false ); + cout << t4c << endl; +#else + sc_time t4a( 0ui64, true ); + cout << t4a << endl; + sc_time t4b( 25ui64, true ); + cout << t4b << endl; + sc_time t4c( 25ui64, false ); + cout << t4c << endl; +#endif + + sc_time t5( t4c ); + cout << t5 << endl; +} + +void +test_assignment() +{ + cout << "test_assignment" << endl; + + sc_time t1; + + sc_time t2; + t1 = t2; + cout << t1 << endl; + + sc_time t3( 1.2345, SC_NS ); + t1 = t3; + cout << t1 << endl; + + sc_time t4( -1.5432, SC_NS ); + t1 = t4; + cout << t1 << endl; +} + +void +test_conversion() +{ + cout << "test_conversion" << endl; + + sc_time t1; + cout << t1.value() << endl; + cout << t1.to_double() << endl; + cout << t1 << endl; + cout << t1.to_seconds() << endl; + + sc_time t2( 1.2345, SC_US ); + cout << t2.value() << endl; + cout << t2.to_double() << endl; + cout << t2 << endl; + cout << t2.to_seconds() << endl; + + sc_time t3( -1.5432, SC_NS ); + cout << t3.value() << endl; + cout << t3.to_double() << endl; + cout << t3 << endl; + cout << t3.to_seconds() << endl; +} + +void +test_relational() +{ + cout << "test_relational" << endl; + + sc_time t1; + sc_time t2( 1, SC_FS ); + sc_time t3( 1.2345, SC_NS ); + sc_time t4( 1.2341, SC_NS ); + sc_time t5( -1.5432, SC_NS ); + + cout << ( t1 == t2 ) << endl; + cout << ( t1 != t2 ) << endl; + cout << ( t1 < t2 ) << endl; + cout << ( t1 <= t2 ) << endl; + cout << ( t1 > t2 ) << endl; + cout << ( t1 >= t2 ) << endl; + + cout << ( t3 == t4 ) << endl; + cout << ( t3 != t4 ) << endl; + cout << ( t3 < t4 ) << endl; + cout << ( t3 <= t4 ) << endl; + cout << ( t3 > t4 ) << endl; + cout << ( t3 >= t4 ) << endl; + + cout << ( t1 == t5 ) << endl; + cout << ( t1 != t5 ) << endl; + cout << ( t1 < t5 ) << endl; + cout << ( t1 <= t5 ) << endl; + cout << ( t1 > t5 ) << endl; + cout << ( t1 >= t5 ) << endl; +} + +void +test_arithmetic() +{ + cout << "test_arithmetic" << endl; + + sc_time t1; + sc_time t2( 1, SC_FS ); + sc_time t3( 1.2345, SC_NS ); + sc_time t4( 1.2341, SC_NS ); + sc_time t5( -1.5432, SC_NS ); + + cout << ( t1 + t2 ) << endl; + cout << ( t1 + t3 ) << endl; + cout << ( t1 + t5 ) << endl; + cout << ( t3 + t2 ) << endl; + cout << ( t3 + t4 ) << endl; + cout << ( t3 + t5 ) << endl; + cout << ( t5 + t5 ) << endl; + + cout << ( t1 - t2 ) << endl; + cout << ( t1 - t3 ) << endl; + cout << ( t1 - t5 ) << endl; + cout << ( t3 - t4 ) << endl; + cout << ( t3 - t5 ) << endl; + cout << ( t5 - t5 ) << endl; + + cout << ( t1 * 1.2345 ) << endl; + cout << ( 1.2345 * t3 ) << endl; + cout << ( t4 * 2 ) << endl; + + cout << ( t1 / 1.2345 ) << endl; + cout << ( t4 / 2 ) << endl; + cout << ( t3 / t4 ) << endl; + + cout << ( t2 += t3 ) << endl; + cout << ( t2 -= t4 ) << endl; + cout << ( t2 *= 1.2345 ) << endl; + cout << ( t2 /= 2 ) << endl; +} + +void +test_SC_ZERO_TIME() +{ + cout << "test_SC_ZERO_TIME" << endl; + + cout << SC_ZERO_TIME << endl; +} + +int +sc_main( int, char*[] ) +{ +#if defined(_MSC_VER) && _MSC_VER < 1900 + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + test_print(); + test_constructors(); + test_assignment(); + test_conversion(); + test_relational(); + test_arithmetic(); + test_SC_ZERO_TIME(); + + return 0; +} |