test02.cpp revision 12855:588919e0e4aa
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  test02.cpp -- Test proper process type for terminated processes
22
23  Original Author: Andy Goodrich, Forte Design Systems
24
25 *****************************************************************************/
26/*****************************************************************************
27  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
28  changes you are making here.
29
30      Name, Affiliation, Date:
31  Description of Modification:
32
33 *****************************************************************************/
34
35// TEST THAT THE CORRECT PROCESS TYPE IS MAINTAINED FOR TERMINATED PROCESSES
36
37#include "systemc.h"
38
39SC_MODULE(DUT)
40{
41    SC_CTOR(DUT)
42    {
43        SC_CTHREAD(cthread_target,m_clk.pos());
44        SC_THREAD(thread_target)
45        sensitive << m_clk.pos();
46        SC_CTHREAD(watcher,m_clk.pos());
47    }
48    void cthread_target()
49    {
50        m_cthread_handle = sc_get_current_process_handle();
51        wait();
52    }
53    void thread_target()
54    {
55        m_thread_handle = sc_get_current_process_handle();
56        wait();
57    }
58    void watcher()
59    {
60        wait();
61        wait();
62        if ( m_cthread_handle.valid() )
63        {
64            if ( m_cthread_handle.proc_kind() == SC_NO_PROC_ )
65                cout << "Cthread process handle kind not maintained" << endl;
66            if ( m_cthread_handle.terminated() == false )
67                cout<< "Cthread process handle doesn't show terminated" << endl;
68        }
69        if ( m_thread_handle.valid() )
70        {
71            if ( m_thread_handle.proc_kind() == SC_NO_PROC_ )
72                cout << "Thread process handle kind not maintained" << endl;
73            if ( m_thread_handle.terminated() == false )
74                cout<< "Thread process handle does not show terminated" << endl;
75        }
76    }
77    sc_in<bool>      m_clk;
78    sc_process_handle m_cthread_handle;
79    sc_process_handle m_thread_handle;
80};
81int sc_main(int argc, char* argv[])
82{
83    sc_clock        clock;
84    DUT             dut("dut");
85
86    dut.m_clk(clock);
87
88    sc_start(5, SC_NS);
89
90    cout << "Program completed" << endl;
91    return 0;
92}
93