summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/dynamic_processes
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/kernel/dynamic_processes')
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/golden/test01.log5
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/sc_barrier.h88
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/test01.cpp47
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/sc_join.log0
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/test01.log10
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/test01.cpp84
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/golden/test02.log10
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/test02.cpp85
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/golden/test03.log86
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/test03.cpp96
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/golden/test04.log11
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/test04.cpp92
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/golden/test05.log10
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/test05.cpp83
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/golden/test01.log26
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/test01.cpp139
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test01/golden/test01.log47
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test01/test01.cpp169
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test02/golden/test02.log25
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test02/test02.cpp161
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test03/golden/test03.log8
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test03/test03.cpp89
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test04/golden/test04.log8
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test04/test04.cpp128
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test05/golden/test05.log5
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test05/test05.cpp65
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test06/golden/test06.log9
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test06/test06.cpp78
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test07/golden/test07.log100
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test07/test07.cpp102
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test08/golden/test08.log7
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test08/test08.cpp103
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test09/golden/test09.log102
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test09/test09.cpp205
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test10/golden/test10.log15
-rw-r--r--src/systemc/tests/systemc/kernel/dynamic_processes/test10/test10.cpp175
36 files changed, 2473 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/golden/test01.log
new file mode 100644
index 000000000..145f99c5e
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/golden/test01.log
@@ -0,0 +1,5 @@
+SystemC Simulation
+11 ns - c
+11 ns - b
+11 ns - a
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/sc_barrier.h b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/sc_barrier.h
new file mode 100644
index 000000000..c2773e97e
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/sc_barrier.h
@@ -0,0 +1,88 @@
+/*****************************************************************************
+
+ 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_barrier.h -- Barrier Process Synchronization Definition
+
+ Original Author: Andy Goodrich, Forte Design Systems, 5 May 2003
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_barrier.h,v $
+// Revision 1.1.1.1 2006/12/15 20:26:03 acg
+// systemc_tests-2.3
+//
+// Revision 1.2 2006/01/24 21:04:52 acg
+// Andy Goodrich: replacement of deprecated features with their non-deprecated
+// counterparts.
+//
+
+#ifndef SC_BARRIER_H
+#define SC_BARRIER_H
+
+namespace sc_dp {
+
+// -----------------------------------------------------------------------------
+// CLASS sc_barrier
+//
+// This class provides a way of synchronising a set of processes. Each process
+// calls the wait() method and one all processes have called that method they
+// will all be released for execution.
+// -----------------------------------------------------------------------------
+
+class sc_barrier {
+ public:
+ void initialize( int thread_n )
+ {
+ m_thread_n = thread_n;
+ }
+
+ void wait()
+ {
+ m_thread_n--;
+ if ( m_thread_n )
+ {
+ ::sc_core::wait(m_barrier_event);
+ }
+ else
+ {
+ m_barrier_event.notify(SC_ZERO_TIME);
+ ::sc_core::wait(m_barrier_event);
+ }
+ }
+
+ protected:
+ sc_event m_barrier_event; // Event to wait on.
+ int m_thread_n; // # of threads left to wait.
+};
+
+} // namespace sc_dp
+
+#endif // SC_BARRIER_H
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/test01.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/test01.cpp
new file mode 100644
index 000000000..5b8c8a8fe
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_barrier/test01/test01.cpp
@@ -0,0 +1,47 @@
+#include "systemc.h"
+#include "sc_barrier.h"
+using sc_dp::sc_barrier;
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ sc_thread_handle last_thread;
+
+ SC_THREAD(a);
+ SC_THREAD(b);
+ SC_THREAD(c);
+
+ m_barrier.initialize(3);
+ }
+ void a()
+ {
+ wait(5.0, SC_NS);
+ m_barrier.wait();
+ cout << sc_time_stamp() << " - a" << endl;
+ }
+ void b()
+ {
+ wait(11.0, SC_NS);
+ m_barrier.wait();
+ cout << sc_time_stamp() << " - b" << endl;
+ }
+ void c()
+ {
+ m_barrier.wait();
+ cout << sc_time_stamp() << " - c" << endl;
+ }
+ sc_barrier m_barrier;
+};
+
+int sc_main( int argc, char* argv[] )
+{
+ sc_clock clock;
+ X x("x");
+
+ sc_start(1000, SC_NS);
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/sc_join.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/sc_join.log
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/sc_join.log
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/test01.log
new file mode 100644
index 000000000..a7237caa7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/golden/test01.log
@@ -0,0 +1,10 @@
+SystemC Simulation
+2 ns: sync(3) terminating
+3 ns: sync(4) terminating
+4 ns: sync(5) terminating
+4 ns: sync(5) terminating
+6 ns: sync(7) terminating
+10 ns: sync(11) terminating
+20 ns: sync(21) terminating
+20 ns: waiting waking
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/test01.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/test01.cpp
new file mode 100644
index 000000000..f82344bb4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test01/test01.cpp
@@ -0,0 +1,84 @@
+/*****************************************************************************
+
+ 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 -- Test using sc_join as barrier mechanism.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 10 October 2004
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+#include "sysc/kernel/sc_dynamic_processes.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 3 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 4 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 5 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 5 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 7 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 11 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 21 ) ) );
+
+ SC_THREAD(waiting);
+ }
+ void sync(int context)
+ {
+ for ( int i = 0; i < context; i++ )
+ {
+ wait(m_clk.posedge_event());
+ }
+ cout << sc_time_stamp() << ": sync(" << context << ") terminating" << endl;
+ }
+ void waiting()
+ {
+ m_join.wait();
+ cout << sc_time_stamp() << ": waiting waking" << endl;
+ }
+
+ sc_in_clk m_clk;
+ sc_join m_join;
+};
+
+int sc_main( int argc, char* argv[] )
+{
+ sc_clock clock;
+ X x("x");
+ x.m_clk(clock);
+
+ sc_start(1000, SC_NS);
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/golden/test02.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/golden/test02.log
new file mode 100644
index 000000000..a7237caa7
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/golden/test02.log
@@ -0,0 +1,10 @@
+SystemC Simulation
+2 ns: sync(3) terminating
+3 ns: sync(4) terminating
+4 ns: sync(5) terminating
+4 ns: sync(5) terminating
+6 ns: sync(7) terminating
+10 ns: sync(11) terminating
+20 ns: sync(21) terminating
+20 ns: waiting waking
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/test02.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/test02.cpp
new file mode 100644
index 000000000..8eba90a5e
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test02/test02.cpp
@@ -0,0 +1,85 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test02.cpp -- Test SC_FORK and SC_JOIN macros.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 10 October 2004
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+#include "sysc/kernel/sc_dynamic_processes.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+
+ SC_THREAD(waiting);
+ }
+ void sync(int context)
+ {
+ for ( int i = 0; i < context; i++ )
+ {
+ wait(m_clk.posedge_event());
+ }
+ cout << sc_time_stamp() << ": sync(" << context << ") terminating"<< endl;
+ }
+ void waiting()
+ {
+ SC_FORK
+ sc_spawn( sc_bind( &X::sync, this, 3 ) ),
+ sc_spawn( sc_bind( &X::sync, this, 4 ) ),
+ sc_spawn( sc_bind( &X::sync, this, 5 ) ),
+ sc_spawn( sc_bind( &X::sync, this, 5 ) ),
+ sc_spawn( sc_bind( &X::sync, this, 7 ) ),
+ sc_spawn( sc_bind( &X::sync, this, 11) ),
+ sc_spawn( sc_bind( &X::sync, this, 21) )
+ SC_JOIN
+ cout << sc_time_stamp() << ": waiting waking" << endl;
+ }
+
+ sc_in_clk m_clk;
+ sc_join m_join;
+};
+
+int sc_main( int argc, char* argv[] )
+{
+ sc_clock clock;
+ X x("x");
+ x.m_clk(clock);
+
+ sc_start(1000, SC_NS);
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/golden/test03.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/golden/test03.log
new file mode 100644
index 000000000..68285dfd4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/golden/test03.log
@@ -0,0 +1,86 @@
+SystemC Simulation
+Time Spawn Start Stop
+----- ----- ----- ----
+0 s 0
+0 s 0
+1 ns 1
+1 ns 1
+3 ns 2
+3 ns 2
+5 ns 0
+5 ns 3
+5 ns 3
+7 ns 1
+7 ns 4
+7 ns 4
+9 ns 2
+9 ns 5
+9 ns 5
+11 ns 3
+11 ns 6
+11 ns 6
+13 ns 4
+13 ns 7
+13 ns 7
+15 ns 5
+15 ns waiting for termination of 2 processes
+17 ns 6
+19 ns 7
+19 ns back from termination wait
+Time Spawn Start Stop
+----- ----- ----- ----
+19 ns 8
+19 ns 8
+21 ns 9
+21 ns 9
+23 ns 10
+23 ns 10
+25 ns 8
+25 ns 11
+25 ns 11
+27 ns 9
+27 ns 12
+27 ns 12
+29 ns 10
+29 ns 13
+29 ns 13
+31 ns 11
+31 ns 14
+31 ns 14
+33 ns 12
+33 ns 15
+33 ns 15
+35 ns 13
+35 ns waiting for termination of 2 processes
+37 ns 14
+39 ns 15
+39 ns back from termination wait
+Time Spawn Start Stop
+----- ----- ----- ----
+39 ns 16
+39 ns 16
+41 ns 17
+41 ns 17
+43 ns 18
+43 ns 18
+45 ns 16
+45 ns 19
+45 ns 19
+47 ns 17
+47 ns 20
+47 ns 20
+49 ns 18
+49 ns 21
+49 ns 21
+51 ns 19
+51 ns 22
+51 ns 22
+53 ns 20
+53 ns 23
+53 ns 23
+55 ns 21
+55 ns waiting for termination of 2 processes
+57 ns 22
+59 ns 23
+59 ns back from termination wait
+Program completed.
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/test03.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/test03.cpp
new file mode 100644
index 000000000..d783150e3
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test03/test03.cpp
@@ -0,0 +1,96 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test03.cpp -- Test sc_join as gating mechanism for a process awaiting the
+ demise of its child processes.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 18 April 2005
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB)
+ {
+ SC_THREAD(abc);
+ sensitive << m_clk.pos();
+ }
+ void abc()
+ {
+ for ( int i = 0; i < 3; i++ )
+ {
+ cout << "Time Spawn Start Stop " << endl;
+ cout << "----- ----- ----- ----" << endl;
+ int ii = 2;
+ int spawn_i;
+ int spawn_n = 8;
+ sc_spawn_options options;
+ sc_join join;
+ options.set_sensitivity(&m_clk.pos());
+ for ( spawn_i = 0; spawn_i < spawn_n; spawn_i++ )
+ {
+ int process_i = spawn_i + i * spawn_n;
+ cout << sc_time_stamp() << " " << process_i << endl;
+ join.add_process(sc_spawn(
+ sc_bind(&TB::process, this, sc_ref(process_i)),
+ sc_gen_unique_name("pipe"), &options ) );
+ sc_core::wait(ii);
+ }
+ cout << sc_time_stamp() << " waiting for termination of "
+ << join.process_count() << " processes" << endl;
+ join.wait();
+ cout << sc_time_stamp() << " back from termination wait " << endl;
+ }
+ }
+ void process( int& instance )
+ {
+ int i = instance;
+ cout << sc_time_stamp() << " " << i << endl;
+ wait(6);
+ cout << sc_time_stamp() << " " << i << endl;
+ }
+ sc_in<bool> m_clk;
+};
+
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ TB tb("tb");
+
+ tb.m_clk(clock);
+ sc_start(100, SC_NS);
+ cout << "Program completed." << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/golden/test04.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/golden/test04.log
new file mode 100644
index 000000000..0d1660025
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/golden/test04.log
@@ -0,0 +1,11 @@
+SystemC Simulation
+2 ns: sync(3) terminating
+3 ns: sync(4) terminating
+4 ns: sync(5) terminating
+4 ns: sync(5) terminating
+6 ns: sync(7) terminating
+10 ns: sync(11) terminating
+20 ns: sync(21) terminating
+20 ns: asynchronous wait waking
+21 ns: clocked wait waking
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/test04.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/test04.cpp
new file mode 100644
index 000000000..e9aa9efd0
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test04/test04.cpp
@@ -0,0 +1,92 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test04.cpp -- Test using sc_join as barrier mechanism with clocked and
+ asynchronous thread waits.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 10 October 2004
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+#include "sysc/kernel/sc_dynamic_processes.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 3 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 4 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 5 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 5 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 7 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 11 ) ) );
+ m_join.add_process( sc_spawn( sc_bind(&X::sync, this, 21 ) ) );
+
+ SC_CTHREAD(cwaiting,m_clk.pos());
+ SC_THREAD(waiting);
+ }
+ void cwaiting()
+ {
+ m_join.wait_clocked();
+ cout << sc_time_stamp() << ": clocked wait waking" << endl;
+ }
+
+ void sync(int context)
+ {
+ for ( int i = 0; i < context; i++ )
+ {
+ wait(m_clk.posedge_event());
+ }
+ cout << sc_time_stamp() << ": sync(" << context << ") terminating" << endl;
+ }
+ void waiting()
+ {
+ m_join.wait();
+ cout << sc_time_stamp() << ": asynchronous wait waking" << endl;
+ }
+
+ sc_in_clk m_clk;
+ sc_join m_join;
+};
+
+int sc_main( int argc, char* argv[] )
+{
+ sc_clock clock;
+ X x("x");
+ x.m_clk(clock);
+
+ sc_start(1000, SC_NS);
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/golden/test05.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/golden/test05.log
new file mode 100644
index 000000000..13684b960
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/golden/test05.log
@@ -0,0 +1,10 @@
+SystemC Simulation
+3 ns: sync(3) terminating
+4 ns: sync(4) terminating
+5 ns: sync(5) terminating
+5 ns: sync(5) terminating
+7 ns: sync(7) terminating
+11 ns: sync(11) terminating
+21 ns: sync(21) terminating
+22 ns: clocked wait waking
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/test05.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/test05.cpp
new file mode 100644
index 000000000..9a7f0242d
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_join/test05/test05.cpp
@@ -0,0 +1,83 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test05.cpp -- Test using SC_FORK and SC_CJOIN macros.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 29 April 2004
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include "systemc.h"
+#include "sysc/kernel/sc_dynamic_processes.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ SC_CTHREAD(cwaiting,m_clk.pos());
+ }
+ void cwaiting()
+ {
+ SC_FORK
+ sc_spawn( sc_bind(&X::sync, this, 3 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 4 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 5 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 5 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 7 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 11 ) ) ,
+ sc_spawn( sc_bind(&X::sync, this, 21 ) )
+ SC_CJOIN
+ cout << sc_time_stamp() << ": clocked wait waking" << endl;
+ }
+
+ void sync(int context)
+ {
+ for ( int i = 0; i < context; i++ )
+ {
+ wait(m_clk.posedge_event());
+ }
+ cout << sc_time_stamp() << ": sync(" << context << ") terminating" << endl;
+ }
+ sc_in_clk m_clk;
+};
+
+int sc_main( int argc, char* argv[] )
+{
+ sc_clock clock;
+ X x("x");
+ x.m_clk(clock);
+
+ sc_start(1000, SC_NS);
+
+ cerr << "Program completed" << endl;
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/golden/test01.log
new file mode 100644
index 000000000..1df950f86
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/golden/test01.log
@@ -0,0 +1,26 @@
+SystemC Simulation
+
+Round robin method 1 at time 100 ns
+Round robin method 2 at time 110 ns
+Round robin method 3 at time 120 ns
+Round robin method 4 at time 130 ns
+Round robin method 1 at time 140 ns
+Round robin method 2 at time 150 ns
+Round robin method 3 at time 160 ns
+Round robin method 4 at time 170 ns
+Round robin method 1 at time 180 ns
+Round robin method 2 at time 190 ns
+Round robin method 3 at time 200 ns
+Round robin method 4 at time 210 ns
+Round robin method 1 at time 220 ns
+Round robin method 2 at time 230 ns
+Round robin method 3 at time 240 ns
+Round robin method 4 at time 250 ns
+Round robin method 1 at time 260 ns
+Round robin method 2 at time 270 ns
+Round robin method 3 at time 280 ns
+Round robin method 4 at time 290 ns
+
+Done.
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/test01.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/test01.cpp
new file mode 100644
index 000000000..67d18e210
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/sc_spawn_options/test01/test01.cpp
@@ -0,0 +1,139 @@
+/*****************************************************************************
+
+ 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 -- Demo "new" dynamic method support.
+
+
+ See the README file for a description of these capabilities. This demo
+ excercises all of the major capabilities.
+
+ Original Author: Stuart Swan, Cadence Design Systems, Inc., 2002-10-22
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 30 July 03
+ Description of Modification: Converted thread demo to method demo.
+
+ *****************************************************************************/
+
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+
+int test_function(double d)
+{
+ cout << endl << "Test_function sees " << d << endl;
+ return int(d);
+}
+
+void void_function(double d)
+{
+ cout << endl << "void_function sees " << d << endl;
+}
+
+int ref_function(const double& d)
+{
+ cout << endl << "ref_function sees " << d << endl;
+ return int(d);
+}
+
+
+class top : public sc_module
+{
+public:
+ SC_HAS_PROCESS(top);
+
+ top(sc_module_name name) : sc_module(name)
+ {
+ SC_THREAD(main);
+ }
+
+ void main()
+ {
+ sc_event e1, e2, e3, e4;
+ sc_spawn_options options1, options2, options3, options4;
+ int r;
+
+ cout << endl;
+
+ e1.notify(100, SC_NS);
+
+ // Spawn several methods that co-operatively execute in round robin order
+
+ options1.spawn_method();
+ options1.dont_initialize();
+ options1.set_sensitivity(&e1);
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "1", sc_ref(e1), sc_ref(e2), 3),
+ "1", &options1
+ );
+
+ options2.spawn_method();
+ options2.dont_initialize();
+ options2.set_sensitivity(&e2);
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "2", sc_ref(e2), sc_ref(e3), 3),
+ "2", &options2
+ );
+
+ options3.spawn_method();
+ options3.dont_initialize();
+ options3.set_sensitivity(&e3);
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "3", sc_ref(e3), sc_ref(e4), 3),
+ "3", &options3
+ );
+
+ options4.spawn_method();
+ options4.dont_initialize();
+ options4.set_sensitivity(&e4);
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "4", sc_ref(e4), sc_ref(e1), 3),
+ "4", &options4
+ );
+ wait(295, SC_NS);
+ cout << endl << "Done." << endl;
+ sc_stop();
+ }
+
+ int round_robin(const char *str, sc_event& receive, sc_event& send, int cnt)
+ {
+ cout << "Round robin method " << str <<
+ " at time " << sc_time_stamp() << endl;
+ next_trigger(receive);
+ send.notify(10, SC_NS);
+ return 0;
+ }
+};
+
+int sc_main (int argc , char *argv[])
+{
+ top top1("Top1");
+ sc_start();
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test01/golden/test01.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test01/golden/test01.log
new file mode 100644
index 000000000..c585cabd3
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test01/golden/test01.log
@@ -0,0 +1,47 @@
+SystemC Simulation
+
+100 ns: Top1.main.t1: Round robin thread 1
+110 ns: Top1.main.t2: Round robin thread 2
+120 ns: Top1.main.t3: Round robin thread 3
+130 ns: Top1.main.t4: Round robin thread 4
+140 ns: Top1.main.t1: Round robin thread 1
+150 ns: Top1.main.t2: Round robin thread 2
+160 ns: Top1.main.t3: Round robin thread 3
+170 ns: Top1.main.t4: Round robin thread 4
+180 ns: Top1.main.t1: Round robin thread 1
+190 ns: Top1.main.t2: Round robin thread 2
+200 ns: Top1.main.t3: Round robin thread 3
+210 ns: Top1.main.t4: Round robin thread 4
+Returned int is 0
+
+
+221 ns: Top1.main.thread_p_0: Thread 0 ending.
+222 ns: Top1.main.thread_p_1: Thread 1 ending.
+223 ns: Top1.main.thread_p_2: Thread 2 ending.
+224 ns: Top1.main.thread_p_3: Thread 3 ending.
+225 ns: Top1.main.thread_p_4: Thread 4 ending.
+226 ns: Top1.main.thread_p_5: Thread 5 ending.
+227 ns: Top1.main.thread_p_6: Thread 6 ending.
+228 ns: Top1.main.thread_p_7: Thread 7 ending.
+229 ns: Top1.main.thread_p_8: Thread 8 ending.
+230 ns: Top1.main.thread_p_9: Thread 9 ending.
+241 ns: Top1.main.thread_p_10: Thread 0 ending.
+242 ns: Top1.main.thread_p_11: Thread 1 ending.
+243 ns: Top1.main.thread_p_12: Thread 2 ending.
+244 ns: Top1.main.thread_p_13: Thread 3 ending.
+245 ns: Top1.main.thread_p_14: Thread 4 ending.
+246 ns: Top1.main.thread_p_15: Thread 5 ending.
+247 ns: Top1.main.thread_p_16: Thread 6 ending.
+248 ns: Top1.main.thread_p_17: Thread 7 ending.
+249 ns: Top1.main.thread_p_18: Thread 8 ending.
+250 ns: Top1.main.thread_p_19: Thread 9 ending.
+
+260 ns: Top1.main.thread_p_20: Test_function sees 3.14159
+Returned int is 3
+
+260 ns: Top1.main.void_function: void_function sees 1.2345
+
+260 ns: Top1.main.thread_p_21: ref_function sees 9.8765
+Returned int is 9
+
+Done.
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test01/test01.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test01/test01.cpp
new file mode 100644
index 000000000..098057691
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test01/test01.cpp
@@ -0,0 +1,169 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: Stuart Swan, Cadence Design Systems, Inc., 2002-10-22
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test01.cpp,v $
+// Revision 1.3 2011/02/08 06:49:37 acg
+// Andy Goodrich: removed carriage returns.
+//
+// Revision 1.2 2011/02/01 17:17:37 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+
+int test_function(double d)
+{
+ cout << endl << sc_time_stamp() << ": " << sc_get_current_process_handle().name()
+ << ": Test_function sees " << d << endl;
+ return int(d);
+}
+
+void void_function(double d)
+{
+ cout << endl << sc_time_stamp() << ": " << sc_get_current_process_handle().name()
+ << ": void_function sees " << d << endl;
+}
+
+int ref_function(const double& d)
+{
+ cout << endl << sc_time_stamp() << ": " << sc_get_current_process_handle().name()
+ << ": ref_function sees " << d << endl;
+ return int(d);
+}
+
+
+class top : public sc_module
+{
+public:
+ SC_HAS_PROCESS(top);
+
+ top(sc_module_name name) : sc_module(name)
+ {
+ SC_THREAD(main);
+ }
+
+ void main()
+ {
+ int r;
+ sc_event e1, e2, e3, e4;
+
+ cout << endl;
+
+ e1.notify(100, SC_NS);
+
+ // Spawn several threads that co-operatively execute in round robin order
+
+ SC_FORK
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "1", sc_ref(e1), sc_ref(e2), 3), "t1") ,
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "2", sc_ref(e2), sc_ref(e3), 3), "t2") ,
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "3", sc_ref(e3), sc_ref(e4), 3), "t3") ,
+ sc_spawn(&r,
+ sc_bind(&top::round_robin, this, "4", sc_ref(e4), sc_ref(e1), 3), "t4") ,
+ SC_JOIN
+
+ cout << "Returned int is " << r << endl;
+ cout << endl << endl;
+
+ // Test that threads in thread pool are successfully reused ...
+
+ for (int i = 0 ; i < 10; i++)
+ sc_spawn(&r, sc_bind(&top::wait_and_end, this, i));
+
+ wait(20, SC_NS);
+
+ // Test thread reuse
+
+ for (int i = 0 ; i < 10; i++)
+ sc_spawn(&r, sc_bind(&top::wait_and_end, this, i));
+
+ wait(20, SC_NS);
+
+ // Demo of a function rather than method call, & use return value ...
+
+ wait( sc_spawn(&r, sc_bind(&test_function, 3.14159)).terminated_event() );
+
+ cout << "Returned int is " << r << endl;
+
+ // demo sc_spawn_options usage
+
+ sc_spawn_options ops;
+ ops.set_stack_size(0);
+ sc_process_handle handle1 = sc_spawn(
+ sc_bind(&void_function, 1.2345), "void_function", &ops
+ );
+ wait(handle1.terminated_event());
+
+ double d = 9.8765;
+ wait( sc_spawn(&r, sc_bind(&ref_function, sc_cref(d))).terminated_event() );
+
+ cout << "Returned int is " << r << endl;
+
+ cout << endl << "Done." << endl;
+ }
+
+ int round_robin(const char *str, sc_event& receive, sc_event& send, int cnt)
+ {
+ while (--cnt >= 0)
+ {
+ wait(receive);
+ cout << sc_time_stamp() << ": " << sc_get_current_process_handle().name()
+ << ": Round robin thread " << str << endl;
+ wait(10, SC_NS);
+ send.notify();
+ }
+
+ return 0;
+ }
+
+ int wait_and_end(int i)
+ {
+ wait( i + 1, SC_NS);
+ cout << sc_time_stamp() << ": " << sc_get_current_process_handle().name()
+ << ": Thread " << i << " ending." << endl;
+ return 0;
+ }
+};
+
+int sc_main (int argc , char *argv[])
+{
+ top top1("Top1");
+ sc_start();
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test02/golden/test02.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test02/golden/test02.log
new file mode 100644
index 000000000..8264ba823
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test02/golden/test02.log
@@ -0,0 +1,25 @@
+SystemC Simulation
+
+0 s: CTOR, Before spawning function_method
+
+0 s, mod1.main: main thread, Before spawning round robin methods
+
+
+0 s, mod1.main: main thread, Issuing wait(60, SC_NS)
+0 s, mod1.main.method1: In Round robin method 1. Issued next_trigger.
+0 s, mod1.main.method2: In Round robin method 2. Issued next_trigger.
+0 s, mod1.main.method3: In Round robin method 3. Issued next_trigger.
+0 s, mod1.main.method4: In Round robin method 4. Issued next_trigger.
+15 ns, mod1.main.method1: In Round robin method 1. Notified. Ending Round robin method 1
+25 ns, mod1.main.method2: In Round robin method 2. Notified. Ending Round robin method 2
+35 ns, mod1.main.method3: In Round robin method 3. Notified. Ending Round robin method 3
+45 ns, mod1.main.method4: In Round robin method 4. Notified. Ending Round robin method 4
+
+55 ns, mod1.event_sensitive_method: function_method sees 1.2345
+
+60 ns, mod1.main: Done main thread.
+
+100 ns: sc_main, Before spawning function_thread
+
+100 ns, thread_p_0: function_thread sees 6.789
+110 ns, thread_p_0: ending thread
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test02/test02.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test02/test02.cpp
new file mode 100644
index 000000000..44af1bbf2
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test02/test02.cpp
@@ -0,0 +1,161 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems,
+ September 5, 2003
+
+ *****************************************************************************/
+
+// test dynamic method processes and hierarchical dynamic process naming
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test02.cpp,v $
+// Revision 1.3 2011/03/06 06:55:19 acg
+// Andy Goodrich: removed carriage returns.
+//
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+int function_method(double d)
+{
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": function_method sees " << d << endl;
+ return int(d);
+}
+
+void function_thread(double d)
+{
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": function_thread sees " << d << endl;
+ sc_core::wait(10, SC_NS);
+ cout << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": ending thread" << endl;
+}
+
+class module1 : public sc_module
+{
+private:
+ sc_event& ev;
+ int method_count;
+ int r;
+public:
+
+ SC_HAS_PROCESS(module1);
+
+ module1(sc_module_name name, sc_event& event) : sc_module(name),
+ ev(event), method_count(0), r(0)
+ {
+ SC_THREAD(main);
+ cout << endl << sc_time_stamp() << ": CTOR, Before spawning function_method " << endl;
+ sc_spawn_options o1;
+ o1.spawn_method();
+ o1.dont_initialize();
+ o1.set_sensitivity(&ev);
+ sc_process_handle h4 = sc_spawn(&r, sc_bind(&function_method, 1.2345), "event_sensitive_method", &o1);
+
+ }
+
+ void main()
+ {
+ int r;
+ sc_event e1, e2, e3, e4;
+ sc_spawn_options o1, o2, o3, o4;
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": main thread, Before spawning round robin methods "
+ << endl << endl;
+
+ e1.notify(15, SC_NS);
+ o1.spawn_method();
+ o2.spawn_method();
+ o3.spawn_method();
+ o4.spawn_method();
+
+ // Spawn several methods that co-operatively execute in round robin order
+
+ sc_spawn(
+ sc_bind(&module1::round_robin, this, "1", sc_ref(e1), sc_ref(e2), 1), "method1", &o1);
+ sc_spawn(
+ sc_bind(&module1::round_robin, this, "2", sc_ref(e2), sc_ref(e3), 1), "method2", &o2);
+ sc_spawn(
+ sc_bind(&module1::round_robin, this, "3", sc_ref(e3), sc_ref(e4), 1), "method3", &o3);
+ sc_spawn(
+ sc_bind(&module1::round_robin, this, "4", sc_ref(e4), sc_ref(e1), 1), "method4", &o4);
+
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": main thread, Issuing wait(60, SC_NS)" << endl;
+
+ sc_core::wait(60, SC_NS);
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": Done main thread." << endl;
+ }
+
+ void round_robin(const char *str, sc_event& receive, sc_event& send, int cnt)
+ {
+ cout << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": In Round robin method " << str;
+
+ if (method_count < 4) {
+ method_count++;
+ next_trigger(receive);
+ cout << ". Issued next_trigger. " << endl;
+ } else {
+ send.notify(10, SC_NS);
+ cout << ". Notified. Ending Round robin method " << str << endl;
+ }
+
+ }
+
+};
+
+int sc_main (int argc , char *argv[])
+{
+ sc_event event1;
+ event1.notify(55, SC_NS);
+
+ module1 mod1("mod1", event1);
+ sc_start(100, SC_NS);
+ cout << endl << sc_time_stamp() << ": sc_main, Before spawning function_thread " << endl;
+ sc_process_handle h4 = sc_spawn(sc_bind(&function_thread, 6.789));
+ sc_start(100, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test03/golden/test03.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/golden/test03.log
new file mode 100644
index 000000000..1131d3324
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/golden/test03.log
@@ -0,0 +1,8 @@
+SystemC Simulation
+
+0 s: static_method, Before spawning function_method
+
+Error: (E519) wait() is only allowed in SC_THREADs and SC_CTHREADs:
+ in SC_METHODs use next_trigger() instead
+In file: <removed by verify.pl>
+In process: mod1.static_method @ 0 s
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test03/test03.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/test03.cpp
new file mode 100644
index 000000000..08040d299
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test03/test03.cpp
@@ -0,0 +1,89 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems,
+ September 5, 2003
+
+ *****************************************************************************/
+
+// test error message for wait() on dynamic method process handle's event.
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 26 Jul 2005
+ Description of Modification: Changed waits to use the new terminated_event
+ support.
+
+ *****************************************************************************/
+// $Log: test03.cpp,v $
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+int function_method(double d)
+{
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": function_method sees " << d << endl;
+ return int(d);
+}
+
+class module1 : public sc_module
+{
+private:
+ sc_event& ev;
+public:
+
+ SC_HAS_PROCESS(module1);
+
+ module1(sc_module_name name, sc_event& event) : sc_module(name),
+ ev(event)
+ {
+ SC_METHOD(static_method);
+ }
+
+ void static_method() {
+ int r;
+ cout << endl << sc_time_stamp() << ": static_method, Before spawning function_method " << endl;
+ sc_spawn_options o1;
+ o1.spawn_method();
+ o1.dont_initialize();
+ o1.set_sensitivity(&ev);
+ sc_process_handle h4 = sc_spawn(&r, sc_bind(&function_method, 1.2345), "event_sensitive_method", &o1);
+ wait(h4.terminated_event());
+ }
+};
+
+int sc_main (int argc , char *argv[])
+{
+ sc_event event1;
+ event1.notify(55, SC_NS);
+
+ module1 mod1("mod1", event1);
+ sc_start(100, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test04/golden/test04.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test04/golden/test04.log
new file mode 100644
index 000000000..3535d567f
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test04/golden/test04.log
@@ -0,0 +1,8 @@
+SystemC Simulation
+
+0 s, mod1.main: main thread, Before spawning round robin methods
+
+
+Error: (E561) Attempt to register method process with sc_join object
+In file: <removed by verify.pl>
+In process: mod1.main @ 0 s
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test04/test04.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test04/test04.cpp
new file mode 100644
index 000000000..f1a55e653
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test04/test04.cpp
@@ -0,0 +1,128 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems,
+ September 5, 2003
+
+ *****************************************************************************/
+
+// test error message for SC_FORK-SC_JOIN on dynamic method process handles
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test04.cpp,v $
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+
+class module1 : public sc_module
+{
+private:
+ int method_count;
+public:
+
+ SC_HAS_PROCESS(module1);
+
+ module1(sc_module_name name) : sc_module(name),
+ method_count(0)
+ {
+ SC_THREAD(main);
+ }
+
+ void main()
+ {
+ int r;
+ sc_event e1, e2, e3, e4;
+ sc_spawn_options o1, o2, o3, o4;
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": main thread, Before spawning round robin methods "
+ << endl << endl;
+
+ e1.notify(15, SC_NS);
+ o1.spawn_method();
+ o2.spawn_method();
+ o3.spawn_method();
+ o4.spawn_method();
+
+ // Spawn several threads that co-operatively execute in round robin order
+
+ SC_FORK
+ sc_spawn(&r,
+ sc_bind(&module1::round_robin, this, "1", sc_ref(e1), sc_ref(e2), 1), "mth1", &o1),
+ sc_spawn(&r,
+ sc_bind(&module1::round_robin, this, "2", sc_ref(e2), sc_ref(e3), 1), "mth2", &o2),
+ sc_spawn(&r,
+ sc_bind(&module1::round_robin, this, "3", sc_ref(e3), sc_ref(e4), 1), "mth3", &o3),
+ sc_spawn(&r,
+ sc_bind(&module1::round_robin, this, "4", sc_ref(e4), sc_ref(e1), 1), "mth4", &o4),
+ SC_JOIN
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": main thread, Issuing wait(60, SC_NS)" << endl;
+
+ wait(60, SC_NS);
+
+ cout << endl << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": Done main thread." << endl;
+ }
+
+ int round_robin(const char *str, sc_event& receive, sc_event& send, int cnt)
+ {
+ cout << sc_time_stamp() << ", "
+ << sc_get_current_process_handle().name()
+ << ": In Round robin method " << str;
+
+ if (method_count < 4) {
+ method_count++;
+ next_trigger(receive);
+ cout << ". Issued next_trigger. " << endl;
+ } else {
+ send.notify(10, SC_NS);
+ cout << ". Notified. Ending Round robin method " << str << endl;
+ }
+
+ return 0;
+ }
+
+};
+int sc_main (int argc , char *argv[])
+{
+ module1 mod1("mod1");
+
+ sc_start(100, SC_NS);
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test05/golden/test05.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test05/golden/test05.log
new file mode 100644
index 000000000..f38eaee80
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test05/golden/test05.log
@@ -0,0 +1,5 @@
+SystemC Simulation
+spawn thetest
+in thetest()
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test05/test05.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test05/test05.cpp
new file mode 100644
index 000000000..c22a81385
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test05/test05.cpp
@@ -0,0 +1,65 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: John Rose, Cadence Design Systems, Inc., 2004-02-15
+
+ *****************************************************************************/
+
+// tests sc_spawn() in start_of_simulation()
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test05.cpp,v $
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+SC_MODULE(mod)
+{
+ void start_of_simulation()
+ {
+ cout << "spawn thetest" << endl;
+ sc_spawn(sc_bind(&mod::thetest, this));
+ }
+ void thetest()
+ {
+ cout << "in thetest()" << endl;
+ wait(10,SC_NS);
+ sc_stop();
+ }
+ SC_CTOR(mod) {
+ }
+};
+
+int sc_main(int, char**) {
+ mod m1("m1");
+ sc_start();
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test06/golden/test06.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test06/golden/test06.log
new file mode 100644
index 000000000..ab7d58f54
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test06/golden/test06.log
@@ -0,0 +1,9 @@
+SystemC Simulation
+10 ns:entering p0, spawning p1
+10 ns:exiting p0
+10 ns:entering p1, spawning p2
+10 ns:entering p2, spawning p3
+10 ns:entering p3
+20 ns:exiting p1
+30 ns:exiting p2
+40 ns:exiting p3
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test06/test06.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test06/test06.cpp
new file mode 100644
index 000000000..4f581df61
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test06/test06.cpp
@@ -0,0 +1,78 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ Original Author: Bishnupriya Bhattacharya, Cadence Design Systems, Inc., 2004-03-10
+
+ *****************************************************************************/
+
+// tests parent spawning process dying before child spawned process.
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test06.cpp,v $
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include <systemc.h>
+
+void p3() {
+ cerr << sc_time_stamp() << ":entering p3" << endl;
+ wait(30, SC_NS);
+ cerr << sc_time_stamp() << ":exiting p3" << endl;
+}
+
+void p2() {
+ cerr << sc_time_stamp() << ":entering p2, spawning p3" << endl;
+ sc_spawn(sc_bind(&p3));
+ wait(20, SC_NS);
+ cerr << sc_time_stamp() << ":exiting p2" << endl;
+}
+
+void p1() {
+ cerr << sc_time_stamp() << ":entering p1, spawning p2" << endl;
+ sc_spawn(sc_bind(&p2));
+ wait(10, SC_NS);
+ cerr << sc_time_stamp() << ":exiting p1" << endl;
+}
+
+void p0() {
+ cerr << sc_time_stamp() << ":entering p0, spawning p1" << endl;
+ sc_spawn(sc_bind(&p1));
+ cerr << sc_time_stamp() << ":exiting p0" << endl;
+}
+
+int sc_main(int, char**) {
+
+ sc_start(10, SC_NS);
+ p0();
+ sc_start(50, SC_NS);
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test07/golden/test07.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test07/golden/test07.log
new file mode 100644
index 000000000..06e667695
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test07/golden/test07.log
@@ -0,0 +1,100 @@
+SystemC Simulation
+1 ns setting m_a
+1 ns callback
+2 ns setting m_b
+2 ns callback
+3 ns setting m_c
+3 ns callback
+4 ns setting m_a
+4 ns callback
+5 ns setting m_b
+5 ns callback
+6 ns setting m_c
+6 ns callback
+7 ns setting m_a
+7 ns callback
+8 ns setting m_b
+8 ns callback
+9 ns setting m_c
+9 ns callback
+10 ns setting m_a
+10 ns callback
+11 ns setting m_b
+11 ns callback
+12 ns setting m_c
+12 ns callback
+13 ns setting m_a
+13 ns callback
+14 ns setting m_b
+14 ns callback
+15 ns setting m_c
+15 ns callback
+16 ns setting m_a
+16 ns callback
+17 ns setting m_b
+17 ns callback
+18 ns setting m_c
+18 ns callback
+19 ns setting m_a
+19 ns callback
+20 ns setting m_b
+20 ns callback
+21 ns setting m_c
+21 ns callback
+22 ns setting m_a
+22 ns callback
+23 ns setting m_b
+23 ns callback
+24 ns setting m_c
+24 ns callback
+25 ns setting m_a
+25 ns callback
+26 ns setting m_b
+26 ns callback
+27 ns setting m_c
+27 ns callback
+28 ns setting m_a
+28 ns callback
+29 ns setting m_b
+29 ns callback
+30 ns setting m_c
+30 ns callback
+31 ns setting m_a
+31 ns callback
+32 ns setting m_b
+32 ns callback
+33 ns setting m_c
+33 ns callback
+34 ns setting m_a
+34 ns callback
+35 ns setting m_b
+35 ns callback
+36 ns setting m_c
+36 ns callback
+37 ns setting m_a
+37 ns callback
+38 ns setting m_b
+38 ns callback
+39 ns setting m_c
+39 ns callback
+40 ns setting m_a
+40 ns callback
+41 ns setting m_b
+41 ns callback
+42 ns setting m_c
+42 ns callback
+43 ns setting m_a
+43 ns callback
+44 ns setting m_b
+44 ns callback
+45 ns setting m_c
+45 ns callback
+46 ns setting m_a
+46 ns callback
+47 ns setting m_b
+47 ns callback
+48 ns setting m_c
+48 ns callback
+49 ns setting m_a
+49 ns callback
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test07/test07.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test07/test07.cpp
new file mode 100644
index 000000000..5b4975045
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test07/test07.cpp
@@ -0,0 +1,102 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test07.cpp -- Test that for all the interfaces of a port a callback occurs
+ for a dynamic process created after the beginning of simulation.
+
+ Original Author: Andy Goodrich, Forte Design Systems
+
+ *****************************************************************************/
+
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test07.cpp,v $
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(thread,m_clk.pos());
+
+ // Set up interfaces for m_port.
+
+ m_port(m_a);
+ m_port(m_b);
+ m_port(m_c);
+ }
+ void method()
+ {
+ cout << sc_time_stamp() << " callback" << endl;
+ }
+ void thread()
+ {
+ sc_spawn_options options;
+ options.spawn_method();
+ options.set_sensitivity( &m_port );
+ options.dont_initialize();
+ sc_spawn( sc_bind(&DUT::method,this), "method", &options );
+ for ( bool value=true;; value = !value)
+ {
+ wait();
+ cout << sc_time_stamp() << " setting m_a " << endl;
+ m_a = value;
+ wait();
+ cout << sc_time_stamp() << " setting m_b " << endl;
+ m_b = value;
+ wait();
+ cout << sc_time_stamp() << " setting m_c " << endl;
+ m_c = value;
+ }
+ }
+ sc_signal<bool> m_a;
+ sc_signal<bool> m_b;
+ sc_signal<bool> m_c;
+ sc_in<bool> m_clk;
+ sc_port<sc_signal_inout_if<bool>,3> m_port;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start(50, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test08/golden/test08.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test08/golden/test08.log
new file mode 100644
index 000000000..818ef6e87
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test08/golden/test08.log
@@ -0,0 +1,7 @@
+SystemC Simulation
+update called...
+thread here...
+update called...
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test08/test08.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test08/test08.cpp
new file mode 100644
index 000000000..5374ff859
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test08/test08.cpp
@@ -0,0 +1,103 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test08.cpp -- Test for sc_spawn during update phase, including after stop.
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test08.cpp,v $
+// Revision 1.4 2011/02/20 13:43:44 acg
+// Andy Goodrich: updates for IEEE 1666 2011.
+//
+// Revision 1.3 2011/02/18 21:11:07 acg
+// Philipp A. Hartmann: rename ABC class to eliminate class with wingdi.h.
+//
+// Revision 1.2 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+class prim_channel : public sc_prim_channel {
+ public:
+ prim_channel(const char* name = sc_gen_unique_name("prim_channel") )
+ : sc_prim_channel(name)
+ {}
+ void thread()
+ {
+ cout << "thread here..." << endl;
+ }
+ void update()
+ {
+ cout << "update called..." << endl;
+ sc_spawn( sc_bind(&prim_channel::thread,this),
+ sc_gen_unique_name("thread"));
+ }
+ void write( int i )
+ {
+ request_update();
+ }
+};
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(thread,m_clk.pos());
+ }
+ void thread()
+ {
+ for (;;)
+ {
+ wait();
+ m_chan.write(0);
+ wait();
+ m_chan.write(0);
+ sc_stop();
+ }
+ }
+ sc_in<bool> m_clk;
+ prim_channel m_chan;
+};
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start(10, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test09/golden/test09.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test09/golden/test09.log
new file mode 100644
index 000000000..fe9a4a428
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test09/golden/test09.log
@@ -0,0 +1,102 @@
+SystemC Simulation
+0 s dut.grand_parent initialization
+
+0 s dut.grand_parent.parent1 initialization
+0 s dut.grand_parent.parent2 initialization
+0 s dut.grand_parent.parent1.child1 initialization
+0 s dut.grand_parent.parent1.child2 initialization
+0 s dut.grand_parent.parent1.child3 initialization
+0 s dut.grand_parent.parent2.child1 initialization
+0 s dut.grand_parent.parent2.child2 initialization
+0 s dut.grand_parent.parent2.child3 initialization
+4 ns stimulus issuing reset
+4 ns dut.grand_parent.parent1.child1 initialization
+4 ns dut.grand_parent.parent1.child2 initialization
+4 ns dut.grand_parent.parent1.child3 initialization
+4 ns dut.grand_parent.parent1 initialization
+4 ns dut.grand_parent.parent2.child1 initialization
+4 ns dut.grand_parent.parent2.child2 initialization
+4 ns dut.grand_parent.parent2.child3 initialization
+4 ns dut.grand_parent.parent2 removing children
+4 ns dut.grand_parent.parent2.child1 got kill
+4 ns dut.grand_parent.parent2.child2 got kill
+4 ns dut.grand_parent.parent2.child3 got kill
+4 ns dut.grand_parent.parent2 initialization
+4 ns dut.grand_parent initialization
+
+4 ns dut.grand_parent.parent2.child1 initialization
+4 ns dut.grand_parent.parent2.child2 initialization
+4 ns dut.grand_parent.parent2.child3 initialization
+8 ns stimulus issuing reset
+8 ns dut.grand_parent.parent1.child1 initialization
+8 ns dut.grand_parent.parent1.child2 initialization
+8 ns dut.grand_parent.parent1.child3 initialization
+8 ns dut.grand_parent.parent1 initialization
+8 ns dut.grand_parent.parent2.child1 initialization
+8 ns dut.grand_parent.parent2.child2 initialization
+8 ns dut.grand_parent.parent2.child3 initialization
+8 ns dut.grand_parent.parent2 removing children
+8 ns dut.grand_parent.parent2.child1 got kill
+8 ns dut.grand_parent.parent2.child2 got kill
+8 ns dut.grand_parent.parent2.child3 got kill
+8 ns dut.grand_parent.parent2 initialization
+8 ns dut.grand_parent initialization
+
+8 ns dut.grand_parent.parent2.child1 initialization
+8 ns dut.grand_parent.parent2.child2 initialization
+8 ns dut.grand_parent.parent2.child3 initialization
+12 ns stimulus issuing reset
+12 ns dut.grand_parent.parent1.child1 initialization
+12 ns dut.grand_parent.parent1.child2 initialization
+12 ns dut.grand_parent.parent1.child3 initialization
+12 ns dut.grand_parent.parent1 initialization
+12 ns dut.grand_parent.parent2.child1 initialization
+12 ns dut.grand_parent.parent2.child2 initialization
+12 ns dut.grand_parent.parent2.child3 initialization
+12 ns dut.grand_parent.parent2 removing children
+12 ns dut.grand_parent.parent2.child1 got kill
+12 ns dut.grand_parent.parent2.child2 got kill
+12 ns dut.grand_parent.parent2.child3 got kill
+12 ns dut.grand_parent.parent2 initialization
+12 ns dut.grand_parent initialization
+
+12 ns dut.grand_parent.parent2.child1 initialization
+12 ns dut.grand_parent.parent2.child2 initialization
+12 ns dut.grand_parent.parent2.child3 initialization
+16 ns stimulus issuing reset
+16 ns dut.grand_parent.parent1.child1 initialization
+16 ns dut.grand_parent.parent1.child2 initialization
+16 ns dut.grand_parent.parent1.child3 initialization
+16 ns dut.grand_parent.parent1 initialization
+16 ns dut.grand_parent.parent2.child1 initialization
+16 ns dut.grand_parent.parent2.child2 initialization
+16 ns dut.grand_parent.parent2.child3 initialization
+16 ns dut.grand_parent.parent2 removing children
+16 ns dut.grand_parent.parent2.child1 got kill
+16 ns dut.grand_parent.parent2.child2 got kill
+16 ns dut.grand_parent.parent2.child3 got kill
+16 ns dut.grand_parent.parent2 initialization
+16 ns dut.grand_parent initialization
+
+16 ns dut.grand_parent.parent2.child1 initialization
+16 ns dut.grand_parent.parent2.child2 initialization
+16 ns dut.grand_parent.parent2.child3 initialization
+20 ns stimulus issuing reset
+20 ns dut.grand_parent.parent1.child1 initialization
+20 ns dut.grand_parent.parent1.child2 initialization
+20 ns dut.grand_parent.parent1.child3 initialization
+20 ns dut.grand_parent.parent1 initialization
+20 ns dut.grand_parent.parent2.child1 initialization
+20 ns dut.grand_parent.parent2.child2 initialization
+20 ns dut.grand_parent.parent2.child3 initialization
+20 ns dut.grand_parent.parent2 removing children
+20 ns dut.grand_parent.parent2.child1 got kill
+20 ns dut.grand_parent.parent2.child2 got kill
+20 ns dut.grand_parent.parent2.child3 got kill
+20 ns dut.grand_parent.parent2 initialization
+20 ns dut.grand_parent initialization
+
+20 ns dut.grand_parent.parent2.child1 initialization
+20 ns dut.grand_parent.parent2.child2 initialization
+20 ns dut.grand_parent.parent2.child3 initialization
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test09/test09.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test09/test09.cpp
new file mode 100644
index 000000000..437628142
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test09/test09.cpp
@@ -0,0 +1,205 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test09.cpp -- Test for hierarchical reset, try/catch and individual kill
+ processes
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test09.cpp,v $
+// Revision 1.4 2011/02/01 17:17:40 acg
+// Andy Goodrich: update of copyright notice, added visible CVS logging.
+//
+// Revision 1.3 2011/01/14 14:23:46 acg
+// Andy Goodrich: Fixes for 1666_2011
+//
+// Revision 1.2 2009/10/14 19:13:27 acg
+// Andy Goodrich: changes for SystemC 2.3
+//
+// Revision 1.1.1.1 2006/12/15 20:26:03 acg
+// systemc_tests-2.3
+//
+// Revision 1.1 2006/04/17 20:10:04 acg
+// Andy Goodrich: first inclusion of test for expanded process support.
+//
+
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_CTHREAD(stimulus,m_clk.pos());
+ reset_signal_is(m_reset, true);
+ SC_THREAD(grand_parent);
+ sensitive << m_clk.pos();
+ }
+
+ void child()
+ {
+ sc_process_handle my_handle = sc_get_current_process_handle();
+ cout << sc_time_stamp() << " " << my_handle.name()
+ << " initialization" << endl;
+ try {
+ for (;;)
+ {
+ wait();
+ }
+ }
+ catch(sc_core::sc_unwind_exception& ex)
+ {
+ if ( !ex.is_reset() )
+ {
+ cout << sc_time_stamp() << " " << my_handle.name()
+ << " got kill" << endl;
+ }
+ throw ex;
+ }
+ }
+
+ void grand_parent()
+ {
+ static bool initialize = true;
+ cout << sc_time_stamp() << " " << "dut.grand_parent initialization"
+ << endl;
+ cout << endl;
+ if ( initialize )
+ {
+ m_grand_parent_handle = sc_get_current_process_handle();
+ sc_spawn( sc_bind(&DUT::parent1, this), "parent1" );
+ sc_spawn( sc_bind(&DUT::parent2, this), "parent2" );
+ initialize = false;
+ }
+
+ for (;;)
+ {
+ wait();
+ }
+ }
+
+ void parent1()
+ {
+ static bool initialize = true;
+ sc_process_handle m_child1;
+ sc_process_handle m_child2;
+ sc_process_handle m_child3;
+ sc_process_handle my_handle = sc_get_current_process_handle();
+ cout << sc_time_stamp() << " " << my_handle.name()
+ << " initialization" << endl;
+ if ( initialize )
+ {
+ m_child1 = sc_spawn( sc_bind(&DUT::child, this), "child1" );
+ m_child2 = sc_spawn( sc_bind(&DUT::child, this), "child2" );
+ m_child3 = sc_spawn( sc_bind(&DUT::child, this), "child3" );
+ initialize = false;
+ }
+
+ for (;;)
+ {
+ wait();
+ }
+ }
+
+ void parent2()
+ {
+ sc_process_handle m_child1;
+ sc_process_handle m_child2;
+ sc_process_handle m_child3;
+ sc_process_handle my_handle;
+ for (;;)
+ {
+ try
+ {
+ my_handle = sc_get_current_process_handle();
+ cout << sc_time_stamp() << " " << my_handle.name()
+ << " initialization" << endl;
+ m_child1 = sc_spawn( sc_bind(&DUT::child, this), "child1" );
+ m_child2 = sc_spawn( sc_bind(&DUT::child, this), "child2" );
+ m_child3 = sc_spawn( sc_bind(&DUT::child, this), "child3" );
+
+ for (;;)
+ {
+ wait();
+ }
+ }
+ catch ( sc_core::sc_unwind_exception& ex )
+ {
+ if ( ex.is_reset() )
+ {
+ cout << sc_time_stamp() << " " << my_handle.name()
+ << " removing children" << endl;
+ m_child1.kill();
+ m_child2.kill();
+ m_child3.kill();
+ }
+ throw ex;
+ }
+ }
+ }
+
+ void stimulus()
+ {
+ for (;;)
+ {
+ wait();
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp() << " stimulus issuing reset" << endl;
+ m_grand_parent_handle.reset(SC_INCLUDE_DESCENDANTS);
+ }
+ }
+
+ sc_in<bool> m_clk;
+ sc_process_handle m_grand_parent_handle;
+ sc_in<bool> m_reset;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+ sc_signal<bool> reset;
+
+ dut.m_clk(clock);
+ dut.m_reset(reset);
+
+ reset = true;
+ sc_start(1, SC_NS);
+ reset = false;
+ sc_start(20, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test10/golden/test10.log b/src/systemc/tests/systemc/kernel/dynamic_processes/test10/golden/test10.log
new file mode 100644
index 000000000..d7d8a9de4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test10/golden/test10.log
@@ -0,0 +1,15 @@
+SystemC Simulation
+0 s thread 0: initialization
+0 s thread 1: initialization
+0 s thread 2: initialization
+4 ns stimulus setting kill
+5 ns killer: killing thread0
+5 ns thread0: received kill
+5 ns thread1: received kill
+5 ns thread0: after killing thread1
+5 ns killer: after killing thread0
+5 ns thread2: received kill
+5 ns killer: after killing thread2
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+Program completed
diff --git a/src/systemc/tests/systemc/kernel/dynamic_processes/test10/test10.cpp b/src/systemc/tests/systemc/kernel/dynamic_processes/test10/test10.cpp
new file mode 100644
index 000000000..2c2dd74eb
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/dynamic_processes/test10/test10.cpp
@@ -0,0 +1,175 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test10.cpp -- Testing proper process execution order for SC_METHOD murderer.
+
+ Original Author: Andy Goodrich
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: test10.cpp,v $
+// Revision 1.2 2011/02/01 20:00:37 acg
+// Andy Goodrich: better messaging for output.
+//
+// Revision 1.1 2011/02/01 17:16:48 acg
+// Andy Goodrich: first check-in.
+//
+
+#define SC_INCLUDE_DYNAMIC_PROCESSES
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT)
+ {
+ SC_METHOD(killer);
+ sensitive << m_clk.pos();
+ SC_CTHREAD(stimulus,m_clk.pos());
+ SC_THREAD(thread0);
+ sensitive << m_clk.pos();
+ m_thread0 = sc_get_current_process_handle();
+ SC_THREAD(thread1);
+ sensitive << m_clk.pos();
+ m_thread1 = sc_get_current_process_handle();
+ SC_THREAD(thread2);
+ sensitive << m_clk.pos();
+ m_thread2 = sc_get_current_process_handle();
+ m_kill = false;
+ }
+
+ void killer()
+ {
+ if ( m_kill )
+ {
+ cout << sc_time_stamp() << " killer: killing thread0 " << endl;
+ m_thread0.kill();
+ cout << sc_time_stamp() << " killer: after killing thread0" << endl;
+ m_thread2.kill();
+ cout << sc_time_stamp() << " killer: after killing thread2" << endl;
+ }
+ }
+
+ void thread0()
+ {
+ cout << sc_time_stamp() << " thread 0: initialization" << endl;
+ try {
+ for (;;)
+ {
+ wait();
+ }
+ }
+ catch(sc_core::sc_unwind_exception& ex)
+ {
+ if ( !ex.is_reset() )
+ {
+ cout << sc_time_stamp() << " thread0: received kill" << endl;
+ m_thread1.kill();
+ cout << sc_time_stamp() << " thread0: after killing thread1"
+ << endl;
+ }
+ throw ex;
+ }
+ }
+
+ void thread1()
+ {
+ cout << sc_time_stamp() << " thread 1: initialization" << endl;
+ try {
+ for (;;)
+ {
+ wait();
+ }
+ }
+ catch(sc_core::sc_unwind_exception& ex)
+ {
+ if ( !ex.is_reset() )
+ {
+ cout << sc_time_stamp() << " thread1: received kill" << endl;
+ }
+ throw ex;
+ }
+ }
+
+ void thread2()
+ {
+ cout << sc_time_stamp() << " thread 2: initialization" << endl;
+ try {
+ for (;;)
+ {
+ wait();
+ }
+ }
+ catch(sc_core::sc_unwind_exception& ex)
+ {
+ if ( !ex.is_reset() )
+ {
+ cout << sc_time_stamp() << " thread2: received kill" << endl;
+ }
+ throw ex;
+ }
+ }
+
+ void stimulus()
+ {
+ for (;;)
+ {
+ wait();
+ wait();
+ wait();
+ wait();
+ cout << sc_time_stamp() << " stimulus setting kill" << endl;
+ m_kill = true;
+ wait();
+ m_kill = false;
+ wait();
+ wait();
+ sc_stop();
+ }
+ }
+
+ sc_in<bool> m_clk;
+ bool m_kill;
+ sc_process_handle m_thread0;
+ sc_process_handle m_thread1;
+ sc_process_handle m_thread2;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start();
+
+ cout << "Program completed" << endl;
+ return 0;
+}