self_reset_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// self_reset_bug.cpp -- test for 21// 22// Original Author: John Aynsley, Doulus 23// 24// MODIFICATION LOG - modifiers, enter your name, affiliation, date and 25// 26 27// 28 29#define SC_INCLUDE_DYNAMIC_PROCESSES 30 31#include <systemc> 32 33using namespace sc_core; 34using std::cout; 35using std::endl; 36 37struct Top: sc_module 38{ 39 Top(sc_module_name _name) 40 { 41 SC_METHOD(target); 42 target_handle = sc_get_current_process_handle(); 43 44 count = 0; 45 f0 = f1 = f2 = f3 = 0; 46 } 47 48 sc_process_handle target_handle; 49 int count; 50 int f0, f1, f2, f3; 51 52 void target() 53 { 54 switch (count) 55 { 56 case 0: 57 f0 = 1; 58 count = 1; 59 next_trigger(10, SC_NS); 60 break; 61 62 case 1: 63 f1 = 1; 64 count = 2; 65 target_handle.reset(); 66 break; 67 68 case 2: 69 f2 = 1; 70 count = 3; 71 target_handle.reset(); 72 break; 73 74 case 3: 75 f3 = 1; 76 count = 4; 77 break; 78 } 79 } 80 81 SC_HAS_PROCESS(Top); 82}; 83 84int sc_main(int argc, char* argv[]) 85{ 86 Top top("top"); 87 88 sc_start(); 89 90 sc_assert( top.f0 ); 91 sc_assert( top.f1 ); 92 sc_assert( top.f2 ); 93 sc_assert( top.f3 ); 94 95 cout << endl << "Success" << endl; 96 return 0; 97} 98 99