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 test08.cpp -- Test for sc_spawn during update phase, including after stop. 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// $Log: test08.cpp,v $ 38// Revision 1.4 2011/02/20 13:43:44 acg 39// Andy Goodrich: updates for IEEE 1666 2011. 40// 41// Revision 1.3 2011/02/18 21:11:07 acg 42// Philipp A. Hartmann: rename ABC class to eliminate class with wingdi.h. 43// 44// Revision 1.2 2011/02/01 17:17:40 acg 45// Andy Goodrich: update of copyright notice, added visible CVS logging. 46// 47 48#define SC_INCLUDE_DYNAMIC_PROCESSES 49#include "systemc.h" 50 51class prim_channel : public sc_prim_channel { 52 public: 53 prim_channel(const char* name = sc_gen_unique_name("prim_channel") ) 54 : sc_prim_channel(name) 55 {} 56 void thread() 57 { 58 cout << "thread here..." << endl; 59 } 60 void update() 61 { 62 cout << "update called..." << endl; 63 sc_spawn( sc_bind(&prim_channel::thread,this), 64 sc_gen_unique_name("thread")); 65 } 66 void write( int i ) 67 { 68 request_update(); 69 } 70}; 71 72SC_MODULE(DUT) 73{ 74 SC_CTOR(DUT) 75 { 76 SC_CTHREAD(thread,m_clk.pos()); 77 } 78 void thread() 79 { 80 for (;;) 81 { 82 wait(); 83 m_chan.write(0); 84 wait(); 85 m_chan.write(0); 86 sc_stop(); 87 } 88 } 89 sc_in<bool> m_clk; 90 prim_channel m_chan; 91}; 92int sc_main(int argc, char* argv[]) 93{ 94 sc_clock clock; 95 DUT dut("dut"); 96 97 dut.m_clk(clock); 98 99 sc_start(10, SC_NS); 100 101 cout << "Program completed" << endl; 102 return 0; 103} 104