sc_start_bug.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// sc_start_bug.cpp 21// 22// Original Author: John Aynsley, Doulos, Inc. 23// 24// MODIFICATION LOG - modifiers, enter your name, affiliation, date and 25// 26 27#define SC_INCLUDE_DYNAMIC_PROCESSES 28 29#include <systemc> 30using namespace sc_core; 31using std::cout; 32using std::endl; 33 34struct Top: sc_module 35{ 36 Top(sc_module_name _name) 37 { 38 SC_THREAD(T1); 39 SC_THREAD(T2); 40 } 41 42 void T1() 43 { 44 sc_assert( sc_time_stamp() == sc_time(0, SC_NS) ); 45 wait(15, SC_NS); 46 sc_assert( sc_time_stamp() == sc_time(15, SC_NS) ); 47 sc_pause(); 48 } 49 50 void T2() 51 { 52 sc_assert( sc_time_stamp() == sc_time(0, SC_NS) ); 53 wait(30, SC_NS); 54 sc_assert( sc_time_stamp() == sc_time(30, SC_NS) ); 55 sc_pause(); 56 } 57 58 SC_HAS_PROCESS(Top); 59}; 60 61int sc_main(int argc, char* argv[]) 62{ 63 Top top("top"); 64 65 sc_start(10, SC_NS, SC_RUN_TO_TIME); 66 sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 67 68 sc_start(10, SC_NS, SC_RUN_TO_TIME); 69 sc_assert( sc_time_stamp() == sc_time(15, SC_NS) ); 70 71 sc_start(10, SC_NS, SC_RUN_TO_TIME); 72 sc_assert( sc_time_stamp() == sc_time(25, SC_NS) ); 73 74 sc_start(10, SC_NS, SC_RUN_TO_TIME); 75 sc_assert( sc_time_stamp() == sc_time(30, SC_NS) ); 76 77 cout << endl << "Success" << endl; 78 return 0; 79} 80