test08.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 test08.cpp -- Test of suspend and asynchronous reset interaction 23 24 Original Author: Andy Goodrich, 14 Februrary 2011 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/04/02 00:08:36 acg 39// Andy Goodrich: turn off corner case error checking. 40// 41// Revision 1.3 2011/03/07 19:32:16 acg 42// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners 43// to true so that this test avoids corner case error messages. 44// 45// Revision 1.2 2011/02/20 13:44:06 acg 46// Andy Goodrich: updates for IEEE 1666 2011. 47// 48// Revision 1.1 2011/02/14 16:59:29 acg 49// Andy Goodrich: first check in. 50// 51 52#include "systemc.h" 53 54sc_event event1; 55sc_process_handle t; 56SC_MODULE(DUT) 57{ 58 SC_CTOR(DUT) 59 { 60 SC_THREAD(thread); 61 t = sc_get_current_process_handle(); 62 } 63 void thread() 64 { 65 cout << sc_time_stamp() << " target: initializing" << endl; 66 for (;;) 67 { 68 wait(event1); 69 cout << sc_time_stamp() << " target: awoke" << endl; 70 } 71 } 72}; 73 74SC_MODULE(TB) 75{ 76 SC_CTOR(TB) 77 { 78 SC_THREAD(tb_thread); 79 } 80 void tb_thread() 81 { 82 wait( 10, SC_NS ); 83 cout << sc_time_stamp() << " tb: firing event " << endl; 84 event1.notify(); 85 wait( 10, SC_NS ); 86 87 cout << sc_time_stamp() << " tb: suspending target " << endl; 88 t.suspend(); 89 wait( 10, SC_NS ); 90 91 cout << sc_time_stamp() << " tb: firing event while target suspended" 92 << endl; 93 event1.notify(); 94 wait( 10, SC_NS ); 95 96 cout << sc_time_stamp() << " tb: resetting target " << endl; 97 t.reset(); 98 wait( 10, SC_NS ); 99 100 cout << sc_time_stamp() << " tb: resuming target" << endl; 101 t.resume(); 102 wait( 10, SC_NS ); 103 104 cout << sc_time_stamp() << " tb: 10ns after resume" << endl; 105 wait( 10, SC_NS ); 106 107 cout << sc_time_stamp() << " tb: firing event again" << endl; 108 event1.notify(); 109 wait( 10, SC_NS ); 110 111 cout << sc_time_stamp() << " tb: stopping" << endl; 112 sc_stop(); 113 } 114}; 115 116int sc_main(int argc, char* argv[]) 117{ 118 sc_core::sc_allow_process_control_corners = true; 119 DUT dut("dut"); 120 TB tb("tb"); 121 122 sc_core::sc_allow_process_control_corners = true; 123 sc_start(); 124 125 cout << "Program completed" << endl; 126 return 0; 127} 128