1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22  test01.cpp --
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32
33      Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
34                               September 5, 2003
35  Description of Modification: - set stop mode to SC_STOP_IMMEDIATE;
36			       - add more output printout to make sure that
37				 the immdiate event notification of "e_b" after
38				 issuing sc_stop() does not make the
39				 sensitive process "thread_a" run
40
41 *****************************************************************************/
42
43// test of immediate event notification
44
45#include "systemc.h"
46
47SC_MODULE( mod_a )
48{
49    sc_event e_a;
50    sc_event e_b;
51
52    int n;
53
54    void thread_a()
55    {
56        wait( SC_ZERO_TIME );
57        n = 0;
58        while( true ) {
59            n ++;
60            e_a.notify();
61            wait( e_b );
62	    cout << "Triggered by event e_b" << endl;
63        }
64    }
65
66    void thread_b()
67    {
68        while( true ) {
69            wait( e_a );
70            cout << sc_delta_count() << " " << n << endl;
71            if( n == 20 ) {
72                cout << "Issuing sc_stop() " << endl;
73                sc_stop();
74            }
75            e_b.notify();
76        }
77    }
78
79    SC_CTOR( mod_a )
80    {
81        SC_THREAD( thread_a );
82        SC_THREAD( thread_b );
83    }
84};
85
86int
87sc_main( int, char*[] )
88{
89    mod_a a( "a" );
90
91    sc_set_stop_mode(SC_STOP_IMMEDIATE);
92    sc_start();
93
94    return 0;
95}
96