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 -- Test for reset_signal_is support. 23 24 Original Author: Andy Goodrich 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: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38#include "systemc.h" 39 40 41SC_MODULE(A) 42{ 43 SC_CTOR(A) 44 { 45 SC_CTHREAD(test,m_clk.pos()); 46 reset_signal_is( m_reset, false ); 47 } 48 void test() 49 { 50 { 51 cout << "A: reset" << endl; 52 wait(); 53 } 54 for (;;) 55 { 56 wait(); 57 } 58 } 59 sc_in_clk m_clk; 60 sc_in<bool> m_reset; 61}; 62 63SC_MODULE(B) 64{ 65 B(sc_module_name name, sc_signal<bool>* reset_p ): 66 sc_module(name), m_reset_p(reset_p) 67 { 68 SC_HAS_PROCESS(B); 69 SC_CTHREAD(test,m_clk.pos()); 70 reset_signal_is( *m_reset_p, false ); 71 } 72 void test() 73 { 74 { 75 cout << "B: reset" << endl; 76 wait(); 77 } 78 for (;;) 79 { 80 wait(); 81 } 82 } 83 sc_in_clk m_clk; 84 sc_signal<bool>* m_reset_p; 85}; 86 87int sc_main(int argc, char* argv[]) 88{ 89 sc_clock clk; 90 sc_signal<bool> reset; 91 A a("a"); 92 B b("b",&reset); 93 94 a.m_clk(clk); 95 a.m_reset(reset); 96 b.m_clk(clk); 97 98 cout << "Before start" << endl; 99 sc_start(2, SC_NS); 100 reset = true; 101 cout << "After reset true" << endl; 102 sc_start(3, SC_NS); 103 cout << "Ending" << endl; 104 105 return 0; 106} 107