summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/process_control/reset
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/kernel/process_control/reset')
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log7
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp100
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log14
-rw-r--r--src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp82
4 files changed, 203 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log
new file mode 100644
index 000000000..31efd2c64
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/golden/sc_method_reset_throw.log
@@ -0,0 +1,7 @@
+SystemC Simulation
+5 ns: reset method m1
+5 ns: in m1
+5 ns: in m1() throwing exception in throwee1
+5 ns: in throwee1, caught exception
+5 ns: in m1() after throwing exception in throwee1
+5 ns: after reset of method m1
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp
new file mode 100644
index 000000000..c6596f0c7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_reset_throw/sc_method_reset_throw.cpp
@@ -0,0 +1,100 @@
+
+/*****************************************************************************
+
+ The following code is derived, directly or indirectly, from the SystemC
+ source code Copyright (c) 1996-2014 by all Contributors.
+ All Rights reserved.
+
+ The contents of this file are subject to the restrictions and limitations
+ set forth in the SystemC Open Source License (the "License");
+ You may not use this file except in compliance with such restrictions and
+ limitations. You may obtain instructions on how to receive a copy of the
+ License at http://www.accellera.org/. Software distributed by Contributors
+ under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the License for the specific
+ language governing rights and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_method_reset_throw.cpp --
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems, 2012-08-07
+
+ *****************************************************************************/
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+class my_exception
+{
+public:
+ explicit my_exception(const char* s) : s_(s) { }
+ const char* message() const { return s_.c_str(); }
+protected:
+ std::string s_;
+};
+
+SC_MODULE(sctop)
+{
+public:
+ SC_CTOR(sctop)
+ {
+ SC_THREAD(run);
+ SC_METHOD(m1); dont_initialize();
+ method_handle = sc_get_current_process_handle();
+ SC_THREAD(throwee1);
+ throwee1_h = sc_get_current_process_handle();
+ }
+
+ void run() {
+ wait (5, SC_NS);
+ cout << sc_time_stamp() << ": reset method m1" << endl;
+ method_handle.reset();
+ cout << sc_time_stamp() << ": after reset of method m1" << endl;
+ }
+
+ void m1()
+ {
+ cout << sc_time_stamp() << ": in m1" << endl;
+ cout << sc_time_stamp() << ": in m1() "
+ << "throwing exception in throwee1" << endl;
+
+ throwee1_h.throw_it(
+ my_exception("thrown in throwee1 from m1()")
+ );
+
+ cout << sc_time_stamp() << ": in m1() "
+ << "after throwing exception in throwee1" << endl;
+ }
+
+ void throwee1()
+ {
+ // catch exception and exit
+ while (1) {
+ try {
+ wait(50, SC_NS);
+ cerr << sc_time_stamp() << ": in throwee1, normal flow" << endl;
+ }
+ catch (my_exception const & x) {
+ cerr << sc_time_stamp() << ": in throwee1, caught exception "
+ << endl;
+ return;
+ }
+ }
+ }
+
+protected:
+ sc_process_handle method_handle;
+ sc_process_handle throwee1_h;
+};
+
+
+int sc_main (int, char*[])
+{
+ sc_report_handler::set_actions( SC_ID_DISABLE_WILL_ORPHAN_PROCESS_, SC_DO_NOTHING );
+ sctop top1("Top1");
+ sc_start(10, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log
new file mode 100644
index 000000000..f5f0d3ebe
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/golden/method_self_reset.log
@@ -0,0 +1,14 @@
+SystemC Simulation
+Entry
+Issuing self reset
+Entry
+Exit
+Entry
+Exit
+Entry
+Issuing self reset
+Entry
+Exit
+Entry
+Exit
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp
new file mode 100644
index 000000000..8b5da09b4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/process_control/reset/method_self_reset/method_self_reset.cpp
@@ -0,0 +1,82 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ method_self_reset.cpp -- Test of method self reset.
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+// $Log: method_self_reset.cpp,v $
+// Revision 1.4 2011/07/24 15:59:53 acg
+// Andy Goodrich: add statement I missed installing Philipp's patch.
+//
+// Revision 1.3 2011/07/24 15:58:39 acg
+// Philipp A. Hartmann: convert first time toggle to counter since need 3
+// states.
+//
+// Revision 1.2 2011/02/04 15:26:33 acg
+// Andy Goodrich: regolden for proper process control semantics.
+//
+// Revision 1.1 2011/01/28 19:48:36 acg
+// Andy Goodrich: first check in.
+//
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_METHOD(method);
+ sensitive << m_clk.pos();
+ }
+ void method()
+ {
+ static int trigger = 0;
+ cout << "Entry " << endl;
+ switch( trigger++ )
+ {
+ case 0:
+ cout << "Issuing self reset " << endl;
+ sc_get_current_process_handle().reset();
+ sc_assert( false );
+ case 1:
+ break;
+ default:
+ trigger = 0;
+ }
+ cout << "Exit " << endl;
+ }
+ sc_in<bool> m_clk;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start(3, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}