diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz |
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6
Reviewed-on: https://gem5-review.googlesource.com/10845
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation')
2 files changed, 163 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/golden/sc_start_starvation.log b/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/golden/sc_start_starvation.log new file mode 100644 index 000000000..ae3e71658 --- /dev/null +++ b/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/golden/sc_start_starvation.log @@ -0,0 +1,12 @@ +SystemC Simulation + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Warning: (W571) no activity or clock movement for sc_start() invocation +In file: <removed by verify.pl> + +Success diff --git a/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/sc_start_starvation.cpp b/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/sc_start_starvation.cpp new file mode 100644 index 000000000..d279c4364 --- /dev/null +++ b/src/systemc/tests/systemc/1666-2011-compliance/sc_start_starvation/sc_start_starvation.cpp @@ -0,0 +1,151 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +// sc_start_starvation.cpp -- test for +// +// Original Author: John Aynsley, Doulos, Inc. +// +// MODIFICATION LOG - modifiers, enter your name, affiliation, date and +// +// $Log: sc_start_starvation.cpp,v $ +// Revision 1.2 2011/05/08 19:18:46 acg +// Andy Goodrich: remove extraneous + prefixes from git diff. +// + +// sc_start with event starvation policy +// sc_pending_activity and friends + +#define SC_INCLUDE_DYNAMIC_PROCESSES + +#include <systemc> +using namespace sc_core; +using std::cout; +using std::endl; + +SC_MODULE(Top) +{ + SC_CTOR(Top) + { + SC_THREAD(T); + } + + sc_event ev2; + + void T() + { + sc_assert( sc_get_status() == SC_RUNNING ); + + sc_assert( sc_pending_activity_at_current_time() == false ); + sc_assert( sc_pending_activity_at_future_time() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(250, SC_NS) ); + + ev2.notify(150, SC_NS); + + sc_assert( sc_pending_activity_at_current_time() == false ); + sc_assert( sc_pending_activity_at_future_time() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(150, SC_NS) ); + } +}; + +int sc_main(int argc, char* argv[]) +{ + Top top("top"); + + sc_event ev; + ev.notify(250, SC_NS); + + sc_assert( sc_pending_activity_at_current_time() == false ); + sc_assert( sc_pending_activity_at_future_time() == true ); + sc_assert( sc_pending_activity() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(250, SC_NS) ); + + sc_assert( sc_get_status() == SC_ELABORATION ); + sc_assert( sc_time_stamp() == SC_ZERO_TIME ); + sc_start(100, SC_NS); + sc_assert( sc_get_status() == SC_PAUSED ); + sc_assert( sc_time_stamp() == sc_time(100, SC_NS) ); + + sc_assert( sc_pending_activity_at_current_time() == false ); + sc_assert( sc_pending_activity_at_future_time() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(50, SC_NS) ); + + sc_start(10, SC_NS, SC_RUN_TO_TIME); + sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); + sc_assert( sc_time_to_pending_activity() == sc_time(40, SC_NS) ); + + sc_start(10, SC_NS, SC_EXIT_ON_STARVATION); + sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); + + sc_start(80, SC_NS, SC_EXIT_ON_STARVATION); + + sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); + sc_assert( sc_pending_activity_at_current_time() == false ); + sc_assert( sc_pending_activity_at_future_time() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(100, SC_NS) ); + + sc_start(50, SC_NS, SC_EXIT_ON_STARVATION); + sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); + sc_assert( sc_time_to_pending_activity() == sc_time(100, SC_NS) ); + + sc_start(50, SC_NS, SC_RUN_TO_TIME); + sc_assert( sc_time_stamp() == sc_time(200, SC_NS) ); + sc_assert( sc_time_to_pending_activity() == sc_time(50, SC_NS) ); + + sc_start(); + sc_assert( sc_get_status() == SC_PAUSED ); + sc_assert( sc_time_stamp() == sc_time(250, SC_NS) ); + + sc_assert( sc_pending_activity() == false ); + sc_assert( sc_time_to_pending_activity() == sc_max_time() - sc_time_stamp() ); + + ev.notify(SC_ZERO_TIME); + + sc_assert( sc_pending_activity_at_current_time() == true ); + sc_assert( sc_pending_activity_at_future_time() == false ); + sc_assert( sc_time_to_pending_activity() == SC_ZERO_TIME ); + + sc_start(); + sc_assert( sc_time_stamp() == sc_time(250, SC_NS) ); + + sc_assert( sc_pending_activity() == false ); + sc_assert( sc_time_to_pending_activity() == sc_max_time() - sc_time_stamp() ); + + ev.notify(10, SC_NS); + + sc_assert( sc_pending_activity() == true ); + sc_assert( sc_time_to_pending_activity() == sc_time(10, SC_NS) ); + + sc_start(); + sc_assert( sc_time_stamp() == sc_time(260, SC_NS) ); + + ev.notify(10, SC_NS); + sc_start(sc_time(100, SC_NS), SC_EXIT_ON_STARVATION); + sc_assert( sc_time_stamp() == sc_time(270, SC_NS) ); + + ev.notify(10, SC_NS); + sc_start(sc_time(100, SC_NS)); // SC_RUN_TO_TIME + sc_assert( sc_time_stamp() == sc_time(370, SC_NS) ); + sc_assert( sc_get_status() == SC_PAUSED ); + + ev.notify(); + sc_assert( sc_pending_activity() == false ); + + cout << endl << "Success" << endl; + return 0; +} |