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  method_self_reset.cpp -- Test of method self reset.
23
24  Original Author: Andy Goodrich
25
26 *****************************************************************************/
27// $Log: method_self_reset.cpp,v $
28// Revision 1.4  2011/07/24 15:59:53  acg
29//  Andy Goodrich: add statement I missed installing Philipp's patch.
30//
31// Revision 1.3  2011/07/24 15:58:39  acg
32//  Philipp A. Hartmann: convert first time toggle to counter since need 3
33//  states.
34//
35// Revision 1.2  2011/02/04 15:26:33  acg
36//  Andy Goodrich: regolden for proper process control semantics.
37//
38// Revision 1.1  2011/01/28 19:48:36  acg
39//  Andy Goodrich: first check in.
40//
41
42#include "systemc.h"
43
44SC_MODULE(DUT)
45{
46    SC_CTOR(DUT)
47    {
48        SC_METHOD(method);
49	sensitive << m_clk.pos();
50    }
51    void method()
52    {
53        static int trigger = 0;
54        cout << "Entry " << endl;
55	switch( trigger++ )
56	{
57	  case 0:
58	    cout << "Issuing self reset " << endl;
59	    sc_get_current_process_handle().reset();
60	    sc_assert( false );
61	  case 1:
62	    break;
63	  default:
64	    trigger = 0;
65	}
66        cout << "Exit " << endl;
67    }
68    sc_in<bool> m_clk;
69};
70
71int sc_main(int argc, char* argv[])
72{
73    sc_clock        clock;
74    DUT             dut("dut");
75
76    dut.m_clk(clock);
77
78    sc_start(3, SC_NS);
79
80    cout << "Program completed" << endl;
81    return 0;
82}
83