test.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 test.cpp -- 23 24 Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 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 38/* 39I believe there is a bug in SystemC 2.0 beta 1 which 40causes simulation to end prematurely in certain cases. 41Specifically, if an event notification occurs at a particular 42time but no processes are ready to run at that time, 43simulation will end. However, there may still be processes 44that need to be run at future times. 45 46Below I've included an example which demonstrates the bug, 47and below that I've provided a proposed fix for the bug. 48 49// This SystemC 2.0 example shows the bug... 50*/ 51 52#include <systemc.h> 53 54class top : public sc_module 55{ 56 public: 57 SC_HAS_PROCESS(top); 58 59 top(sc_module_name name) : sc_module(name) 60 { 61 SC_THREAD(main); 62 } 63 64 void main() 65 { 66 sc_event e; 67 68 // comment out the following line to see bug go away 69 70 e.notify(55, SC_NS); 71 72 for (int i = 0; i < 10; i++) 73 { 74 wait(10, SC_NS); 75 cout << "main thread at time " << sc_time_stamp() << endl; 76 } 77 } 78}; 79 80int sc_main (int argc , char *argv[]) 81{ 82 top top1("Top1"); 83 sc_start(); 84 return 0; 85} 86 87/* 88/////// End of example 89 90The proposed fix for this in SystemC 2.0 beta 1 is: 91 92Edit src/sysc/kernel/sc_simcontext.cpp 93 94Lines 801-802, which read: 95 96// no more runnable processes 97break; 98 99Should be changed to read: 100 101// no runnable processes at current time, but maybe in future 102t = next_time(); 103continue; 104 105The same changes should be applied at lines 845-846 106Then rebuild and reinstall the SystemC library. 107 108 109___________________________________________________ 110Stuart Swan, Senior Architect 111System Level Design Group, Cadence Design Systems 112Building 11 1132670 Seely Avenue 114San Jose, CA 95134 115Phone: +1 408 895 4579 116Email: stuart@cadence.com 117___________________________________________________ 118 119*/ 120