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// proc_ctrl_elab.cpp -- test for 2112855Sgabeblack@google.com// 2212855Sgabeblack@google.com// Original Author: John Aynsley, Doulos, Inc. 2312855Sgabeblack@google.com// 2412855Sgabeblack@google.com// MODIFICATION LOG - modifiers, enter your name, affiliation, date and 2512855Sgabeblack@google.com// 2612855Sgabeblack@google.com// $Log: proc_ctrl_elab.cpp,v $ 2712855Sgabeblack@google.com// Revision 1.2 2011/05/08 19:18:46 acg 2812855Sgabeblack@google.com// Andy Goodrich: remove extraneous + prefixes from git diff. 2912855Sgabeblack@google.com// 3012855Sgabeblack@google.com 3112855Sgabeblack@google.com// Calling process control methods during elaboration 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com#define SC_INCLUDE_DYNAMIC_PROCESSES 3412855Sgabeblack@google.com 3512855Sgabeblack@google.com#include "systemc.h" 3612855Sgabeblack@google.com 3712855Sgabeblack@google.comSC_MODULE(Top) 3812855Sgabeblack@google.com{ 3912855Sgabeblack@google.com SC_CTOR(Top) 4012855Sgabeblack@google.com : caught_throw_it(0) 4112855Sgabeblack@google.com , caught_reset(0) 4212855Sgabeblack@google.com , caught_kill(0) 4312855Sgabeblack@google.com 4412855Sgabeblack@google.com , target_suspend_1_called(false) 4512855Sgabeblack@google.com , target_suspend_2_called(false) 4612855Sgabeblack@google.com , target_suspend_3_called(false) 4712855Sgabeblack@google.com , target_suspend_4_called(false) 4812855Sgabeblack@google.com , target_suspend_5_called(false) 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com , target_disable_1_called(false) 5112855Sgabeblack@google.com , target_disable_2_called(false) 5212855Sgabeblack@google.com , target_disable_2_called_again(false) 5312855Sgabeblack@google.com , target_disable_3_called(false) 5412855Sgabeblack@google.com , target_disable_4_called(false) 5512855Sgabeblack@google.com , target_disable_5_called(false) 5612855Sgabeblack@google.com 5712855Sgabeblack@google.com , target_sync_reset_1_called(false) 5812855Sgabeblack@google.com , target_sync_reset_2_called(false) 5912855Sgabeblack@google.com , target_sync_reset_3_called(false) 6012855Sgabeblack@google.com , target_sync_reset_4_called(false) 6112855Sgabeblack@google.com 6212855Sgabeblack@google.com , reset_1_count(0) 6312855Sgabeblack@google.com , reset_2_count(0) 6412855Sgabeblack@google.com , reset_3_count(0) 6512855Sgabeblack@google.com , reset_4_count(0) 6612855Sgabeblack@google.com { 6712855Sgabeblack@google.com SC_THREAD(ctrl); 6812855Sgabeblack@google.com 6912855Sgabeblack@google.com SC_THREAD(target_suspend_1); 7012855Sgabeblack@google.com sensitive << ev; 7112855Sgabeblack@google.com ts1 = sc_get_current_process_handle(); 7212855Sgabeblack@google.com 7312855Sgabeblack@google.com SC_THREAD(target_suspend_2); 7412855Sgabeblack@google.com dont_initialize(); 7512855Sgabeblack@google.com sensitive << ev; 7612855Sgabeblack@google.com ts2 = sc_get_current_process_handle(); 7712855Sgabeblack@google.com 7812855Sgabeblack@google.com SC_THREAD(target_suspend_3); 7912855Sgabeblack@google.com dont_initialize(); 8012855Sgabeblack@google.com sensitive << ev; 8112855Sgabeblack@google.com ts3 = sc_get_current_process_handle(); 8212855Sgabeblack@google.com 8312855Sgabeblack@google.com SC_THREAD(target_suspend_4); 8412855Sgabeblack@google.com dont_initialize(); 8512855Sgabeblack@google.com sensitive << ev; 8612855Sgabeblack@google.com ts4 = sc_get_current_process_handle(); 8712855Sgabeblack@google.com ts4.suspend(); 8812855Sgabeblack@google.com 8912855Sgabeblack@google.com SC_THREAD(target_suspend_5); 9012855Sgabeblack@google.com dont_initialize(); 9112855Sgabeblack@google.com sensitive << ev; 9212855Sgabeblack@google.com ts5 = sc_get_current_process_handle(); 9312855Sgabeblack@google.com ts5.suspend(); 9412855Sgabeblack@google.com ts5.resume(); 9512855Sgabeblack@google.com 9612855Sgabeblack@google.com SC_THREAD(target_disable_1); 9712855Sgabeblack@google.com sensitive << dummy_ev; 9812855Sgabeblack@google.com td1 = sc_get_current_process_handle(); 9912855Sgabeblack@google.com 10012855Sgabeblack@google.com SC_THREAD(target_disable_2); 10112855Sgabeblack@google.com sensitive << ev; 10212855Sgabeblack@google.com td2 = sc_get_current_process_handle(); 10312855Sgabeblack@google.com 10412855Sgabeblack@google.com SC_THREAD(target_disable_3); 10512855Sgabeblack@google.com td3 = sc_get_current_process_handle(); 10612855Sgabeblack@google.com 10712855Sgabeblack@google.com SC_THREAD(target_disable_4); 10812855Sgabeblack@google.com dont_initialize(); 10912855Sgabeblack@google.com sensitive << ev; 11012855Sgabeblack@google.com td4 = sc_get_current_process_handle(); 11112855Sgabeblack@google.com td4.disable(); 11212855Sgabeblack@google.com 11312855Sgabeblack@google.com SC_THREAD(target_disable_5); 11412855Sgabeblack@google.com dont_initialize(); 11512855Sgabeblack@google.com sensitive << ev; 11612855Sgabeblack@google.com td5 = sc_get_current_process_handle(); 11712855Sgabeblack@google.com td5.disable(); 11812855Sgabeblack@google.com td5.enable(); 11912855Sgabeblack@google.com td5.sync_reset_on(); 12012855Sgabeblack@google.com td5.sync_reset_off(); 12112855Sgabeblack@google.com 12212855Sgabeblack@google.com SC_THREAD(target_sync_reset_1); 12312855Sgabeblack@google.com sensitive << ev; 12412855Sgabeblack@google.com tr1 = sc_get_current_process_handle(); 12512855Sgabeblack@google.com 12612855Sgabeblack@google.com SC_THREAD(target_sync_reset_2); 12712855Sgabeblack@google.com sensitive << ev; 12812855Sgabeblack@google.com tr2 = sc_get_current_process_handle(); 12912855Sgabeblack@google.com 13012855Sgabeblack@google.com SC_THREAD(target_sync_reset_3); 13112855Sgabeblack@google.com dont_initialize(); 13212855Sgabeblack@google.com sensitive << ev; 13312855Sgabeblack@google.com tr3 = sc_get_current_process_handle(); 13412855Sgabeblack@google.com 13512855Sgabeblack@google.com SC_THREAD(target_sync_reset_4); 13612855Sgabeblack@google.com dont_initialize(); 13712855Sgabeblack@google.com sensitive << ev; 13812855Sgabeblack@google.com tr4 = sc_get_current_process_handle(); 13912855Sgabeblack@google.com tr4.sync_reset_on(); 14012855Sgabeblack@google.com 14112855Sgabeblack@google.com try { 14212855Sgabeblack@google.com ts2.throw_it(ex); 14312855Sgabeblack@google.com sc_assert( false ); 14412855Sgabeblack@google.com } 14512855Sgabeblack@google.com catch (std::exception e) { 14612855Sgabeblack@google.com ++caught_throw_it; 14712855Sgabeblack@google.com } 14812855Sgabeblack@google.com 14912855Sgabeblack@google.com try { 15012855Sgabeblack@google.com ts2.reset(); 15112855Sgabeblack@google.com sc_assert( false ); 15212855Sgabeblack@google.com } 15312855Sgabeblack@google.com catch (std::exception e) { 15412855Sgabeblack@google.com ++caught_reset; 15512855Sgabeblack@google.com } 15612855Sgabeblack@google.com 15712855Sgabeblack@google.com try { 15812855Sgabeblack@google.com ts2.kill(); 15912855Sgabeblack@google.com sc_assert( false ); 16012855Sgabeblack@google.com } 16112855Sgabeblack@google.com catch (std::exception e) { 16212855Sgabeblack@google.com ++caught_kill; 16312855Sgabeblack@google.com } 16412855Sgabeblack@google.com } 16512855Sgabeblack@google.com 16612855Sgabeblack@google.com void before_end_of_elaboration() 16712855Sgabeblack@google.com { 16812855Sgabeblack@google.com ts1.suspend(); 16912855Sgabeblack@google.com ts2.suspend(); 17012855Sgabeblack@google.com ts3.suspend(); 17112855Sgabeblack@google.com 17212855Sgabeblack@google.com td1.disable(); 17312855Sgabeblack@google.com td2.disable(); 17412855Sgabeblack@google.com td3.disable(); 17512855Sgabeblack@google.com 17612855Sgabeblack@google.com tr1.sync_reset_on(); 17712855Sgabeblack@google.com tr2.sync_reset_on(); 17812855Sgabeblack@google.com tr3.sync_reset_on(); 17912855Sgabeblack@google.com 18012855Sgabeblack@google.com try { 18112855Sgabeblack@google.com ts2.throw_it(ex); 18212855Sgabeblack@google.com sc_assert( false ); 18312855Sgabeblack@google.com } 18412855Sgabeblack@google.com catch (std::exception e) { 18512855Sgabeblack@google.com ++caught_throw_it; 18612855Sgabeblack@google.com } 18712855Sgabeblack@google.com 18812855Sgabeblack@google.com try { 18912855Sgabeblack@google.com ts2.reset(); 19012855Sgabeblack@google.com sc_assert( false ); 19112855Sgabeblack@google.com } 19212855Sgabeblack@google.com catch (std::exception e) { 19312855Sgabeblack@google.com ++caught_reset; 19412855Sgabeblack@google.com } 19512855Sgabeblack@google.com 19612855Sgabeblack@google.com try { 19712855Sgabeblack@google.com ts2.kill(); 19812855Sgabeblack@google.com sc_assert( false ); 19912855Sgabeblack@google.com } 20012855Sgabeblack@google.com catch (std::exception e) { 20112855Sgabeblack@google.com ++caught_kill; 20212855Sgabeblack@google.com } 20312855Sgabeblack@google.com } 20412855Sgabeblack@google.com 20512855Sgabeblack@google.com void start_of_simulation() 20612855Sgabeblack@google.com { 20712855Sgabeblack@google.com td3.enable(); 20812855Sgabeblack@google.com tr3.sync_reset_off(); 20912855Sgabeblack@google.com 21012855Sgabeblack@google.com try { 21112855Sgabeblack@google.com ts2.throw_it(ex); 21212855Sgabeblack@google.com sc_assert( false ); 21312855Sgabeblack@google.com } 21412855Sgabeblack@google.com catch (std::exception e) { 21512855Sgabeblack@google.com ++caught_throw_it; 21612855Sgabeblack@google.com } 21712855Sgabeblack@google.com 21812855Sgabeblack@google.com try { 21912855Sgabeblack@google.com ts2.reset(); 22012855Sgabeblack@google.com sc_assert( false ); 22112855Sgabeblack@google.com } 22212855Sgabeblack@google.com catch (std::exception e) { 22312855Sgabeblack@google.com ++caught_reset; 22412855Sgabeblack@google.com } 22512855Sgabeblack@google.com 22612855Sgabeblack@google.com try { 22712855Sgabeblack@google.com ts2.kill(); 22812855Sgabeblack@google.com sc_assert( false ); 22912855Sgabeblack@google.com } 23012855Sgabeblack@google.com catch (std::exception e) { 23112855Sgabeblack@google.com ++caught_kill; 23212855Sgabeblack@google.com } 23312855Sgabeblack@google.com } 23412855Sgabeblack@google.com 23512855Sgabeblack@google.com sc_event ev, dummy_ev; 23612855Sgabeblack@google.com 23712855Sgabeblack@google.com std::exception ex; 23812855Sgabeblack@google.com 23912855Sgabeblack@google.com sc_process_handle ts1; 24012855Sgabeblack@google.com sc_process_handle ts2; 24112855Sgabeblack@google.com sc_process_handle ts3; 24212855Sgabeblack@google.com sc_process_handle ts4; 24312855Sgabeblack@google.com sc_process_handle ts5; 24412855Sgabeblack@google.com 24512855Sgabeblack@google.com sc_process_handle td1; 24612855Sgabeblack@google.com sc_process_handle td2; 24712855Sgabeblack@google.com sc_process_handle td3; 24812855Sgabeblack@google.com sc_process_handle td4; 24912855Sgabeblack@google.com sc_process_handle td5; 25012855Sgabeblack@google.com 25112855Sgabeblack@google.com sc_process_handle tr1; 25212855Sgabeblack@google.com sc_process_handle tr2; 25312855Sgabeblack@google.com sc_process_handle tr3; 25412855Sgabeblack@google.com sc_process_handle tr4; 25512855Sgabeblack@google.com 25612855Sgabeblack@google.com int caught_throw_it; 25712855Sgabeblack@google.com int caught_reset; 25812855Sgabeblack@google.com int caught_kill; 25912855Sgabeblack@google.com 26012855Sgabeblack@google.com bool target_suspend_1_called; 26112855Sgabeblack@google.com bool target_suspend_2_called; 26212855Sgabeblack@google.com bool target_suspend_3_called; 26312855Sgabeblack@google.com bool target_suspend_4_called; 26412855Sgabeblack@google.com bool target_suspend_5_called; 26512855Sgabeblack@google.com 26612855Sgabeblack@google.com bool target_disable_1_called; 26712855Sgabeblack@google.com bool target_disable_2_called; 26812855Sgabeblack@google.com bool target_disable_2_called_again; 26912855Sgabeblack@google.com bool target_disable_3_called; 27012855Sgabeblack@google.com bool target_disable_4_called; 27112855Sgabeblack@google.com bool target_disable_5_called; 27212855Sgabeblack@google.com 27312855Sgabeblack@google.com bool target_sync_reset_1_called; 27412855Sgabeblack@google.com bool target_sync_reset_2_called; 27512855Sgabeblack@google.com bool target_sync_reset_3_called; 27612855Sgabeblack@google.com bool target_sync_reset_4_called; 27712855Sgabeblack@google.com 27812855Sgabeblack@google.com int reset_1_count; 27912855Sgabeblack@google.com int reset_2_count; 28012855Sgabeblack@google.com int reset_3_count; 28112855Sgabeblack@google.com int reset_4_count; 28212855Sgabeblack@google.com 28312855Sgabeblack@google.com void ctrl() 28412855Sgabeblack@google.com { 28512855Sgabeblack@google.com ts3.resume(); 28612855Sgabeblack@google.com 28712855Sgabeblack@google.com wait(10, SC_NS); 28812855Sgabeblack@google.com ts1.resume(); 28912855Sgabeblack@google.com ev.notify(); 29012855Sgabeblack@google.com 29112855Sgabeblack@google.com wait(10, SC_NS); 29212855Sgabeblack@google.com ts2.resume(); 29312855Sgabeblack@google.com tr2.sync_reset_off(); 29412855Sgabeblack@google.com tr4.sync_reset_off(); 29512855Sgabeblack@google.com 29612855Sgabeblack@google.com wait(10, SC_NS); 29712855Sgabeblack@google.com td2.enable(); 29812855Sgabeblack@google.com 29912855Sgabeblack@google.com wait(10, SC_NS); 30012855Sgabeblack@google.com ev.notify(); 30112855Sgabeblack@google.com 30212855Sgabeblack@google.com wait(10, SC_NS); 30312855Sgabeblack@google.com ev.notify(); 30412855Sgabeblack@google.com td2.disable(); 30512855Sgabeblack@google.com 30612855Sgabeblack@google.com wait(10, SC_NS); 30712855Sgabeblack@google.com td4.enable(); 30812855Sgabeblack@google.com ts4.resume(); 30912855Sgabeblack@google.com ev.notify(); 31012855Sgabeblack@google.com } 31112855Sgabeblack@google.com 31212855Sgabeblack@google.com void target_suspend_1() 31312855Sgabeblack@google.com { 31412855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 31512855Sgabeblack@google.com target_suspend_1_called = true; 31612855Sgabeblack@google.com } 31712855Sgabeblack@google.com 31812855Sgabeblack@google.com void target_suspend_2() 31912855Sgabeblack@google.com { 32012855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(20, SC_NS) ); 32112855Sgabeblack@google.com target_suspend_2_called = true; 32212855Sgabeblack@google.com } 32312855Sgabeblack@google.com 32412855Sgabeblack@google.com void target_suspend_3() 32512855Sgabeblack@google.com { 32612855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 32712855Sgabeblack@google.com target_suspend_3_called = true; 32812855Sgabeblack@google.com } 32912855Sgabeblack@google.com 33012855Sgabeblack@google.com void target_suspend_4() 33112855Sgabeblack@google.com { 33212855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(60, SC_NS) ); 33312855Sgabeblack@google.com target_suspend_4_called = true; 33412855Sgabeblack@google.com } 33512855Sgabeblack@google.com 33612855Sgabeblack@google.com void target_suspend_5() 33712855Sgabeblack@google.com { 33812855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 33912855Sgabeblack@google.com target_suspend_5_called = true; 34012855Sgabeblack@google.com ts5.suspend(); 34112855Sgabeblack@google.com } 34212855Sgabeblack@google.com 34312855Sgabeblack@google.com void target_disable_1() 34412855Sgabeblack@google.com { 34512855Sgabeblack@google.com sc_assert( false ); 34612855Sgabeblack@google.com target_disable_1_called = true; 34712855Sgabeblack@google.com } 34812855Sgabeblack@google.com 34912855Sgabeblack@google.com void target_disable_2() 35012855Sgabeblack@google.com { 35112855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(40, SC_NS) ); 35212855Sgabeblack@google.com target_disable_2_called = true; 35312855Sgabeblack@google.com wait(); // on ev 35412855Sgabeblack@google.com 35512855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(50, SC_NS) ); 35612855Sgabeblack@google.com target_disable_2_called_again = true; 35712855Sgabeblack@google.com } 35812855Sgabeblack@google.com 35912855Sgabeblack@google.com void target_disable_3() 36012855Sgabeblack@google.com { 36112855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(0, SC_NS) ); 36212855Sgabeblack@google.com sc_assert( sc_delta_count() == 0 ); 36312855Sgabeblack@google.com target_disable_3_called = true; 36412855Sgabeblack@google.com } 36512855Sgabeblack@google.com 36612855Sgabeblack@google.com void target_disable_4() 36712855Sgabeblack@google.com { 36812855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(60, SC_NS) ); 36912855Sgabeblack@google.com target_disable_4_called = true; 37012855Sgabeblack@google.com } 37112855Sgabeblack@google.com 37212855Sgabeblack@google.com void target_disable_5() 37312855Sgabeblack@google.com { 37412855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 37512855Sgabeblack@google.com target_disable_5_called = true; 37612855Sgabeblack@google.com td5.disable(); 37712855Sgabeblack@google.com } 37812855Sgabeblack@google.com 37912855Sgabeblack@google.com void target_sync_reset_1() 38012855Sgabeblack@google.com { 38112855Sgabeblack@google.com switch (reset_1_count) 38212855Sgabeblack@google.com { 38312855Sgabeblack@google.com case 0: sc_assert( sc_time_stamp() == sc_time(0, SC_NS) ); 38412855Sgabeblack@google.com sc_assert( sc_delta_count() == 0 ); 38512855Sgabeblack@google.com break; 38612855Sgabeblack@google.com case 1: sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 38712855Sgabeblack@google.com break; 38812855Sgabeblack@google.com case 2: sc_assert( sc_time_stamp() == sc_time(40, SC_NS) ); 38912855Sgabeblack@google.com break; 39012855Sgabeblack@google.com case 3: sc_assert( sc_time_stamp() == sc_time(50, SC_NS) ); 39112855Sgabeblack@google.com target_sync_reset_1_called = true; 39212855Sgabeblack@google.com break; 39312855Sgabeblack@google.com } 39412855Sgabeblack@google.com ++reset_1_count; 39512855Sgabeblack@google.com 39612855Sgabeblack@google.com while (true) 39712855Sgabeblack@google.com { 39812855Sgabeblack@google.com wait(); 39912855Sgabeblack@google.com sc_assert( false ); 40012855Sgabeblack@google.com } 40112855Sgabeblack@google.com } 40212855Sgabeblack@google.com 40312855Sgabeblack@google.com void target_sync_reset_2() 40412855Sgabeblack@google.com { 40512855Sgabeblack@google.com switch (reset_2_count) 40612855Sgabeblack@google.com { 40712855Sgabeblack@google.com case 0: sc_assert( sc_time_stamp() == sc_time(0, SC_NS) ); 40812855Sgabeblack@google.com sc_assert( sc_delta_count() == 0 ); 40912855Sgabeblack@google.com break; 41012855Sgabeblack@google.com case 1: sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 41112855Sgabeblack@google.com break; 41212855Sgabeblack@google.com case 2: sc_assert( false ); 41312855Sgabeblack@google.com break; 41412855Sgabeblack@google.com case 3: sc_assert( false ); 41512855Sgabeblack@google.com break; 41612855Sgabeblack@google.com } 41712855Sgabeblack@google.com ++reset_2_count; 41812855Sgabeblack@google.com 41912855Sgabeblack@google.com while (true) 42012855Sgabeblack@google.com { 42112855Sgabeblack@google.com wait(); 42212855Sgabeblack@google.com 42312855Sgabeblack@google.com switch (reset_2_count) 42412855Sgabeblack@google.com { 42512855Sgabeblack@google.com case 0: sc_assert( false ); 42612855Sgabeblack@google.com break; 42712855Sgabeblack@google.com case 1: sc_assert( false ); 42812855Sgabeblack@google.com break; 42912855Sgabeblack@google.com case 2: sc_assert( sc_time_stamp() == sc_time(40, SC_NS) ); 43012855Sgabeblack@google.com break; 43112855Sgabeblack@google.com case 3: sc_assert( sc_time_stamp() == sc_time(50, SC_NS) ); 43212855Sgabeblack@google.com target_sync_reset_2_called = true; 43312855Sgabeblack@google.com break; 43412855Sgabeblack@google.com } 43512855Sgabeblack@google.com ++reset_2_count; 43612855Sgabeblack@google.com 43712855Sgabeblack@google.com } 43812855Sgabeblack@google.com } 43912855Sgabeblack@google.com 44012855Sgabeblack@google.com void target_sync_reset_3() 44112855Sgabeblack@google.com { 44212855Sgabeblack@google.com switch (reset_3_count) 44312855Sgabeblack@google.com { 44412855Sgabeblack@google.com case 0: sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 44512855Sgabeblack@google.com break; 44612855Sgabeblack@google.com case 1: sc_assert( false ); 44712855Sgabeblack@google.com break; 44812855Sgabeblack@google.com case 2: sc_assert( false ); 44912855Sgabeblack@google.com break; 45012855Sgabeblack@google.com } 45112855Sgabeblack@google.com ++reset_3_count; 45212855Sgabeblack@google.com 45312855Sgabeblack@google.com while (true) 45412855Sgabeblack@google.com { 45512855Sgabeblack@google.com wait(); 45612855Sgabeblack@google.com 45712855Sgabeblack@google.com switch (reset_3_count) 45812855Sgabeblack@google.com { 45912855Sgabeblack@google.com case 0: sc_assert( false ); 46012855Sgabeblack@google.com break; 46112855Sgabeblack@google.com case 1: sc_assert( sc_time_stamp() == sc_time(40, SC_NS) ); 46212855Sgabeblack@google.com break; 46312855Sgabeblack@google.com case 2: sc_assert( sc_time_stamp() == sc_time(50, SC_NS) ); 46412855Sgabeblack@google.com target_sync_reset_3_called = true; 46512855Sgabeblack@google.com break; 46612855Sgabeblack@google.com } 46712855Sgabeblack@google.com ++reset_3_count; 46812855Sgabeblack@google.com 46912855Sgabeblack@google.com } 47012855Sgabeblack@google.com } 47112855Sgabeblack@google.com 47212855Sgabeblack@google.com void target_sync_reset_4() 47312855Sgabeblack@google.com { 47412855Sgabeblack@google.com switch (reset_4_count) 47512855Sgabeblack@google.com { 47612855Sgabeblack@google.com case 0: sc_assert( sc_time_stamp() == sc_time(10, SC_NS) ); 47712855Sgabeblack@google.com break; 47812855Sgabeblack@google.com case 1: sc_assert( false ); 47912855Sgabeblack@google.com break; 48012855Sgabeblack@google.com case 2: sc_assert( false ); 48112855Sgabeblack@google.com break; 48212855Sgabeblack@google.com } 48312855Sgabeblack@google.com ++reset_4_count; 48412855Sgabeblack@google.com 48512855Sgabeblack@google.com while (true) 48612855Sgabeblack@google.com { 48712855Sgabeblack@google.com wait(); 48812855Sgabeblack@google.com 48912855Sgabeblack@google.com switch (reset_4_count) 49012855Sgabeblack@google.com { 49112855Sgabeblack@google.com case 0: sc_assert( false ); 49212855Sgabeblack@google.com break; 49312855Sgabeblack@google.com case 1: sc_assert( sc_time_stamp() == sc_time(40, SC_NS) ); 49412855Sgabeblack@google.com break; 49512855Sgabeblack@google.com case 2: sc_assert( sc_time_stamp() == sc_time(50, SC_NS) ); 49612855Sgabeblack@google.com target_sync_reset_4_called = true; 49712855Sgabeblack@google.com break; 49812855Sgabeblack@google.com } 49912855Sgabeblack@google.com ++reset_4_count; 50012855Sgabeblack@google.com 50112855Sgabeblack@google.com } 50212855Sgabeblack@google.com } 50312855Sgabeblack@google.com}; 50412855Sgabeblack@google.com 50512855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 50612855Sgabeblack@google.com{ 50712855Sgabeblack@google.com Top top("top"); 50812855Sgabeblack@google.com sc_start(); 50912855Sgabeblack@google.com 51012855Sgabeblack@google.com sc_assert( top.caught_throw_it == 3 ); 51112855Sgabeblack@google.com sc_assert( top.caught_reset == 3 ); 51212855Sgabeblack@google.com sc_assert( top.caught_kill == 3 ); 51312855Sgabeblack@google.com 51412855Sgabeblack@google.com sc_assert( top.target_suspend_1_called ); 51512855Sgabeblack@google.com sc_assert( top.target_suspend_2_called ); 51612855Sgabeblack@google.com sc_assert( top.target_suspend_3_called ); 51712855Sgabeblack@google.com sc_assert( top.target_suspend_4_called ); 51812855Sgabeblack@google.com sc_assert( top.target_suspend_5_called ); 51912855Sgabeblack@google.com 52012855Sgabeblack@google.com sc_assert( !top.target_disable_1_called ); 52112855Sgabeblack@google.com sc_assert( top.target_disable_2_called ); 52212855Sgabeblack@google.com sc_assert( top.target_disable_2_called_again ); 52312855Sgabeblack@google.com sc_assert( top.target_disable_3_called ); 52412855Sgabeblack@google.com sc_assert( top.target_disable_4_called ); 52512855Sgabeblack@google.com sc_assert( top.target_disable_5_called ); 52612855Sgabeblack@google.com 52712855Sgabeblack@google.com sc_assert( top.target_sync_reset_1_called ); 52812855Sgabeblack@google.com sc_assert( top.target_sync_reset_2_called ); 52912855Sgabeblack@google.com sc_assert( top.target_sync_reset_3_called ); 53012855Sgabeblack@google.com sc_assert( top.target_sync_reset_4_called ); 53112855Sgabeblack@google.com 53212855Sgabeblack@google.com cout << endl << "Success" << endl; 53312855Sgabeblack@google.com return 0; 53412855Sgabeblack@google.com} 535