test07.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
22  test07.cpp -- Test that for all the interfaces of a port a callback occurs
23                for a dynamic process created after the beginning of simulation.
24
25  Original Author: Andy Goodrich, Forte Design Systems
26
27 *****************************************************************************/
28
29
30/*****************************************************************************
31
32  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
33  changes you are making here.
34
35      Name, Affiliation, Date:
36  Description of Modification:
37
38 *****************************************************************************/
39// $Log: test07.cpp,v $
40// Revision 1.2  2011/02/01 17:17:40  acg
41//  Andy Goodrich: update of copyright notice, added visible CVS logging.
42//
43
44
45#define SC_INCLUDE_DYNAMIC_PROCESSES
46#include "systemc.h"
47
48SC_MODULE(DUT)
49{
50	SC_CTOR(DUT)
51	{
52		SC_CTHREAD(thread,m_clk.pos());
53
54		// Set up interfaces for m_port.
55
56		m_port(m_a);
57		m_port(m_b);
58		m_port(m_c);
59	}
60	void method()
61	{
62		cout << sc_time_stamp() << " callback" << endl;
63	}
64	void thread()
65	{
66		sc_spawn_options options;
67		options.spawn_method();
68		options.set_sensitivity( &m_port );
69		options.dont_initialize();
70		sc_spawn( sc_bind(&DUT::method,this), "method", &options );
71		for ( bool value=true;; value = !value)
72		{
73			wait();
74			cout << sc_time_stamp() << " setting m_a " << endl;
75			m_a = value;
76			wait();
77			cout << sc_time_stamp() << " setting m_b " << endl;
78			m_b = value;
79			wait();
80			cout << sc_time_stamp() << " setting m_c " << endl;
81			m_c = value;
82		}
83	}
84	sc_signal<bool>                     m_a;
85	sc_signal<bool>                     m_b;
86	sc_signal<bool>                     m_c;
87	sc_in<bool>                         m_clk;
88	sc_port<sc_signal_inout_if<bool>,3> m_port;
89};
90
91int sc_main(int argc, char* argv[])
92{
93	sc_clock clock;
94    DUT      dut("dut");
95
96	dut.m_clk(clock);
97
98	sc_start(50, SC_NS);
99
100	cout << "Program completed" << endl;
101	return 0;
102}
103