112855Sgabeblack@google.com/***************************************************************************** 212855Sgabeblack@google.com 312855Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412855Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512855Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612855Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712855Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812855Sgabeblack@google.com License. You may obtain a copy of the License at 912855Sgabeblack@google.com 1012855Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112855Sgabeblack@google.com 1212855Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312855Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412855Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512855Sgabeblack@google.com implied. See the License for the specific language governing 1612855Sgabeblack@google.com permissions and limitations under the License. 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com *****************************************************************************/ 1912855Sgabeblack@google.com 2012855Sgabeblack@google.com/***************************************************************************** 2112855Sgabeblack@google.com 2212855Sgabeblack@google.com test02.cpp -- Test of resume after dynamic event completion 2312855Sgabeblack@google.com 2412855Sgabeblack@google.com Original Author: Andy Goodrich 2512855Sgabeblack@google.com 2612855Sgabeblack@google.com *****************************************************************************/ 2712855Sgabeblack@google.com 2812855Sgabeblack@google.com/***************************************************************************** 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112855Sgabeblack@google.com changes you are making here. 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com Name, Affiliation, Date: 3412855Sgabeblack@google.com Description of Modification: 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com Revision log at end of the file to let __LINE__ give the same results 3712855Sgabeblack@google.com after a check-in. 3812855Sgabeblack@google.com *****************************************************************************/ 3912855Sgabeblack@google.com 4012855Sgabeblack@google.com#include "systemc.h" 4112855Sgabeblack@google.com 4212855Sgabeblack@google.comSC_MODULE(DUT) 4312855Sgabeblack@google.com{ 4412855Sgabeblack@google.com SC_CTOR(DUT) 4512855Sgabeblack@google.com { 4612855Sgabeblack@google.com SC_CTHREAD(cthread,m_clk.pos()); 4712855Sgabeblack@google.com reset_signal_is(m_reset, true); 4812855Sgabeblack@google.com m_cthread = sc_get_current_process_handle(); 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com SC_METHOD(dynamic_method); 5112855Sgabeblack@google.com m_dynamic_method = sc_get_current_process_handle(); 5212855Sgabeblack@google.com 5312855Sgabeblack@google.com SC_THREAD(dynamic_thread); 5412855Sgabeblack@google.com m_dynamic_thread = sc_get_current_process_handle(); 5512855Sgabeblack@google.com 5612855Sgabeblack@google.com SC_METHOD(static_method); 5712855Sgabeblack@google.com sensitive << m_event1 << m_event2; 5812855Sgabeblack@google.com m_static_method = sc_get_current_process_handle(); 5912855Sgabeblack@google.com 6012855Sgabeblack@google.com SC_THREAD(static_thread); 6112855Sgabeblack@google.com sensitive << m_event1 << m_event2; 6212855Sgabeblack@google.com m_static_thread = sc_get_current_process_handle(); 6312855Sgabeblack@google.com 6412855Sgabeblack@google.com SC_CTHREAD(stimulus,m_clk.pos()); 6512855Sgabeblack@google.com reset_signal_is(m_reset, true); 6612855Sgabeblack@google.com } 6712855Sgabeblack@google.com void cthread() 6812855Sgabeblack@google.com { 6912855Sgabeblack@google.com for (;;) 7012855Sgabeblack@google.com { 7112855Sgabeblack@google.com wait(); 7212855Sgabeblack@google.com cout << sc_time_stamp() << ": clocked thread (" << __LINE__ 7312855Sgabeblack@google.com << ") after wait on m_clk.pos() " << endl; 7412855Sgabeblack@google.com } 7512855Sgabeblack@google.com } 7612855Sgabeblack@google.com void dynamic_method() 7712855Sgabeblack@google.com { 7812855Sgabeblack@google.com static int state = 0; 7912855Sgabeblack@google.com switch ( state ) 8012855Sgabeblack@google.com { 8112855Sgabeblack@google.com case 0: 8212855Sgabeblack@google.com next_trigger( m_clk.posedge_event() ); 8312855Sgabeblack@google.com cout << sc_time_stamp() << ": dynamic method (" << __LINE__ 8412855Sgabeblack@google.com << "," << state << ") initialization call " << endl; 8512855Sgabeblack@google.com state = 1; 8612855Sgabeblack@google.com break; 8712855Sgabeblack@google.com default: 8812855Sgabeblack@google.com case 1: 8912855Sgabeblack@google.com next_trigger( m_event1 & m_event2 ); 9012855Sgabeblack@google.com cout << sc_time_stamp() << ": dynamic method (" << __LINE__ 9112855Sgabeblack@google.com << "," << state << ") after wait on m_clk.posedge() " << endl; 9212855Sgabeblack@google.com break; 9312855Sgabeblack@google.com } 9412855Sgabeblack@google.com } 9512855Sgabeblack@google.com void dynamic_thread() 9612855Sgabeblack@google.com { 9712855Sgabeblack@google.com cout << sc_time_stamp() << ": dynamic thread (" << __LINE__ << ")" 9812855Sgabeblack@google.com << " initialization call " << endl; 9912855Sgabeblack@google.com wait(m_clk.posedge_event()); 10012855Sgabeblack@google.com cout << sc_time_stamp() << ": dynamic thread (" << __LINE__ 10112855Sgabeblack@google.com << ") after wait on m_clk.posedge_event() " << endl; 10212855Sgabeblack@google.com for (;;) 10312855Sgabeblack@google.com { 10412855Sgabeblack@google.com wait(m_event1 & m_event2 ); 10512855Sgabeblack@google.com cout << sc_time_stamp() << ": dynamic thread (" << __LINE__ 10612855Sgabeblack@google.com << ") after wait on m_event1 & m_event2 " << endl; 10712855Sgabeblack@google.com } 10812855Sgabeblack@google.com } 10912855Sgabeblack@google.com void static_method() 11012855Sgabeblack@google.com { 11112855Sgabeblack@google.com static bool initialized = false; 11212855Sgabeblack@google.com if ( !initialized ) 11312855Sgabeblack@google.com { 11412855Sgabeblack@google.com initialized = true; 11512855Sgabeblack@google.com cout << sc_time_stamp() << ": static method (" << __LINE__ 11612855Sgabeblack@google.com << ")" << " initialization call " << endl; 11712855Sgabeblack@google.com } 11812855Sgabeblack@google.com else 11912855Sgabeblack@google.com { 12012855Sgabeblack@google.com cout << sc_time_stamp() << ": static method (" << __LINE__ 12112855Sgabeblack@google.com << ") after wait on m_event1 | m_event2 " << endl; 12212855Sgabeblack@google.com } 12312855Sgabeblack@google.com } 12412855Sgabeblack@google.com void static_thread() 12512855Sgabeblack@google.com { 12612855Sgabeblack@google.com cout << sc_time_stamp() << ": static thread (" << __LINE__ << ")" 12712855Sgabeblack@google.com << " initialization call " << endl; 12812855Sgabeblack@google.com for (;;) 12912855Sgabeblack@google.com { 13012855Sgabeblack@google.com wait(); 13112855Sgabeblack@google.com cout << sc_time_stamp() << ": static thread (" << __LINE__ 13212855Sgabeblack@google.com << ") after wait on m_event1 | m_event2 " << endl; 13312855Sgabeblack@google.com } 13412855Sgabeblack@google.com 13512855Sgabeblack@google.com } 13612855Sgabeblack@google.com void stimulus() 13712855Sgabeblack@google.com { 13812855Sgabeblack@google.com for (;;) 13912855Sgabeblack@google.com { 14012855Sgabeblack@google.com wait(); 14112855Sgabeblack@google.com wait(); 14212855Sgabeblack@google.com cout << sc_time_stamp() << ": stimulus (" 14312855Sgabeblack@google.com << __LINE__ << ") - suspending all processes" << endl; 14412855Sgabeblack@google.com m_cthread.suspend(); 14512855Sgabeblack@google.com m_dynamic_method.suspend(); 14612855Sgabeblack@google.com m_dynamic_thread.suspend(); 14712855Sgabeblack@google.com m_static_method.suspend(); 14812855Sgabeblack@google.com m_static_thread.suspend(); 14912855Sgabeblack@google.com wait(); 15012855Sgabeblack@google.com 15112855Sgabeblack@google.com m_event1.notify(SC_ZERO_TIME); 15212855Sgabeblack@google.com cout << sc_time_stamp() << ": stimulus (" 15312855Sgabeblack@google.com << __LINE__ << ") - firing event1 " << endl; 15412855Sgabeblack@google.com wait(); 15512855Sgabeblack@google.com m_event2.notify(SC_ZERO_TIME); 15612855Sgabeblack@google.com cout << sc_time_stamp() << ": stimulus (" 15712855Sgabeblack@google.com << __LINE__ << ") - firing event2 " << endl; 15812855Sgabeblack@google.com wait(); 15912855Sgabeblack@google.com wait(); 16012855Sgabeblack@google.com 16112855Sgabeblack@google.com m_cthread.resume(); 16212855Sgabeblack@google.com m_dynamic_method.resume(); 16312855Sgabeblack@google.com m_dynamic_thread.resume(); 16412855Sgabeblack@google.com m_static_method.resume(); 16512855Sgabeblack@google.com m_static_thread.resume(); 16612855Sgabeblack@google.com cout << endl << sc_time_stamp() << ": stimulus (" 16712855Sgabeblack@google.com << __LINE__ << ") - resuming all processes" << endl; 16812855Sgabeblack@google.com wait(); 16912855Sgabeblack@google.com wait(); 17012855Sgabeblack@google.com wait(); 17112855Sgabeblack@google.com sc_stop(); 17212855Sgabeblack@google.com } 17312855Sgabeblack@google.com } 17412855Sgabeblack@google.com sc_in<bool> m_clk; 17512855Sgabeblack@google.com sc_process_handle m_cthread; 17612855Sgabeblack@google.com sc_process_handle m_dynamic_method; 17712855Sgabeblack@google.com sc_process_handle m_dynamic_thread; 17812855Sgabeblack@google.com sc_event m_event1; 17912855Sgabeblack@google.com sc_event m_event2; 18012855Sgabeblack@google.com sc_event m_event3; 18112855Sgabeblack@google.com sc_event m_event4; 18212855Sgabeblack@google.com sc_in<bool> m_reset; 18312855Sgabeblack@google.com sc_process_handle m_static_method; 18412855Sgabeblack@google.com sc_process_handle m_static_thread; 18512855Sgabeblack@google.com}; 18612855Sgabeblack@google.com 18712855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 18812855Sgabeblack@google.com{ 18912855Sgabeblack@google.com sc_core::sc_allow_process_control_corners = true; 19012855Sgabeblack@google.com sc_clock clock; 19112855Sgabeblack@google.com DUT dut("dut"); 19212855Sgabeblack@google.com sc_signal<bool> reset; 19312855Sgabeblack@google.com 19412855Sgabeblack@google.com dut.m_clk(clock); 19512855Sgabeblack@google.com dut.m_reset(reset); 19612855Sgabeblack@google.com 19712855Sgabeblack@google.com sc_core::sc_allow_process_control_corners = true; 19812855Sgabeblack@google.com reset = true; 19912855Sgabeblack@google.com sc_start(1, SC_NS); 20012855Sgabeblack@google.com reset = false; 20112855Sgabeblack@google.com sc_start(21, SC_NS); 20212855Sgabeblack@google.com 20312855Sgabeblack@google.com cout << "Program completed" << endl; 20412855Sgabeblack@google.com return 0; 20512855Sgabeblack@google.com} 20612855Sgabeblack@google.com 20712855Sgabeblack@google.com// $Log: test02.cpp,v $ 20812855Sgabeblack@google.com// Revision 1.6 2011/04/02 00:08:27 acg 20912855Sgabeblack@google.com// Andy Goodrich: turn off corner case error checking. 21012855Sgabeblack@google.com// 21112855Sgabeblack@google.com// Revision 1.5 2011/03/07 19:32:11 acg 21212855Sgabeblack@google.com// Andy Goodrich: addition to set sc_core::sc_allow_process_control_corners 21312855Sgabeblack@google.com// to true so that this test avoids corner case error messages. 21412855Sgabeblack@google.com// 21512855Sgabeblack@google.com// Revision 1.4 2011/02/20 13:43:58 acg 21612855Sgabeblack@google.com// Andy Goodrich: updates for IEEE 1666 2011. 21712855Sgabeblack@google.com// 21812855Sgabeblack@google.com// Revision 1.3 2011/02/14 17:00:00 acg 21912855Sgabeblack@google.com// Andy Goodrich: updated copyright and added cvs logging information inline. 22012855Sgabeblack@google.com// 22112855Sgabeblack@google.com// Revision 1.2 2011/01/20 16:55:23 acg 22212855Sgabeblack@google.com// Andy Goodrich: changes for IEEE 1666 2011. 22312855Sgabeblack@google.com// 22412855Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:26:03 acg 22512855Sgabeblack@google.com// systemc_tests-2.3 22612855Sgabeblack@google.com// 22712855Sgabeblack@google.com// Revision 1.1 2006/12/14 21:40:06 acg 22812855Sgabeblack@google.com// Andy Goodrich: moving test to new directory. 22912855Sgabeblack@google.com// 23012855Sgabeblack@google.com// Revision 1.2 2006/04/20 19:43:34 acg 23112855Sgabeblack@google.com// Andy Goodrich: moved CVS log to end of file so that __LINE__ does not 23212855Sgabeblack@google.com// change when a checkin is done. 23312855Sgabeblack@google.com// 23412855Sgabeblack@google.com// Revision 1.1 2006/04/17 20:11:02 acg 23512855Sgabeblack@google.com// Andy Goodrich: First inclusion of test for suspend and resume support. 23612855Sgabeblack@google.com// 23712855Sgabeblack@google.com 238