test04.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 test04.cpp -- Test of interaction of suspend-resume, disable-enable, and 23 resets on processes 24 25 Original Author: Andy Goodrich 26 27 *****************************************************************************/ 28 29/***************************************************************************** 30 31 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 32 changes you are making here. 33 34 Name, Affiliation, Date: 35 Description of Modification: 36 37 Revision log at end of the file to let __LINE__ give the same results 38 after a check-in. 39 *****************************************************************************/ 40// $Log: test04.cpp,v $ 41// Revision 1.5 2011/04/02 00:08:29 acg 42// Andy Goodrich: turn off corner case error checking. 43// 44// Revision 1.4 2011/03/07 19:32:14 acg 45// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners 46// to true so that this test avoids corner case error messages. 47// 48// Revision 1.3 2011/02/14 17:00:00 acg 49// Andy Goodrich: updated copyright and added cvs logging information inline. 50// 51 52#include "systemc.h" 53 54SC_MODULE(DUT) 55{ 56 SC_CTOR(DUT) 57 { 58 SC_CTHREAD(master,m_clk.pos()); 59 SC_CTHREAD(slave,m_clk.pos()); 60 } 61 void slave() 62 { 63 m_handle0 = sc_get_current_process_handle(); 64 cout << sc_time_stamp() << ":slave - in reset" << endl; 65 for (;;) 66 { 67 wait(); 68 cout << sc_time_stamp() << ":slave - self-suspend..." << endl; 69 m_handle0.suspend(); 70 cout << sc_time_stamp() << ":slave - ... resumed" << endl; 71 wait(); 72 cout << sc_time_stamp() << ":slave - self-disable ..." << endl; 73 m_handle0.disable(); 74 cout << sc_time_stamp() << ":slave - ... executing ..." << endl; 75 wait(); 76 cout << sc_time_stamp() << ":slave - ... enabled" << endl; 77 wait(); 78 wait(); 79 wait(); 80 } 81 } 82 void master() 83 { 84 m_handle1 = sc_get_current_process_handle(); 85 for (;;) 86 { 87 wait(); 88 wait(); 89 wait(); 90 cout << sc_time_stamp() 91 << ":master - resuming slave" << endl; 92 m_handle0.resume(); 93 wait(); 94 wait(); 95 wait(); 96 cout << sc_time_stamp() 97 << ":master - enabling slave" << endl; 98 m_handle0.enable(); 99 wait(); 100 cout << sc_time_stamp() 101 << ":master - sync reset on slave" << endl; 102 m_handle0.sync_reset_on(); 103 wait(); 104 wait(); 105 wait(); 106 cout << sc_time_stamp() 107 << ":master - sync reset off slave" << endl; 108 m_handle0.sync_reset_off(); 109 wait(); 110 wait(); 111 wait(); 112 cout << sc_time_stamp() 113 << ":master - async reset on slave" << endl; 114 m_handle0.reset(); 115 wait(20); 116 sc_stop(); 117 } 118 } 119 sc_in<bool> m_clk; 120 sc_process_handle m_handle0; 121 sc_process_handle m_handle1; 122}; 123 124int sc_main(int argc, char* argv[]) 125{ 126 sc_core::sc_allow_process_control_corners = true; 127 sc_clock clock; 128 DUT dut("dut"); 129 130 dut.m_clk(clock); 131 132 sc_core::sc_allow_process_control_corners = true; 133 sc_start(); 134 135 cout << "Program completed" << endl; 136 return 0; 137} 138